void collectSourceFile(list * names, list * paths, const char *path) { DIR *dp; struct dirent *ep; char file[MAX_PATH_LEN]; dp = opendir(path); if (dp != NULL) { while (ep = readdir(dp)) { strcpy(file, path); strcat(file, "/"); strcat(file, ep->d_name); if (isSourceFile(ep->d_name) && isRegularFile(file)) { addNode(names, ep->d_name); addNode(paths, file); } } (void) closedir(dp); } else perror("Couldn't open the directory"); }
int main(int argc, char** argv) { int i; int checktab = 0; int checklen = 0; int summarize = 0; int checkbadcr = 0; int checktrailbl = 0; char c; arg0 = argv[0]; if (argc < 2) { usage(); exit(1); } /* Get options from first parameter */ if( argc > 1 && argv[1][0] == '-' ) { for( i=1; (c=argv[1][i]) != '\0'; i++ ) { if( c =='t' ) checktab++; else if( c == 'l' ) checklen++; else if( c == 'm' ) checkbadcr++; else if( c == 's' ) summarize++; else if( c == 'b' ) checktrailbl++; else if( c =='h' ) {usage(); exit(1);} else printf("Error Option %c?\n", c); } --argc; ++argv; } /* default is to test all if none optioned*/ if (checktab == 0 && checklen == 0 && checktrailbl == 0) { checktab = 1; checklen = 1; checkbadcr = 1; /* Defaults to off for now since there are so many * cased of trailing blanks in the environment today */ checktrailbl = 0; } /* retest after argument removal */ if (argc < 2) { usage(); exit(1); } for (i = 1; i < argc; i++) { if (isSourceFile(argv[i])) chksrc(argv[i], checktab, checklen, checkbadcr, checktrailbl,summarize); } return 0; }