/* Copyright (c) 2009-2018 Roger Light All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 and Eclipse Distribution License v1.0 which accompany this distribution. The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. Contributors: Roger Light - initial implementation and documentation. */ #include "config.h" #include #include #include #include #include #ifdef WIN32 #else # include #endif #ifndef WIN32 # include # include # include #else # include # include #endif #if !defined(WIN32) && !defined(__CYGWIN__) # include #endif #include "mosquitto_broker_internal.h" #include "memory_mosq.h" #include "tls_mosq.h" #include "util_mosq.h" #include "mqtt_protocol.h" int strcasecmp_p(const void *p1, const void *p2) { return strcasecmp(*(const char **)p1, *(const char **)p2); } #ifdef WIN32 int config__get_dir_files(const char *include_dir, char ***files, int *file_count) { int len; int i; char **l_files = NULL; int l_file_count = 0; char **files_tmp; HANDLE fh; char dirpath[MAX_PATH]; WIN32_FIND_DATA find_data; snprintf(dirpath, MAX_PATH, "%s\\*.conf", include_dir); fh = FindFirstFile(dirpath, &find_data); if(fh == INVALID_HANDLE_VALUE){ log__printf(NULL, MOSQ_LOG_ERR, "Error: Unable to open include_dir '%s'.", include_dir); return 1; } do{ len = strlen(include_dir)+1+strlen(find_data.cFileName)+1; l_file_count++; files_tmp = mosquitto__realloc(l_files, l_file_count*sizeof(char *)); if(!files_tmp){ for(i=0; id_name) > 5){ if(!strcmp(&de->d_name[strlen(de->d_name)-5], ".conf")){ len = strlen(include_dir)+1+strlen(de->d_name)+1; l_file_count++; files_tmp = mosquitto__realloc(l_files, l_file_count*sizeof(char *)); if(!files_tmp){ for(i=0; id_name); l_files[l_file_count-1][len] = '\0'; } } } closedir(dh); *files = l_files; *file_count = l_file_count; return 0; } #endif