int main(int argv, char *argc []) { int num_of_articles = 0; int num_of_threads = 0; args arguments; DIR *directory; art *articles; Process_Args (&arguments, argv, argc); num_of_articles = Open_Dir (&arguments, &directory); articles = (art *) malloc (sizeof (art) * num_of_articles); if (articles == NULL) { Error ("main: Unable to allocate memory"); } num_of_threads = Process_Articles (&arguments, articles, directory, &num_of_articles); /* Print_Out (&arguments, articles, num_of_articles, num_of_threads); */ BuildDataBase (articles, num_of_articles, argc[1] ); closedir (directory); return 0; }
int main(int argc, char * argv[]) { printf("%d,%s,%s,%s\n",argc,argv[0],argv[1],argv[2]); int Operation = -1; if (argc > 3) { printf("bad movement\n"); exit(-1); } if (argc == 1) { printf("-a:add path and key\n-g:use key to open\n-l:list all the key and path\n"); exit(0); } if (strcmp(argv[1], "-l") == 0) { Operation = LISTDIR; } else if (strcmp(argv[1], "-a") == 0) { Operation = ADDDIR; } else if (strcmp(argv[1], "-g") == 0) { Operation = OPENDIR; if (argc != 3) { printf("no key!\n"); exit(-1); } } if (Operation == -1) { printf("something wrong!\n"); exit(-1); } switch (Operation) { case LISTDIR: List_All_Dir(); break; case ADDDIR: Add_Dir(); break; case OPENDIR: Open_Dir(argv[2]); break; } return 0; }