diff options
Diffstat (limited to 'load_config.h')
-rw-r--r-- | load_config.h | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/load_config.h b/load_config.h index 165c676..65f5e7f 100644 --- a/load_config.h +++ b/load_config.h @@ -4,41 +4,41 @@ #define CONFIG_PARSE_SUCCESS 0 #define CONFIG_PARSE_FAILED -1 -int parse_config( server_config_t *svconfig, long long int cfg_len ){ +int parse_config( server_config_t *svconfig, ssize_t cfg_len ){ if ( svconfig->config_contents == NULL || cfg_len <= 0 ) return CONFIG_PARSE_FAILED; svconfig->config_parsed = cJSON_ParseWithLength( svconfig->config_contents, (size_t)cfg_len ); if ( svconfig->config_parsed == NULL ) return CONFIG_PARSE_FAILED; svconfig->log_enabled = cJSON_GetObjectItemCaseSensitive( svconfig->config_parsed, "log_enabled" ); - if ( svconfig->log_enabled == NULL || (long long int)strlen(svconfig->log_enabled->valuestring) <= 0 ) + if ( svconfig->log_enabled == NULL || (int64_t)strlen(svconfig->log_enabled->valuestring) <= 0 ) return CONFIG_PARSE_FAILED; svconfig->log_file = cJSON_GetObjectItemCaseSensitive( svconfig->config_parsed, "log_file" ); - if ( svconfig->log_file == NULL || (long long int)strlen(svconfig->log_file->valuestring) <= 0 ) + if ( svconfig->log_file == NULL || (int64_t)strlen(svconfig->log_file->valuestring) <= 0 ) return CONFIG_PARSE_FAILED; svconfig->bind_address = cJSON_GetObjectItemCaseSensitive( svconfig->config_parsed, "bind_address" ); - if ( svconfig->bind_address == NULL || (long long int)strlen(svconfig->bind_address->valuestring) <= 0 ) + if ( svconfig->bind_address == NULL || (int64_t)strlen(svconfig->bind_address->valuestring) <= 0 ) return CONFIG_PARSE_FAILED; svconfig->bind_port = cJSON_GetObjectItemCaseSensitive( svconfig->config_parsed, "bind_port" ); - if ( svconfig->bind_port == NULL || (long long int)strlen(svconfig->bind_port->valuestring) <= 0 ) + if ( svconfig->bind_port == NULL || (int64_t)strlen(svconfig->bind_port->valuestring) <= 0 ) return CONFIG_PARSE_FAILED; svconfig->server_password = cJSON_GetObjectItemCaseSensitive( svconfig->config_parsed, "server_password" ); - if ( svconfig->server_password == NULL || (long long int)strlen(svconfig->server_password->valuestring) <= 0 ) + if ( svconfig->server_password == NULL || (int64_t)strlen(svconfig->server_password->valuestring) <= 0 ) return CONFIG_PARSE_FAILED; svconfig->cert_file = cJSON_GetObjectItemCaseSensitive( svconfig->config_parsed, "cert_file" ); - if ( svconfig->cert_file == NULL || (long long int)strlen(svconfig->cert_file->valuestring) <= 0 ) + if ( svconfig->cert_file == NULL || (int64_t)strlen(svconfig->cert_file->valuestring) <= 0 ) return CONFIG_PARSE_FAILED; svconfig->cert_key_file = cJSON_GetObjectItemCaseSensitive( svconfig->config_parsed, "cert_key_file" ); - if ( svconfig->cert_key_file == NULL || (long long int)strlen(svconfig->cert_key_file->valuestring) <= 0 ) + if ( svconfig->cert_key_file == NULL || (int64_t)strlen(svconfig->cert_key_file->valuestring) <= 0 ) return CONFIG_PARSE_FAILED; svconfig->webhooks_file = cJSON_GetObjectItemCaseSensitive( svconfig->config_parsed, "webhooks_file" ); - if ( svconfig->webhooks_file == NULL || (long long int)strlen(svconfig->webhooks_file->valuestring) <= 0 ) + if ( svconfig->webhooks_file == NULL || (int64_t)strlen(svconfig->webhooks_file->valuestring) <= 0 ) return CONFIG_PARSE_FAILED; return CONFIG_PARSE_SUCCESS; } int load_config( char *config_file_name, server_config_t *sv_config ){ - if ( config_file_name == NULL || (long long int)strlen(config_file_name) <= 0 || strcmp((const char*)config_file_name, "") == 0 ) + if ( config_file_name == NULL || (int64_t)strlen(config_file_name) <= 0 || strcmp((const char*)config_file_name, "") == 0 ) return CONFIG_LOAD_FAILED; FILE *cfg_file = fopen( config_file_name, "r" ); if ( cfg_file == NULL ) @@ -47,7 +47,7 @@ int load_config( char *config_file_name, server_config_t *sv_config ){ fclose( cfg_file ); return CONFIG_LOAD_FAILED; } - long long int cfg_file_size = (long long int)ftell( cfg_file ); + ssize_t cfg_file_size = (ssize_t)ftell( cfg_file ); if ( cfg_file_size <= 0 ){ rewind( cfg_file ); fclose( cfg_file ); @@ -60,7 +60,7 @@ int load_config( char *config_file_name, server_config_t *sv_config ){ cfg_file_size = 0; return CONFIG_LOAD_FAILED; } - if ( (long long int)fread(sv_config->config_contents, sizeof(char), (size_t)(cfg_file_size * sizeof(char)), cfg_file) == (long long int)-1 ){ + if ( (int64_t)fread(sv_config->config_contents, sizeof(char), (size_t)(cfg_file_size * sizeof(char)), cfg_file) == (int64_t)-1 ){ free( sv_config->config_contents ); sv_config->config_contents = NULL; fclose( cfg_file ); |