diff options
author | Jeonghoon Park <jh1979.park@samsung.com> | 2017-09-11 15:49:41 +0900 |
---|---|---|
committer | Jeonghoon Park <jh1979.park@samsung.com> | 2017-09-11 15:49:41 +0900 |
commit | 3e9be00dba2ea9e5abd0aaec1aa8f17f710ef3c6 (patch) | |
tree | d41392c3a447b8d430b41e685f72cb178e857b19 /src | |
parent | f522f8534c05c53e7687933bf89d11a2140ab3bf (diff) | |
download | position-finder-server-3e9be00dba2ea9e5abd0aaec1aa8f17f710ef3c6.tar.gz position-finder-server-3e9be00dba2ea9e5abd0aaec1aa8f17f710ef3c6.tar.bz2 position-finder-server-3e9be00dba2ea9e5abd0aaec1aa8f17f710ef3c6.zip |
apply coding rule
Change-Id: I274cb765899873d9ebf957e348736ed4c17df189
Diffstat (limited to 'src')
-rw-r--r-- | src/connectivity.c | 26 | ||||
-rw-r--r-- | src/controller.c | 8 | ||||
-rw-r--r-- | src/resource/resource_led.c | 2 | ||||
-rwxr-xr-x | src/resource/resource_rain_sensor.c | 60 | ||||
-rw-r--r-- | src/webutil.c | 85 |
5 files changed, 90 insertions, 91 deletions
diff --git a/src/connectivity.c b/src/connectivity.c index 1c33e5e..a6b0350 100644 --- a/src/connectivity.c +++ b/src/connectivity.c @@ -189,18 +189,18 @@ error: static void _print_iotcon_error(int err_no) { switch (err_no) { - case IOTCON_ERROR_NOT_SUPPORTED: - _E("IOTCON_ERROR_NOT_SUPPORTED"); - break; - case IOTCON_ERROR_PERMISSION_DENIED: - _E("IOTCON_ERROR_PERMISSION_DENIED"); - break; - case IOTCON_ERROR_INVALID_PARAMETER: - _E("IOTCON_ERROR_INVALID_PARAMETER"); - break; - default: - _E("Error : [%d]", err_no); - break; + case IOTCON_ERROR_NOT_SUPPORTED: + _E("IOTCON_ERROR_NOT_SUPPORTED"); + break; + case IOTCON_ERROR_PERMISSION_DENIED: + _E("IOTCON_ERROR_PERMISSION_DENIED"); + break; + case IOTCON_ERROR_INVALID_PARAMETER: + _E("IOTCON_ERROR_INVALID_PARAMETER"); + break; + default: + _E("Error : [%d]", err_no); + break; } } @@ -406,7 +406,7 @@ static void _copy_file(const char *in_filename, const char *out_filename) rewind(in); while ((nread = fread(buf, 1, sizeof(buf), in)) > 0) { - if (fwrite (buf, 1, nread, out) < nread) { + if (fwrite(buf, 1, nread, out) < nread) { _E("critical error to copy a file"); break; } diff --git a/src/controller.c b/src/controller.c index 5b391ce..e6e4ae3 100644 --- a/src/controller.c +++ b/src/controller.c @@ -75,16 +75,16 @@ static bool service_app_create(void *data) return false; } - return true; + return true; } static void service_app_terminate(void *data) { app_data *ad = (app_data *)data; - if (ad->getter_timer) { + if (ad->getter_timer) ecore_timer_del(ad->getter_timer); - } + /** * Releases the resource about connectivity. @@ -102,7 +102,7 @@ static void service_app_terminate(void *data) static void service_app_control(app_control_h app_control, void *data) { - // Todo: add your code here. + // Todo: add your code here. } static void service_app_lang_changed(app_event_info_h event_info, void *user_data) diff --git a/src/resource/resource_led.c b/src/resource/resource_led.c index 136a9e9..7c10836 100644 --- a/src/resource/resource_led.c +++ b/src/resource/resource_led.c @@ -53,7 +53,7 @@ int resource_write_led(int pin_num, int write_value) ret = peripheral_gpio_write(resource_get_info(pin_num)->sensor_h, write_value); retv_if(ret < 0, -1); - _I("LED Value : %s", write_value ? "ON":"OFF"); + _I("LED Value : %s", write_value ? "ON" : "OFF"); return 0; } diff --git a/src/resource/resource_rain_sensor.c b/src/resource/resource_rain_sensor.c index d5fc10b..32e6daf 100755 --- a/src/resource/resource_rain_sensor.c +++ b/src/resource/resource_rain_sensor.c @@ -19,43 +19,43 @@ * limitations under the License. */ - #include <stdlib.h> - #include <unistd.h> +#include <stdlib.h> +#include <unistd.h> - #include "log.h" - #include "resource_internal.h" +#include "log.h" +#include "resource_internal.h" - void resource_close_rain_sensor(int pin_num) - { - if (!resource_get_info(pin_num)->opened) return; +void resource_close_rain_sensor(int pin_num) +{ + if (!resource_get_info(pin_num)->opened) return; - _I("Rain Sensor is finishing..."); - peripheral_gpio_close(resource_get_info(pin_num)->sensor_h); - resource_get_info(pin_num)->opened = 0; - } + _I("Rain Sensor is finishing..."); + peripheral_gpio_close(resource_get_info(pin_num)->sensor_h); + resource_get_info(pin_num)->opened = 0; +} - int resource_read_rain_sensor(int pin_num, int *out_value) - { - int ret = PERIPHERAL_ERROR_NONE; +int resource_read_rain_sensor(int pin_num, int *out_value) +{ + int ret = PERIPHERAL_ERROR_NONE; - if (!resource_get_info(pin_num)->opened) { - ret = peripheral_gpio_open(pin_num, &resource_get_info(pin_num)->sensor_h); - retv_if(!resource_get_info(pin_num)->sensor_h, -1); + if (!resource_get_info(pin_num)->opened) { + ret = peripheral_gpio_open(pin_num, &resource_get_info(pin_num)->sensor_h); + retv_if(!resource_get_info(pin_num)->sensor_h, -1); - ret = peripheral_gpio_set_direction(resource_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN); - retv_if(ret != 0, -1); + ret = peripheral_gpio_set_direction(resource_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN); + retv_if(ret != 0, -1); - resource_get_info(pin_num)->opened = 1; - resource_get_info(pin_num)->close = resource_close_flame_sensor; - } + resource_get_info(pin_num)->opened = 1; + resource_get_info(pin_num)->close = resource_close_flame_sensor; + } - /** - * This model(FC-37 + YL-38) normally outputs 1, and outputs 0 as out_value when a rain is detected. - */ - ret = peripheral_gpio_read(resource_get_info(pin_num)->sensor_h, out_value); - retv_if(ret < 0, -1); + /** + * This model(FC-37 + YL-38) normally outputs 1, and outputs 0 as out_value when a rain is detected. + */ + ret = peripheral_gpio_read(resource_get_info(pin_num)->sensor_h, out_value); + retv_if(ret < 0, -1); - *out_value = !*out_value; + *out_value = !*out_value; - return 0; - } + return 0; +} diff --git a/src/webutil.c b/src/webutil.c index 839f885..55fd071 100644 --- a/src/webutil.c +++ b/src/webutil.c @@ -43,7 +43,7 @@ static size_t _response_write_callback(char *ptr, size_t size, size_t nmemb, voi res_size = size*nmemb; - if(res_size > 0) + if (res_size > 0) _I("POST response : %s", ptr); /* What should we do here, if response body has negative message? */ @@ -55,7 +55,7 @@ int web_util_noti_init(void) int ret = 0; CURLcode result; result = curl_global_init(CURL_GLOBAL_DEFAULT); - if(result != CURLE_OK) { + if (result != CURLE_OK) { _E("curl_global_init() failed: %s", curl_easy_strerror(result)); ret = -1; @@ -76,15 +76,15 @@ int web_util_noti_post(const char *resource, const char *json_data) CURLcode response = CURLE_OK; struct curl_slist *headers = NULL; - retv_if(resource == NULL,-1); - retv_if(json_data == NULL,-1); + retv_if(resource == NULL, -1); + retv_if(json_data == NULL, -1); _I("server : %s", resource); _I("json_data : %s", json_data); curl = curl_easy_init(); - if(!curl) { + if (!curl) { _E("fail to init curl"); return -1; } @@ -100,7 +100,7 @@ int web_util_noti_post(const char *resource, const char *json_data) response = curl_easy_perform(curl); - if(response != CURLE_OK) { + if (response != CURLE_OK) { _E("curl_easy_perform() failed: %s", curl_easy_strerror(response)); /* What should we do here, if response is kind of errors? */ @@ -116,9 +116,8 @@ int web_util_noti_post(const char *resource, const char *json_data) int web_util_json_init(void) { - if(Json_h.builder) { + if (Json_h.builder) g_object_unref(Json_h.builder); - } Json_h.is_begin = false; Json_h.is_end = false; @@ -131,7 +130,7 @@ int web_util_json_init(void) int web_util_json_fini(void) { - if(Json_h.builder) { + if (Json_h.builder) { g_object_unref(Json_h.builder); Json_h.builder = NULL; } @@ -157,7 +156,7 @@ int web_util_json_data_array_begin(void) */ json_builder_begin_object(Json_h.builder); - json_builder_set_member_name(Json_h.builder,"SensorDataList"); + json_builder_set_member_name(Json_h.builder, "SensorDataList"); json_builder_begin_array(Json_h.builder); return 0; @@ -265,77 +264,77 @@ int web_util_json_add_sensor_data(const char* sensorpi_id, web_util_sensor_data_ json_builder_set_member_name(Json_h.builder, n_id); json_builder_add_string_value(Json_h.builder, path); - if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_MOTION) { + if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_MOTION) { json_builder_set_member_name(Json_h.builder, n_motion); json_builder_add_int_value(Json_h.builder, sensor_data->motion); } - if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_FLAME) { + if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_FLAME) { json_builder_set_member_name(Json_h.builder, n_flame); json_builder_add_int_value(Json_h.builder, sensor_data->flame); } - if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_HUMIDITY) { + if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_HUMIDITY) { json_builder_set_member_name(Json_h.builder, n_hum); json_builder_add_double_value(Json_h.builder, sensor_data->humidity); } - if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_TEMPERATURE) { + if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_TEMPERATURE) { json_builder_set_member_name(Json_h.builder, n_temp); json_builder_add_double_value(Json_h.builder, sensor_data->temperature); } - if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_VIB) { + if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_VIB) { json_builder_set_member_name(Json_h.builder, n_vib); json_builder_add_int_value(Json_h.builder, sensor_data->virbration); } - if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_CO2) { + if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_CO2) { json_builder_set_member_name(Json_h.builder, n_co2); json_builder_add_double_value(Json_h.builder, sensor_data->co2); } - if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_SOUND) { + if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_SOUND) { json_builder_set_member_name(Json_h.builder, n_sound); json_builder_add_int_value(Json_h.builder, sensor_data->soundlevel); } - if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_TILT) { + if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_TILT) { json_builder_set_member_name(Json_h.builder, n_tilt); json_builder_add_int_value(Json_h.builder, sensor_data->tilt); } - if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_LIGHT) { + if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_LIGHT) { json_builder_set_member_name(Json_h.builder, n_light); json_builder_add_int_value(Json_h.builder, sensor_data->light); } - if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_COLLISION) { + if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_COLLISION) { json_builder_set_member_name(Json_h.builder, n_collision); json_builder_add_int_value(Json_h.builder, sensor_data->collision); } - if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_OBSTACLE) { + if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_OBSTACLE) { json_builder_set_member_name(Json_h.builder, n_obstacle); json_builder_add_int_value(Json_h.builder, sensor_data->obstacle); } - if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_ULTRASONIC_DISTANCE) { + if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_ULTRASONIC_DISTANCE) { json_builder_set_member_name(Json_h.builder, n_distance); json_builder_add_double_value(Json_h.builder, sensor_data->distance); } - if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_RAIN) { + if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_RAIN) { json_builder_set_member_name(Json_h.builder, n_rain); json_builder_add_int_value(Json_h.builder, sensor_data->rain); } - if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_TOUCH) { + if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_TOUCH) { json_builder_set_member_name(Json_h.builder, n_touch); json_builder_add_int_value(Json_h.builder, sensor_data->touch); } - if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_GAS) { + if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_GAS) { json_builder_set_member_name(Json_h.builder, n_gas); json_builder_add_int_value(Json_h.builder, sensor_data->gas); } @@ -343,54 +342,54 @@ int web_util_json_add_sensor_data(const char* sensorpi_id, web_util_sensor_data_ json_builder_set_member_name(Json_h.builder, n_e_sensor); json_builder_begin_array(Json_h.builder); - if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_MOTION) + if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_MOTION) json_builder_add_string_value(Json_h.builder, n_motion); - if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_FLAME) + if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_FLAME) json_builder_add_string_value(Json_h.builder, n_flame); - if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_HUMIDITY) + if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_HUMIDITY) json_builder_add_string_value(Json_h.builder, n_hum); - if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_TEMPERATURE) + if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_TEMPERATURE) json_builder_add_string_value(Json_h.builder, n_temp); - if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_VIB) + if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_VIB) json_builder_add_string_value(Json_h.builder, n_vib); - if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_CO2) + if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_CO2) json_builder_add_string_value(Json_h.builder, n_co2); - if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_SOUND) + if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_SOUND) json_builder_add_string_value(Json_h.builder, n_sound); - if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_TILT) + if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_TILT) json_builder_add_string_value(Json_h.builder, n_tilt); - if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_LIGHT) + if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_LIGHT) json_builder_add_string_value(Json_h.builder, n_light); - if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_COLLISION) + if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_COLLISION) json_builder_add_string_value(Json_h.builder, n_collision); - if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_OBSTACLE) + if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_OBSTACLE) json_builder_add_string_value(Json_h.builder, n_obstacle); - if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_ULTRASONIC_DISTANCE) + if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_ULTRASONIC_DISTANCE) json_builder_add_string_value(Json_h.builder, n_distance); - if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_RAIN) + if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_RAIN) json_builder_add_string_value(Json_h.builder, n_rain); - if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_TOUCH) + if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_TOUCH) json_builder_add_string_value(Json_h.builder, n_touch); - if(sensor_data->enabled_sensor & WEB_UTIL_SENSOR_GAS) + if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_GAS) json_builder_add_string_value(Json_h.builder, n_gas); json_builder_end_array(Json_h.builder); - if(sensor_data->hash) { + if (sensor_data->hash) { json_builder_set_member_name(Json_h.builder, n_hash); json_builder_add_string_value(Json_h.builder, sensor_data->hash); } @@ -422,10 +421,10 @@ char *web_util_get_json_string(void) return str; error_release_all: - if(root) + if (root) json_node_free(root); - if(gen) + if (gen) g_object_unref(gen); return NULL; |