int main(int argc, char* argv[]) { CLineFields file; if (argc < 4) { cerr << "join files according to a numerical field (1-based)" <<endl; cerr << "only keep the ones contained in all files, and print them out from the first file" <<endl; cerr << "syntax:" << endl; cerr << " " << argv[0] << " field file1 file2 [file3...] > output" << endl; return -1; } memset(mark,0,sizeof(mark)); // handle the files int f2 = atoi(argv[1])-1; if (f2>=0) { for (int i=3; i<argc; i++) handlefile(argv[i], f2, argc-2); handlefile(argv[2], f2, argc-2); } else { cerr << "parameter error! " << endl; return -1; } return 0; }
int main(int argc, char* argv[]) { CLineFields file; if (argc != 4) { cerr << "join the file with itself according to fields (1-based) so that duplicate lines can be removed" <<endl; cerr << "syntax:" << endl; cerr << " " << argv[0] << " file field1 field2 > output" << endl; return -1; } // handle the first file int f1 = atoi(argv[2])-1; int f2 = atoi(argv[3])-1; if (f1>=0 && f2>=0) { handlefile(argv[1], f1, f2); } else { cerr << "parameter error! " << endl; return -1; } // output the final results for (map<string, string>::iterator it= results.begin(); it!= results.end(); it++) { cout << (*it).second << endl; } return 0; }
int main(int argc, char* argv[]) { CLineFields file; if (argc < 4) { cerr << "union files according to a numerical field (1-based)" <<endl; cerr << "syntax:" << endl; cerr << " " << argv[0] << " field file1 file2 [file3...] > output" << endl; return -1; } memset(mark,0,sizeof(mark)); // handle the files int f2 = atoi(argv[1])-1; if (f2>=0) { for (int i=2; i<argc; i++) handlefile(argv[i], f2); } else { cerr << "parameter error! " << endl; return -1; } return 0; }
static void handledir(struct hthead *req, int fd, char *path) { struct config **cfs; int i, o; struct stat sb; char *inm, *ipath, *cpath; struct pattern *pat; cpath = sprintf2("%s/", path); cfs = getconfigs(cpath); for(i = 0; cfs[i] != NULL; i++) { if(cfs[i]->index != NULL) { for(o = 0; cfs[i]->index[o] != NULL; o++) { inm = cfs[i]->index[o]; ipath = sprintf2("%s/%s", path, inm); if(!stat(ipath, &sb) && S_ISREG(sb.st_mode)) { handlefile(req, fd, ipath); free(ipath); goto out; } free(ipath); if(!strchr(inm, '.') && ((ipath = findfile(path, inm, NULL)) != NULL)) { handlefile(req, fd, ipath); free(ipath); goto out; } } break; } } if((pat = findmatch(cpath, 0, PT_DIR)) != NULL) { handle(req, fd, cpath, pat); goto out; } simpleerror(fd, 403, "Not Authorized", "Will not send listings for this directory."); out: free(cpath); }