summaryrefslogtreecommitdiff
path: root/src/components/config_profile/src
diff options
context:
space:
mode:
authorKozoriz <kozorizandriy@gmail.com>2016-04-26 12:41:54 +0300
committerKozoriz <kozorizandriy@gmail.com>2016-04-26 15:50:21 +0300
commit4ecdb2a83871784f34430ed09d5ef6a2c0855506 (patch)
treedc36b449e5d32ac3e493e16865cf9d88d9991817 /src/components/config_profile/src
parentcf58bb97d09c536dce3b492d1517da0b837bc8eb (diff)
downloadsdl_core-4ecdb2a83871784f34430ed09d5ef6a2c0855506.tar.gz
Format all code in project
Formated all code in appMain, components, plugins to correct coding-style Used clang-format-3.6 Used 2 commands : find src/appMain/ -name "*.h" -o -name "*.cc" -o -name "*.hpp" -o -name "*.cpp" | xargs clang-format-3.6 -i -style=file find src/components/ -name "*.h" -o -name "*.cc" -o -name "*.hpp" -o -name "*.cpp" | xargs clang-format-3.6 -i -style=file find src/plugins/ -name "*.h" -o -name "*.cc" -o -name "*.hpp" -o -name "*.cpp" | xargs clang-format-3.6 -i -style=file
Diffstat (limited to 'src/components/config_profile/src')
-rw-r--r--src/components/config_profile/src/ini_file.cc141
1 files changed, 69 insertions, 72 deletions
diff --git a/src/components/config_profile/src/ini_file.cc b/src/components/config_profile/src/ini_file.cc
index fcdf24db31..d6d72060e8 100644
--- a/src/components/config_profile/src/ini_file.cc
+++ b/src/components/config_profile/src/ini_file.cc
@@ -42,19 +42,19 @@
#ifndef _WIN32
#include <unistd.h>
#else
-#define PATH_MAX _MAX_PATH
+#define PATH_MAX _MAX_PATH
#endif
#ifdef __linux__
-#define USE_MKSTEMP 1
+#define USE_MKSTEMP 1
#endif
#include <string>
namespace profile {
-char* ini_write_inst(const char *fname, uint8_t flag) {
- FILE *fp = 0;
+char* ini_write_inst(const char* fname, uint8_t flag) {
+ FILE* fp = 0;
if (NULL == fname)
return NULL;
@@ -89,15 +89,17 @@ char* ini_write_inst(const char *fname, uint8_t flag) {
return const_cast<char*>(fname);
}
-char* ini_read_value(const char *fname,
- const char *chapter, const char *item, char *value) {
- FILE *fp = 0;
- bool chapter_found = false;
- char line[INI_LINE_LEN] = "";
- char val[INI_LINE_LEN] = "";
- char tag[INI_LINE_LEN] = "";
-
- Ini_search_id result;
+char* ini_read_value(const char* fname,
+ const char* chapter,
+ const char* item,
+ char* value) {
+ FILE* fp = 0;
+ bool chapter_found = false;
+ char line[INI_LINE_LEN] = "";
+ char val[INI_LINE_LEN] = "";
+ char tag[INI_LINE_LEN] = "";
+
+ Ini_search_id result;
*line = '\0';
*val = '\0';
*tag = '\0';
@@ -146,19 +148,21 @@ char* ini_read_value(const char *fname,
return NULL;
}
-char ini_write_value(const char *fname,
- const char *chapter, const char *item,
- const char *value, uint8_t flag) {
- FILE *rd_fp, *wr_fp = 0;
- uint16_t i, cr_count;
- int32_t wr_result;
- bool chapter_found = false;
- bool value_written = false;
- char line[INI_LINE_LEN] = "";
- char val[INI_LINE_LEN] = "";
- char tag[INI_LINE_LEN] = "";
- char temp_fname[PATH_MAX] = "";
- Ini_search_id result;
+char ini_write_value(const char* fname,
+ const char* chapter,
+ const char* item,
+ const char* value,
+ uint8_t flag) {
+ FILE* rd_fp, * wr_fp = 0;
+ uint16_t i, cr_count;
+ int32_t wr_result;
+ bool chapter_found = false;
+ bool value_written = false;
+ char line[INI_LINE_LEN] = "";
+ char val[INI_LINE_LEN] = "";
+ char tag[INI_LINE_LEN] = "";
+ char temp_fname[PATH_MAX] = "";
+ Ini_search_id result;
*line = '\0';
*val = '\0';
*tag = '\0';
@@ -177,11 +181,10 @@ char ini_write_value(const char *fname,
#if USE_MKSTEMP
{
- const char *temp_str = "./";
+ const char* temp_str = "./";
int32_t fd = -1;
if (temp_str) {
- snprintf(temp_fname, PATH_MAX,
- "%s/ini.XXXXXX", temp_str);
+ snprintf(temp_fname, PATH_MAX, "%s/ini.XXXXXX", temp_str);
fd = mkstemp(temp_fname);
if (-1 == fd) {
@@ -200,16 +203,17 @@ char ini_write_value(const char *fname,
#else // #if USE_MKSTEMP
tmpnam(temp_fname);
if (0 == (wr_fp = fopen(temp_fname, "w"))) {
- fclose(rd_fp);
- return FALSE;
+ fclose(rd_fp);
+ return FALSE;
}
-#endif // #else #if USE_MKSTEMP
+#endif // #else #if USE_MKSTEMP
snprintf(tag, INI_LINE_LEN, "%s", chapter);
- for (uint32_t i = 0; i < strlen (tag); i++)
+ for (uint32_t i = 0; i < strlen(tag); i++)
tag[i] = toupper(tag[i]);
- wr_result = 1; cr_count = 0;
+ wr_result = 1;
+ cr_count = 0;
while ((NULL != fgets(line, INI_LINE_LEN, rd_fp)) && (0 < wr_result)) {
// Now start the line parsing
result = ini_parse_line(line, tag, val);
@@ -220,7 +224,7 @@ char ini_write_value(const char *fname,
chapter_found = true;
// coding style
snprintf(tag, INI_LINE_LEN, "%s", item);
- for (uint32_t i = 0; i < strlen (tag); i++)
+ for (uint32_t i = 0; i < strlen(tag); i++)
tag[i] = toupper(tag[i]);
}
} else {
@@ -241,7 +245,7 @@ char ini_write_value(const char *fname,
continue;
}
}
- } /* if (!value_written) */
+ } /* if (!value_written) */
if (0 == strcmp(val, "\n")) {
cr_count++;
@@ -262,7 +266,6 @@ char ini_write_value(const char *fname,
}
fprintf(wr_fp, "\n");
-
fclose(wr_fp);
fclose(rd_fp);
@@ -275,10 +278,10 @@ char ini_write_value(const char *fname,
return (value_written);
}
-Ini_search_id ini_parse_line(const char *line, const char *tag, char *value) {
- const char *line_ptr;
- char *temp_ptr;
- char temp_str[INI_LINE_LEN] = "";
+Ini_search_id ini_parse_line(const char* line, const char* tag, char* value) {
+ const char* line_ptr;
+ char* temp_ptr;
+ char temp_str[INI_LINE_LEN] = "";
*temp_str = '\0';
snprintf(value, INI_LINE_LEN, "%s", line);
@@ -286,13 +289,12 @@ Ini_search_id ini_parse_line(const char *line, const char *tag, char *value) {
/* cut leading spaces */
line_ptr = line;
for (uint32_t i = 0; i < strlen(line); i++) {
- if ((line[i] == ' ') ||
- (line[i] == 9) || // TAB
- (line[i] == 10) || // LF
- (line[i] == 13)) { // CR
+ if ((line[i] == ' ') || (line[i] == 9) || // TAB
+ (line[i] == 10) || // LF
+ (line[i] == 13)) { // CR
line_ptr++;
} else {
- break;
+ break;
}
}
if ('\0' == *line_ptr) {
@@ -300,7 +302,7 @@ Ini_search_id ini_parse_line(const char *line, const char *tag, char *value) {
return INI_NOTHING;
}
- if ((*line_ptr == ';') || (*line_ptr == '*')) /* remark */
+ if ((*line_ptr == ';') || (*line_ptr == '*')) /* remark */
return INI_REMARK;
if (*line_ptr == '[' && strrchr(line_ptr, ']') != NULL) {
@@ -309,13 +311,12 @@ Ini_search_id ini_parse_line(const char *line, const char *tag, char *value) {
/* cut leading stuff */
uint16_t len = strlen(line_ptr);
for (int32_t i = 0; i < len; i++) {
- if ((*line_ptr == ' ') ||
- (*line_ptr == 9) || // TAB
- (*line_ptr == 10) || // LF
- (*line_ptr == 13)) { // CR
+ if ((*line_ptr == ' ') || (*line_ptr == 9) || // TAB
+ (*line_ptr == 10) || // LF
+ (*line_ptr == 13)) { // CR
line_ptr++;
} else {
- break;
+ break;
}
}
if (*line_ptr == '\0')
@@ -331,13 +332,12 @@ Ini_search_id ini_parse_line(const char *line, const char *tag, char *value) {
/* cut trailing stuff */
for (int32_t i = strlen(temp_str) - 1; i > 0; i--) {
- if ((temp_str[i] == ' ') ||
- (temp_str[i] == 9) || // TAB
- (temp_str[i] == 10) || // LF
- (temp_str[i] == 13)) { // CR
+ if ((temp_str[i] == ' ') || (temp_str[i] == 9) || // TAB
+ (temp_str[i] == 10) || // LF
+ (temp_str[i] == 13)) { // CR
temp_str[i] = '\0';
} else {
- break;
+ break;
}
}
@@ -355,11 +355,10 @@ Ini_search_id ini_parse_line(const char *line, const char *tag, char *value) {
strncpy(temp_str, line_ptr, (strchr(line_ptr, '=') - line_ptr));
/* cut trailing stuff */
for (int32_t i = strlen(temp_str) - 1; i > 0; i--) {
- if ((temp_str[i] == '=') ||
- (temp_str[i] == ' ') ||
- (temp_str[i] == 9) || // TAB
- (temp_str[i] == 10) || // LF
- (temp_str[i] == 13)) { // CR
+ if ((temp_str[i] == '=') || (temp_str[i] == ' ') ||
+ (temp_str[i] == 9) || // TAB
+ (temp_str[i] == 10) || // LF
+ (temp_str[i] == 13)) { // CR
temp_str[i] = '\0';
} else {
break;
@@ -368,17 +367,16 @@ Ini_search_id ini_parse_line(const char *line, const char *tag, char *value) {
snprintf(value, INI_LINE_LEN, "%s", temp_str);
- for (uint32_t i = 0; i < strlen (temp_str); i++)
+ for (uint32_t i = 0; i < strlen(temp_str); i++)
temp_str[i] = toupper(temp_str[i]);
if (strcmp(temp_str, tag) == 0) {
line_ptr = strchr(line_ptr, '=') + 1;
uint16_t len = strlen(line_ptr);
/* cut trailing stuff */
for (uint32_t i = 0; i < len; i++) {
- if ((*line_ptr == ' ') ||
- (*line_ptr == 9) || // TAB
- (*line_ptr == 10) || // LF
- (*line_ptr == 13)) { // CR
+ if ((*line_ptr == ' ') || (*line_ptr == 9) || // TAB
+ (*line_ptr == 10) || // LF
+ (*line_ptr == 13)) { // CR
line_ptr++;
} else {
break;
@@ -390,11 +388,10 @@ Ini_search_id ini_parse_line(const char *line, const char *tag, char *value) {
if (value[0] != '\0') {
/* cut trailing stuff */
for (int32_t i = strlen(value) - 1; i > 0; i--) {
- if ((value[i] == ' ') ||
- (value[i] == ';') ||
- (value[i] == 9) || // TAB
- (value[i] == 10) || // LF
- (value[i] == 13)) { // CR
+ if ((value[i] == ' ') || (value[i] == ';') ||
+ (value[i] == 9) || // TAB
+ (value[i] == 10) || // LF
+ (value[i] == 13)) { // CR
value[i] = '\0';
} else {
break;