19 #if !defined(_WRS_KERNEL) 25 #include <sys/types.h> 29 #if defined(_WIN32) || defined(_WIN64) 56 static const char*
libraries[] = {
"paho-mqtt3c",
"paho-mqtt3cs",
"paho-mqtt3a",
"paho-mqtt3as"};
57 static const char*
eyecatchers[] = {
"MQTTAsyncV3_Version",
"MQTTAsyncV3_Timestamp",
58 "MQTTClientV3_Version",
"MQTTClientV3_Timestamp"};
61 char*
FindString(
char* filename,
const char* eyecatcher_input);
73 char*
FindString(
char* filename,
const char* eyecatcher_input)
76 static char value[100];
79 memset(value, 0, 100);
80 if ((infile = fopen(filename,
"rb")) != NULL)
82 size_t buflen = strlen(eyecatcher);
83 char* buffer = (
char*)
malloc(buflen + 1);
87 int c = fgetc(infile);
89 while (feof(infile) == 0)
93 if (memcmp(eyecatcher, buffer, buflen) == 0)
107 memmove(buffer, &buffer[1], buflen - 1);
127 printf(
"%s: %s\n", info->
name, info->
value);
140 #if defined(_WIN32) || defined(_WIN64) 141 HMODULE APILibrary = LoadLibraryA(libname);
142 if (APILibrary == NULL)
143 printf(
"Error loading library %s, error code %d\n", libname, GetLastError());
146 func_address = (
func_type)GetProcAddress(APILibrary,
"MQTTAsync_getVersionInfo");
147 if (func_address == NULL)
148 func_address = (
func_type)GetProcAddress(APILibrary,
"MQTTClient_getVersionInfo");
151 FreeLibrary(APILibrary);
154 void* APILibrary = dlopen(libname, RTLD_LAZY);
155 if (APILibrary == NULL)
156 printf(
"Error loading library %s, error %s\n", libname, dlerror());
159 *(
void **) (&func_address) = dlsym(APILibrary,
"MQTTAsync_getVersionInfo");
160 if (func_address == NULL)
161 func_address = dlsym(APILibrary,
"MQTTClient_getVersionInfo");
171 #if !defined(ARRAY_SIZE) 172 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) 188 int main(
int argc,
char** argv)
190 printf(
"MQTTVersion: print the version strings of an MQTT client library\n");
191 printf(
"Copyright (c) 2012, 2018 IBM Corp.\n");
198 printf(
"Specify a particular library name if it is not in the current directory, or not executable on this platform\n");
202 #if defined(__CYGWIN__) 203 sprintf(namebuf,
"cyg%s-1.dll",
libraries[i]);
204 #elif defined(_WIN32) || defined(_WIN64) 205 sprintf(namebuf,
"%s.dll",
libraries[i]);
207 sprintf(namebuf,
"lib%s.1.dylib",
libraries[i]);
209 sprintf(namebuf,
"lib%s.so.1",
libraries[i]);
211 printf(
"--- Trying library %s ---\n",
libraries[i]);
227 fprintf(stderr,
"This tool is not supported on this platform yet.\n");
int loadandcall(const char *libname)
enum MQTTPropertyCodes value
void printEyecatchers(char *filename)
char * FindString(char *filename, const char *eyecatcher_input)
int printVersionInfo(MQTTAsync_nameValue *info)
MQTTAsync_nameValue *(* func_type)(void)
int main(int argc, char **argv)
static const char * eyecatchers[]
static eyecatcherType eyecatcher
static const char * libraries[]