struct direct *readdir(DIR *dfd) { static struct direct *dentry; static char resultspec[MAXNAMLEN+1]; int i; if ((dentry = (struct direct *)xmalloc(sizeof (struct direct))) == NULL) { printf("Error mallocing for direct\n"); return(NULL); } dfd->fab$l_nam->nam$l_rsa = resultspec; dfd->fab$l_nam->nam$b_rss = MAXNAMLEN; if (debug_flag) printf("."); if (!((i = sys$search(dfd)) & 1)) { if (debug_flag) printf("sys$search failed with %d\n", i); free(dentry); return(NULL); } dentry->d_off = 0; if (dfd->fab$l_nam->nam$w_fid == 0) dentry->d_fileno = 1; else dentry->d_fileno = dfd->fab$l_nam->nam$w_fid[0] +dfd->fab$l_nam->nam$w_fid[1]<<16; dentry->d_reclen = sizeof (struct direct); /* if (!strcmp(dfd->fab$l_nam->nam$l_type,".DIR")) dentry->d_namlen = dfd->fab$l_nam->nam$b_name; else */ dentry->d_namlen = dfd->fab$l_nam->nam$b_name+dfd->fab$l_nam->nam$b_type; strncpy(dentry->d_name,dfd->fab$l_nam->nam$l_name,dentry->d_namlen); dentry->d_name[dentry->d_namlen] = '\0'; uppercasify(dentry->d_name); /* uvUnFixRCSSeparator(dentry->d_name);*/ return(dentry); }
struct direct * readdir (DIR *dir) { struct FAB *dfab = &dir->fab; struct NAM *dnam = (struct NAM *)(dfab->fab$l_nam); struct direct *dentry = &dir->dir; int i; memset (dentry, 0, sizeof *dentry); dnam->nam$l_rsa = dir->d_result; dnam->nam$b_rss = MAXNAMLEN; DB (DB_VERBOSE, (".")); if (!((i = sys$search (dfab)) & 1)) { DB (DB_VERBOSE, (_("sys$search() failed with %d\n"), i)); return (NULL); } dentry->d_off = 0; if (dnam->nam$w_fid == 0) dentry->d_fileno = 1; else dentry->d_fileno = dnam->nam$w_fid[0] + (dnam->nam$w_fid[1] << 16); dentry->d_reclen = sizeof (struct direct); dentry->d_namlen = dnam->nam$b_name + dnam->nam$b_type; strncpy (dentry->d_name, dnam->nam$l_name, dentry->d_namlen); dentry->d_name[dentry->d_namlen] = '\0'; #ifdef HAVE_CASE_INSENSITIVE_FS uppercasify (dentry->d_name); #endif return (dentry); }
static void init_maketex (kpathsea kpse, kpse_file_format_type fmt, const_string dflt_prog, ...) { kpse_format_info_type *f = &(kpse->format_info[fmt]); const_string prog = f->program ? f->program : dflt_prog; /* mktexpk */ string PROG = uppercasify (prog); /* MKTEXPK */ string progval = kpathsea_var_value (kpse, PROG); /* $ENV/cnf{"MKTEXPK"} */ const_string arg; va_list ap; /* Doesn't hurt to always set this info. */ f->program = prog; /* Set up the argument vector. */ f->argc = 0; f->argv = XTALLOC (2, const_string); f->argv[f->argc++] = dflt_prog; va_start (ap, dflt_prog); while ((arg = va_arg (ap, string)) != NULL) { f->argc++; f->argv = (const_string *) xrealloc ((void *) f->argv, (f->argc + 1) * sizeof(const_string)); f->argv[f->argc - 1] = arg; } va_end (ap); f->argv[f->argc] = NULL; if (progval && *progval) { /* This might actually be from an environment variable value, but in that case, we'll have previously set it from kpse_init_prog. */ kpathsea_set_program_enabled (kpse, fmt, *progval == '1', kpse_src_client_cnf); } free (PROG); }
int main (int argc, string *argv) { int getopt_return_val; int option_index = 0; name_program = xbasename(argv[0]); if (!strcmp(name_program, "ofm2opl") || !strcmp(name_program, "OFM2OPL.EXE")) { program = PROG_OFM2OPL; name_help = OFM2OPLHELP; name_program = "ofm2opl"; name_msg = "This is ofm2opl, Version 2.0"; no_files = 2; files[0] = &name_ofm; files[1] = &name_opl; suffixes[0] = "ofm"; suffixes[1] = "opl"; full_suffixes[0] = ".ofm"; full_suffixes[1] = ".opl"; } else if (!strcmp(name_program, "opl2ofm") || !strcmp(name_program, "OPL2OFM.EXE")) { program = PROG_OPL2OFM; name_help = OPL2OFMHELP; name_program = "opl2ofm"; name_msg = "This is opl2ofm, Version 2.0"; no_files = 2; files[0] = &name_opl; files[1] = &name_ofm; suffixes[0] = "opl"; suffixes[1] = "ofm"; full_suffixes[0] = ".opl"; full_suffixes[1] = ".ofm"; } else if (!strcmp(name_program, "ovp2ovf") || !strcmp(name_program, "OVP2OVF.EXE")) { program = PROG_OVP2OVF; name_help = OVP2OVFHELP; name_program = "ovp2ovf"; name_msg = "This is ovp2ovf, Version 2.0"; no_files = 3; files[0] = &name_ovp; files[1] = &name_ovf; files[2] = &name_ofm; suffixes[0] = "ovp"; suffixes[1] = "ovf"; suffixes[2] = "ofm"; full_suffixes[0] = ".ovp"; full_suffixes[1] = ".ovf"; full_suffixes[2] = ".ofm"; } else if (!strcmp(name_program, "ovf2ovp") || !strcmp(name_program, "OVF2OVP.EXE")) { program = PROG_OVF2OVP; name_help = OVF2OVPHELP; name_program = "ovf2ovp"; name_msg = "This is ovf2ovp, Version 2.0"; no_files = 3; files[0] = &name_ovf; files[1] = &name_ofm; files[2] = &name_ovp; suffixes[0] = "ovf"; suffixes[1] = "ofm"; suffixes[2] = "ovp"; full_suffixes[0] = ".ovf"; full_suffixes[1] = ".ofm"; full_suffixes[2] = ".ovp"; } else { fprintf(stderr , "Unrecognized program: %s\n", name_program); fprintf(stderr , "This binary supports ofm2opl, opl2ofm, ovf2ovp, and ovp2ovf\n"); exit(1); } kpse_set_program_name(name_program, NULL); kpse_init_prog(uppercasify(name_program), 0, nil, nil); do { getopt_return_val = getopt_long_only(argc, argv, "", long_options, &option_index) ; if (getopt_return_val == -1) { ; } else if ( getopt_return_val == 63 ) { usage (name_program); } else if (!strcmp(long_options[option_index].name, "help")) { usagehelp (name_help, NULL); } else if (!strcmp(long_options[option_index ].name, "version")) { printversionandexit(name_msg, nil, "J. Plaice, Y. Haralambous, D.E. Knuth", nil); } else if (!strcmp(long_options[option_index ].name, "char-format")) { if (!strcmp(optarg, "ascii")) char_format = CHAR_CODE_ASCII; else if (!strcmp(optarg, "num")) char_format = CHAR_CODE_NUM; else warning_s("Bad character code format (%s)", optarg); } else if (!strcmp(long_options[option_index ].name, "num-format")) { if (!strcmp(optarg, "hex")) num_format = NUM_CODE_HEX; else if (!strcmp(optarg, "octal")) num_format = NUM_CODE_OCTAL; else warning_s("Bad number code format (%s)", optarg); } else if (!strcmp(long_options[option_index ].name, "text-format")) { if (!strcmp(optarg, "upper")) text_format = TEXT_CODE_UPPER; else if (!strcmp(optarg, "mixed")) text_format = TEXT_CODE_MIXED; else warning_s("Bad text code format (%s)", optarg); } } while (getopt_return_val != -1); if (((argc-optind) > no_files) || ((argc-optind) < 1)) { fprintf(stderr , "%s: %s\n", name_program, no_files == 2 ? "Need one or two file arguments." : "Need one to three file arguments."); usage (name_program); } *(files[0]) = extend_filename(cmdline(optind) , suffixes[0]); if (optind+2 <= argc) { *(files[1]) = extend_filename(cmdline(optind+1) , suffixes[1]); if (no_files == 3) { if (optind+3 <= argc) { *(files[2]) = extend_filename(cmdline(optind+2) , suffixes[2]); } else if (program == PROG_OVP2OVF) { *(files[2]) = extend_filename(cmdline(optind+1), suffixes[2]); } } } else if (program != PROG_OFM2OPL) { *(files[1]) = basenamechangesuffix(*(files[0]), full_suffixes[0], full_suffixes[1]); if ((no_files == 3) && (program == PROG_OVP2OVF)) { *(files[2]) = basenamechangesuffix(*(files[0]), full_suffixes[0], full_suffixes[2]); } } switch(program) { case PROG_OFM2OPL: { file_ofm = kpse_open_file(name_ofm, kpse_ofm_format); read_in_whole(&ofm, &length_ofm, file_ofm, name_ofm); (void)fclose(file_ofm); if (name_opl==NULL) file_opl = stdout; else rewrite(file_opl, name_opl); file_output = file_opl; parse_ofm(FALSE); break; } case PROG_OVF2OVP: { file_ovf = kpse_open_file(name_ovf, kpse_ovf_format); read_in_whole(&ovf, &length_ovf, file_ovf, name_ovf); (void)fclose(file_ovf); file_ofm = kpse_open_file(name_ofm, kpse_ofm_format); read_in_whole(&ofm, &length_ofm, file_ofm, name_ofm); (void)fclose(file_ofm); if (name_ovp==NULL) file_ovp = stdout; else rewrite(file_ovp, name_ovp); file_output = file_ovp; parse_ofm(TRUE); break; } case PROG_OPL2OFM: { file_opl = kpse_open_file(name_opl, kpse_opl_format); rewritebin(file_ofm, name_ofm); init_tables(); yyin = file_opl; (void)yyparse(); output_ofm_file(); (void)fclose(file_ofm); break; } case PROG_OVP2OVF: { file_ovp = kpse_open_file(name_ovp, kpse_ovp_format); rewritebin(file_ovf, name_ovf); rewritebin(file_ofm, name_ofm); init_tables(); yyin = file_ovp; (void)yyparse(); output_ofm_file(); /*(void)fclose(file_ofm);*/ output_ovf_file(); (void)fclose(file_ovf); break; } default: {exit(1);} } exit(0); }