windows MQTT mosquitto2.0.18a安装包
立即下载
资源介绍:
用于windows c++ 连接MQTT
/*
Copyright (c) 2010-2020 Roger Light
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License 2.0
and Eclipse Distribution License v1.0 which accompany this distribution.
The Eclipse Public License is available at
https://www.eclipse.org/legal/epl-2.0/
and the Eclipse Distribution License is available at
http://www.eclipse.org/org/documents/edl-v10.php.
SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
Contributors:
Roger Light - initial implementation and documentation.
*/
#ifndef MOSQUITTO_H
#define MOSQUITTO_H
/*
* File: mosquitto.h
*
* This header contains functions and definitions for use with libmosquitto, the Mosquitto client library.
*
* The definitions are also used in Mosquitto broker plugins, and some functions are available to plugins.
*/
#ifdef __cplusplus
extern "C" {
#endif
#ifdef WIN32
# ifdef mosquitto_EXPORTS
# define libmosq_EXPORT __declspec(dllexport)
# else
# ifndef LIBMOSQUITTO_STATIC
# ifdef libmosquitto_EXPORTS
# define libmosq_EXPORT __declspec(dllexport)
# else
# define libmosq_EXPORT __declspec(dllimport)
# endif
# else
# define libmosq_EXPORT
# endif
# endif
#else
# define libmosq_EXPORT
#endif
#if defined(_MSC_VER) && _MSC_VER < 1900 && !defined(bool)
# ifndef __cplusplus
# define bool char
# define true 1
# define false 0
# endif
#else
# ifndef __cplusplus
# include
# endif
#endif
#include
#include
#define LIBMOSQUITTO_MAJOR 2
#define LIBMOSQUITTO_MINOR 0
#define LIBMOSQUITTO_REVISION 18
/* LIBMOSQUITTO_VERSION_NUMBER looks like 1002001 for e.g. version 1.2.1. */
#define LIBMOSQUITTO_VERSION_NUMBER (LIBMOSQUITTO_MAJOR*1000000+LIBMOSQUITTO_MINOR*1000+LIBMOSQUITTO_REVISION)
/* Log types */
#define MOSQ_LOG_NONE 0
#define MOSQ_LOG_INFO (1<<0)
#define MOSQ_LOG_NOTICE (1<<1)
#define MOSQ_LOG_WARNING (1<<2)
#define MOSQ_LOG_ERR (1<<3)
#define MOSQ_LOG_DEBUG (1<<4)
#define MOSQ_LOG_SUBSCRIBE (1<<5)
#define MOSQ_LOG_UNSUBSCRIBE (1<<6)
#define MOSQ_LOG_WEBSOCKETS (1<<7)
#define MOSQ_LOG_INTERNAL 0x80000000U
#define MOSQ_LOG_ALL 0xFFFFFFFFU
/* Enum: mosq_err_t
* Integer values returned from many libmosquitto functions. */
enum mosq_err_t {
MOSQ_ERR_AUTH_CONTINUE = -4,
MOSQ_ERR_NO_SUBSCRIBERS = -3,
MOSQ_ERR_SUB_EXISTS = -2,
MOSQ_ERR_CONN_PENDING = -1,
MOSQ_ERR_SUCCESS = 0,
MOSQ_ERR_NOMEM = 1,
MOSQ_ERR_PROTOCOL = 2,
MOSQ_ERR_INVAL = 3,
MOSQ_ERR_NO_CONN = 4,
MOSQ_ERR_CONN_REFUSED = 5,
MOSQ_ERR_NOT_FOUND = 6,
MOSQ_ERR_CONN_LOST = 7,
MOSQ_ERR_TLS = 8,
MOSQ_ERR_PAYLOAD_SIZE = 9,
MOSQ_ERR_NOT_SUPPORTED = 10,
MOSQ_ERR_AUTH = 11,
MOSQ_ERR_ACL_DENIED = 12,
MOSQ_ERR_UNKNOWN = 13,
MOSQ_ERR_ERRNO = 14,
MOSQ_ERR_EAI = 15,
MOSQ_ERR_PROXY = 16,
MOSQ_ERR_PLUGIN_DEFER = 17,
MOSQ_ERR_MALFORMED_UTF8 = 18,
MOSQ_ERR_KEEPALIVE = 19,
MOSQ_ERR_LOOKUP = 20,
MOSQ_ERR_MALFORMED_PACKET = 21,
MOSQ_ERR_DUPLICATE_PROPERTY = 22,
MOSQ_ERR_TLS_HANDSHAKE = 23,
MOSQ_ERR_QOS_NOT_SUPPORTED = 24,
MOSQ_ERR_OVERSIZE_PACKET = 25,
MOSQ_ERR_OCSP = 26,
MOSQ_ERR_TIMEOUT = 27,
MOSQ_ERR_RETAIN_NOT_SUPPORTED = 28,
MOSQ_ERR_TOPIC_ALIAS_INVALID = 29,
MOSQ_ERR_ADMINISTRATIVE_ACTION = 30,
MOSQ_ERR_ALREADY_EXISTS = 31,
};
/* Enum: mosq_opt_t
*
* Client options.
*
* See , , and .
*/
enum mosq_opt_t {
MOSQ_OPT_PROTOCOL_VERSION = 1,
MOSQ_OPT_SSL_CTX = 2,
MOSQ_OPT_SSL_CTX_WITH_DEFAULTS = 3,
MOSQ_OPT_RECEIVE_MAXIMUM = 4,
MOSQ_OPT_SEND_MAXIMUM = 5,
MOSQ_OPT_TLS_KEYFORM = 6,
MOSQ_OPT_TLS_ENGINE = 7,
MOSQ_OPT_TLS_ENGINE_KPASS_SHA1 = 8,
MOSQ_OPT_TLS_OCSP_REQUIRED = 9,
MOSQ_OPT_TLS_ALPN = 10,
MOSQ_OPT_TCP_NODELAY = 11,
MOSQ_OPT_BIND_ADDRESS = 12,
MOSQ_OPT_TLS_USE_OS_CERTS = 13,
};
/* MQTT specification restricts client ids to a maximum of 23 characters */
#define MOSQ_MQTT_ID_MAX_LENGTH 23
#define MQTT_PROTOCOL_V31 3
#define MQTT_PROTOCOL_V311 4
#define MQTT_PROTOCOL_V5 5
/* Struct: mosquitto_message
*
* Contains details of a PUBLISH message.
*
* int mid - the message/packet ID of the PUBLISH message, assuming this is a
* QoS 1 or 2 message. Will be set to 0 for QoS 0 messages.
*
* char *topic - the topic the message was delivered on.
*
* void *payload - the message payload. This will be payloadlen bytes long, and
* may be NULL if a zero length payload was sent.
*
* int payloadlen - the length of the payload, in bytes.
*
* int qos - the quality of service of the message, 0, 1, or 2.
*
* bool retain - set to true for stale retained messages.
*/
struct mosquitto_message{
int mid;
char *topic;
void *payload;
int payloadlen;
int qos;
bool retain;
};
struct mosquitto;
typedef struct mqtt5__property mosquitto_property;
/*
* Topic: Threads
* libmosquitto provides thread safe operation, with the exception of
* which is not thread safe.
*
* If the library has been compiled without thread support it is *not*
* guaranteed to be thread safe.
*
* If your application uses threads you must use to
* tell the library this is the case, otherwise it makes some optimisations
* for the single threaded case that may result in unexpected behaviour for
* the multi threaded case.
*/
/***************************************************
* Important note
*
* The following functions that deal with network operations will return
* MOSQ_ERR_SUCCESS on success, but this does not mean that the operation has
* taken place. An attempt will be made to write the network data, but if the
* socket is not available for writing at that time then the packet will not be
* sent. To ensure the packet is sent, call mosquitto_loop() (which must also
* be called to process incoming network data).
* This is especially important when disconnecting a client that has a will. If
* the broker does not receive the DISCONNECT command, it will assume that the
* client has disconnected unexpectedly and send the will.
*
* mosquitto_connect()
* mosquitto_disconnect()
* mosquitto_subscribe()
* mosquitto_unsubscribe()
* mosquitto_publish()
***************************************************/
/* ======================================================================
*
* Section: Library version, init, and cleanup
*
* ====================================================================== */
/*
* Function: mosquitto_lib_version
*
* Can be used to obtain version information for the mosquitto library.
* This allows the application to compare the library version against the
* version it was compiled against by using the LIBMOSQUITTO_MAJOR,
* LIBMOSQUITTO_MINOR and LIBMOSQUITTO_REVISION defines.
*
* Parameters:
* major - an integer pointer. If not NULL, the major version of the
* library will be returned in this variable.
* minor - an integer pointer. If not NULL, the minor version of the
* library will be returned in this variable.
* revision - an integer pointer. If not NULL, the revision of the library will
* be returned in this variable.
*
* Returns:
* LIBMOSQUITTO_VERSION_NUMBER - which is a unique number based on the major,
* minor and revision values.
* See Also:
* ,
*/
libmosq_EXPORT int mosquitto_lib_version(int *major, int *minor, int *revision);
/*
* Function: mosquitto_lib_init
*
* Must be called before any other mosquitto functions.
*
* This function is *not* thread safe.
*
* Returns:
* MOSQ_ERR_SUCCESS - on success.
* MOSQ_ERR_UNKNOWN - on Windows, if sockets couldn't be initialized.
*
* See Also:
* ,
*/
libmosq_EXPORT int mosquitto_lib_init(void);
/*
* Function: mosquitto_lib_cleanup
*
* Call to free resources associated with the library.
*
* Returns:
* MOSQ_ERR_SUCCESS - always
*
* S