/*
Copyright (c) 2010-2020 Roger Light <roger@atchoo.org>
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 <stdbool.h>
# endif
#endif
#include <stddef.h>
#include <stdint.h>
#define LIBMOSQUITTO_MAJOR 2
#define LIBMOSQUITTO_MINOR 0
#define LIBMOSQUITTO_REVISION 15
/* 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 <mosquitto_int_option>, <mosquitto_string_option>, and <mosquitto_void_option>.
*/
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
* <mosquitto_lib_init> 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 <mosquitto_threaded_set> 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:
* <mosquitto_lib_cleanup>, <mosquitto_lib_init>
*/
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:
* <mosquitto_lib_cleanup>, <mosquitto_lib_version>
*/
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
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
参照大神的教程:https://blog.csdn.net/qq_43229894/article/details/127814278 自己基于以下资源编译的库文件: 1,mosquitto 2.0.15版本 2,win10+vs2019 3,依赖库文件版本:pthread-win32-2.9.10/tassl1.1.1k/cjson-vs2019-1.7.15 压缩包里有三个版本,分别是: 基于tassl1.1.1k 动态库生成的动态版本libmosquitto 基于tassl1.1.1k 动态库生成的静态版本libmosquitto 基于tassl1.1.1k静态库生成的静态版本libmosquitto
资源推荐
资源详情
资源评论
收起资源包目录
libmosquitto-2.0.15-x64.zip (8个子文件)
libmosquitto-2.0.15-x64-vs2019-static_with-cjson1.7.15-pthread2.9.10-tassl1.1.1static
mosquitto.h 123KB
mosquitto.dll 340KB
libmosquitto-2.0.15-x64-vs2019-dynamic_with-cjson1.7.15-pthread2.9.10-tassl1.1.1dynamic
mosquitto.h 123KB
mosquitto.exp 17KB
mosquitto.lib 28KB
mosquitto.dll 89KB
libmosquitto-2.0.15-x64-vs2019-static_with-cjson1.7.15-pthread2.9.10-tassl1.1.1dynamic
mosquitto.h 123KB
mosquitto.dll 340KB
共 8 条
- 1
资源评论
lessicke
- 粉丝: 1
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- #P0015. 全排列 超级简单
- pta题库答案c语言之排序4统计工龄.zip
- pta题库答案c语言之树结构7堆中的路径.zip
- pta题库答案c语言之树结构3TreeTraversalsAgain.zip
- pta题库答案c语言之树结构2ListLeaves.zip
- pta题库答案c语言之树结构1树的同构.zip
- 基于C++实现民航飞行与地图简易管理系统可执行程序+说明+详细注释.zip
- pta题库答案c语言之复杂度1最大子列和问题.zip
- 三维装箱问题(Three-Dimensional Bin Packing Problem,3D-BPP)是一个经典的组合优化问题
- 以下是一些关于Linux线程同步的基本概念和方法.txt
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功