/*! \brief recursive function to iterate over the XML nodes \param a_node is the current XML node */ G_MODULE_EXPORT void load_xmlcomm_elements(xmlNode *a_node) { static GHashTable *arguments = NULL; static GHashTable *commands = NULL; xmlNode *cur_node = NULL; ENTER(); if (!arguments) arguments = (GHashTable *)DATA_GET(global_data,"potential_arguments"); if (!commands) commands = (GHashTable *)DATA_GET(global_data,"commands_hash"); /* Iterate though all nodes... */ for (cur_node = a_node;cur_node;cur_node = cur_node->next) { if (cur_node->type == XML_ELEMENT_NODE) { if (g_ascii_strcasecmp((gchar *)cur_node->name,"potential_args") == 0) load_potential_args(arguments,cur_node); if (g_ascii_strcasecmp((gchar *)cur_node->name,"commands") == 0) load_commands(commands,cur_node); } load_xmlcomm_elements(cur_node->children); } EXIT(); return; }
struct conf* config_load() { dictionary *dict; struct conf *config = NULL; int res = 0; if( (res = access( CONFIG_FILE, R_OK ))) { syslog(LOG_ERR,"FAILED to access: %s\n\tcause:%s",CONFIG_FILE,strerror(errno)); return NULL; } dict = iniparser_load(CONFIG_FILE); if (!dict) { return NULL ; } config = allocate_config(dict); if (config == NULL ) { goto clean_up; } if (load_fire_on(dict, config)) { goto clean_up; } if (load_watch_dir(dict, config)) { goto clean_up; } if (load_watch_content(dict, config)) { goto clean_up; } if (load_fire_on(dict, config)) { goto clean_up; } if (load_commands(dict,config)) { goto clean_up; } load_min_read_close(dict, config); clean_up: iniparser_freedict(dict); return config; }
void redis_commands::init(const char* cmds_file) { set_commands(); if (cmds_file && *cmds_file) { acl::ifstream in; if (in.open_read(cmds_file) == false) { logger_error("load file %s error: %s", cmds_file, acl::last_serror()); return; } load_commands(in); } show_commands(); }
int main() { load_commands(); do_command("NoR"); do_command("sOu"); do_command("WeS"); }
int main(int argc, char **argv) { // test shell config struct stat shelltest; struct wordnode* commands; //head for list of possible paths to commands int rv = stat("shell-config", &shelltest); if (rv < 0) { printf("shell-config DNE. Please enter full path"); } else { int num_words = 0; commands = load_commands("shell-config",&num_words); //commands = "/bin/"; } char prompt[] = "prompt> "; printf("%s",prompt); fflush(stdout); int m=0; //keep track of mode char buffer[1024]; while (fgets(buffer, 1024, stdin) != NULL) { //handles comments, but only at the end of command int i=0; while (buffer[i]!='\0') { if (buffer[i]=='#') { buffer[i] = '\0'; i--; } i++; } // int size = size_of_array(buffer); char** argv = (char**) malloc(sizeof(char*)*(size+1)); make_array(buffer,argv,size); //print_array(argv,size); //printf("%d\n", size); if (m==0) { m = run_sequential(argv,size,commands); } else if (m==1) { m = run_par(argv,size); //pid_t pid; //int num; /*while ((pid = waitpid(-1, &stat, WNOHANG))>0) { printf("child process finished /n"); }*/ } printf("%s",prompt); } // end shell while loop free(argv); free_wordlist(commands); return 0; }