From 1305cfcd24ccd53218818427978fac5242523089 Mon Sep 17 00:00:00 2001 From: "hwajeong.son" Date: Mon, 1 Oct 2018 19:43:59 +0900 Subject: [PATCH] Applied coding rule Not to make coding rule error, check tizen coding rule --- src/adaptor.c | 77 ++++++------- src/input_file.c | 266 +++++++++++++++++++------------------------- src/input_file.h | 10 +- src/sa_common.h | 6 - src/sa_types.h | 44 ++++---- src/setup_network.c | 145 ++++++++++-------------- src/setup_network.h | 7 +- src/setup_system.c | 17 ++- src/setup_system.h | 5 +- 9 files changed, 245 insertions(+), 332 deletions(-) mode change 100644 => 100755 src/adaptor.c mode change 100644 => 100755 src/input_file.c mode change 100644 => 100755 src/input_file.h mode change 100644 => 100755 src/sa_common.h mode change 100644 => 100755 src/sa_types.h mode change 100644 => 100755 src/setup_network.c mode change 100644 => 100755 src/setup_network.h mode change 100644 => 100755 src/setup_system.c mode change 100644 => 100755 src/setup_system.h diff --git a/src/adaptor.c b/src/adaptor.c old mode 100644 new mode 100755 index 843cf41..aa4beaa --- a/src/adaptor.c +++ b/src/adaptor.c @@ -24,8 +24,7 @@ #include "setup_network.h" #include "input_file.h" - -static gboolean prepare(GSource *source, gint *timeout) +static gboolean prepare(GSource * source, gint * timeout) { return TRUE; } @@ -33,33 +32,29 @@ static gboolean prepare(GSource *source, gint *timeout) gboolean setup_cb(gpointer data) { sa_error_e ret = SA_ERROR_NONE; - sa_config_s config = {0,}; + sa_config_s config = { 0, }; sa_error_e file_read = SA_ERROR_NONE; - + _D("callback>>>setup_cb start !!!"); file_read = sa_inputfile_get_config_info(&config); if (file_read == SA_ERROR_NONE) { _D("flag_completion(system=%d)(eth=%d)(wifi=%d)", sa_inputfile_get_completion_flag(SA_FILE_CONFIG_SYSTEM) - , sa_inputfile_get_completion_flag(SA_FILE_CONFIG_ETHERNET) - , sa_inputfile_get_completion_flag(SA_FILE_CONFIG_WIFI) ); + , sa_inputfile_get_completion_flag(SA_FILE_CONFIG_ETHERNET) + , sa_inputfile_get_completion_flag(SA_FILE_CONFIG_WIFI)); - if (config.systemData != NULL && !sa_inputfile_get_completion_flag(SA_FILE_CONFIG_SYSTEM) ) { + if (config.systemData != NULL && !sa_inputfile_get_completion_flag(SA_FILE_CONFIG_SYSTEM)) { ret = sa_setup_system(config.systemData); - if(ret != SA_ERROR_NONE) { + if (ret != SA_ERROR_NONE) _E("sa_setup_system return error(%d)", ret); - } } sa_inputfile_set_completion_flag(SA_FILE_CONFIG_SYSTEM); - if (config.networkData != NULL) { ret = sa_setup_network(config.networkData); - if(ret != SA_ERROR_NONE) { + if (ret != SA_ERROR_NONE) _E("sa_setup_network return error(%d)", ret); - } - } - else { + } else { sa_inputfile_set_completion_flag(SA_FILE_CONFIG_ETHERNET); sa_inputfile_set_completion_flag(SA_FILE_CONFIG_WIFI); } @@ -71,52 +66,52 @@ gboolean setup_cb(gpointer data) sa_inputfile_remove(); } -static GSourceFuncs SourceFuncs = -{ - prepare, // prepare function - NULL, // function check - sa_inputfile_thread, // main function to execute +static GSourceFuncs SourceFuncs = { + prepare, // prepare function + NULL, // function check + sa_inputfile_thread, // main function to execute NULL }; -// config for main thread & callback function -static gpointer main_thread (gpointer data) +// config for main thread & callback function +static gpointer main_thread(gpointer data) { - GSource* src = NULL; + GSource *src = NULL; _D("main_thread ~~~"); - GMainLoop* main_loop; - GMainContext* context = NULL; + GMainLoop *main_loop; + GMainContext *context = NULL; - context = g_main_context_new (); - main_loop = g_main_loop_new (context, FALSE); + context = g_main_context_new(); + main_loop = g_main_loop_new(context, FALSE); src = g_source_new(&SourceFuncs, sizeof(GSource)); - - g_source_set_name (src, "setup-adaptor-func"); - g_source_set_priority (src, G_PRIORITY_DEFAULT); - g_source_set_callback(src, // GSourceFuncs prototype - (GSourceFunc) setup_cb, // callabck function - (gpointer) main_loop, // gpointer : set as GMainLoop handle to destroy in thread - NULL); - g_source_attach (src, context); + + g_source_set_name(src, "setup-adaptor-func"); + g_source_set_priority(src, G_PRIORITY_DEFAULT); + g_source_set_callback(src, // GSourceFuncs prototype + (GSourceFunc) setup_cb, // callabck function + (gpointer) main_loop, // gpointer : set as GMainLoop handle to destroy in thread + NULL); + g_source_attach(src, context); g_main_loop_run(main_loop); g_main_loop_unref(main_loop); - if(data) { - g_main_loop_quit( (GMainLoop*)data ); - } + + if (data) + g_main_loop_quit((GMainLoop *) data); + _D("main_thread exit~~~"); return NULL; } int main(int argc, char *argv[]) -{ +{ sa_file_state_e file_state = SA_FILE_STATE_NOT_EXISTED; - sa_config_s config = {0,}; + sa_config_s config = { 0, }; // check if exists config file file_state = sa_inputfile_get_config_state(); @@ -135,6 +130,6 @@ int main(int argc, char *argv[]) g_main_loop_run(main_loop); g_main_loop_unref(main_loop); - + return 0; -} \ No newline at end of file +} diff --git a/src/input_file.c b/src/input_file.c old mode 100644 new mode 100755 index d9d61b5..78f75a3 --- a/src/input_file.c +++ b/src/input_file.c @@ -42,7 +42,7 @@ static void *__config_main_loop(void *arg) _D("__config_main_loop start\n"); - callback = (file_state_cb)arg; + callback = (file_state_cb) arg; if (callback == NULL) { _D("Ccallback is null for event"); @@ -74,28 +74,23 @@ static void *__config_main_loop(void *arg) if (event->mask & IN_CREATE) { if (event->mask & IN_ISDIR) { _D("The directory %s was created", event->name); - } - else { + } else { _D("The file %s was create.", event->name); - if (!strcmp(event->name, CONFIG_NAME)) { + if (!strcmp(event->name, CONFIG_NAME)) _D("config.json is created!!"); - } } } else if (event->mask & IN_DELETE) { if (event->mask & IN_ISDIR) { _D("The directory %s was deleted.", event->name); - } - else { + } else { _D("The file %s was deleted", event->name); - if (!strcmp(event->name, CONFIG_NAME)) { + if (!strcmp(event->name, CONFIG_NAME)) _D("config.json is deleted!!"); - } } } else if (event->mask & IN_MODIFY) { if (event->mask & IN_ISDIR) { _D("The directory %s was modified", event->name); - } - else { + } else { if (!strcmp(event->name, CONFIG_NAME)) { _D("config.json is modified!!"); callback(SA_FILE_STATE_CHANGED, NULL, NULL); @@ -131,7 +126,7 @@ static int __init_event_listener(file_state_cb callback) return 0; } -static int json_get_int_from_obj(json_object *inputObj, char *key) +static int json_get_int_from_obj(json_object * inputObj, char *key) { struct json_object *bodyObj; enum json_type type; @@ -140,14 +135,13 @@ static int json_get_int_from_obj(json_object *inputObj, char *key) type = json_object_get_type(inputObj); if (type == json_type_object) { - if (json_object_object_get_ex(inputObj, key, &bodyObj)) { + if (json_object_object_get_ex(inputObj, key, &bodyObj)) ret = json_object_get_int(bodyObj); - } } return ret; } -static int json_get_boolean_from_obj(json_object *inputObj, char *key) +static int json_get_boolean_from_obj(json_object * inputObj, char *key) { struct json_object *bodyObj; enum json_type type; @@ -156,14 +150,13 @@ static int json_get_boolean_from_obj(json_object *inputObj, char *key) type = json_object_get_type(inputObj); if (type == json_type_object) { - if (json_object_object_get_ex(inputObj, key, &bodyObj)) { + if (json_object_object_get_ex(inputObj, key, &bodyObj)) ret = json_object_get_boolean(bodyObj); - } } return ret; } -static char *json_get_string_from_obj(json_object *inputObj, char *key) +static char *json_get_string_from_obj(json_object * inputObj, char *key) { const char *buf = NULL; char *ret_buf = NULL; @@ -191,7 +184,7 @@ static char *json_get_string_from_obj(json_object *inputObj, char *key) return ret_buf; } -static void print_config_network_static_info(sa_network_static_s *staticInfo) +static void print_config_network_static_info(sa_network_static_s * staticInfo) { if (staticInfo != NULL) { if (staticInfo->ipAddress != NULL) @@ -207,7 +200,7 @@ static void print_config_network_static_info(sa_network_static_s *staticInfo) } } -static void print_network_config(sa_network_s *network) +static void print_network_config(sa_network_s * network) { sa_wifi_s *wifi = NULL; sa_eth_s *eth = NULL; @@ -237,7 +230,7 @@ static void print_network_config(sa_network_s *network) } } -static void print_system_config(sa_system_s *systemData) +static void print_system_config(sa_system_s * systemData) { if (systemData != NULL) { if (systemData->proxy != NULL) { @@ -247,24 +240,21 @@ static void print_system_config(sa_system_s *systemData) } } -static void print_config_info(sa_config_s *config) +static void print_config_info(sa_config_s * config) { if (config != NULL) { - if (config->version != NULL) { + if (config->version != NULL) _D("Version [%s]", config->version); - } - if(config->networkData) - { + + if (config->networkData) print_network_config(config->networkData); - } - if(config->systemData) - { + + if (config->systemData) print_system_config(config->systemData); - } } } -static int __parse_network_static_info(json_object *inputObj, sa_network_static_s *staticInfo) +static int __parse_network_static_info(json_object * inputObj, sa_network_static_s * staticInfo) { char *ipAddress = NULL; char *netmask = NULL; @@ -276,7 +266,6 @@ static int __parse_network_static_info(json_object *inputObj, sa_network_static_ _D("__parse_network_static_info input error"); return -1; } - //ipAddress ipAddress = json_get_string_from_obj(inputObj, SA_CONFIG_NETWORKDATA_IPADDRESS); if (ipAddress != NULL) { @@ -285,15 +274,13 @@ static int __parse_network_static_info(json_object *inputObj, sa_network_static_ free(ipAddress); ipAddress = NULL; } - //netmask netmask = json_get_string_from_obj(inputObj, SA_CONFIG_NETWORKDATA_NETMASK); if (netmask != NULL) { - memcpy(staticInfo->netmask, netmask,strlen(netmask)); + memcpy(staticInfo->netmask, netmask, strlen(netmask)); free(netmask); netmask = NULL; } - //defaultGateway defaultGateway = json_get_string_from_obj(inputObj, SA_CONFIG_NETWORKDATA_DEFAULTGATEWAY); if (defaultGateway != NULL) { @@ -301,7 +288,6 @@ static int __parse_network_static_info(json_object *inputObj, sa_network_static_ free(defaultGateway); defaultGateway = NULL; } - //primaryDnsServer primaryDnsServer = json_get_string_from_obj(inputObj, SA_CONFIG_NETWORKDATA_PRIMARYDNSSERVER); if (primaryDnsServer != NULL) { @@ -309,7 +295,6 @@ static int __parse_network_static_info(json_object *inputObj, sa_network_static_ free(primaryDnsServer); primaryDnsServer = NULL; } - //secondaryDnsServer secondaryDnsServer = json_get_string_from_obj(inputObj, SA_CONFIG_NETWORKDATA_SECONDARYDNSSERVER); if (secondaryDnsServer != NULL) { @@ -321,7 +306,7 @@ static int __parse_network_static_info(json_object *inputObj, sa_network_static_ return 0; } -static int __parse_network_eth(json_object *inputObj, sa_eth_s *eth) +static int __parse_network_eth(json_object * inputObj, sa_eth_s * eth) { int ret = 0; @@ -329,25 +314,23 @@ static int __parse_network_eth(json_object *inputObj, sa_eth_s *eth) _D("__parse_network_eth input error"); return -1; } - // enabled eth->enabled = json_get_boolean_from_obj(inputObj, SA_CONFIG_NETWORKDATA_ENABLED); // dhcpEnabled eth->dhcpEnabled = json_get_boolean_from_obj(inputObj, SA_CONFIG_NETWORKDATA_DHCPENABLED); if (eth->dhcpEnabled == FALSE) { - eth->staticInfo = (sa_network_static_s *)malloc(sizeof(sa_network_static_s)); - if (eth->staticInfo != NULL) { + eth->staticInfo = (sa_network_static_s *) malloc(sizeof(sa_network_static_s)); + if (eth->staticInfo != NULL) ret = __parse_network_static_info(inputObj, eth->staticInfo); - } else { + else ret = -1; - } } return ret; } -static int __parse_network_wifi(json_object *inputObj, sa_wifi_s *wifi) +static int __parse_network_wifi(json_object * inputObj, sa_wifi_s * wifi) { char *ssid = NULL; char *password = NULL; @@ -363,7 +346,7 @@ static int __parse_network_wifi(json_object *inputObj, sa_wifi_s *wifi) // ssid ssid = json_get_string_from_obj(inputObj, SA_CONFIG_NETWORKDATA_WIFI_SSID); if (ssid != NULL) { - memcpy(wifi->ssid, ssid, MIN(strlen(ssid), sizeof(wifi->ssid)-1)); + memcpy(wifi->ssid, ssid, MIN(strlen(ssid), sizeof(wifi->ssid) - 1)); free(ssid); ssid = NULL; } else { @@ -373,7 +356,7 @@ static int __parse_network_wifi(json_object *inputObj, sa_wifi_s *wifi) // password password = json_get_string_from_obj(inputObj, SA_CONFIG_NETWORKDATA_WIFI_PASSWORD); if (password != NULL) { - memcpy(wifi->password, password, MIN(strlen(password), sizeof(wifi->password)-1)); + memcpy(wifi->password, password, MIN(strlen(password), sizeof(wifi->password) - 1)); free(password); password = NULL; } else { @@ -383,18 +366,17 @@ static int __parse_network_wifi(json_object *inputObj, sa_wifi_s *wifi) // dhcpEnabled wifi->dhcpEnabled = json_get_boolean_from_obj(inputObj, SA_CONFIG_NETWORKDATA_DHCPENABLED); if (wifi->dhcpEnabled == FALSE) { - wifi->staticInfo = (sa_network_static_s *)malloc(sizeof(sa_network_static_s)); - if (wifi->staticInfo != NULL) { + wifi->staticInfo = (sa_network_static_s *) malloc(sizeof(sa_network_static_s)); + if (wifi->staticInfo != NULL) ret = __parse_network_static_info(inputObj, wifi->staticInfo); - } else { + else ret = -1; - } - } + } return ret; } -static int __parse_network_data(json_object *inputObj, sa_config_s *setupConfig) +static int __parse_network_data(json_object * inputObj, sa_config_s * setupConfig) { struct json_object *wifiObj = NULL; struct json_object *ethernetObj = NULL; @@ -405,31 +387,28 @@ static int __parse_network_data(json_object *inputObj, sa_config_s *setupConfig) return -1; } - setupConfig->networkData = (sa_network_s *)malloc(sizeof(sa_network_s)); + setupConfig->networkData = (sa_network_s *) malloc(sizeof(sa_network_s)); if (setupConfig->networkData != NULL) { //parse wifi if (json_object_object_get_ex(inputObj, SA_CONFIG_NETWORKDATA_WIFI, &wifiObj)) { if (json_object_get_type(wifiObj) == json_type_object) { // malloc - setupConfig->networkData->wifi = (sa_wifi_s *)malloc(sizeof(sa_wifi_s)); - if (setupConfig->networkData->wifi != NULL) { + setupConfig->networkData->wifi = (sa_wifi_s *) malloc(sizeof(sa_wifi_s)); + if (setupConfig->networkData->wifi != NULL) wifiRet = __parse_network_wifi(wifiObj, setupConfig->networkData->wifi); - } else { + else _D("network->wifi malloc fail"); - } } } - //parse eth if (json_object_object_get_ex(inputObj, SA_CONFIG_NETWORKDATA_ETHERNET, ðernetObj)) { if (json_object_get_type(ethernetObj) == json_type_object) { // malloc - setupConfig->networkData->eth = (sa_eth_s *)malloc(sizeof(sa_eth_s)); - if (setupConfig->networkData->eth != NULL) { + setupConfig->networkData->eth = (sa_eth_s *) malloc(sizeof(sa_eth_s)); + if (setupConfig->networkData->eth != NULL) ethRet = __parse_network_eth(ethernetObj, setupConfig->networkData->eth); - } else { + else _D("network->eth malloc fail"); - } } } } else { @@ -445,8 +424,7 @@ static int __parse_network_data(json_object *inputObj, sa_config_s *setupConfig) return 0; } - -static int __parse_system_data(json_object *inputObj, sa_config_s *setupConfig) +static int __parse_system_data(json_object * inputObj, sa_config_s * setupConfig) { int ret = 0; char *httpProxyHost = NULL; @@ -454,15 +432,14 @@ static int __parse_system_data(json_object *inputObj, sa_config_s *setupConfig) _D("__parse_system_data input error"); return -1; } - //httpProxyHost httpProxyHost = json_get_string_from_obj(inputObj, SA_CONFIG_NETWORKDATA_HTTPPROXYHOST); if (httpProxyHost != NULL) { - setupConfig->systemData = (sa_system_s *)malloc(sizeof(sa_system_s)); + setupConfig->systemData = (sa_system_s *) malloc(sizeof(sa_system_s)); if (setupConfig->systemData != NULL) { - setupConfig->systemData->proxy = (sa_proxy_s *)malloc(sizeof(sa_proxy_s)); + setupConfig->systemData->proxy = (sa_proxy_s *) malloc(sizeof(sa_proxy_s)); if (setupConfig->systemData->proxy != NULL) { - memcpy(setupConfig->systemData->proxy->httpProxyHost, httpProxyHost, MIN(strlen(httpProxyHost), sizeof(setupConfig->systemData->proxy->httpProxyHost)-1)); + memcpy(setupConfig->systemData->proxy->httpProxyHost, httpProxyHost, MIN(strlen(httpProxyHost), sizeof(setupConfig->systemData->proxy->httpProxyHost) - 1)); free(httpProxyHost); httpProxyHost = NULL; @@ -482,8 +459,7 @@ static int __parse_system_data(json_object *inputObj, sa_config_s *setupConfig) return ret; } - -static int __parse_version(json_object *inputObj, sa_config_s *setupConfig) +static int __parse_version(json_object * inputObj, sa_config_s * setupConfig) { char *version = NULL; @@ -495,7 +471,7 @@ static int __parse_version(json_object *inputObj, sa_config_s *setupConfig) version = json_get_string_from_obj(inputObj, SA_CONFIG_VERSION); if (version != NULL) { - memcpy(setupConfig->version, version, MIN(strlen(version), sizeof(setupConfig->version)-1)); + memcpy(setupConfig->version, version, MIN(strlen(version), sizeof(setupConfig->version) - 1)); free(version); version = NULL; } @@ -503,7 +479,7 @@ static int __parse_version(json_object *inputObj, sa_config_s *setupConfig) return 0; } -static int __parse_config(char *file, sa_config_s *setupConfig) +static int __parse_config(char *file, sa_config_s * setupConfig) { struct json_object *configObj = NULL; char *jsonData = NULL; @@ -529,13 +505,12 @@ static int __parse_config(char *file, sa_config_s *setupConfig) if (configObj != NULL && readLen > 0) { // parse version ret = __parse_version(configObj, setupConfig); - if (ret == 0) { + if (ret == 0) ret = __parse_system_data(configObj, setupConfig); - } - if (ret == 0) { + if (ret == 0) ret = __parse_network_data(configObj, setupConfig); - } + } else { ret = -1; _D("ConfigObj is not existed"); @@ -558,13 +533,13 @@ static int __parse_config(char *file, sa_config_s *setupConfig) return ret; } -sa_error_e sa_inputfile_get_config_info(sa_config_s *config) +sa_error_e sa_inputfile_get_config_info(sa_config_s * config) { sa_error_e ret = SA_ERROR_NONE; // check file - if (access(CONFIG_FILE, 0) != 0) { + if (access(CONFIG_FILE, 0) != 0) return SA_ERROR_NOT_SUPPORTED; - } + // parsing and fill into struct ret = __parse_config(CONFIG_FILE, config); if (ret != 0) { @@ -581,16 +556,15 @@ sa_file_state_e sa_inputfile_get_config_state(void) { sa_file_state_e ret = SA_FILE_STATE_NOT_EXISTED; - if (access(CONFIG_FILE, F_OK) != -1) { + if (access(CONFIG_FILE, F_OK) != -1) ret = SA_FILE_STATE_EXIST; - } else { + else ret = SA_FILE_STATE_NOT_EXISTED; - } return ret; } -static void release_system_resource(sa_system_s *system) +static void release_system_resource(sa_system_s * system) { if (system != NULL) { if (system->proxy != NULL) @@ -600,7 +574,7 @@ static void release_system_resource(sa_system_s *system) } } -static void release_network_resource(sa_network_s *network) +static void release_network_resource(sa_network_s * network) { if (network != NULL) { if (network->wifi != NULL) { @@ -621,33 +595,31 @@ static void release_network_resource(sa_network_s *network) } } -gboolean sa_inputfile_thread(GSource *source, GSourceFunc callbackFuntion, gpointer user_data) +gboolean sa_inputfile_thread(GSource * source, GSourceFunc callbackFuntion, gpointer user_data) { - GMainLoop* loop = user_data; - GSource* src = NULL; + GMainLoop *loop = user_data; + GSource *src = NULL; _D("GSourceFuncs>>>Execution !!!"); #if 0 sa_error_e ret = SA_ERROR_NONE; - if (__init_event_listener(callback)) { + if (__init_event_listener(callback)) ret = SA_ERROR_UNKNOWN; - } #else callbackFuntion(NULL); #endif - if(user_data) { - g_main_loop_quit( (GMainLoop*)user_data ); - } + if (user_data) + g_main_loop_quit((GMainLoop *) user_data); // if return value is "FALSE", function stop // if return value is "TRUE", function restart return FALSE; } -void sa_inputfile_release_resource(sa_config_s *config) +void sa_inputfile_release_resource(sa_config_s * config) { if (config != NULL) { @@ -659,56 +631,53 @@ void sa_inputfile_release_resource(sa_config_s *config) } } -#define FLAG_FILE_SYSTEM "/etc/setup-adaptor/system_executed" -#define FLAG_FILE_ETH "/etc/setup-adaptor/ethernet_executed" -#define FLAG_FILE_WIFI "/etc/setup-adaptor/wifi_executed" +#define FLAG_FILE_SYSTEM "/etc/setup-adaptor/system_executed" +#define FLAG_FILE_ETH "/etc/setup-adaptor/ethernet_executed" +#define FLAG_FILE_WIFI "/etc/setup-adaptor/wifi_executed" void sa_inputfile_remove(void) { - if (remove(CONFIG_FILE) != 0) { + if (remove(CONFIG_FILE) != 0) _E("Can't remove file{%s}! %s", CONFIG_FILE, strerror(errno)); - } - else { + else _D("file removed successfully..{%s}", CONFIG_FILE); - } + } void sa_inputfile_clear_completion_flag(void) { - if (remove(FLAG_FILE_SYSTEM) == 0) { + if (remove(FLAG_FILE_SYSTEM) == 0) _D("file removed successfully..{%s}", FLAG_FILE_SYSTEM); - } - if (remove(FLAG_FILE_ETH) == 0) { + + if (remove(FLAG_FILE_ETH) == 0) _D("file removed successfully..{%s}", FLAG_FILE_ETH); - } - if (remove(FLAG_FILE_WIFI) == 0) { + + if (remove(FLAG_FILE_WIFI) == 0) _D("file removed successfully..{%s}", FLAG_FILE_WIFI); - } + } void sa_inputfile_set_completion_flag(sa_file_config_e config_type) { int fd; - - switch(config_type) - { - case SA_FILE_CONFIG_SYSTEM: - fd = creat(FLAG_FILE_SYSTEM, NULL); - break; - case SA_FILE_CONFIG_ETHERNET: - fd = creat(FLAG_FILE_ETH, NULL); - break; - case SA_FILE_CONFIG_WIFI: - fd = creat(FLAG_FILE_WIFI, NULL); - break; - default: - _E("unknown parameter (%d)", config_type); - break; - } - - if(fd == -1) { + + switch (config_type) { + case SA_FILE_CONFIG_SYSTEM: + fd = creat(FLAG_FILE_SYSTEM, NULL); + break; + case SA_FILE_CONFIG_ETHERNET: + fd = creat(FLAG_FILE_ETH, NULL); + break; + case SA_FILE_CONFIG_WIFI: + fd = creat(FLAG_FILE_WIFI, NULL); + break; + default: + _E("unknown parameter (%d)", config_type); + break; + } + + if (fd == -1) _E("Can't create file for (%d)! %s", config_type, strerror(errno)); - } } // return TRUE if set @@ -716,34 +685,31 @@ gboolean sa_inputfile_get_completion_flag(sa_file_config_e config_type) { int ret = 0; - switch(config_type) - { - case SA_FILE_CONFIG_SYSTEM: - ret = access(FLAG_FILE_SYSTEM, 0); - break; - case SA_FILE_CONFIG_ETHERNET: + switch (config_type) { + case SA_FILE_CONFIG_SYSTEM: + ret = access(FLAG_FILE_SYSTEM, 0); + break; + case SA_FILE_CONFIG_ETHERNET: + ret = access(FLAG_FILE_ETH, 0); + break; + case SA_FILE_CONFIG_WIFI: + ret = access(FLAG_FILE_WIFI, 0); + break; + case SA_FILE_CONFIG_ALL: + ret = access(FLAG_FILE_SYSTEM, 0); + if (ret == 0) ret = access(FLAG_FILE_ETH, 0); - break; - case SA_FILE_CONFIG_WIFI: + + if (ret == 0) ret = access(FLAG_FILE_WIFI, 0); - break; - case SA_FILE_CONFIG_ALL: - ret = access(FLAG_FILE_SYSTEM, 0); - if(ret == 0) { - ret = access(FLAG_FILE_ETH, 0); - } - if(ret == 0) { - ret = access(FLAG_FILE_WIFI, 0); - } - break; - default: - _E("unknown parameter (%d)", config_type); - break; + + break; + default: + _E("unknown parameter (%d)", config_type); + break; } - if (ret == 0) { + if (ret == 0) return TRUE; - } else { + else return FALSE; - } } - diff --git a/src/input_file.h b/src/input_file.h old mode 100644 new mode 100755 index 10cf9cf..501c9f3 --- a/src/input_file.h +++ b/src/input_file.h @@ -25,7 +25,7 @@ * @param sa_config_s [out] parsed config info * @return sa_file_state_e return of state */ -sa_error_e sa_inputfile_get_config_info(sa_config_s *config); +sa_error_e sa_inputfile_get_config_info(sa_config_s * config); /** * @fn int sa_inputfile_get_config_state(void) @@ -38,9 +38,9 @@ sa_file_state_e sa_inputfile_get_config_state(void); * @fn int sa_inputfile_thread * @brief This function to call callback at the condition of file * @param GSource parameter - * @return gboolean FALSE + * @return gboolean FALSE */ -gboolean sa_inputfile_thread(GSource *source, GSourceFunc callbackFuntion, gpointer user_data); +gboolean sa_inputfile_thread(GSource * source, GSourceFunc callbackFuntion, gpointer user_data); /** * @fn void sa_inputfile_release_resource @@ -48,7 +48,7 @@ gboolean sa_inputfile_thread(GSource *source, GSourceFunc callbackFuntion, gpoin * @param sa_config_s * @return void */ -void sa_inputfile_release_resource(sa_config_s *config); +void sa_inputfile_release_resource(sa_config_s * config); /** * @fn void sa_inputfile_remove @@ -82,4 +82,4 @@ void sa_inputfile_set_completion_flag(sa_file_config_e config_type); */ gboolean sa_inputfile_get_completion_flag(sa_file_config_e config_type); -#endif/* __INPUT_FILE_H__ */ \ No newline at end of file +#endif /* __INPUT_FILE_H__ */ diff --git a/src/sa_common.h b/src/sa_common.h old mode 100644 new mode 100755 index ad762d1..110f63a --- a/src/sa_common.h +++ b/src/sa_common.h @@ -37,14 +37,8 @@ #define FALSE 0 #endif -#if 1 #define _E(fmt, arg...) LOGE(fmt, ##arg) #define _D(fmt, arg...) LOGD(fmt, ##arg) #define _W(fmt, arg...) LOGW(fmt, ##arg) -#else -#define _E(fmt, arg...) {printf(fmt, ##arg);printf("\n");} -#define _D(fmt, arg...) {printf(fmt, ##arg);printf("\n");} -#define _W(fmt, arg...) {printf(fmt, ##arg);printf("\n");} -#endif #endif /* __SA_COMMON_H__ */ diff --git a/src/sa_types.h b/src/sa_types.h old mode 100644 new mode 100755 index 826797d..4c05371 --- a/src/sa_types.h +++ b/src/sa_types.h @@ -17,8 +17,8 @@ #define __SA_TYPES_H__ #define SA_CONFIG_VERSION "version" -#define SA_CONFIG_NETWORKDATA "networkData" -#define SA_CONFIG_SYSTEMDATA "systemData" +#define SA_CONFIG_NETWORKDATA "networkData" +#define SA_CONFIG_SYSTEMDATA "systemData" #define SA_CONFIG_NETWORKDATA_WIFI "wifi" #define SA_CONFIG_NETWORKDATA_WIFI_SSID "ssid" @@ -26,18 +26,17 @@ #define SA_CONFIG_NETWORKDATA_ETHERNET "ethernet" -#define SA_CONFIG_NETWORKDATA_ENABLED "enabled" -#define SA_CONFIG_NETWORKDATA_DHCPENABLED "dhcpEnabled" -#define SA_CONFIG_NETWORKDATA_IPADDRESS "ipAddress" -#define SA_CONFIG_NETWORKDATA_NETMASK "netmask" -#define SA_CONFIG_NETWORKDATA_DEFAULTGATEWAY "defaultGateway" -#define SA_CONFIG_NETWORKDATA_PRIMARYDNSSERVER "primaryDnsServer" +#define SA_CONFIG_NETWORKDATA_ENABLED "enabled" +#define SA_CONFIG_NETWORKDATA_DHCPENABLED "dhcpEnabled" +#define SA_CONFIG_NETWORKDATA_IPADDRESS "ipAddress" +#define SA_CONFIG_NETWORKDATA_NETMASK "netmask" +#define SA_CONFIG_NETWORKDATA_DEFAULTGATEWAY "defaultGateway" +#define SA_CONFIG_NETWORKDATA_PRIMARYDNSSERVER "primaryDnsServer" #define SA_CONFIG_NETWORKDATA_SECONDARYDNSSERVER "secondaryDnsServer" #define SA_CONFIG_NETWORKDATA_HTTPPROXYHOST "httpProxyHost" #define SA_CONFIG_NETWORKDATA_HTTPPROXYPORT "httpProxyPort" - /** * @brief This enum contains setup-adaptor error information * @@ -95,7 +94,6 @@ typedef enum { SA_FILE_STATE_CHANGED, /**< Changed */ } sa_file_state_e; - typedef enum { SA_FILE_CONFIG_SYSTEM = 0, /**< system configuration type */ SA_FILE_CONFIG_ETHERNET, /**< ethernet configuration type */ @@ -112,7 +110,6 @@ typedef enum { */ typedef void (*file_state_cb) (sa_network_state_e state, void *param1, void *param2); - /** * @struct sa_network_static_s * @brief This struct contains network static information in the config @@ -121,11 +118,11 @@ typedef void (*file_state_cb) (sa_network_state_e state, void *param1, void *par * */ typedef struct { - char ipAddress[255+1]; - char netmask[255+1]; - char defaultGateway[255+1]; - char primaryDnsServer[255+1]; - char secondaryDnsServer[255+1]; + char ipAddress[255 + 1]; + char netmask[255 + 1]; + char defaultGateway[255 + 1]; + char primaryDnsServer[255 + 1]; + char secondaryDnsServer[255 + 1]; } sa_network_static_s; /** @@ -138,8 +135,8 @@ typedef struct { typedef struct { int enabled; int dhcpEnabled; - char ssid[255+1]; - char password[255+1]; + char ssid[255 + 1]; + char password[255 + 1]; sa_network_static_s *staticInfo; } sa_wifi_s; @@ -158,14 +155,14 @@ typedef struct { /** * @struct sa_proxy_s - * @brief This struct contains proxy information + * @brief This struct contains proxy information * * The sa_network_s struct encapsulate httpproxyHost and httpProxyPort information in the one data * */ typedef struct { - char httpProxyHost[255+1]; - int httpProxyPort; + char httpProxyHost[255 + 1]; + int httpProxyPort; } sa_proxy_s; /** @@ -180,7 +177,6 @@ typedef struct { sa_eth_s *eth; } sa_network_s; - /** * @struct sa_system_s * @brief This struct contains system data information in the config @@ -189,7 +185,7 @@ typedef struct { * */ typedef struct { - char deviceName[255+1]; + char deviceName[255 + 1]; sa_proxy_s *proxy; } sa_system_s; @@ -201,7 +197,7 @@ typedef struct { * */ typedef struct { - char version[127+1]; + char version[127 + 1]; sa_network_s *networkData; sa_system_s *systemData; } sa_config_s; diff --git a/src/setup_network.c b/src/setup_network.c old mode 100644 new mode 100755 index c539487..dfbe151 --- a/src/setup_network.c +++ b/src/setup_network.c @@ -31,7 +31,6 @@ typedef struct { char *password; } _wifi_data_s; - static char *__print_connection_state(sa_network_state_e state) { switch (state) { @@ -46,7 +45,6 @@ static char *__print_connection_state(sa_network_state_e state) } } - static const char *__print_wifi_state(connection_wifi_state_e state) { switch (state) { @@ -191,35 +189,31 @@ static const char *__print_wifi_error(wifi_manager_error_e err_type) } } - -static void __wifi_exit_loop(_wifi_data_s *wifi_data) +static void __wifi_exit_loop(_wifi_data_s * wifi_data) { _D("__wifi_exit_loop !!!"); - if( wifi_data ) { - g_main_loop_quit( (GMainLoop*)wifi_data->loop ); - } + if (wifi_data) + g_main_loop_quit((GMainLoop *) wifi_data->loop); } static void __wifi_connected_cb(wifi_manager_error_e result, void *user_data) { - _wifi_data_s *wifi_data = (_wifi_data_s*)user_data; + _wifi_data_s *wifi_data = (_wifi_data_s *) user_data; - if (result == WIFI_MANAGER_ERROR_NONE){ + if (result == WIFI_MANAGER_ERROR_NONE) _D("__wifi_connected_cb() connected Successfully !!!"); - } - else { + else _D("__wifi_connected_cb() connection Failed!(%s)", __print_wifi_error(result)); - } + __wifi_exit_loop(wifi_data); } - // CAUTION : this callback function should be boolean type. // return true : continue search ap (not found) // return false : stop search ap (found) static bool __wifi_connect_ap_cb(wifi_manager_ap_h ap, void *user_data) { - _wifi_data_s *wifi_data = (_wifi_data_s*)user_data; + _wifi_data_s *wifi_data = (_wifi_data_s *) user_data; _D("__wifi_connect_ap_cb()"); @@ -228,7 +222,7 @@ static bool __wifi_connect_ap_cb(wifi_manager_ap_h ap, void *user_data) rv = wifi_manager_ap_get_essid(ap, &ap_name); if (rv != WIFI_MANAGER_ERROR_NONE) { - _D("Fail to get AP name [%s]", __print_wifi_error((wifi_manager_error_e)rv)); + _D("Fail to get AP name [%s]", __print_wifi_error((wifi_manager_error_e) rv)); g_free(ap_name); return false; } else { @@ -241,7 +235,7 @@ static bool __wifi_connect_ap_cb(wifi_manager_ap_h ap, void *user_data) _D("OK!!! connect AP [%s]", ap_name); rv = wifi_manager_ap_is_passphrase_required(ap, &required); - + if (rv == WIFI_MANAGER_ERROR_NONE) { if (required) { _D(" passphrase1 : [%s]", wifi_data->password); @@ -251,19 +245,16 @@ static bool __wifi_connect_ap_cb(wifi_manager_ap_h ap, void *user_data) __wifi_exit_loop(wifi_data); } } - if (rv == WIFI_MANAGER_ERROR_NONE) - { + if (rv == WIFI_MANAGER_ERROR_NONE) { rv = wifi_manager_connect(wifi_data->wifi_h, ap, __wifi_connected_cb, wifi_data); if (rv != WIFI_MANAGER_ERROR_NONE) { _D("Fail to connection request [%s] : %s", ap_name, __print_wifi_error(rv)); __wifi_exit_loop(wifi_data); - } - else { + } else { _D("Success to connection request [%s]", ap_name); } } - } - else { + } else { _D("Fail to passphrase_required request [%s]", __print_wifi_error(rv)); __wifi_exit_loop(wifi_data); } @@ -278,7 +269,7 @@ static bool __wifi_connect_ap_cb(wifi_manager_ap_h ap, void *user_data) static void __wifi_scan_finished_cb(wifi_manager_error_e result, void *user_data) { - _wifi_data_s *wifi_data = (_wifi_data_s*)user_data; + _wifi_data_s *wifi_data = (_wifi_data_s *) user_data; _D("__wifi_scan_finished_cb() result=[%s]", __print_wifi_error(result)); @@ -287,7 +278,7 @@ static void __wifi_scan_finished_cb(wifi_manager_error_e result, void *user_data static void __wifi_state_changed_cb(wifi_manager_device_state_e state, void *user_data) { - _wifi_data_s *wifi_data = (_wifi_data_s*)user_data; + _wifi_data_s *wifi_data = (_wifi_data_s *) user_data; _D("__wifi_state_changed_cb() state=[%d]", state); @@ -302,17 +293,17 @@ static void __wifi_activate_cb(wifi_manager_error_e result, void *user_data) _D("__wifi_activate_cb() result=[%s]", __print_wifi_error(result)); } -static int __wifi_connect_main(sa_wifi_s *info) +static int __wifi_connect_main(sa_wifi_s * info) { GMainLoop *gmain_loop = NULL; GMainContext *context; - _wifi_data_s wifi_data = {0,}; + _wifi_data_s wifi_data = { 0, }; int rv = 0; sa_error_e ret = SA_ERROR_UNKNOWN; wifi_manager_h wifi_h = NULL; - + _D("__wifi_connect_main (ssid=%s, pw=%s)", info->ssid, info->password); if (info == NULL) { @@ -320,10 +311,10 @@ static int __wifi_connect_main(sa_wifi_s *info) return -1; } - context = g_main_context_new (); - g_main_context_push_thread_default (context); // should be.. to get mainloop message in thread - gmain_loop = g_main_loop_new (context, FALSE); - + context = g_main_context_new(); + g_main_context_push_thread_default(context); // should be.. to get mainloop message in thread + gmain_loop = g_main_loop_new(context, FALSE); + rv = wifi_manager_initialize(&wifi_h); if (rv == WIFI_MANAGER_ERROR_NONE) { @@ -339,13 +330,12 @@ static int __wifi_connect_main(sa_wifi_s *info) _E("wifi_manager_activated failed.[%s]", __print_wifi_error(rv)); return SA_ERROR_UNKNOWN; } - } - else { + } else { _E("Wifi init failed [%s]", __print_wifi_error(rv)); return SA_ERROR_UNKNOWN; } - g_main_loop_run (gmain_loop); + g_main_loop_run(gmain_loop); gmain_loop = NULL; @@ -364,10 +354,9 @@ static int __wifi_connect_main(sa_wifi_s *info) return ret; } - connection_h eth_connect; -static bool __eth_get_user_selected_profile(connection_profile_h *profile, bool select) +static bool __eth_get_user_selected_profile(connection_profile_h * profile, bool select) { int rv = 0; int input = 0; @@ -379,7 +368,7 @@ static bool __eth_get_user_selected_profile(connection_profile_h *profile, bool rv = connection_get_profile_iterator(eth_connect, CONNECTION_ITERATOR_TYPE_REGISTERED, &profile_iter); if (rv != CONNECTION_ERROR_NONE) { - printf("Fail to get profile iterator error\n" ); + printf("Fail to get profile iterator error\n"); return false; } @@ -408,9 +397,8 @@ static bool __eth_get_user_selected_profile(connection_profile_h *profile, bool if (!strncmp(profile_name, "eth0", strlen("eth0"))) { printf("profile > %s\n", profile_name); - if (profile) { + if (profile) *profile = profile_h; - } } g_free(profile_name); } @@ -418,54 +406,42 @@ static bool __eth_get_user_selected_profile(connection_profile_h *profile, bool return true; } -static int __eth_update_ip_info(sa_eth_s *info, connection_profile_h profile, connection_address_family_e address_family) +static int __eth_update_ip_info(sa_eth_s * info, connection_profile_h profile, connection_address_family_e address_family) { int rv = 0; int input_int = 0; - char input_str[100] = {0,}; + char input_str[100] = { 0, }; _D("ipaddress =%s", info->staticInfo->ipAddress); if (info->staticInfo->ipAddress != NULL) { - rv = connection_profile_set_ip_address(profile, - address_family, - info->staticInfo->ipAddress); + rv = connection_profile_set_ip_address(profile, address_family, info->staticInfo->ipAddress); if (rv != CONNECTION_ERROR_NONE) return -1; } _D("netmask =%s", info->staticInfo->netmask); if (info->staticInfo->netmask != NULL) { - rv = connection_profile_set_subnet_mask(profile, - address_family, - info->staticInfo->netmask); + rv = connection_profile_set_subnet_mask(profile, address_family, info->staticInfo->netmask); if (rv != CONNECTION_ERROR_NONE) return -1; } if (info->staticInfo->defaultGateway != NULL) { - rv = connection_profile_set_gateway_address(profile, - address_family, - info->staticInfo->defaultGateway); + rv = connection_profile_set_gateway_address(profile, address_family, info->staticInfo->defaultGateway); if (rv != CONNECTION_ERROR_NONE) return -1; _D("gateway =%s", info->staticInfo->defaultGateway); } - if (info->staticInfo->primaryDnsServer != NULL ) { - rv = connection_profile_set_dns_address(profile, - 1, - address_family, - info->staticInfo->primaryDnsServer); + if (info->staticInfo->primaryDnsServer != NULL) { + rv = connection_profile_set_dns_address(profile, 1, address_family, info->staticInfo->primaryDnsServer); if (rv != CONNECTION_ERROR_NONE) return -1; _D("DNS 1 =%s", info->staticInfo->primaryDnsServer); - if (info->staticInfo->secondaryDnsServer != NULL ) { - rv = connection_profile_set_dns_address(profile, - 2, - address_family, - info->staticInfo->secondaryDnsServer); + if (info->staticInfo->secondaryDnsServer != NULL) { + rv = connection_profile_set_dns_address(profile, 2, address_family, info->staticInfo->secondaryDnsServer); if (rv != CONNECTION_ERROR_NONE) return -1; _D("DNS 2 =%s", info->staticInfo->secondaryDnsServer); @@ -475,13 +451,13 @@ static int __eth_update_ip_info(sa_eth_s *info, connection_profile_h profile, co return 1; } -static int __eth_update_ip(sa_eth_s *info) +static int __eth_update_ip(sa_eth_s * info) { int rv = 0; connection_profile_type_e prof_type; connection_profile_h profile; - int address_family = 0; // IPv4 + int address_family = 0; // IPv4 //printf("\n** Choose a profile to update. **\n"); if (__eth_get_user_selected_profile(&profile, true) == false) { @@ -503,7 +479,7 @@ static int __eth_update_ip(sa_eth_s *info) return -1; } - if(connection_profile_set_proxy_type(profile,CONNECTION_PROXY_TYPE_DIRECT) != CONNECTION_ERROR_NONE) + if (connection_profile_set_proxy_type(profile, CONNECTION_PROXY_TYPE_DIRECT) != CONNECTION_ERROR_NONE) return -1; if (connection_update_profile(eth_connect, profile) != CONNECTION_ERROR_NONE) { @@ -551,44 +527,38 @@ static int __eth_deregister_client(void) return 1; } -static int __ethernet_connect_main(sa_eth_s *info) +static int __ethernet_connect_main(sa_eth_s * info) { - if (info == NULL) { + if (info == NULL) return -1; - } - if(__eth_register_client() == 1) { + if (__eth_register_client() == 1) { __eth_update_ip(info); __eth_deregister_client(); - } - else + } else _D("connection error!!!\n"); - return 0; } - -static int __network_get_wifi_state(connection_h connection, connection_wifi_state_e *wifi_state) +static int __network_get_wifi_state(connection_h connection, connection_wifi_state_e * wifi_state) { int rv = 0; - if (connection == NULL) { + if (connection == NULL) return -1; - } rv = connection_get_wifi_state(connection, wifi_state); - if (rv != CONNECTION_ERROR_NONE) { + if (rv != CONNECTION_ERROR_NONE) _D("Fail to get WiFi state [%s]", __print_error(rv)); - } else { + else _D("Retval = [%s] WiFi state [%s]", __print_error(rv), __print_wifi_state(*wifi_state)); - } return 0; } -static sa_error_e __network_get_state(sa_network_state_e *conn_state, sa_network_type_e *conn_type) +static sa_error_e __network_get_state(sa_network_state_e * conn_state, sa_network_type_e * conn_type) { connection_h connection = NULL; sa_error_e ret = SA_ERROR_UNKNOWN; @@ -601,7 +571,6 @@ static sa_error_e __network_get_state(sa_network_state_e *conn_state, sa_network _E("create connection handle error [%s]", __print_error(rv)); return -1; } - // check network state(eth/wifi) rv = connection_get_type(connection, &net_state); if (rv != CONNECTION_ERROR_NONE) { @@ -615,11 +584,10 @@ static sa_error_e __network_get_state(sa_network_state_e *conn_state, sa_network *conn_type = SA_NETWORK_TYPE_WIFI; // check wifi state if (!__network_get_wifi_state(connection, &wifi_state)) { - if (wifi_state == CONNECTION_WIFI_STATE_CONNECTED) { + if (wifi_state == CONNECTION_WIFI_STATE_CONNECTED) *conn_state = SA_NETWORK_STATE_CONNECTED; - } else { + else *conn_state = SA_NETWORK_STATE_DISCONNECTED; - } } } else if (CONNECTION_TYPE_ETHERNET == net_state) { *conn_type = SA_NETWORK_TYPE_ETH; @@ -639,10 +607,9 @@ static sa_error_e __network_get_state(sa_network_state_e *conn_state, sa_network return ret; } - extern void sa_inputfile_flag(void); -static sa_error_e __network_connect(sa_network_s *info) +static sa_error_e __network_connect(sa_network_s * info) { sa_error_e ret = SA_ERROR_NONE; int retWifi = 0; @@ -665,7 +632,7 @@ static sa_error_e __network_connect(sa_network_s *info) _D("info|wifi|staticInfo|secondaryDnsServer(%s)", info->wifi->staticInfo->secondaryDnsServer); } } - + if (info->eth != NULL) { _D("----------- ethernet info -----------"); _D("info|eth|enabled(%d)", info->eth->enabled); @@ -681,7 +648,7 @@ static sa_error_e __network_connect(sa_network_s *info) } if (info->eth != NULL) { // decide whether it will be set according to policy - if ( (info->eth->enabled == TRUE) && !sa_inputfile_get_completion_flag(SA_FILE_CONFIG_ETHERNET) ){ + if ((info->eth->enabled == TRUE) && !sa_inputfile_get_completion_flag(SA_FILE_CONFIG_ETHERNET)) { retEth = __ethernet_connect_main(info->eth); _D("return ethernet [%d]", retEth); } @@ -689,7 +656,7 @@ static sa_error_e __network_connect(sa_network_s *info) sa_inputfile_set_completion_flag(SA_FILE_CONFIG_ETHERNET); if (info->wifi != NULL) { - if ( (info->wifi->enabled == TRUE) && !sa_inputfile_get_completion_flag(SA_FILE_CONFIG_WIFI) ) { + if ((info->wifi->enabled == TRUE) && !sa_inputfile_get_completion_flag(SA_FILE_CONFIG_WIFI)) { retWifi = __wifi_connect_main(info->wifi); _D("return wifi [%d]", retWifi); } else { @@ -701,7 +668,7 @@ static sa_error_e __network_connect(sa_network_s *info) return ret; } -sa_error_e sa_setup_network(sa_network_s *network) +sa_error_e sa_setup_network(sa_network_s * network) { sa_error_e ret = SA_ERROR_NONE; sa_network_type_e conn_type; @@ -716,4 +683,4 @@ sa_error_e sa_setup_network(sa_network_s *network) ret = __network_connect(network); return ret; -} \ No newline at end of file +} diff --git a/src/setup_network.h b/src/setup_network.h old mode 100644 new mode 100755 index 07afe87..6407530 --- a/src/setup_network.h +++ b/src/setup_network.h @@ -21,10 +21,9 @@ /** * @fn int sa_setup_network(sa_network_s *info) * @brief This function to set network connection - @param sa_network_s [in] network info struture + @param sa_network_s [in] network info struture * @return sa_error_e return of function */ -sa_error_e sa_setup_network(sa_network_s *network); +sa_error_e sa_setup_network(sa_network_s * network); - -#endif/* __SETUP_NETWORK_H__ */ +#endif /* __SETUP_NETWORK_H__ */ diff --git a/src/setup_system.c b/src/setup_system.c old mode 100644 new mode 100755 index 539398f..7d09c86 --- a/src/setup_system.c +++ b/src/setup_system.c @@ -18,17 +18,17 @@ #include "sa_types.h" #include "setup_system.h" -static sa_error_e system_set_proxy(sa_proxy_s *info) +static sa_error_e system_set_proxy(sa_proxy_s * info) { return SA_ERROR_NOT_SUPPORTED; } -static sa_error_e system_get_proxy(sa_proxy_s *info) +static sa_error_e system_get_proxy(sa_proxy_s * info) { return SA_ERROR_NOT_SUPPORTED; } -static int compare_proxy_info(sa_proxy_s *devProxy, sa_proxy_s *newProxy) +static int compare_proxy_info(sa_proxy_s * devProxy, sa_proxy_s * newProxy) { // comapre proxy if (devProxy != NULL && newProxy != NULL) { @@ -38,9 +38,8 @@ static int compare_proxy_info(sa_proxy_s *devProxy, sa_proxy_s *newProxy) return 1; } else { // Host address is the same, but port is different - if (devProxy->httpProxyPort != newProxy->httpProxyPort) { + if (devProxy->httpProxyPort != newProxy->httpProxyPort) return 1; - } } } } @@ -48,9 +47,7 @@ static int compare_proxy_info(sa_proxy_s *devProxy, sa_proxy_s *newProxy) return 0; } - - -sa_error_e sa_setup_system(sa_system_s *system) +sa_error_e sa_setup_system(sa_system_s * system) { sa_proxy_s *devProxy = NULL; sa_error_e ret = SA_ERROR_NONE; @@ -59,7 +56,7 @@ sa_error_e sa_setup_system(sa_system_s *system) _E("__set_system is null"); return -1; } - + if (system->proxy != NULL) { ret = system_get_proxy(devProxy); if (ret == SA_ERROR_NONE && compare_proxy_info(devProxy, system->proxy)) { @@ -69,4 +66,4 @@ sa_error_e sa_setup_system(sa_system_s *system) } return ret; -} \ No newline at end of file +} diff --git a/src/setup_system.h b/src/setup_system.h old mode 100644 new mode 100755 index 4e683ba..8b22d73 --- a/src/setup_system.h +++ b/src/setup_system.h @@ -24,7 +24,6 @@ @param sa_system_s [in] system info * @return sa_error_e return of function */ -sa_error_e sa_setup_system(sa_system_s *system); +sa_error_e sa_setup_system(sa_system_s * system); - -#endif/* __SETUP_SYSTEMDATA_H__ */ +#endif /* __SETUP_SYSTEMDATA_H__ */ -- 2.34.1