#include int main(int argc,char*argv[]) { char a[100],b[100]; long red(FILE*,FILE*,char*),l; int comp(char*,char*); FILE*forig,*fdest; if(argc==1) {printf("\nDigitare : path_file_da_aggiungere path_file_destinazione .\n\n__"); scanf("%s %s",a,b); for(;(getchar())!=10;);} else if(argc==3) {strcpy(a,argv[1]); strcpy(b,argv[2]);} else if(argc==2&&comp("--help",argv[1])) {printf("WORDLIST CHECKER : %s path_file_da_aggiungere path_file_destinazione\n" ,argv[0]);exit(0);} else {printf("Errore di sintassi .\n");exit(1);} printf("\n\nWORDLIST CHECKER (x D4rK da _Me_)\n\n"); if((forig=fopen(a,"r"))==NULL||ferror(forig)) {printf("\nErrore nell'apertura di %s\n",a);exit(1);} if((fdest=fopen(b,"r"))==NULL) {printf("\nFile %s inesistente\n",b);exit(1);} fprintf(stderr,"\nAttenzione : Questo processo puo' risultare veramente lungo ;\n" " Ogni \".\" corrisponde ad 1a nuova parola aggiunta .\n\n" "[ Elaborazione in corso ] "); printf("\n\nProcesso Completato : %d parol%s aggiunt%s\n" ,l=red(forig,fdest,b),l==1?"a":"e",l==1?"a":"e"); fclose(fdest); fclose(forig); } long red(FILE*a,FILE*b,char*select) { long nw=0; int nword(FILE*,char*),check(char*,FILE*); void copia(char*,FILE*,char*); char tmp[1000]; for(;nword(a,tmp);) if(check(tmp,b)) {copia(tmp,b,select);++nw;} return nw; } int nword(FILE*a,char*s) { char c; for(;(c=getc(a))!=10&&c!=-1;*s++=c); *s='\0'; if(c==-1) return 0; else return 1; } int check(char*s,FILE*b) { int i,comp(char*,char*); char c=0,tmp[1000],*p; for(;c!=EOF;) {for(i=0,p=tmp;(c=getc(b))!=10&&c!=EOF;tmp[i++]=c); tmp[i]='\0'; if(comp(s,tmp)) return 0;} return 1; } void copia(char*s,FILE*b,char*select) { fclose(b); b=fopen(select,"a"); for(;*s!='\0';++s) putc(*s,b); putc(10,b); fclose(b); b=fopen(select,"r"); fprintf(stderr,"."); } int comp(char*a,char*b) { if(strlen(a)!=strlen(b)) return 0; for(;*a!='\0'&&*b!='\0';) if(*a++!=*b++) return 0; return 1; }