int main() { int choice; char filename[200] = {0}; get_fold_id(); printf("Enetr ur choice\n 1.auth_tok\n 2.refresh_tok\n 3.putdata\n 4.down_data \n 5.read_fold\n 6.Create Folder\n"); scanf("%d",&choice); if(choice == 1) auth_tok(); if(choice == 2){ get_toks(); refresh_tok(); } //read_fold(); //uplaod_data(); if(choice == 3){ printf("\nEnter File name: "); gets(filename); get_toks(); putdata("downfile.txt",fold_id); } if(choice ==4) { get_toks(); down_data(); } if(choice ==5){ get_toks(); read_fold(); } if(choice ==6){ get_toks(); create_fold(); } main(); }
int shell(int argc, char *argv[]) { char *input_bytes; tok_t *tokens; int line_num = 0; int fundex = -1; init_shell(); if (shell_is_interactive) /* Please only print shell prompts when standard input is not a tty */ fprintf(stdout, "%d: ", line_num); while ((input_bytes = freadln(stdin))) { tokens = get_toks(input_bytes); fundex = lookup(tokens[0]); if (fundex >= 0) { cmd_table[fundex].fun(&tokens[1]); } else { int pid = fork(); if (pid == 0){ int i; for(i = 1;i < MAXTOKS - 1;i++) if(strcmp(">",tokens[i]) == 0){ FILE *f = fopen(tokens[i + 1],"w"); if(f == NULL) { exit(1); } dup2(fileno(f),STDOUT_FILENO); fclose(f); } else if(strcmp("<",tokens[i]) == 0){ FILE *f = fopen(tokens[i + 1],"r"); if(f == NULL) { exit(1); } dup2(fileno(f),fileno(stdin)); fclose(f); } execvp(tokens[0],tokens + 1); exit(0); } } if (shell_is_interactive) /* Please only print shell prompts when standard input is not a tty */ fprintf(stdout, "%d: ", ++line_num); } return 0; }