X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fail_vconf.c;h=27bb36645b0b16eb56a002645d33b6d8ccf75aa1;hb=refs%2Ftags%2Fsubmit%2Ftizen_common%2F20151229.144031;hp=8fa3088d22adee693237fe63be0a950094010a29;hpb=8bcc17cce742412499493719b2b4f11a980a1f17;p=platform%2Fcore%2Fappfw%2Fail.git diff --git a/src/ail_vconf.c b/src/ail_vconf.c index 8fa3088..27bb366 100644 --- a/src/ail_vconf.c +++ b/src/ail_vconf.c @@ -29,19 +29,18 @@ #include #include "ail_vconf.h" +#include "ail_private.h" #define VCONFTOOL "/usr/bin/vconftool" #define CMD_VCONF_GET_STR VCONFTOOL " -q get '%s'" #define CMD_VCONF_SET_STR VCONFTOOL " -q set -t string '%s' '%s' -f" /* - - Reads the content of the input 'stream' (it should be a text without nul -characters) in a feshly allocated buffer, using allocations of 'block_size' -increment. - - Returns the read string or NULL in case of error. -*/ + * Reads the content of the input 'stream' (it should be a text without nul + * characters) in a feshly allocated buffer, using allocations of 'block_size' + * increment. + * Returns the read string or NULL in case of error. + */ static char *_pread_(FILE *stream, size_t block_size) { char *result = NULL; @@ -49,7 +48,7 @@ static char *_pread_(FILE *stream, size_t block_size) size_t length = 0; char *string; - for(;;) { + for (;;) { /* is on error ? */ if (ferror(stream) != 0) { free(result); @@ -78,13 +77,11 @@ static char *_pread_(FILE *stream, size_t block_size) } /* - Runs the command given by 'cmddef' and its arguments formated as printf. - - The resulting output stream of the command is return as a freshly allocated -string in '*readen'. - - Retruns 0 in case of success or -1 in case of error. -*/ + * Runs the command given by 'cmddef' and its arguments formated as printf. + * The resulting output stream of the command is return as a freshly allocated + * string in '*readen'. + * Retruns 0 in case of success or -1 in case of error. + */ static int _ail_vconf_exec_(char **readen, const char *cmddef, ...) { int result; @@ -101,9 +98,8 @@ static int _ail_vconf_exec_(char **readen, const char *cmddef, ...) stream = popen(command, "r"); if (stream != NULL) { *readen = _pread_(stream, 1024); - if (pclose(stream) != -1 && *readen != NULL) { + if (pclose(stream) != -1 && *readen != NULL) result = 0; - } } free(command); } @@ -111,9 +107,9 @@ static int _ail_vconf_exec_(char **readen, const char *cmddef, ...) } /* - vconf_get_str with fallback to the command vconftool. -*/ -char *ail_vconf_get_str(const char *keyname) + * vconf_get_str with fallback to the command vconftool. + */ +EXPORT_API char *ail_vconf_get_str(const char *keyname) { char *result; char *data; @@ -131,9 +127,8 @@ char *ail_vconf_get_str(const char *keyname) result = result + 3; /* remove trailing '\n' */ length = strlen(result); - if (length > 0 && result[length-1] == '\n') { - result[length-1] = 0; - } + if (length > 0 && result[length-1] == '\n') + result[length - 1] = 0; /* get the final result */ result = strdup(result); } @@ -144,9 +139,9 @@ char *ail_vconf_get_str(const char *keyname) } /* - vconf_set_str with fallback to the command vconftool. -*/ -int ail_vconf_set_str(const char *keyname, const char *strval) + * vconf_set_str with fallback to the command vconftool. + */ +EXPORT_API int ail_vconf_set_str(const char *keyname, const char *strval) { int result; char *data; @@ -160,6 +155,3 @@ int ail_vconf_set_str(const char *keyname, const char *strval) } #endif - - -