#ifndef __PROGRAMS__H_ #define __PROGRAMS__H_ #ifdef FOR_PSP #include #include #include #include #endif static char *programs_array[] = { "ls","cd", "about","add", 0 }; enum { ID_LS,ID_CD, ID_ABOUT, ID_ADD }; int get_prog_id(char *buf) { for(i = 0; programs_array[i] != 0; i++) { if(strcmp(programs_array[i], buf) == 0) return i; } return -1; } void print_dir(char *dir) { #ifdef FOR_PSP int file_count = 0; DIR *d = 0; struct dirent *de = 0; if(!(d = opendir(dir))) { printconf("\n couldnt open directory "); } while ((de = readdir(d)) != 0) { printconf("\n%s", de->d_name); } closedir(d); #endif } void change_dir(char *dir) { chdir(dir); } int master_main(int argc, char **argv) { printf(argv[0]); switch(get_prog_id(argv[0])) { case ID_LS: print_dir("."); set_scroll(1); break; case ID_CD: if(argc != 3) { printconf("\nto few arguments "); break; } change_dir(argv[1]); printconf("\n directory changed to %s", argv[1]); break; case ID_ABOUT: printconf("\n--mxconsole written by jared bruni"); break; case ID_ADD: { int i = 0, total = 0; printconf("\n adding "); for(i = 1; i < argc-1; i++) { printconf("%d ", atoi(argv[i])); total += atoi(argv[i]); } printconf(" = %d", total); } break; default: return 1; } return 0; } #endif