void viwmfs(int argc, char **argv) { size_t i; char *cmd, str[256] = { 0 }; Bool e; if(!argc) return; if(argc > 3) { for(i = 2; i < (size_t)argc; ++i) { strcat(str, argv[i]); if(*(str + strlen(str) - 1) != ':') strcat(str, " "); } } else strncpy(str, argv[2], sizeof(str)); if(!strcmp(str, "help")) { viwmfs_help(); return; } if(*str == ':') { for(i = 0; i < strlen(str); str[i] = str[i + 1], ++i); cmd = xstrdup(str); for(i = 0; cmd[i] && cmd[i] != ' '; ++i); cmd[i] = '\0'; for(i = 0; i < LEN(vicmd); ++i) if(!strncmp(cmd, vicmd[i].cmd, strlen(cmd))) { exec_uicb_function(vicmd[i].uicb, clean_value(str + strlen(cmd))); e = True; break; } /* For uicb function with normal name specified */ if(!e) { if(!strcmp(str, "h") || !strcmp(str, "help")) viwmfs_help(); else exec_uicb_function(cmd, str + strlen(cmd)); } } return; }
void add_entry(char *section_name, char *key, char *value) { section_t *s = get_section(section_name); if (s == NULL) { s = new_section(section_name); } s->entry_count++; int len = s->entry_count; s->entries = realloc(s->entries, sizeof(entry_t) * len); s->entries[s->entry_count - 1].key = g_strdup(key); s->entries[s->entry_count - 1].value = clean_value(value); }