?? l-biblio.c
字號:
#include "head.h"int main(){char *risp;pid_t pid;system("clear");do{menu:{risp=malloc(sizeof("s"));fprintf (stdout, "[*]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++[*]\n" " + L-biblioteca Main Menu + \n" "[*]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++[*]\n" " * *\n" " * *\n" " * (C) Create new database (.db) file *\n" " * *\n" " * (A) Add an entry in memory (Title,Author,Editor,Pages,Cost,file.db) in a required position *\n" " * *\n" " * (D) Delete an entry in memory (required a position and the file.db) *\n" " * *\n" " * (P) Print the database file *\n" " * *\n" " * (Q) Quit *\n" " * *\n" " * *\n" "[*]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++[*]\n");fscanf(stdin,"%s",risp);}if (memcmp(risp,"C",sizeof("C"))==0 || memcmp(risp,"c",sizeof("c"))==0){char *nome;FILE *f; fprintf (stdout,"[*] Please enter the name of your new database file :"); nome=malloc(sizeof(nome)); fscanf(stdin,"%s",nome); if ( (f=fopen(nome,"w+"))==NULL){ fprintf (stdout,"[*] Error in CREATE,look the source code [*]\n"); goto menu;} fclose(f); fprintf (stdout,"[*] Create is end Return to main menu...[*]\n"); goto menu;}if(memcmp(risp,"A",sizeof("A"))==0 || memcmp(risp,"a",sizeof("a"))==0) { char *ze,*position,*pages,*title,*author,*editor,*cost,*database; fprintf (stdout,"[*] Insert title of the book whitout spaces use underline (_):"); title=malloc(sizeof(title)); fscanf (stdin,"%s",title); fprintf (stdout,"[*] Insert author of the book whitout spaces use underline (_) :"); author=malloc(sizeof(author)); fscanf (stdin,"%s",author); fprintf (stdout,"[*] Insert editor of the book whitout spaces use underline (_) :"); editor=malloc(sizeof(editor)); fscanf (stdin,"%s",editor); fprintf (stdout,"[*] Insert pages of the book whitout spaces use underline (_) :"); pages=malloc(sizeof(pages)); fscanf (stdin,"%s",pages); fprintf (stdout,"[*] Insert cost of the book whitout spaces use underline (_) :"); cost=malloc(sizeof(cost)); fscanf (stdin,"%s",cost); fprintf (stdout,"[*] Insert postion of the book in the database whitout spaces use underline (_) :"); position=malloc(sizeof(position)); fscanf (stdin,"%s",position); fprintf (stdout,"[*] Insert the name of the database to elaborate or write new name for new database whitout spaces use underline (_) :"); database=malloc(sizeof(database)); fscanf (stdin,"%s",database); fprintf (stdout,"[*] Are you sure ? (Y/N) :"); ze=malloc(sizeof(ze)); fscanf(stdin,"%s",ze); if (memcmp(ze,"n",sizeof("n"))==0 || memcmp(ze,"n",sizeof("n"))==0) goto menu; //Forking switch(pid = fork()) { case -1: fprintf (stdout,"[*] Error in add : Fork failed ,return to main menu [*] \n"); break; case 0: system("clear"); execl("add","add","-t",title,"-a",author,"-e",editor,"-n",pages,"-c",cost,"-p",position ,"-f",database); fprintf (stdout,"[*] Error in ADD ,look the source code [*]\n"); break; default: waitpid(pid,NULL,0); printf("[*] Add completed. Return to main menu[*]\n\n"); }} if(memcmp(risp,"P",sizeof("P"))==0 || memcmp(risp,"p",sizeof("p"))==0) { char *name,*start,*end; fprintf (stdout,"[*] Insert the database file name to print [*] :"); name=malloc(sizeof(name)); fscanf(stdin,"%s",name); fprintf (stdout,"[*] Print from position : "); start=malloc(sizeof(start)); fscanf (stdin,"%s",start); fprintf (stdout,"[*] To position :"); end=malloc(sizeof(end)); fscanf(stdin,"%s",end); //FORKO switch(pid = fork()) { case -1: fprintf (stdout,"[*] Error in print : Fork failed ,return to main menu [*] \n"); break; case 0: system("clear"); execl ("print","print",name,start,end); fprintf (stdout,"[*] Error in PRINT look the source code [*]\n"); break; default: waitpid(pid,NULL,0); printf("[*] Print completed. Return to main menu[*]\n\n"); } }if(memcmp(risp,"D",sizeof("D"))==0 || memcmp(risp,"d",sizeof("d"))==0) { char *file,*position,*risp; fprintf (stdout,"[*] Database name , to modify ? : "); file=malloc(sizeof(file)); fscanf(stdin,"%s",file); fprintf (stdout,"[*] Position to erase ? : "); position=malloc(sizeof(position)); fscanf(stdin,"%s",position); fprintf (stdout,"[*] Are you sure ? (Y/N) : "); risp=malloc(sizeof(risp)); fscanf(stdin,"%s",risp); if (memcmp(risp,"n",sizeof("n"))==0 || memcmp(risp,"n",sizeof("n"))==0) goto menu; //FORKO switch(pid = fork()) { case -1: fprintf (stdout,"[*] Error in DELETE : Fork failed ,return to main menu [*] \n"); break; case 0: execl ("delete","delete","-p",position,"-f",file); fprintf (stdout ,"[*] Error in Delete look the source code [*] \n"); break; default: waitpid(pid,NULL,0); printf("[*] Delete completed. Return to main menu[*]\n\n"); } }}while ( memcmp(risp,"q",sizeof("q"))!=0 && memcmp(risp,"Q",sizeof("Q"))!=0);}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -