1 module mosquittod.api; 2 3 import mosquittod.types; 4 5 import ssll; 6 7 import std.exception : enforce; 8 9 version (Posix) private enum libNames = ["libmosquitto.so", "libmosquitto.so.1"]; 10 version (Windows) private enum libNames = ["mosquitto.dll"]; 11 12 private __gshared void* lib; 13 14 /// 15 int initMosquittoLib(LoadApiSymbolsVerbose verb=LoadApiSymbolsVerbose.message) 16 { 17 if (lib !is null) return MOSQ_ERR.SUCCESS; 18 19 foreach (name; libNames) 20 { 21 lib = loadLibrary(name); 22 if (lib !is null) break; 23 } 24 enforce(lib, "can't load libmosquitto"); 25 26 loadApiSymbols(verb); 27 return mosquitto_lib_init(); 28 } 29 30 /// 31 int[3] mosquittoLibVersion() 32 { 33 int[3] ver; 34 mosquitto_lib_version(&ver[0], &ver[1], &ver[2]); 35 return ver; 36 } 37 38 /// 39 void cleanupMosquittoLib() 40 { 41 mosquitto_lib_cleanup(); 42 unloadLibrary(lib); 43 } 44 45 mixin SSLL_INIT; 46 47 @api("lib"): 48 int mosquitto_lib_version( 49 int* major, 50 int* minor, 51 int* revision) { mixin(SSLL_CALL); } 52 53 int mosquitto_lib_init() { mixin(SSLL_CALL); } 54 55 int mosquitto_lib_cleanup() { mixin(SSLL_CALL); } 56 57 58 mosquitto* mosquitto_new( 59 const(char)* id, 60 bool clean_session, 61 void* obj) { mixin(SSLL_CALL); } 62 63 void mosquitto_destroy(mosquitto* mosq) { mixin(SSLL_CALL); } 64 65 int mosquitto_reinitialise( 66 mosquitto* mosq, 67 const(char)* id, 68 bool clean_session, 69 void* obj) { mixin(SSLL_CALL); } 70 71 72 int mosquitto_will_set( 73 mosquitto* mosq, 74 const(char)* topic, 75 int payloadlen, 76 const(void)* payload, 77 int qos, 78 bool retain) { mixin(SSLL_CALL); } 79 80 int mosquitto_will_set_v5( 81 mosquitto* mosq, 82 const(char)* topic, 83 int payloadlen, 84 const(void)* payload, 85 int qos, 86 bool retain, 87 mosquitto_property* prop) { mixin(SSLL_CALL); } 88 89 int mosquitto_will_clear(mosquitto* mosq) { mixin(SSLL_CALL); } 90 91 92 int mosquitto_username_pw_set( 93 mosquitto* mosq, 94 const(char)* username, 95 const(char)* password) { mixin(SSLL_CALL); } 96 97 98 int mosquitto_connect( 99 mosquitto* mosq, 100 const(char)* host, 101 int port, 102 int keepalive) { mixin(SSLL_CALL); } 103 104 int mosquitto_connect_bind( 105 mosquitto* mosq, 106 const(char)* host, 107 int port, 108 int keepalive, 109 const(char)* bind_address) { mixin(SSLL_CALL); } 110 111 int mosquitto_connect_bind_v5( 112 mosquitto* mosq, 113 const(char)* host, 114 int port, 115 int keepalive, 116 const(char)* bind_address, 117 const mosquitto_property* prop) { mixin(SSLL_CALL); } 118 119 int mosquitto_connect_async( 120 mosquitto* mosq, 121 const(char)* host, 122 int port, 123 int keepalive) { mixin(SSLL_CALL); } 124 125 int mosquitto_connect_bind_async( 126 mosquitto* mosq, 127 const(char)* host, 128 int port, 129 int keepalive, 130 const(char)* bind_address) { mixin(SSLL_CALL); } 131 132 int mosquitto_connect_srv( 133 mosquitto* mosq, 134 const(char)* host, 135 int keepalive, 136 const(char)* bind_address) { mixin(SSLL_CALL); } 137 138 int mosquitto_reconnect(mosquitto* mosq) { mixin(SSLL_CALL); } 139 140 int mosquitto_reconnect_async(mosquitto* mosq) { mixin(SSLL_CALL); } 141 142 int mosquitto_disconnect(mosquitto* mosq) { mixin(SSLL_CALL); } 143 144 int mosquitto_disconnect_v5( 145 mosquitto* mosq, 146 int reason, 147 const mosquitto_property* prop) { mixin(SSLL_CALL); } 148 149 150 int mosquitto_publish( 151 mosquitto* mosq, 152 int* mid, 153 const(char)* topic, 154 int payloadlen, 155 const(void)* payload, 156 int qos, 157 bool retain) { mixin(SSLL_CALL); } 158 159 int mosquitto_publish_v5( 160 mosquitto* mosq, 161 int* mid, 162 const(char)* topic, 163 int payloadlen, 164 const(void)* payload, 165 int qos, 166 bool retain, 167 const mosquitto_property* prop) { mixin(SSLL_CALL); } 168 169 int mosquitto_subscribe( 170 mosquitto* mosq, 171 int* mid, 172 const(char)* sub, 173 int qos) { mixin(SSLL_CALL); } 174 175 int mosquitto_subscribe_v5( 176 mosquitto* mosq, 177 int* mid, 178 const(char)* sub, 179 int qos, 180 const mosquitto_property* prop) { mixin(SSLL_CALL); } 181 182 int mosquitto_subscribe_multiple( 183 mosquitto* mosq, 184 int* mid, 185 int sub_count, 186 const(char)** sub, 187 int qos, 188 int options, 189 const mosquitto_property* prop) { mixin(SSLL_CALL); } 190 191 int mosquitto_unsubscribe( 192 mosquitto* mosq, 193 int* mid, 194 const(char)* sub) { mixin(SSLL_CALL); } 195 196 int mosquitto_unsubscribe_v5( 197 mosquitto* mosq, 198 int* mid, 199 const(char)* sub, 200 const mosquitto_property* prop) { mixin(SSLL_CALL); } 201 202 int mosquitto_unsubscribe_multiple( 203 mosquitto* mosq, 204 int *mid, 205 int sub_count, 206 const(char)** sub, 207 const mosquitto_property* prop) { mixin(SSLL_CALL); } 208 209 210 int mosquitto_message_copy( 211 mosquitto_message* dst, 212 const mosquitto_message* src) { mixin(SSLL_CALL); } 213 214 void mosquitto_message_free(mosquitto_message** message) { mixin(SSLL_CALL); } 215 216 void mosquitto_message_free_contents(mosquitto_message* message) { mixin(SSLL_CALL); } 217 218 219 int mosquitto_loop_forever( 220 mosquitto* mosq, 221 int timeout, 222 int max_packets) { mixin(SSLL_CALL); } 223 224 int mosquitto_loop_start(mosquitto* mosq) { mixin(SSLL_CALL); } 225 226 int mosquitto_loop_stop( 227 mosquitto* mosq, 228 bool force) { mixin(SSLL_CALL); } 229 230 int mosquitto_loop( 231 mosquitto* mosq, 232 int timeout, 233 int max_packets) { mixin(SSLL_CALL); } 234 235 236 int mosquitto_loop_read( 237 mosquitto* mosq, 238 int max_packets) { mixin(SSLL_CALL); } 239 240 int mosquitto_loop_write( 241 mosquitto* mosq, 242 int max_packets) { mixin(SSLL_CALL); } 243 244 int mosquitto_loop_misc(mosquitto* mosq) { mixin(SSLL_CALL); } 245 246 247 int mosquitto_socket(mosquitto* mosq) { mixin(SSLL_CALL); } 248 249 bool mosquitto_want_write(mosquitto* mosq) { mixin(SSLL_CALL); } 250 251 int mosquitto_threaded_set( 252 mosquitto* mosq, 253 bool threaded) { mixin(SSLL_CALL); } 254 255 256 //deprecated("use 'mosquitto_int_option' or 'mosquitto_void_option'") 257 //int mosquitto_opts_set(mosquitto* mosq, 258 // MOSQ_OPT option, 259 // void* value) { mixin(SSLL_CALL); } 260 261 int mosquitto_int_option( 262 mosquitto* mosq, 263 MOSQ_OPT option, 264 int value) { mixin(SSLL_CALL); } 265 266 int mosquitto_void_option( 267 mosquitto* mosq, 268 MOSQ_OPT option, 269 void* value) { mixin(SSLL_CALL); } 270 271 int mosquitto_string_option( 272 mosquitto* mosq, 273 MOSQ_OPT option, 274 const(char)* value) { mixin(SSLL_CALL); } 275 276 void mosquitto_user_data_set( 277 mosquitto* mosq, 278 void* obj) { mixin(SSLL_CALL); } 279 280 void* mosquitto_userdata(mosquitto* mosq) { mixin(SSLL_CALL); } 281 282 283 int mosquitto_tls_set( 284 mosquitto* mosq, 285 const(char)* cafile, 286 const(char)* capath, 287 const(char)* certfile, 288 const(char)* keyfile, 289 mosq_tls_callback pw_callback) { mixin(SSLL_CALL); } 290 291 int mosquitto_tls_insecure_set( 292 mosquitto* mosq, 293 bool value) { mixin(SSLL_CALL); } 294 295 int mosquitto_tls_opts_set( 296 mosquitto* mosq, 297 int cert_reqs, 298 const(char)* tls_version, 299 const(char)* ciphers) { mixin(SSLL_CALL); } 300 301 int mosquitto_tls_psk_set( 302 mosquitto* mosq, 303 const(char)* psk, 304 const(char)* identity, 305 const(char)* ciphers) { mixin(SSLL_CALL); } 306 307 308 void mosquitto_connect_callback_set( 309 mosquitto* mosq, 310 mosq_base_callback on_connect) { mixin(SSLL_CALL); } 311 312 void mosquitto_connect_with_flags_callback_set( 313 mosquitto* mosq, 314 mosq_wf_callback on_connect) { mixin(SSLL_CALL); } 315 316 void mosquitto_connect_v5_callback_set( 317 mosquitto* mosq, 318 mosq_v5_base2_callback on_connect) { mixin(SSLL_CALL); } 319 320 void mosquitto_disconnect_callback_set( 321 mosquitto* mosq, 322 mosq_base_callback on_disconnect) { mixin(SSLL_CALL); } 323 324 void mosquitto_disconnect_v5_callback_set( 325 mosquitto* mosq, 326 mosq_v5_base1_callback on_disconnect) { mixin(SSLL_CALL); } 327 328 void mosquitto_publish_callback_set( 329 mosquitto* mosq, 330 mosq_base_callback on_publish) { mixin(SSLL_CALL); } 331 332 void mosquitto_publish_v5_callback_set( 333 mosquitto* mosq, 334 mosq_v5_base2_callback on_publish) { mixin(SSLL_CALL); } 335 336 void mosquitto_message_callback_set( 337 mosquitto* mosq, 338 mosq_msg_callback on_message) { mixin(SSLL_CALL); } 339 340 void mosquitto_message_v5_callback_set( 341 mosquitto* mosq, 342 mosq_v5_msg_callback on_message) { mixin(SSLL_CALL); } 343 344 void mosquitto_subscribe_callback_set( 345 mosquitto* mosq, 346 mosq_sub_callback on_subscribe) { mixin(SSLL_CALL); } 347 348 void mosquitto_subscribe_v5_callback_set( 349 mosquitto* mosq, 350 mosq_v5_sub_callback on_subscribe) { mixin(SSLL_CALL); } 351 352 void mosquitto_unsubscribe_callback_set( 353 mosquitto* mosq, 354 mosq_base_callback on_unsubscribe) { mixin(SSLL_CALL); } 355 356 void mosquitto_unsubscribe_v5_callback_set( 357 mosquitto* mosq, 358 mosq_v5_base1_callback on_unsubscribe) { mixin(SSLL_CALL); } 359 360 void mosquitto_log_callback_set( 361 mosquitto* mosq, 362 mosq_log_callback on_log) { mixin(SSLL_CALL); } 363 364 int mosquitto_reconnect_delay_set( 365 mosquitto* mosq, 366 uint reconnect_delay, 367 uint reconnect_delay_max, 368 bool reconnect_exponential_backoff) { mixin(SSLL_CALL); } 369 370 int mosquitto_socks5_set( 371 mosquitto* mosq, 372 const(char)* host, 373 int port, 374 const(char)* username, 375 const(char)* password) { mixin(SSLL_CALL); } 376 377 const(char)* mosquitto_strerror(int mosq_errno) { mixin(SSLL_CALL); } 378 379 const(char)* mosquitto_connack_string(int connack_code) { mixin(SSLL_CALL); } 380 381 const(char)* mosquitto_reason_string(int reason_code) { mixin(SSLL_CALL); } 382 383 int mosquitto_string_to_command( 384 const(char)* str, 385 int* cmd) { mixin(SSLL_CALL); } 386 387 int mosquitto_sub_topic_tokenise( 388 const(char)* subtopic, 389 char*** topics, 390 int* count) { mixin(SSLL_CALL); } 391 392 int mosquitto_sub_topic_tokens_free( 393 char*** topics, 394 int count) { mixin(SSLL_CALL); } 395 396 int mosquitto_topic_matches_sub( 397 const(char)* sub, 398 const(char)* topic, 399 bool* result) { mixin(SSLL_CALL); } 400 401 int mosquitto_topic_matches_sub2( 402 const(char)* sub, 403 size_t sublen, 404 const(char)* topic, 405 size_t topiclen, 406 bool* result) { mixin(SSLL_CALL); } 407 408 int mosquitto_pub_topic_check(const(char)* topic) { mixin(SSLL_CALL); } 409 410 int mosquitto_pub_topic_check2( 411 const(char)* topic, 412 size_t topiclen) { mixin(SSLL_CALL); } 413 414 int mosquitto_sub_topic_check(const(char)* topic) { mixin(SSLL_CALL); } 415 416 int mosquitto_sub_topic_check2( 417 const(char)* topic, 418 size_t topiclen) { mixin(SSLL_CALL); } 419 420 int mosquitto_validate_utf8( 421 const(char)* str, 422 int len) { mixin(SSLL_CALL); } 423 424 int mosquitto_subscribe_simple( 425 mosquitto_message** messages, 426 int msg_count, 427 bool want_retained, 428 const(char)* topic, 429 int qos, 430 const(char)* host, 431 int port, 432 const(char)* client_id, 433 int keepalive, 434 bool clean_session, 435 const(char)* username, 436 const(char)* password, 437 const libmosquitto_will* will, 438 const libmosquitto_tls* tls) { mixin(SSLL_CALL); } 439 440 int mosquitto_subscribe_callback( 441 mosq_msg_callback callback, 442 void* userdata, 443 const(char)* topic, 444 int qos, 445 const(char)* host, 446 int port, 447 const(char)* client_id, 448 int keepalive, 449 bool clean_session, 450 const(char)* username, 451 const(char)* password, 452 const libmosquitto_will* will, 453 const libmosquitto_tls* tls) { mixin(SSLL_CALL); } 454 455 456 int mosquitto_property_add_byte( 457 mosquitto_property** proplist, 458 int identifier, 459 ubyte value) { mixin(SSLL_CALL); } 460 461 int mosquitto_property_add_int16( 462 mosquitto_property** proplist, 463 int identifier, 464 ushort value) { mixin(SSLL_CALL); } 465 466 int mosquitto_property_add_int32( 467 mosquitto_property** proplist, 468 int identifier, 469 uint value) { mixin(SSLL_CALL); } 470 471 int mosquitto_property_add_varint( 472 mosquitto_property** proplist, 473 int identifier, 474 uint value) { mixin(SSLL_CALL); } 475 476 int mosquitto_property_add_binary( 477 mosquitto_property** proplist, 478 int identifier, 479 const(void)* value, 480 ushort len) { mixin(SSLL_CALL); } 481 482 int mosquitto_property_add_string( 483 mosquitto_property** proplist, 484 int identifier, 485 const(char)* value) { mixin(SSLL_CALL); } 486 487 int mosquitto_property_add_string_pair( 488 mosquitto_property** proplist, 489 int identifier, 490 const(char)* name, 491 const(char)* value) { mixin(SSLL_CALL); } 492 493 const(mosquitto_property)* mosquitto_property_read_byte( 494 const mosquitto_property* proplist, 495 int identifier, 496 ubyte* value, 497 bool skip_first) { mixin(SSLL_CALL); } 498 499 const(mosquitto_property)* mosquitto_property_read_int16( 500 const mosquitto_property* proplist, 501 int identifier, 502 ushort* value, 503 bool skip_first) { mixin(SSLL_CALL); } 504 505 const(mosquitto_property)* mosquitto_property_read_int32( 506 const mosquitto_property* proplist, 507 int identifier, 508 uint* value, 509 bool skip_first) { mixin(SSLL_CALL); } 510 511 const(mosquitto_property)* mosquitto_property_read_varint( 512 const mosquitto_property* proplist, 513 int identifier, 514 uint* value, 515 bool skip_first) { mixin(SSLL_CALL); } 516 517 const(mosquitto_property)* mosquitto_property_read_binary( 518 const mosquitto_property* proplist, 519 int identifier, 520 void** value, 521 ushort* len, 522 bool skip_first) { mixin(SSLL_CALL); } 523 524 const(mosquitto_property)* mosquitto_property_read_string( 525 const mosquitto_property *proplist, 526 int identifier, 527 char** value, 528 bool skip_first) { mixin(SSLL_CALL); } 529 530 const(mosquitto_property)* mosquitto_property_read_string_pair( 531 const mosquitto_property* proplist, 532 int identifier, 533 char** name, 534 char** value, 535 bool skip_first) { mixin(SSLL_CALL); } 536 537 void mosquitto_property_free_all(mosquitto_property** properties); 538 539 int mosquitto_property_copy_all( 540 mosquitto_property** dest, 541 const mosquitto_property* src) { mixin(SSLL_CALL); } 542 543 int mosquitto_property_check_command( 544 int command, 545 int identifier) { mixin(SSLL_CALL); } 546 547 int mosquitto_property_check_all( 548 int command, 549 const mosquitto_property *properties) { mixin(SSLL_CALL); } 550 551 int mosquitto_string_to_property_info( 552 const(char)* propname, 553 int* identifier, 554 int* type) { mixin(SSLL_CALL); }