{
char *token;
char *saveptr = NULL;
- char tok[LINE_MAX];
- token = strtok_r(line, "|", &saveptr);
+ token = strtok_r(line, "\t |\n", &saveptr);
while (token) {
- tok[0] = '\0';
- sscanf(token, "%s", tok);
- if (tok[0] != '\0' && strcasecmp(tok, "null") != 0) {
- info->app_types = g_list_append(info->app_types,
- strdup(tok));
- }
- token = strtok_r(NULL, "|", &saveptr);
+ info->app_types = g_list_append(info->app_types, strdup(token));
+ token = strtok_r(NULL, "\t |\n", &saveptr);
}
}
{
FILE *fp;
char buf[LINE_MAX];
- char tok1[LINE_MAX];
- char tok2[LINE_MAX];
+ char *tok1 = NULL;
+ char *tok2 = NULL;
struct debugger_info_s *info = NULL;
fp = fopen(path, "rt");
return list;
while (fgets(buf, sizeof(buf), fp) != NULL) {
- tok1[0] = '\0';
- tok2[0] = '\0';
- sscanf(buf, "%s %s", tok1, tok2);
-
- if (strcasecmp(TAG_DEBUGGER, tok1) == 0) {
+ FREE_AND_NULL(tok1);
+ FREE_AND_NULL(tok2);
+ sscanf(buf, "%ms %ms", &tok1, &tok2);
+ if (tok1 && strcasecmp(TAG_DEBUGGER, tok1) == 0) {
if (info) {
_D("name: %s, exe: %s", info->name, info->exe);
list = g_list_append(list, info);
continue;
}
+ if (!tok1 || !tok2)
+ continue;
if (tok1[0] == '\0' || tok2[0] == '\0' || tok1[0] == '#')
continue;
if (info == NULL)
list = g_list_append(list, info);
}
+ if (tok1)
+ free(tok1);
+ if (tok2)
+ free(tok2);
+
return list;
}
{
char *token;
char *saveptr = NULL;
- char tok[LINE_MAX];
- token = strtok_r(line, "|", &saveptr);
+ token = strtok_r(line, "\t |\n", &saveptr);
while (token) {
- tok[0] = '\0';
- sscanf(token, "%s", tok);
- if (tok[0] != '\0' && strcasecmp(tok, "null") != 0) {
- info->app_types = g_list_append(info->app_types,
- strdup(tok));
- }
- token = strtok_r(NULL, "|", &saveptr);
+ info->app_types = g_list_append(info->app_types, strdup(token));
+ token = strtok_r(NULL, "\t |\n", &saveptr);
}
}
{
FILE *fp;
char buf[LINE_MAX];
- char tok1[LINE_MAX];
- char tok2[LINE_MAX];
+ char *tok1 = NULL;
+ char *tok2 = NULL;
struct launcher_info_s *info = NULL;
fp = fopen(path, "rt");
return list;
while (fgets(buf, sizeof(buf), fp) != NULL) {
- tok1[0] = '\0';
- tok2[0] = '\0';
- sscanf(buf, "%s %s", tok1, tok2);
-
- if (strcasecmp(TAG_LAUNCHER, tok1) == 0) {
+ FREE_AND_NULL(tok1);
+ FREE_AND_NULL(tok2);
+ sscanf(buf, "%ms %ms", &tok1, &tok2);
+ if (tok1 && strcasecmp(TAG_LAUNCHER, tok1) == 0) {
if (info) {
_D("name: %s, exe: %s", info->name, info->exe);
list = g_list_append(list, info);
continue;
}
+ if (!tok1 || !tok2)
+ continue;
if (tok1[0] == '\0' || tok2[0] == '\0' || tok1[0] == '#')
continue;
if (info == NULL)
list = g_list_append(list, info);
}
+ if (tok1)
+ free(tok1);
+ if (tok2)
+ free(tok2);
+
return list;
}
{
char *token;
char *savedptr;
- char refined_tok[LINE_MAX];
- token = strtok_r(line, "|", &savedptr);
+ token = strtok_r(line, "\t |\n", &savedptr);
info->detection_method = 0;
while (token) {
- sscanf(token, "%s", refined_tok);
- if (!strcmp(refined_tok, VAL_METHOD_TIMEOUT))
+ if (!strcmp(token, VAL_METHOD_TIMEOUT))
info->detection_method |= METHOD_TIMEOUT;
- if (!strcmp(refined_tok, VAL_METHOD_VISIBILITY))
+ else if (!strcmp(token, VAL_METHOD_VISIBILITY))
info->detection_method |= METHOD_VISIBILITY;
- if (!strcmp(refined_tok, VAL_METHOD_DEMAND))
+ else if (!strcmp(token, VAL_METHOD_DEMAND))
info->detection_method |= METHOD_DEMAND;
- token = strtok_r(NULL, "|", &savedptr);
+ token = strtok_r(NULL, "\t |\n", &savedptr);
}
_D("detection_method:%d", info->detection_method);
{
char *token;
char *savedptr;
- char refined_tok[LINE_MAX];
- token = strtok_r(line, "|", &savedptr);
+ token = strtok_r(line, "\t |\n", &savedptr);
while (token) {
- refined_tok[0] = '\0';
- sscanf(token, "%s", refined_tok);
- if (refined_tok[0] != '\0' &&
- strcasecmp("null", refined_tok) != 0) {
- info->app_types = g_list_append(info->app_types,
- strdup(refined_tok));
- }
- token = strtok_r(NULL, "|", &savedptr);
+ info->app_types = g_list_append(info->app_types, strdup(token));
+ token = strtok_r(NULL, "\t |\n", &savedptr);
}
}
static void __parse_extra(loader_info_t *info, char *line)
{
- char tok1[LINE_MAX] = { 0, };
- char tok2[LINE_MAX] = { 0, };
- char tok3[LINE_MAX] = { 0, };
+ char *tok1 = NULL;
+ char *tok2 = NULL;
+ char *tok3 = NULL;
if (info->extra == NULL)
return;
- sscanf(line, "%s %s %s", tok1, tok2, tok3);
+ sscanf(line, "%ms %ms %ms", &tok1, &tok2, &tok3);
+
+ if (!tok1 || !tok2 || !tok3)
+ goto end;
if (strlen(tok2) == 0 || strlen(tok3) == 0)
- return;
+ goto end;
bundle_add_str(info->extra, tok2, tok3);
+
+end:
+ if (tok1)
+ free(tok1);
+ if (tok2)
+ free(tok2);
+ if (tok3)
+ free(tok3);
}
static void __add_extra_array_from_list(bundle *b, const char *key, GList *list)
{
FILE *fp;
char buf[LINE_MAX];
- char tok1[LINE_MAX];
- char tok2[LINE_MAX];
+ char *tok1 = NULL;
+ char *tok2 = NULL;
loader_info_t *cur_info = NULL;
char *key = NULL;
GList *extra_array = NULL;
return list;
while (fgets(buf, sizeof(buf), fp) != NULL) {
- tok1[0] = '\0';
- tok2[0] = '\0';
- sscanf(buf, "%s %s", tok1, tok2);
-
- if (strcasecmp(TAG_LOADER, tok1) == 0) {
+ FREE_AND_NULL(tok1);
+ FREE_AND_NULL(tok2);
+ sscanf(buf, "%ms %ms", &tok1, &tok2);
+ if (tok1 && strcasecmp(TAG_LOADER, tok1) == 0) {
if (cur_info != NULL) {
__flush_extra_array(cur_info->extra, key,
extra_array);
continue;
}
+ if (!tok1 || !tok2)
+ continue;
if (tok1[0] == '\0' || tok2[0] == '\0' || tok1[0] == '#')
continue;
list = g_list_append(list, cur_info);
}
+ if (tok1)
+ free(tok1);
+ if (tok2)
+ free(tok2);
+
fclose(fp);
return list;