int main (int argc, char *argv[]) { dki_t *data = NULL; int c; int opt_index; int action; const char *file; const char *defconfname = NULL; char *p; char str[254+1]; zconf_t *config; progname = *argv; if ( (p = strrchr (progname, '/')) ) progname = ++p; view = getnameappendix (progname, "zkt-ls"); defconfname = getdefconfname (view); config = loadconfig ("", (zconf_t *)NULL); /* load built in config */ if ( fileexist (defconfname) ) /* load default config file */ config = loadconfig (defconfname, config); if ( config == NULL ) fatal ("Out of memory\n"); setglobalflags (config); opterr = 0; opt_index = 0; action = 0; #if defined(HAVE_GETOPT_LONG) && HAVE_GETOPT_LONG while ( (c = getopt_long (argc, argv, short_options, long_options, &opt_index)) != -1 ) #else while ( (c = getopt (argc, argv, short_options)) != -1 ) #endif { switch ( c ) { #if defined(COLOR_MODE) && COLOR_MODE case 'C': /* color mode on; optional with terminal name */ if ( optarg ) term = optarg; else term = getenv ("TERM"); break; #endif case 'M': managedkeyflag = 1; subdomain_before_parent = 0; zskflag = pathflag = 0; action = c; break; case 'T': trustedkeyflag = 1; subdomain_before_parent = 0; zskflag = pathflag = 0; /* fall through */ case 'H': case 'K': case 'Z': action = c; break; case 'a': /* age */ ageflag = !ageflag; break; case 'f': /* key lifetime */ lifetimeflag = !lifetimeflag; break; case 'V': /* view name */ view = optarg; defconfname = getdefconfname (view); if ( fileexist (defconfname) ) /* load default config file */ config = loadconfig (defconfname, config); if ( config == NULL ) fatal ("Out of memory\n"); setglobalflags (config); break; case 'c': config = loadconfig (optarg, config); setglobalflags (config); checkconfig (config); break; case 'O': /* read option from commandline */ config = loadconfig_fromstr (optarg, config); setglobalflags (config); checkconfig (config); break; case 'd': /* ignore directory arg */ dirflag = 1; break; case 'h': /* print no headline */ headerflag = 0; break; case 'k': /* ksk only */ zskflag = 0; break; case 'L': /* ljust */ ljustflag = !ljustflag; break; case 'l': /* label list */ labellist = prepstrlist (optarg, LISTDELIM); if ( labellist == NULL ) fatal ("Out of memory\n"); break; case 'p': /* print path */ pathflag = 1; break; case 'r': /* switch recursive flag */ recflag = !recflag; break; case 's': /* switch subdomain sorting flag */ subdomain_before_parent = !subdomain_before_parent; break; case 't': /* time */ timeflag = !timeflag; break; case 'e': /* expire time */ exptimeflag = !exptimeflag; break; case 'z': /* zsk only */ kskflag = 0; break; case ':': snprintf (str, sizeof(str), "option \"-%c\" requires an argument.\n", optopt); usage (str, config); break; case '?': if ( isprint (optopt) ) snprintf (str, sizeof(str), "Unknown option \"-%c\".\n", optopt); else snprintf (str, sizeof (str), "Unknown option char \\x%x.\n", optopt); usage (str, config); break; default: abort(); } } if ( kskflag == 0 && zskflag == 0 ) kskflag = zskflag = 1; tc_init (stdout, term); c = optind; do { if ( c >= argc ) /* no args left */ file = config->zonedir; /* use default directory */ else file = argv[c++]; if ( is_directory (file) ) parsedirectory (file, &data, subdomain_before_parent); else parsefile (file, &data, subdomain_before_parent); } while ( c < argc ); /* for all arguments */ switch ( action ) { case 'H': usage ("", config); case 'K': zkt_list_dnskeys (data); break; case 'T': zkt_list_trustedkeys (data); break; case 'M': zkt_list_managedkeys (data); break; default: zkt_list_keys (data); } tc_end (stdout, term); return 0; }
int main(int argc, char **argv) { int ch; int warncount = 0; setlocale(LC_NUMERIC, ""); setbuf(stdout,0); setbuf(stderr,0); while ((ch = getopt(argc, argv, "Aabdef:hiNnoqTwWxX")) != -1) { switch (ch) { case 'A': /* compatibility */ aflag = oflag = 1; break; case 'a': aflag = 1; break; case 'b': bflag = 1; break; case 'd': dflag = 1; break; case 'e': eflag = 1; break; case 'f': conffile = optarg; break; case 'h': hflag = 1; break; case 'i': iflag = 1; break; case 'N': Nflag = 1; break; case 'n': nflag = 1; break; case 'o': oflag = 1; break; case 'q': qflag = 1; break; case 'T': Tflag = 1; break; case 'w': /* compatibility */ /* ignored */ break; case 'W': Wflag = 1; break; case 'X': /* compatibility */ aflag = xflag = 1; break; case 'x': xflag = 1; break; default: usage(); } } argc -= optind; argv += optind; if (Nflag && nflag) usage(); if (aflag && argc == 0) exit(sysctl_all(0, 0)); if (argc == 0 && conffile == NULL) usage(); warncount = 0; if (conffile != NULL) warncount += parsefile(conffile); while (argc-- > 0) warncount += parse(*argv++, 0); return (warncount); }
int main (int argc, char *argv[]) { dki_t *data = NULL; dki_t *dkp; int c; int opt_index; int action; const char *file; const char *defconfname = NULL; char *p; char str[254+1]; const char *keyname = NULL; int searchtag; zconf_t *config; progname = *argv; if ( (p = strrchr (progname, '/')) ) progname = ++p; view = getnameappendix (progname, "dnssec-zkt"); defconfname = getdefconfname (view); config = loadconfig ("", (zconf_t *)NULL); /* load built in config */ if ( fileexist (defconfname) ) /* load default config file */ config = loadconfig (defconfname, config); if ( config == NULL ) fatal ("Out of memory\n"); setglobalflags (config); opterr = 0; opt_index = 0; action = 0; #if defined(HAVE_GETOPT_LONG) && HAVE_GETOPT_LONG while ( (c = getopt_long (argc, argv, short_options, long_options, &opt_index)) != -1 ) #else while ( (c = getopt (argc, argv, short_options)) != -1 ) #endif { switch ( c ) { case '9': /* ksk rollover help */ ksk_roll ("help", c - '0', NULL, NULL); exit (1); case '1': /* ksk rollover: create new key */ case '2': /* ksk rollover: publish DS */ case '3': /* ksk rollover: delete old key */ case '0': /* ksk rollover: show current status */ action = c; if ( !optarg ) usage ("ksk rollover requires an domain argument", config); kskdomain = domain_canonicdup (optarg); break; case 'h': case 'K': case 'Z': action = c; break; case 'C': pathflag = !pathflag; /* fall through */ case 'P': case 'S': case 'A': case 'D': case 'R': case 's': case 19: case 20: if ( (keyname = parsetag (optarg, &searchtag)) != NULL ) keyname = domain_canonicdup (keyname); action = c; break; case 'F': /* set key lifetime */ lifetime = atoi (optarg); action = c; break; case 'V': /* view name */ view = optarg; defconfname = getdefconfname (view); if ( fileexist (defconfname) ) /* load default config file */ config = loadconfig (defconfname, config); if ( config == NULL ) fatal ("Out of memory\n"); setglobalflags (config); break; case 'c': config = loadconfig (optarg, config); setglobalflags (config); checkconfig (config); break; case 'O': /* read option from commandline */ config = loadconfig_fromstr (optarg, config); setglobalflags (config); checkconfig (config); break; case 'd': /* ignore directory arg */ dirflag = 1; break; case 'k': /* ksk only */ zskflag = 0; break; case 'r': /* switch recursive flag */ recflag = !recflag; break; case 'z': /* zsk only */ kskflag = 0; break; case ':': snprintf (str, sizeof(str), "option \"-%c\" requires an argument.\n", optopt); usage (str, config); break; case '?': if ( isprint (optopt) ) snprintf (str, sizeof(str), "Unknown option \"-%c\".\n", optopt); else snprintf (str, sizeof (str), "Unknown option char \\x%x.\n", optopt); usage (str, config); break; default: abort(); } } if ( kskflag == 0 && zskflag == 0 ) kskflag = zskflag = 1; c = optind; do { if ( c >= argc ) /* no args left */ file = config->zonedir; /* use default directory */ else file = argv[c++]; if ( is_directory (file) ) parsedirectory (file, &data); else parsefile (file, &data); } while ( c < argc ); /* for all arguments */ switch ( action ) { case 'h': usage ("", config); case 'C': createkey (keyname, data, config); break; case 'P': case 'S': case 'A': case 'D': if ( (dkp = (dki_t*)zkt_search (data, searchtag, keyname)) == NULL ) fatal ("Key with tag %u not found\n", searchtag); else if ( dkp == (void *) 01 ) fatal ("Key with tag %u found multiple times\n", searchtag); if ( (c = dki_setstatus_preservetime (dkp, action)) != 0 ) fatal ("Couldn't change status of key %u: %d\n", searchtag, c); break; case 19: /* remove (rename) key file */ if ( (dkp = (dki_t *)zkt_search (data, searchtag, keyname)) == NULL ) fatal ("Key with tag %u not found\n", searchtag); else if ( dkp == (void *) 01 ) fatal ("Key with tag %u found multiple times\n", searchtag); dki_remove (dkp); break; case 20: /* destroy the key (remove the files!) */ if ( (dkp = (dki_t *)zkt_search (data, searchtag, keyname)) == NULL ) fatal ("Key with tag %u not found\n", searchtag); else if ( dkp == (void *) 01 ) fatal ("Key with tag %u found multiple times\n", searchtag); dki_destroy (dkp); break; case 'R': if ( (dkp = (dki_t *)zkt_search (data, searchtag, keyname)) == NULL ) fatal ("Key with tag %u not found\n", searchtag); else if ( dkp == (void *) 01 ) fatal ("Key with tag %u found multiple times\n", searchtag); if ( (c = dki_setstatus (dkp, action)) != 0 ) fatal ("Couldn't change status of key %u: %d\n", searchtag, c); break; case '1': /* ksk rollover new key */ case '2': /* ksk rollover publish DS */ case '3': /* ksk rollover delete old key */ case '0': /* ksk rollover status */ ksk_roll (kskdomain, action - '0', data, config); break; case 'F': zkt_setkeylifetime (data); /* fall through */ default: zkt_list_keys (data); } return 0; }
/*! \bug When you have a section completely in one block in characters (ie {1}), it does not realize that the start and end are there, and chaos ensues. */ void parsefile(ifstream & inputfile, vector <string> & words) { string temp; vector <string> tempwords; while(inputfile >> temp) { string temp2, temp3; unsigned int pos; //Ignore comments pos=temp.find(comment); if( pos < temp.size() ) { temp.erase(pos,temp.size()-pos); inputfile.ignore(800, '\n'); } //Put start section markers in their own word pos = temp.find(startsec); if( pos < temp.size() ) { temp.erase(pos,startsec.size()); temp2=startsec; temp3.append(temp, pos, temp.size()); temp.erase(pos, temp.size()-pos); } //Put any end section markers in their //own word pos = temp.find(endsec); if( pos < temp.size() ) { temp.erase(pos,endsec.size()); temp2=endsec; temp3.append(temp, pos, temp.size()); temp.erase(pos, temp.size()-pos); } if( ! temp.empty() ) tempwords.push_back(temp); if( ! temp2.empty() ) tempwords.push_back(temp2); if( ! temp3.empty() ) tempwords.push_back(temp3); } // Include any include files(It's recursive here..) for(unsigned int i=0; i < tempwords.size(); i++) { if(caseless_eq(tempwords[i],"INCLUDE")) { ifstream includefile(tempwords[i+1].c_str()); vector <string> includewords; if(!includefile) { error("couldn't open ", tempwords[i+1]); } parsefile(includefile, includewords); for(unsigned int j=0; j< includewords.size(); j++) { words.push_back(includewords[j]); } includefile.close(); i++; } else { words.push_back(tempwords[i]); } } }
// compilation // [filename/src packages] -> [packages] int Compiler::gocompile(int type) { int k; if (STACKGET(m,0)==NIL) { STACKDROP(m); return 0; } const char* name=STRSTART(VALTOPNT(STACKGET(m,0))); if (type==COMPILE_FROMFILE) { parser=new Parser(m->term,m->filesystem,name); PRINTF(m)(LOG_COMPILER,"Compiler : compiling file '%s'\n",name); } else { parser=new Parser(m->term,name); name="..."; PRINTF(m)(LOG_COMPILER,"Compiler : compiling string buffer\n"); } if (k=createpackage(name,4)) return k; // [package nom_fichier env] TABSET(m,VALTOPNT(STACKGET(m,0)),PACK_NEXT,STACKGET(m,2)); STACKSET(m,2,STACKGET(m,0)); // [newenv nom_fichier newenv] STACKDROPN(m,2); // [newenv] newpackage=VALTOPNT(STACKGET(m,0)); // parsing //### ici on doit pouvoir ajouter la liste des globales et la liste des fonctions //### c'est ici également qu'on va réinitialiser la structure bc if (k=STACKPUSH(m,NIL)) return k; // GLOBALS globals=STACKREF(m); ifuns=0; k=parsefile(0); //### c'est fait, on a le bytecode, la liste des fonctions, et la liste des globales if (!k) { Prodbuffer* btab=new Prodbuffer(); int n=nblabels(globals); brelease->addint(0); recglobals(STACKGETFROMREF(m,globals,0),brelease); brelease->setint(0,brelease->getsize()); int sizebc=brelease->getsize(); brelease->addint(0); // on prépare le champ pour la taille du bytecode int* p=VALTOPNT(TABGET(newpackage,PACK_HACH)); int vref=TABGET(p,TABLEN(p)-1); int nfun=recbc(vref,brelease,btab,sizebc+4); if (nfun<0) return nfun; brelease->setint(sizebc,brelease->getsize()-sizebc-4); brelease->addshort(nfun+1); brelease->addstr(btab->getstart(),btab->getsize()); delete btab; } if (k) parser->echoposition(); PRINTF(m)(LOG_COMPILER,"\n"); // dumppackage(STACKGET(m,0)); delete parser; return k; }
InternalArgument execute(const std::vector<InternalArgument>& args) const { parsefile(*get<0>(args)); return nilarg(); }
int main(int argc, char **argv) { const char *av = NULL; int db; int optchar; int option_index = 0; int status = 0; /* * get path of following directories. * o current directory * o root of source tree * o dbpath directory * * if GTAGS not found, exit with an error message. */ status = setupdbpath(0); if (status == 0) { cwd = get_cwd(); root = get_root(); dbpath = get_dbpath(); } /* * Setup GTAGSCONF and GTAGSLABEL environment variable * according to the --gtagsconf and --gtagslabel option. */ preparse_options(argc, argv); /* * Open configuration file. */ openconf(root); setenv_from_config(); logging_arguments(argc, argv); while ((optchar = getopt_long(argc, argv, "acde:EifFgGIlL:MnoOpPqrsS:tTuvVx", long_options, &option_index)) != EOF) { switch (optchar) { case 0: break; case 'a': aflag++; break; case 'c': cflag++; setcom(optchar); break; case 'd': dflag++; break; case 'e': av = optarg; break; case 'E': Gflag = 0; break; case 'f': fflag++; xflag++; setcom(optchar); break; case 'F': Tflag = 0; break; case 'g': gflag++; setcom(optchar); break; case 'G': Gflag++; break; case 'i': iflag++; break; case 'I': Iflag++; setcom(optchar); break; case 'l': Sflag++; scope = "."; break; case 'L': file_list = optarg; break; case 'M': Mflag++; iflag = 0; break; case 'n': nflag++; if (optarg) { if (!strcmp(optarg, "sort")) nofilter |= SORT_FILTER; else if (!strcmp(optarg, "path")) nofilter |= PATH_FILTER; } else { nofilter = BOTH_FILTER; } break; case 'o': oflag++; break; case 'O': Oflag++; break; case 'p': pflag++; setcom(optchar); break; case 'P': Pflag++; setcom(optchar); break; case 'q': qflag++; setquiet(); break; case 'r': rflag++; break; case 's': sflag++; break; case 'S': Sflag++; scope = optarg; break; case 't': tflag++; break; case 'T': Tflag++; break; case 'u': uflag++; setcom(optchar); break; case 'v': vflag++; setverbose(); break; case 'V': Vflag++; break; case 'x': xflag++; break; case OPT_USE_COLOR: if (optarg) { if (!strcmp(optarg, "never")) use_color = 0; else if (!strcmp(optarg, "always")) use_color = 1; else if (!strcmp(optarg, "auto")) use_color = 2; else die_with_code(2, "unknown color type."); } else { use_color = 2; } break; case OPT_ENCODE_PATH: encode_chars = optarg; break; case OPT_FROM_HERE: { char *p = optarg; const char *usage = "usage: global --from-here=lineno:path."; context_lineno = p; while (*p && isdigit(*p)) p++; if (*p != ':') die_with_code(2, usage); *p++ = '\0'; if (!*p) die_with_code(2, usage); context_file = p; } break; case OPT_GTAGSCONF: case OPT_GTAGSLABEL: /* These options are already parsed in preparse_options() */ break; case OPT_MATCH_PART: if (!strcmp(optarg, "first")) match_part = MATCH_PART_FIRST; else if (!strcmp(optarg, "last")) match_part = MATCH_PART_LAST; else if (!strcmp(optarg, "all")) match_part = MATCH_PART_ALL; else die_with_code(2, "unknown part type for the --match-part option."); break; case OPT_PATH_CONVERT: do_path = 1; if (!strcmp("absolute", optarg)) convert_type = PATH_ABSOLUTE; else if (!strcmp("relative", optarg)) convert_type = PATH_RELATIVE; else if (!strcmp("through", optarg)) convert_type = PATH_THROUGH; else die("Unknown path type."); break; case OPT_PATH_STYLE: path_style = optarg; break; case OPT_RESULT: if (!strcmp(optarg, "ctags-x")) format = FORMAT_CTAGS_X; else if (!strcmp(optarg, "ctags-xid")) format = FORMAT_CTAGS_XID; else if (!strcmp(optarg, "ctags")) format = FORMAT_CTAGS; else if (!strcmp(optarg, "ctags-mod")) format = FORMAT_CTAGS_MOD; else if (!strcmp(optarg, "path")) format = FORMAT_PATH; else if (!strcmp(optarg, "grep")) format = FORMAT_GREP; else if (!strcmp(optarg, "cscope")) format = FORMAT_CSCOPE; else die_with_code(2, "unknown format type for the --result option."); break; case OPT_SINGLE_UPDATE: single_update = optarg; break; default: usage(); break; } } if (qflag) vflag = 0; if (show_version) version(av, vflag); if (show_help) help(); if (dbpath == NULL) die_with_code(-status, gtags_dbpath_error); /* * decide format. * The --result option is given to priority more than the -t and -x option. */ if (format == 0) { if (tflag) { /* ctags format */ format = FORMAT_CTAGS; } else if (xflag) { /* print details */ format = FORMAT_CTAGS_X; } else { /* print just a file name */ format = FORMAT_PATH; } } /* * GTAGSBLANKENCODE will be used in less(1). */ switch (format) { case FORMAT_CTAGS_X: case FORMAT_CTAGS_XID: if (encode_chars == NULL && getenv("GTAGSBLANKENCODE")) encode_chars = " \t"; break; } if (encode_chars) { if (strlen(encode_chars) > 255) die("too many encode chars."); if (strchr(encode_chars, '/') || strchr(encode_chars, '.')) warning("cannot encode '/' and '.' in the path. Ignored."); set_encode_chars((unsigned char *)encode_chars); } if (getenv("GTAGSTHROUGH")) Tflag++; if (use_color) { #if defined(_WIN32) && !defined(__CYGWIN__) if (!(getenv("ANSICON") || LoadLibrary("ANSI32.dll")) && use_color == 2) use_color = 0; #endif if (use_color == 2 && !isatty(1)) use_color = 0; if (Vflag) use_color = 0; } argc -= optind; argv += optind; /* * Path filter */ if (do_path) { /* * This code is needed for globash.rc. * This code extract path name from tag line and * replace it with the relative or the absolute path name. * * By default, if we are in src/ directory, the output * should be converted like follows: * * main 10 ./src/main.c main(argc, argv)\n * main 22 ./libc/func.c main(argc, argv)\n * v * main 10 main.c main(argc, argv)\n * main 22 ../libc/func.c main(argc, argv)\n * * Similarly, the --path-convert=absolute option specified, then * v * main 10 /prj/xxx/src/main.c main(argc, argv)\n * main 22 /prj/xxx/libc/func.c main(argc, argv)\n */ STRBUF *ib = strbuf_open(MAXBUFLEN); CONVERT *cv; char *ctags_x; if (argc < 3) die("global --path-convert: 3 arguments needed."); cv = convert_open(convert_type, FORMAT_CTAGS_X, argv[0], argv[1], argv[2], stdout, NOTAGS); while ((ctags_x = strbuf_fgets(ib, stdin, STRBUF_NOCRLF)) != NULL) convert_put(cv, ctags_x); convert_close(cv); strbuf_close(ib); exit(0); } /* * At first, we pickup pattern from -e option. If it is not found * then use argument which is not option. */ if (!av) { av = *argv; /* * global -g pattern [files ...] * av argv */ if (gflag && av) argv++; } if (single_update) { if (command == 0) { uflag++; command = 'u'; } else if (command != 'u') { ; /* ignored */ } } /* * only -c, -u, -P and -p allows no argument. */ if (!av) { switch (command) { case 'c': case 'u': case 'p': case 'P': break; case 'f': if (file_list) break; default: usage(); break; } } /* * -u and -p cannot have any arguments. */ if (av) { switch (command) { case 'u': case 'p': usage(); default: break; } } if (tflag) xflag = 0; if (nflag > 1) nosource = 1; /* to keep compatibility */ if (print0) set_print0(); if (cflag && match_part == 0) match_part = MATCH_PART_ALL; /* * remove leading blanks. */ if (!Iflag && !gflag && av) for (; *av == ' ' || *av == '\t'; av++) ; if (cflag && !Pflag && av && isregex(av)) die_with_code(2, "only name char is allowed with -c option."); /* * print dbpath or rootdir. */ if (pflag) { fprintf(stdout, "%s\n", (rflag) ? root : dbpath); exit(0); } /* * incremental update of tag files. */ if (uflag) { STRBUF *sb = strbuf_open(0); char *gtags_path = usable("gtags"); if (!gtags_path) die("gtags command not found."); if (chdir(root) < 0) die("cannot change directory to '%s'.", root); #if defined(_WIN32) && !defined(__CYGWIN__) /* * Get around CMD.EXE's weird quoting rules by sticking another * perceived whitespace in front (also works with Take Command). */ strbuf_putc(sb, ';'); #endif strbuf_puts(sb, quote_shell(gtags_path)); strbuf_puts(sb, " -i"); if (vflag) strbuf_puts(sb, " -v"); if (single_update) { if (!isabspath(single_update)) { static char regular_path_name[MAXPATHLEN]; if (rel2abs(single_update, cwd, regular_path_name, sizeof(regular_path_name)) == NULL) die("rel2abs failed."); single_update = regular_path_name; } strbuf_puts(sb, " --single-update "); strbuf_puts(sb, quote_shell(single_update)); } strbuf_putc(sb, ' '); strbuf_puts(sb, quote_shell(dbpath)); if (system(strbuf_value(sb))) exit(1); strbuf_close(sb); exit(0); } /* * decide tag type. */ if (context_file) { if (isregex(av)) die_with_code(2, "regular expression is not allowed with the --from-here option."); db = decide_tag_by_context(av, context_file, atoi(context_lineno)); } else { if (dflag) db = GTAGS; else if (rflag && sflag) db = GRTAGS + GSYMS; else db = (rflag) ? GRTAGS : ((sflag) ? GSYMS : GTAGS); } /* * complete function name */ if (cflag) { if (Iflag) completion_idutils(dbpath, root, av); else if (Pflag) completion_path(dbpath, av); else completion(dbpath, root, av, db); exit(0); } /* * make local prefix. * local prefix must starts with './' and ends with '/'. */ if (Sflag) { STRBUF *sb = strbuf_open(0); static char buf[MAXPATHLEN]; const char *path = scope; /* * normalize the path of scope directory. */ if (!test("d", path)) die("'%s' not found or not a directory.", scope); if (!isabspath(path)) path = makepath(cwd, path, NULL); if (realpath(path, buf) == NULL) die("cannot get real path of '%s'.", scope); if (!in_the_project(buf)) die("'%s' is out of the source project.", scope); scope = buf; /* * make local prefix. */ strbuf_putc(sb, '.'); if (strcmp(root, scope) != 0) { const char *p = scope + strlen(root); if (*p != '/') strbuf_putc(sb, '/'); strbuf_puts(sb, p); } strbuf_putc(sb, '/'); localprefix = check_strdup(strbuf_value(sb)); strbuf_close(sb); #ifdef DEBUG fprintf(stderr, "root=%s\n", root); fprintf(stderr, "cwd=%s\n", cwd); fprintf(stderr, "localprefix=%s\n", localprefix); #endif } /* * convert the file-list path into an absolute path. */ if (file_list && strcmp(file_list, "-") && !isabspath(file_list)) { static char buf[MAXPATHLEN]; if (realpath(file_list, buf) == NULL) die("'%s' not found.", file_list); file_list = buf; } /* * decide path conversion type. */ if (nofilter & PATH_FILTER) type = PATH_THROUGH; else if (aflag) type = PATH_ABSOLUTE; else type = PATH_RELATIVE; if (path_style) { if (!strcmp(path_style, "relative")) type = PATH_RELATIVE; else if (!strcmp(path_style, "absolute")) type = PATH_ABSOLUTE; else if (!strcmp(path_style, "through")) type = PATH_THROUGH; else if (!strcmp(path_style, "shorter")) type = PATH_SHORTER; else if (!strcmp(path_style, "abslib")) { type = PATH_RELATIVE; abslib++; } else die("invalid path style."); } /* * exec lid(idutils). */ if (Iflag) { chdir(root); idutils(av, dbpath); } /* * search pattern (regular expression). */ else if (gflag) { chdir(root); grep(av, argv, dbpath); } /* * locate paths including the pattern. */ else if (Pflag) { chdir(root); pathlist(av, dbpath); } /* * parse source files. */ else if (fflag) { chdir(root); parsefile(argv, cwd, root, dbpath, db); } /* * tag search. */ else { tagsearch(av, cwd, root, dbpath, db); } return 0; }