/* **++ ** ROUTINE: main ** ** FUNCTIONAL DESCRIPTION: ** ** Main program. Fetches the command from the command line, ** uses CLI$ routines to parse it, then starts the build process. ** ** RETURNS: cond_value, longword (unsigned), write only, by value ** ** PROTOTYPE: ** ** main ** ** IMPLICIT INPUTS: See global definitions at module head. ** ** IMPLICIT OUTPUTS: See global definitions at module head. ** ** COMPLETION CODES: ** ** SS$_NORMAL, MMK__ALLOK : normal successful completion. ** ** SIDE EFFECTS: None. ** **-- */ unsigned int main (void) { DESCRIP cmdstr; char Output_File[256], tmp[256]; $DESCRIPTOR(cmdname, "MMKC "); unsigned int status; int i; /* ** Initialize the globals */ temporary_symbols = 0; for (i = 0; i < MMK_K_SYMTABLE_SIZE; i++) { INIT_QUEUE(global_symbols.symlist[i]); INIT_QUEUE(local_symbols.symlist[i]); INIT_QUEUE(cmdline_symbols.symlist[i]); INIT_QUEUE(builtin_symbols.symlist[i]); } INIT_QUEUE(rules); INIT_QUEUE(dependencies); INIT_QUEUE(dep_internal); INIT_QUEUE(dep_deferred); INIT_QUEUE(suffixes); INIT_QUEUE(do_first); INIT_QUEUE(do_last); exit_status = SS$_NORMAL; ignore = override_silent = override_ignore = symbol_override = 0; skip_intermediates = 0; /* ** Fetch and parse command string */ INIT_DYNDESC(cmdstr); status = lib$get_foreign(&cmdstr); str$prefix(&cmdstr, &cmdname); status = cli$dcl_parse(&cmdstr, MMK_COMPILE_RULES_CLD, lib$get_input, lib$get_input); if (!OK(status)) return (status | STS$M_INHIB_MSG); /* ** Get the command parameters and qualifiers */ Output_File[0] = '\0'; if (cli_present("OUTPUT") == CLI$_PRESENT) { cli_get_value("OUTPUT", Output_File, sizeof(Output_File)); } status = cli_get_value("RULES_FILE", tmp, sizeof(tmp)); if (!OK(status)) return status | STS$M_INHIB_MSG; Read_Description(tmp, "SYS$DISK:[].MMS", 1); if (OK(exit_status)) Generate_Structures(tmp, Output_File); return exit_status | STS$M_INHIB_MSG; }
main() { int retlen=0; $DESCRIPTOR(p, "p1"); char c[80]; struct dsc$descriptor o; o.dsc$a_pointer=c; o.dsc$w_length=80; memset (c, 0, 80); int sts = cli$present(&p); if (sts&1) { sts = lib$get_foreign(&o, 0, &retlen, 0); o.dsc$w_length=retlen; char * ostr = strchr(o.dsc$a_pointer, ' '); int olen = ostr - (char *)o.dsc$a_pointer; if (0==strncasecmp(o.dsc$a_pointer, "install", olen)) { memset(o.dsc$a_pointer, 32, olen); } o.dsc$a_pointer+=olen+1; o.dsc$w_length-=olen+1; printf("o is %s\n",o.dsc$a_pointer); fflush(stdout); int sts = cli$dcl_parse(&o, &sysman_parse, 0, 0, 0); if (sts&1) cli$dispatch(0); return 1; } while(!do_ret) { printf("SYSMAN> "); fflush(stdout); char command_str[256]; int len = read (0, command_str, 255); struct dsc$descriptor command_line; command_line.dsc$a_pointer = command_str; command_line.dsc$w_length = len; extern int hexmode; hexmode = 1; // temp workaround int sts = cli$dcl_parse(&command_line, sysman_parse, 0, 0, 0); hexmode = 0; if (sts&1) cli$dispatch(0); } }
license_adm() { int cli$dispatch() ; int4 stat0 ; int4 stat1 ; int4 fl= 0 ; char *ln[2]= { LADB,LAFILE } ; char buf[256] ; unsigned short len ; bool rep; $DESCRIPTOR (prompt,"LMA> ") ; $DESCRIPTOR (dbuf,buf) ; stat0= lib$get_foreign(&dbuf,0,&len,&fl); rep = (len==0); do { stat1= cli$dcl_parse(&dbuf,&la_cmnd,&lib$get_input,&lib$get_input,&prompt); if (stat1==CLI$_NORMAL) stat0= cli$dispatch(ln); if (stat0!=RMS$_EOF && rep) stat0= lib$get_foreign(&dbuf,&prompt,&len,&fl); } while (stat0!=RMS$_EOF && rep); return SS$_NORMAL; }
void list_cmd(void) { unsigned short cmd_len; unsigned char cmd_line[256]; static readonly unsigned char command_line[] = "COMMAND LINE"; static readonly unsigned char command_line_under[] = "-----------------"; $DESCRIPTOR(d_cmd,cmd_line); if (lib$get_foreign(&d_cmd, 0, &cmd_len) == SS$_NORMAL) { list_line(command_line); list_line(command_line_under); cmd_line[cmd_len]='\0'; list_line(cmd_line); } }
void lke(void) { char buff[MAX_LINE]; $DESCRIPTOR (command, buff); uint4 status; short len; bool dcl; DCL_THREADGBL_ACCESS; GTM_THREADGBL_INIT; gtm_imagetype_init(LKE_IMAGE); gtm_env_init(); /* read in all environment variables */ util_out_open(0); SET_EXIT_HANDLER(exi_blk, generic_exit_handler, exi_condition); /* Establish exit handler */ ESTABLISH(util_base_ch); status =lp_id(&lkid); if (SS$_NORMAL != status) rts_error(VARLSTCNT(1) status); get_page_size(); stp_init(STP_INITSIZE); rts_stringpool = stringpool; getjobname(); INVOKE_INIT_SECSHR_ADDRS; ast_init(); initialize_pattern_table(); gvinit(); region_init(TRUE); getjobnum(); status = lib$get_foreign(&command, 0, &len, 0); if ((status & 1) && len > 0) { command.dsc$w_length = len; status = CLI$DCL_PARSE(&command, &lke_cmd, &lib$get_input, 0, 0); if (CLI$_NORMAL == status) { util_out_open(&output_qualifier); CLI$DISPATCH(); util_out_close(); } lke_exit(); } for (;;) lke_process(); }
cce() { $DESCRIPTOR(prompt,"CCE> "); int status; char buff[512]; $DESCRIPTOR(command,buff); unsigned short outlen; mstr lnm$group = {9, "LNM$GROUP"}; int CCE_CMD(), CLI$DCL_PARSE(), CLI$DISPATCH(); DCL_THREADGBL_ACCESS; GTM_THREADGBL_INIT; /* This is the first C routine in the cce so do init here */ gtm_env_init(); /* read in all environment variables before any function call (particularly malloc) */ getjobnum(); get_page_size(); dfntmpmbx (lnm$group.len, lnm$group.addr); status = lib$get_foreign(&command,0,&outlen,0); if ((status & 1) && outlen > 0) { command.dsc$w_length = outlen; status = CLI$DCL_PARSE(&command ,&CCE_CMD, &lib$get_input, 0, 0); if (status == CLI$_NORMAL) CLI$DISPATCH(); } else { while (!cce_done) { status = CLI$DCL_PARSE(0 ,&CCE_CMD, &lib$get_input , &lib$get_input, &prompt); if (status == RMS$_EOF) cce_done = TRUE; else if (status == CLI$_NORMAL) { ret_status = 1; CLI$DISPATCH(); } } } return ret_status; }
/* ** Re-read the command line and convert it from VMS style to unix style. ** Replaces argv and argc with Unix-correct versions. This is ** a poor solution to parsing VMS command lines because some information ** is lost and some elements of the syntax are not checked. Users also ** can't abbreviate qualifiers as is customary under VMS. */ void ConvertVMSCommandLine(int *argc, char **argv[]) { int i; short cmdLineLen; char *c, cmdLine[MAX_CMD_LENGTH], *oldArg0; struct dsc$descriptor_s *cmdLineDesc; /* get the command line (don't use the old argv and argc because VMS has removed the quotes and altered the line somewhat */ cmdLineDesc = NulStrWrtDesc(cmdLine, MAX_CMD_LENGTH); lib$get_foreign(cmdLineDesc, 0, &cmdLineLen, 0); FreeStrDesc(cmdLineDesc); /* begin a new argv and argc, but preserve the original argv[0] which is not returned by lib$get_foreign */ oldArg0 = (*argv)[0]; *argv = (char **)malloc(sizeof(char *) * MAX_ARGS); (*argv)[0] = oldArg0; *argc = 1; /* scan all of the text on the command line, reconstructing the arg list */ for (i=0, c=cmdLine; i<cmdLineLen; c++, i++) { if (*c == '\t') { addArgChar(argc, *argv, ' '); } else if (*c == '/') { addArgChar(argc, *argv, ' '); addArgChar(argc, *argv, '-'); } else if (*c == '=') { addArgChar(argc, *argv, ' '); } else if (*c == ',') { addArgChar(argc, *argv, ' '); } else { addArgChar(argc, *argv, *c); } } addArgChar(argc, *argv, ' '); }
unsigned long vms_zip_cmdline (int *argc_p, char ***argv_p) { /* ** Routine: vms_zip_cmdline ** ** Function: ** ** Parse the DCL command line and create a fake argv array to be ** handed off to Zip. ** ** NOTE: the argv[] is built as we go, so all the parameters are ** checked in the appropriate order!! ** ** Formal parameters: ** ** argc_p - Address of int to receive the new argc ** argv_p - Address of char ** to receive the argv address ** ** Calling sequence: ** ** status = vms_zip_cmdline (&argc, &argv); ** ** Returns: ** ** SS$_NORMAL - Success. ** SS$_INSFMEM - A malloc() or realloc() failed ** SS$_ABORT - Bad time value ** */ register unsigned long status; char options[48]; char *the_cmd_line; /* buffer for argv strings */ unsigned long cmdl_size; /* allocated size of buffer */ unsigned long cmdl_len; /* used size of buffer */ char *ptr; int x, len; int new_argc; char **new_argv; struct dsc$descriptor_d work_str; struct dsc$descriptor_d foreign_cmdline; init_dyndesc(work_str); init_dyndesc(foreign_cmdline); /* ** See if the program was invoked by the CLI (SET COMMAND) or by ** a foreign command definition. Check for /YYZ_ZIP, which is a ** valid default qualifier solely for this test. */ show_VMSCLI_help = TRUE; status = check_cli(&cli_yyz); if (!(status & 1)) { lib$get_foreign(&foreign_cmdline); /* ** If nothing was returned or the first character is a "-", then ** assume it's a UNIX-style command and return. */ if (foreign_cmdline.dsc$w_length == 0) return (SS$_NORMAL); if ((*(foreign_cmdline.dsc$a_pointer) == '-') || ((foreign_cmdline.dsc$w_length > 1) && (*(foreign_cmdline.dsc$a_pointer) == '"') && (*(foreign_cmdline.dsc$a_pointer + 1) == '-'))) { show_VMSCLI_help = FALSE; return (SS$_NORMAL); } str$concat(&work_str, &zip_command, &foreign_cmdline); status = cli$dcl_parse(&work_str, &zip_clitable, lib$get_input, lib$get_input, 0); if (!(status & 1)) return (status); } /* ** There's always going to be a new_argv[] because of the image name. */ if ((the_cmd_line = (char *) malloc(cmdl_size = ARGBSIZE_UNIT)) == NULL) return (SS$_INSFMEM); strcpy(the_cmd_line, "zip"); cmdl_len = sizeof("zip"); /* ** First, check to see if any of the regular options were specified. */ options[0] = '-'; ptr = &options[1]; /* Point to temporary buffer */ /* ** Delete the specified files from the zip file? */ status = cli$present(&cli_delete); if (status & 1) *ptr++ = 'd'; /* ** Freshen (only changed files). */ status = cli$present(&cli_freshen); if (status & 1) *ptr++ = 'f'; /* ** Delete the files once they've been added to the zip file. */ status = cli$present(&cli_move); if (status & 1) *ptr++ = 'm'; /* ** Add changed and new files. */ status = cli$present(&cli_update); if (status & 1) *ptr++ = 'u'; /* ** Check for the compression level (-0 through -9). */ status = cli$present(&cli_level); if (status & 1) { unsigned long binval; status = cli$get_value(&cli_level, &work_str); status = ots$cvt_tu_l(&work_str, &binval); if (!(status & 1) || (binval > 9)) { return (SS$_ABORT); } *ptr++ = binval + '0'; } /* ** Adjust offsets of zip archive entries. */ status = cli$present(&cli_adjust); if (status & 1) *ptr++ = 'A'; /* ** Add comments? */ status = cli$present(&cli_comments); if (status & 1) { /* while ((status = cli$get_value(&cli_comments, &work_str)) & 1) { if (strncmp(work_str.dsc$a_pointer,"ZIP",3) == 0) *ptr++ = 'z'; if (strncmp(work_str.dsc$a_pointer,"FIL",3) == 0) *ptr++ = 'c'; } */ if ((status = cli$present(&cli_comment_zipfile)) & 1) *ptr++ = 'z'; if ((status = cli$present(&cli_comment_files)) & 1) *ptr++ = 'c'; } /* ** Do not add/modify directory entries. */ status = cli$present(&cli_dirnames); if (!(status & 1)) *ptr++ = 'D'; /* ** Encrypt? */ status = cli$present(&cli_encrypt); if (status & 1) if ((status = cli$get_value(&cli_encrypt, &work_str)) & 1) { x = cmdl_len; cmdl_len += work_str.dsc$w_length + 4; CHECK_BUFFER_ALLOCATION(the_cmd_line, cmdl_size, cmdl_len) strcpy(&the_cmd_line[x], "-P"); strncpy(&the_cmd_line[x+3], work_str.dsc$a_pointer, work_str.dsc$w_length); the_cmd_line[cmdl_len-1] = '\0'; } else { *ptr++ = 'e'; } /* ** Fix the zip archive structure. */ status = cli$present(&cli_fix_archive); if (status & 1) { *ptr++ = 'F'; if ((status = cli$present(&cli_fix_full)) & 1) { *ptr++ = 'F'; } } /* ** Append (allow growing of existing zip file). */ status = cli$present(&cli_append); if (status & 1) *ptr++ = 'g'; /* ** Show the help. */ status = cli$present(&cli_help); if (status & 1) *ptr++ = 'h'; /* ** Junk path names (directory specs). */ status = cli$present(&cli_junk); if (status & 1) *ptr++ = 'j'; /* ** Simulate zip file made by PKZIP. */ status = cli$present(&cli_pkzip); if (status & 1) *ptr++ = 'k'; /* ** Translate end-of-line. */ status = cli$present(&cli_translate_eol); if (status & 1) { *ptr++ = 'l'; if ((status = cli$present(&cli_transl_eol_crlf)) & 1) { *ptr++ = 'l'; } } /* ** Show the software license. */ status = cli$present(&cli_license); if (status & 1) *ptr++ = 'L'; /* ** Set zip file time to time of latest file in it. */ status = cli$present(&cli_latest); if (status & 1) *ptr++ = 'o'; /* ** Store full path (default). */ status = cli$present(&cli_full_path); if (status == CLI$_PRESENT) *ptr++ = 'p'; else if (status == CLI$_NEGATED) *ptr++ = 'j'; /* ** Junk Zipfile prefix (SFX stub etc.). */ status = cli$present(&cli_unsfx); if (status & 1) *ptr++ = 'J'; /* ** Recurse through subdirectories. */ status = cli$present(&cli_recurse); if (status & 1) { if ((status = cli$present(&cli_recurse_fnames)) & 1) *ptr++ = 'R'; else *ptr++ = 'r'; } /* ** Be verbose. */ status = cli$present(&cli_verbose); if (status & 1) { int i; int verbo = 0; /* /VERBOSE */ if ((status = cli$present(&cli_verbose_command)) & 1) { /* /VERBOSE = COMMAND */ verbose_command = 1; } /* Note that any or all of the following options may be specified, and the maximum one is used. */ if ((status = cli$present(&cli_verbose_normal)) & 1) /* /VERBOSE [ = NORMAL ] */ verbo = 1; if ((status = cli$present(&cli_verbose_more)) & 1) /* /VERBOSE = MORE */ verbo = 2; if ((status = cli$present(&cli_verbose_debug)) & 1) { /* /VERBOSE = DEBUG */ verbo = 3; } for (i = 0; i < verbo; i++) *ptr++ = 'v'; } /* ** Quiet mode. ** (Quiet mode is processed after verbose, because a "-v" modifier ** resets "noisy" to 1.) */ status = cli$present(&cli_quiet); if (status & 1) *ptr++ = 'q'; /* ** Suppress creation of any extra field. */ status = cli$present(&cli_extra_fields); if (!(status & 1)) *ptr++ = 'X'; /* ** Save the VMS file attributes (and all allocated blocks?). */ status = cli$present(&cli_vms); if (status & 1) { /* /VMS */ *ptr++ = 'V'; if ((status = cli$present(&cli_vms_all)) & 1) { /* /VMS = ALL */ *ptr++ = 'V'; } } /* ** Keep the VMS version number as part of the file name when stored. */ status = cli$present(&cli_keep_version); if (status & 1) *ptr++ = 'w'; /* ** `Batch' processing: read filenames to archive from stdin ** or the specified file. */ status = cli$present(&cli_batch); if (status & 1) { status = cli$get_value(&cli_batch, &work_str); if (status & 1) { work_str.dsc$a_pointer[work_str.dsc$w_length] = '\0'; if ((stdin = freopen(work_str.dsc$a_pointer, "r", stdin)) == NULL) { sprintf(errbuf, "could not open list file: %s", work_str.dsc$a_pointer); ziperr(ZE_PARMS, errbuf); } } *ptr++ = '@'; } /* ** Now copy the final options string to the_cmd_line. */ len = ptr - &options[0]; if (len > 1) { options[len] = '\0'; x = cmdl_len; cmdl_len += len + 1; CHECK_BUFFER_ALLOCATION(the_cmd_line, cmdl_size, cmdl_len) strcpy(&the_cmd_line[x], options); } /* ** ** OK. We've done all the regular options, so check for -b (temporary ** file path), -t (exclude before time), -n (special suffixes), zipfile, ** files to zip, and exclude list. ** */ status = cli$present(&cli_temp_path); if (status & 1) { status = cli$get_value(&cli_temp_path, &work_str); x = cmdl_len; cmdl_len += work_str.dsc$w_length + 4; CHECK_BUFFER_ALLOCATION(the_cmd_line, cmdl_size, cmdl_len) strcpy(&the_cmd_line[x], "-b"); strncpy(&the_cmd_line[x+3], work_str.dsc$a_pointer, work_str.dsc$w_length); the_cmd_line[cmdl_len-1] = '\0'; } /* ** Demand that all input files exist (and wildcards match something). */ #define OPT_MM "-MM" /* Input file specs must exist. */ status = cli$present(&cli_must_match); if (status & 1) { x = cmdl_len; cmdl_len += strlen( OPT_MM)+ 1; CHECK_BUFFER_ALLOCATION(the_cmd_line, cmdl_size, cmdl_len) strcpy( &the_cmd_line[ x], OPT_MM); } /* ** Handle "-t mmddyyyy". */ status = cli$present(&cli_since); if (status & 1) { char since_time[9]; status = get_time(&cli_since, &since_time[0]); if (!(status & 1)) return (status); /* ** Now let's add the option "-t mmddyyyy" to the new command line. */ x = cmdl_len; cmdl_len += (3 + 9); CHECK_BUFFER_ALLOCATION(the_cmd_line, cmdl_size, cmdl_len) strcpy(&the_cmd_line[x], "-t"); strcpy(&the_cmd_line[x+3], since_time); } /* ** Handle "-tt mmddyyyy". */ status = cli$present(&cli_before); if (status & 1) { char before_time[9]; status = get_time(&cli_before, &before_time[0]); if (!(status & 1)) return (status); /* ** Now let's add the option "-tt mmddyyyy" to the new command line. */ x = cmdl_len; cmdl_len += (4 + 9); CHECK_BUFFER_ALLOCATION(the_cmd_line, cmdl_size, cmdl_len) strcpy(&the_cmd_line[x], "-tt"); strcpy(&the_cmd_line[x+4], before_time); } /* ** Handle "-n suffix:suffix:...". (File types to store only.) */ status = cli$present(&cli_store_types); if (status & 1) { x = cmdl_len; cmdl_len += 3; CHECK_BUFFER_ALLOCATION(the_cmd_line, cmdl_size, cmdl_len) strcpy(&the_cmd_line[x], "-n"); status = get_list(&cli_store_types, &foreign_cmdline, ':', &the_cmd_line, &cmdl_size, &cmdl_len); if (!(status & 1)) return (status); } /* ** Now get the specified zip file name. */ status = cli$present(&cli_zipfile); if (status & 1) { status = cli$get_value(&cli_zipfile, &work_str); x = cmdl_len; cmdl_len += work_str.dsc$w_length + 1; CHECK_BUFFER_ALLOCATION(the_cmd_line, cmdl_size, cmdl_len) strncpy(&the_cmd_line[x], work_str.dsc$a_pointer, work_str.dsc$w_length); the_cmd_line[cmdl_len-1] = '\0'; } /* ** Run through the list of input files. */ status = cli$present(&cli_infile); if (status & 1) { status = get_list(&cli_infile, &foreign_cmdline, '\0', &the_cmd_line, &cmdl_size, &cmdl_len); if (!(status & 1)) return (status); } /* ** List file containing exclude patterns present? ("*****@*****.**") */ status = cli$present(&cli_exlist); if (status & 1) { status = cli$get_value(&cli_exlist, &work_str); x = cmdl_len; cmdl_len += work_str.dsc$w_length + 4; CHECK_BUFFER_ALLOCATION(the_cmd_line, cmdl_size, cmdl_len) strncpy(&the_cmd_line[x], "-x@", 3); strncpy(&the_cmd_line[x+3], work_str.dsc$a_pointer, work_str.dsc$w_length); the_cmd_line[cmdl_len-1] = '\0'; } /* ** Any files to exclude? ("-x file file") */ status = cli$present(&cli_exclude); if (status & 1) { x = cmdl_len; cmdl_len += 3; CHECK_BUFFER_ALLOCATION(the_cmd_line, cmdl_size, cmdl_len) strcpy(&the_cmd_line[x], "-x"); status = get_list(&cli_exclude, &foreign_cmdline, '\0', &the_cmd_line, &cmdl_size, &cmdl_len); if (!(status & 1)) return (status); } /* ** List file containing include patterns present? ("*****@*****.**") */ status = cli$present(&cli_inlist); if (status & 1) { status = cli$get_value(&cli_inlist, &work_str); x = cmdl_len; cmdl_len += work_str.dsc$w_length + 4; CHECK_BUFFER_ALLOCATION(the_cmd_line, cmdl_size, cmdl_len) strncpy(&the_cmd_line[x], "-i@", 3); strncpy(&the_cmd_line[x+3], work_str.dsc$a_pointer, work_str.dsc$w_length); the_cmd_line[cmdl_len-1] = '\0'; } /* ** Any files to include? ("-i file file") */ status = cli$present(&cli_include); if (status & 1) { x = cmdl_len; cmdl_len += 3; CHECK_BUFFER_ALLOCATION(the_cmd_line, cmdl_size, cmdl_len) strcpy(&the_cmd_line[x], "-i"); status = get_list(&cli_exclude, &foreign_cmdline, '\0', &the_cmd_line, &cmdl_size, &cmdl_len); if (!(status & 1)) return (status); } /* ** We have finished collecting the strings for the argv vector, ** release unused space. */ if ((the_cmd_line = (char *) realloc(the_cmd_line, cmdl_len)) == NULL) return (SS$_INSFMEM); /* ** Now that we've built our new UNIX-like command line, count the ** number of args and build an argv array. */ for (new_argc = 0, x = 0; x < cmdl_len; x++) if (the_cmd_line[x] == '\0') new_argc++; /* ** Allocate memory for the new argv[]. The last element of argv[] ** is supposed to be NULL, so allocate enough for new_argc+1. */ if ((new_argv = (char **) calloc(new_argc+1, sizeof(char *))) == NULL) return (SS$_INSFMEM); /* ** For each option, store the address in new_argv[] and convert the ** separating blanks to nulls so each argv[] string is terminated. */ for (ptr = the_cmd_line, x = 0; x < new_argc; x++) { new_argv[x] = ptr; ptr += strlen(ptr) + 1; } new_argv[new_argc] = NULL; #if defined(TEST) || defined(DEBUG) printf("new_argc = %d\n", new_argc); for (x = 0; x < new_argc; x++) printf("new_argv[%d] = %s\n", x, new_argv[x]); #endif /* TEST || DEBUG */ /* Show the complete UNIX command line, if requested. */ if (verbose_command != 0) { printf( " UNIX command line args (argc = %d):\n", new_argc); for (x = 0; x < new_argc; x++) printf( "%s\n", new_argv[ x]); printf( "\n"); } /* ** All finished. Return the new argc and argv[] addresses to Zip. */ *argc_p = new_argc; *argv_p = new_argv; return (SS$_NORMAL); }
main(int argc, char *argv[]) /* MAIN Purpose : 1 Get privilege mask 2 Setup SMG environment unless no VT or DFU$NOSMG is set 3 Get and Parse command (syntax only) 4 Dispatch to correct subroutine Inputs : Command line (if specified through foreign command) Outputs : returns last status code to DCL in case of single command processing. In interactive mode always returns SS$_NORMAL. */ { const rms_eof=98938,smg$_eof=1213442; struct { short status, count; int extra ; } iosb; static char command_line[255], *e; unsigned int out_len,ret_len,prvmask; void reset_ctrl(), clean_ctrlc(), prev_screen(), next_screen(), dump_screen(), toggle_width() ; int smg_flag, x, y, i, ttype; int cursor_on = SMG$M_CURSOR_ON; $DESCRIPTOR(input_line , command_line); $DESCRIPTOR(prompt,"DFU> "); $DESCRIPTOR(terminal,"SYS$COMMAND"); $DESCRIPTOR(top_txt,"< DFU V2.2 (Freeware) >"); $DESCRIPTOR(status_txt,"Statistics"); $DESCRIPTOR(do_key,"DO"); $DESCRIPTOR(pf2,"PF2"); $DESCRIPTOR(pf4,"PF4"); $DESCRIPTOR(prev,"PREV_SCREEN"); $DESCRIPTOR(next,"NEXT_SCREEN"); $DESCRIPTOR(select,"SELECT"); $DESCRIPTOR(help,"HELP"); /* First find out how we got called ( by RUN, or a foreign command */ ret_len = 0; #if 0 status = lib$get_foreign(&input_line,0,&ret_len,0); #else status = 1; #if 0 strcpy(command_line,argv[1]); #endif #endif out_len = ret_len; smg$enable = TRUE; key_tab = 0; disp2_id = 0; cip = 0; setvbuf(stdout, NULL, _IONBF, 0); // need this to see i/o at all #if 0 smg$enable = FALSE; vms_mm = check_vms_mm(); #else /* Now create the SMG environment */ colls=80; rows=24; SMG$CREATE_PASTEBOARD(&paste_id, 0, &rows, &colls,&SMG$M_KEEP_CONTENTS,&ttype,0); if ((e = (char *) getenv("DFU$NOSMG")) && *e) smg$enable = FALSE; else { if (ttype != SMG$K_VTTERMTABLE) smg$enable = FALSE; if (ttype != SMG$K_VTTERMTABLE) SMG$DELETE_PASTEBOARD(&paste_id,&i0); } SMG$CREATE_VIRTUAL_KEYBOARD(&keyb_id,0,0,0,0); if (smg$enable) /* Setup key table */ { SMG$ERASE_PASTEBOARD(&paste_id, 0, 0, 0, 0, 0, 0); SMG$CREATE_KEY_TABLE(&key_tab); colls -=2; orig_colls = colls; smg_flag = SMG$M_KEY_NOECHO + SMG$M_KEY_TERMINATE; SMG$ADD_KEY_DEF(&key_tab,&do_key,0, &smg_flag, &do_key,0); SMG$ADD_KEY_DEF(&key_tab,&pf4,0, &smg_flag,&pf4,0); SMG$ADD_KEY_DEF(&key_tab,&prev,0, &smg_flag, &prev,0); SMG$ADD_KEY_DEF(&key_tab,&next,0, &smg_flag, &next,0); SMG$ADD_KEY_DEF(&key_tab,&pf2,0, &smg_flag, &help,0); SMG$ADD_KEY_DEF(&key_tab,&help,0, &smg_flag, &help,0); SMG$ADD_KEY_DEF(&key_tab,&select,0, &smg_flag, &select,0); SMG$CREATE_VIRTUAL_DISPLAY(&i500, &colls , &disp1_id, &SMG$M_BORDER, 0, 0); x = 508 - rows; y = rows - 7; SMG$CREATE_VIEWPORT(&disp1_id,&x,&i1,&y,&colls); SMG$CREATE_VIRTUAL_DISPLAY(&i2, &colls, &status_id, 0 , 0, 0); SMG$CREATE_VIRTUAL_DISPLAY(&i2, &colls, &disp2_id, 0 , 0, 0); SMG$SET_BROADCAST_TRAPPING(&paste_id,brdcst_ast,0); SMG$LABEL_BORDER(&disp1_id, &top_txt, 0, 0,&SMG$M_BOLD, 0, 0); SMG$LABEL_BORDER(&status_id, &status_txt, 0, 0,&SMG$M_BOLD, 0, 0); SMG$PASTE_VIRTUAL_DISPLAY(&disp1_id, &paste_id, &i2,&i2,0); x = rows - 4; SMG$PASTE_VIRTUAL_DISPLAY(&status_id, &paste_id, &x,&i2,0); x = rows - 1; SMG$PASTE_VIRTUAL_DISPLAY(&disp2_id, &paste_id, &x,&i2,0); x = 508 - rows; SMG$SET_CURSOR_ABS(&disp1_id,&x,&i1); SMG$SET_CURSOR_ABS(&disp2_id,&i1,&i1); SMG$BEGIN_PASTEBOARD_UPDATE(&paste_id); } #endif sprintf(outbuf,"\n Disk and File Utilities for OpenVMS DFU V2.2"); put_disp(); sprintf(outbuf," Freeware version"); put_disp(); sprintf(outbuf," Copyright © 1995 Digital Equipment Corporation\n"); put_disp(); if (smg$enable) { /* Enter additional info */ sprintf(outbuf," DFU functions are : \n"); put_disp(); sprintf(outbuf," DEFRAGMENT : Defragment files"); put_disp(); sprintf(outbuf," DELETE : Delete files by File-ID; delete directory (trees)"); put_disp(); sprintf(outbuf," DIRECTORY : Manipulate directories"); put_disp(); sprintf(outbuf," REPORT : Generate a complete disk report"); put_disp(); sprintf(outbuf," SEARCH : Fast file search"); put_disp(); sprintf(outbuf," SET : Modify file attributes"); put_disp(); sprintf(outbuf," UNDELETE : Recover deleted files"); put_disp(); sprintf(outbuf," VERIFY : Check and repair disk structure"); put_disp(); SMG$END_PASTEBOARD_UPDATE(&paste_id); } prvmask = 0; status = dfu_check_access(&prvmask); /*Get the privilege mask */ /* Setup terminal channel for control purposes; get the terminal chars */ status = SYS$ASSIGN(&terminal, &tchan, 0,0); status = SYS$QIOW(0,tchan, IO$_SENSEMODE,0,0,0,&orgttchar,12,0,0,0,0); for (i = 0; i < 3; i++) ttchar[i] = orgttchar[i]; ttchar[2] &= ~TT2$M_EDITING; /* Clear line edit bit */ clean_ctrlc(); /* Enable CTRL/W if needed */ if (ret_len==0) { if (smg$enable) status = SMG$READ_COMPOSED_LINE(&keyb_id,&key_tab,&input_line,&prompt, &out_len,&disp2_id,0,0,0,0,0); else status = SMG$READ_COMPOSED_LINE(&keyb_id,0,&input_line,&prompt, &out_len,0,0,0,0,0,0); } memcpy (command_line, input_line.dsc$a_pointer, input_line.dsc$w_length); cip = 1; /* Main loop starts here. Get a command and pasre it*/ for (;;) { /* loop forever until EXIT is entered */ if(status==smg$_eof) status = exit_command(prvmask); if ((status&1) != 1) goto endfor; if (out_len == 0) goto endfor; /* First catch special screen commands */ if (smg$enable) { status = strncmp(command_line, "PREV_SCREEN", 11); if (status == 0) { prev_screen(); goto endfor; } status = strncmp(command_line, "DO",2); if (status == 0) { status = spawn_command(prvmask); goto endfor; } status = strncmp(command_line, "PF4",3); if (status == 0) { dump_screen(); goto endfor; } status = strncmp(command_line, "NEXT_SCREEN", 11); if (status == 0) { next_screen(); goto endfor; } status = strncmp(command_line, "SELECT", 6); if (status == 0) { toggle_width(); goto endfor; } SMG$ERASE_DISPLAY(&disp1_id, 0, 0, 0, 0); SMG$ERASE_DISPLAY(&status_id, 0, 0, 0, 0); SMG$CHANGE_VIEWPORT(&disp1_id,&x,&i1,&y,&colls); SMG$SET_CURSOR_ABS(&disp1_id,&x,&i1); } /* Catch the CLI errors do avoid disrupting the SMG screen... */ #if 0 VAXC$ESTABLISH(prim_hand); #endif status = CLI$DCL_PARSE(&input_line,&dfu_tables,0 /* not yet lib$get_input*/,0,&prompt); // check added & before dfu_tables #if 0 VAXC$ESTABLISH(NULL); #endif if (status == CLI$_NOCOMD) singlemsg(0,status); if ((status & 1 ) != 1) goto endfor; else /* Now dispatch if no errors */ { reset_ctrl(); CLI$DISPATCH(prvmask); clean_ctrlc(); cip = 0; status = brdcst_ast(); if (smg$enable) SMG$SET_CURSOR_MODE(&paste_id, &cursor_on); } endfor: if (ret_len !=0) { /* Single command processing , so exit here */ status += 0x10000000; /* Do not echo the error on DCL level */ if (smg$enable) { if (colls != orig_colls) toggle_width(); SMG$SET_CURSOR_ABS(&disp2_id,&i2,&i1); } exit(status); } /* Get next line */ cip = 0; #if 1 if (smg$enable) { SMG$ERASE_LINE(&disp2_id, &i1, &i1); SMG$SET_CURSOR_ABS(&disp2_id,&i1,&i1); status = SMG$READ_COMPOSED_LINE(&keyb_id,&key_tab,&input_line, &prompt,&out_len,&disp2_id,0,0,0,0,0); /*Get next command */ cip = 1; } else status = SMG$READ_COMPOSED_LINE(&keyb_id,0,&input_line, &prompt,&out_len,0,0,0,0,0,0); /*Get next command */ #else printf("%s",prompt.dsc$a_pointer); out_len = read(0,command_line,254); out_len--; command_line[out_len]=0; if (strncmp(command_line,"exit",4)==0) return 0; #endif } } /* END of MAIN */
gtcm_server() { static readonly int4 reptim[2] = {-100000, -1}; /* 10ms */ static readonly int4 wait[2] = {-1000000, -1}; /* 100ms */ void gtcm_ch(), gtcm_exi_handler(), gtcm_init_ast(), gtcm_int_unpack(), gtcm_mbxread_ast(), gtcm_neterr(), gtcm_read_ast(), gtcm_remove_from_action_queue(), gtcm_shutdown_ast(), gtcm_write_ast(), la_freedb(); bool gtcm_link_accept(); bool alid; char buff[512]; char *h = NULL; char *la_getdb(); char nbuff[256]; char *pak = NULL; char reply; unsigned short outlen; int4 closewait[2] = {0, -1}; int4 inid = 0, mdl = 0, nid = 0, days = 0; int4 lic_status; int4 lic_x; int4 lm_mdl_nid(); uint4 status; int i, receive(), value; mstr name1, name2; struct NTD *cmu_ntdroot(); connection_struct *prev_curr_entry; struct dsc$descriptor_s dprd; struct dsc$descriptor_s dver; $DESCRIPTOR(node_name, nbuff); $DESCRIPTOR(proc_name, "GTCM_SERVER"); $DESCRIPTOR(timout, buff); DCL_THREADGBL_ACCESS; GTM_THREADGBL_INIT; assert(0 == EMPTY_QUEUE); /* check so dont need gdsfhead everywhere */ common_startup_init(GTCM_GNP_SERVER_IMAGE); /* Side-effect: Sets skip_dbtriggers to TRUE for non-trigger platforms */ gtm_env_init(); /* read in all environment variables */ name1.addr = "GTCMSVRNAM"; name1.len = SIZEOF("GTCMSVRNAM") - 1; status = trans_log_name(&name1, &name2, nbuff); if (SS$_NORMAL == status) { proc_name.dsc$a_pointer = nbuff; proc_name.dsc$w_length = node_name.dsc$w_length = name2.len; } else if (SS$_NOLOGNAM == status) { MEMCPY_LIT(nbuff, "GTCMSVR"); node_name.dsc$w_length = SIZEOF("GTCMSVR") - 1; } else rts_error_csa(CSA_ARG(NULL) VARLSTCNT(1) status); sys$setprn(&proc_name); status = lib$get_foreign(&timout, 0, &outlen, 0); if ((status & 1) && (6 > outlen)) { for (i = 0; i < outlen; i++) { value = value * 10; if (buff[i] <= '9' && buff[i] >= '0') value += buff[i] - 48; else break; } if (outlen && (i == outlen)) { cm_timeout = TRUE; closewait[0] = value * -10000000; } } dprd.dsc$w_length = cm_prd_len; dprd.dsc$b_dtype = DSC$K_DTYPE_T; dprd.dsc$b_class = DSC$K_CLASS_S; dprd.dsc$a_pointer= cm_prd_name; dver.dsc$w_length = cm_ver_len; dver.dsc$b_dtype = DSC$K_DTYPE_T; dver.dsc$b_class = DSC$K_CLASS_S; dver.dsc$a_pointer= cm_ver_name; ast_init(); licensed = TRUE; lkid = 2; # ifdef NOLICENSE lid = 1; # else /* this code used to be scattered to discourage reverse engineering, but since it now disabled, that seems pointless */ lic_status = ((NULL == (h = la_getdb(LMDB))) ? LP_NOCNFDB : SS$_NORMAL); lic_status = ((1 == (lic_status & 1)) ? lm_mdl_nid(&mdl, &nid, &inid) : lic_status); lic_status = ((1 == (lic_status & 1)) ? lp_licensed(h, &dprd, &dver, mdl, nid, &lid, &lic_x, &days, pak) : lic_status); if (LP_NOCNFDB != lic_status) la_freedb(h); if (1 == (lic_status & 1)) { licensed = TRUE; if (days < 14) rts_error_csa(CSA_ARG(NULL) VARLSTCNT(1) ERR_WILLEXPIRE); } else { licensed = FALSE; sys$exit(lic_status); } # endif gtcm_ast_avail = astq_dyn_avail - GTCM_AST_OVRHD; stp_init(STP_INITSIZE); rts_stringpool = stringpool; cache_init(); procnum = 0; get_proc_info(0, TADR(login_time), &image_count); memset(proc_to_clb, 0, SIZEOF(proc_to_clb)); status = cmi_init(&node_name, 0, 0, gtcm_init_ast, gtcm_link_accept); if (!(status & 1)) { rts_error_csa(CSA_ARG(NULL) VARLSTCNT(1) ((status ^ 3) | 4)); sys$exit(status); } ntd_root = cmu_ntdroot(); ntd_root->mbx_ast = gtcm_mbxread_ast; ntd_root->err = gtcm_neterr; gtcm_connection = FALSE; lib$establish(gtcm_ch); gtcm_exi_blk.exit_hand = >cm_exi_handler; gtcm_exi_blk.arg_cnt = 1; gtcm_exi_blk.cond_val = >cm_exi_condition; sys$dclexh(>cm_exi_blk); INVOKE_INIT_SECSHR_ADDRS; initialize_pattern_table(); assert(run_time); /* Should have been set by common_startup_init */ while (!cm_shutdown) { if (blkdlist) gtcml_chkreg(); assert(!lib$ast_in_prog()); status = sys$dclast(>cm_remove_from_action_queue, 0, 0); if (SS$_NORMAL != status) rts_error_csa(CSA_ARG(NULL) VARLSTCNT(4) CMERR_CMSYSSRV, 0, status, 0); if (INTERLOCK_FAIL == curr_entry) rts_error_csa(CSA_ARG(NULL) VARLSTCNT(1) CMERR_CMINTQUE); if (EMPTY_QUEUE != curr_entry) { switch (*curr_entry->clb_ptr->mbf) { case CMMS_L_LKCANALL: reply = gtcmtr_lkcanall(); break; case CMMS_L_LKCANCEL: reply = gtcmtr_lkcancel(); break; case CMMS_L_LKREQIMMED: reply = gtcmtr_lkreqimmed(); break; case CMMS_L_LKREQNODE: reply = gtcmtr_lkreqnode(); break; case CMMS_L_LKREQUEST: reply = gtcmtr_lkrequest(); break; case CMMS_L_LKRESUME: reply = gtcmtr_lkresume(); break; case CMMS_L_LKACQUIRE: reply = gtcmtr_lkacquire(); break; case CMMS_L_LKSUSPEND: reply = gtcmtr_lksuspend(); break; case CMMS_L_LKDELETE: reply = gtcmtr_lkdelete(); break; case CMMS_Q_DATA: reply = gtcmtr_data(); break; case CMMS_Q_GET: reply = gtcmtr_get(); break; case CMMS_Q_KILL: reply = gtcmtr_kill(); break; case CMMS_Q_ORDER: reply = gtcmtr_order(); break; case CMMS_Q_PREV: reply = gtcmtr_zprevious(); break; case CMMS_Q_PUT: reply = gtcmtr_put(); break; case CMMS_Q_QUERY: reply = gtcmtr_query(); break; case CMMS_Q_ZWITHDRAW: reply = gtcmtr_zwithdraw(); break; case CMMS_S_INITPROC: reply = gtcmtr_initproc(); break; case CMMS_S_INITREG: reply = gtcmtr_initreg(); break; case CMMS_S_TERMINATE: reply = gtcmtr_terminate(TRUE); break; case CMMS_E_TERMINATE: reply = gtcmtr_terminate(FALSE); break; case CMMS_U_LKEDELETE: reply = gtcmtr_lke_clearrep(curr_entry->clb_ptr, curr_entry->clb_ptr->mbf); break; case CMMS_U_LKESHOW: reply = gtcmtr_lke_showrep(curr_entry->clb_ptr, curr_entry->clb_ptr->mbf); break; case CMMS_B_BUFRESIZE: reply = CM_WRITE; value = *(unsigned short *)(curr_entry->clb_ptr->mbf + 1); if (value > curr_entry->clb_ptr->mbl) { free(curr_entry->clb_ptr->mbf); curr_entry->clb_ptr->mbf = malloc(value); } *curr_entry->clb_ptr->mbf = CMMS_C_BUFRESIZE; curr_entry->clb_ptr->mbl = value; curr_entry->clb_ptr->cbl = 1; break; case CMMS_B_BUFFLUSH: reply = gtcmtr_bufflush(); break; case CMMS_Q_INCREMENT: reply = gtcmtr_increment(); break; default: reply = FALSE; if (SS$_NORMAL == status) rts_error_csa(CSA_ARG(NULL) VARLSTCNT(3) ERR_BADGTMNETMSG, 1, (int)*curr_entry->clb_ptr->mbf); break; } if (curr_entry) /* curr_entry can be NULL if went through gtcmtr_terminate */ { status = sys$gettim(&curr_entry->lastact[0]); if (SS$_NORMAL != status) rts_error_csa(CSA_ARG(NULL) VARLSTCNT(1) status); /* curr_entry is used by gtcm_mbxread_ast to determine if it needs to defer the interrupt message */ prev_curr_entry = curr_entry; if (CM_WRITE == reply) { /* if ast == gtcm_write_ast, let it worry */ curr_entry->clb_ptr->ast = gtcm_write_ast; curr_entry = EMPTY_QUEUE; cmi_write(prev_curr_entry->clb_ptr); } else { curr_entry = EMPTY_QUEUE; if (1 == (prev_curr_entry->int_cancel.laflag & 1)) { /* valid interrupt cancel msg, handle in gtcm_mbxread_ast */ status = sys$dclast(gtcm_int_unpack, prev_curr_entry, 0); if (SS$_NORMAL != status) rts_error_csa(CSA_ARG(NULL) VARLSTCNT(1) status); } else if (CM_READ == reply) { prev_curr_entry->clb_ptr->ast = gtcm_read_ast; cmi_read(prev_curr_entry->clb_ptr); } } } } else if (1 < astq_dyn_avail) { # ifdef GTCM_REPTIM /* if reptim is not needed - and smw doesn't know why it would be - remove this */ status = sys$schdwk(0, 0, &wait[0], &reptim[0]); # else status = sys$schdwk(0, 0, &wait[0], 0); # endif sys$hiber(); sys$canwak(0, 0); } if (cm_timeout && (0 == gtcm_users)) sys$setimr(efn_ignore, closewait, gtcm_shutdown_ast, &cm_shutdown, 0); } }
parse_vms_args(int *argc, char **argv[]) { static char command[S_LENGTH], value_template[S_LENGTH]; static char qual_template[S_LENGTH]; char verb[] = "VARG "; char *vms_arg[MAX_ARGS]; char *unix_arg[MAX_ARGS]; char *unix_narg[MAX_ARGS]; char *vms_key[MAX_ARGS]; char *unix_key[MAX_ARGS]; char *separator[MAX_ARGS]; char *pattern[MAX_ARGS]; char *outverb, *arg_symbol, *image_name; char foreign_image[S_LENGTH]; int flags[MAX_ARGS], action_flags; int nvargs, u_length, l_element, index; char arg_string[S_LENGTH], arg_element[S_LENGTH]; static char value[S_LENGTH]; char *special_chars; char default_special[] = "!@#^&()=+\'\"/?,"; $DESCRIPTOR(command_desc, command); $DESCRIPTOR(qual_desc, ""); $DESCRIPTOR(value_desc, value); int i, length, status, i_length, arg_count, q_length; static char command_args[S_LENGTH]; $DESCRIPTOR(command_arg_desc, command_args); extern VARG_CLD; static char *newargv[MAX_ARGS]; int affirm_flag, negative_flag, keywords_flag, separator_flag; int date_flag, append_flag, present, more_flag, multivalue, help_flag; int vmsarg_mapping(); /* Get the VMS -> Unix mapping definitions from the routine generated by the GEN_MAPPING utility. */ vmsarg_mapping(&nvargs, vms_arg, unix_arg, unix_narg, vms_key, unix_key, separator, flags, pattern, &outverb, &action_flags, &arg_symbol, &image_name ); /* Get the original command line from the foreign command utility. */ length = 0; /* RTL only writes word */ lib$get_foreign(&command_arg_desc, 0, &length); command_args[length] = 0; /* add NULL terminator */ /* Check to see if any of the exising arguments start with a "-" character. if so, assume he's already using Unix style arguments so we don't have to do anything. Only do this if the Unix_Arg bit is set in the action flags. */ if ((action_flags & VARGACT_M_UNIXARG)) { for (i = 1; i <= *argc - 1; i++) if ((*argv) [i][0] == '-') { /* He's using Unix style args. */ if ((action_flags & VARGACT_M_RETURN)) { return 1; /* back out quietly */ } else { status = varg_do_exit(action_flags, arg_symbol, command_args, image_name, outverb); sys$exit(status); /* exit with DCL stuff done */ } } } /* Catenate verb and arguments into the command string for DCL to parse. */ strcpy(command, verb); strcat(command, command_args); command_desc.dsc$w_length = strlen(verb) + strlen(command_args); /* Pass it to the DCL parser for its approval. */ status = cli$dcl_parse(&command_desc, &VARG_CLD); if ((status & 1) != 1) sys$exit (status); /* Now that DCL is happy, we go through all the defined VMS qualifiers and parameters to check if they are present or defaulted. */ arg_count = 0; /* so far so good */ for (i = 1; i <= nvargs; i++) { /* Set The various flags for this qualifier. */ affirm_flag = (VARG_M_AFFIRM & flags[i]) != 0; negative_flag = (VARG_M_NEGATIVE & flags[i]) != 0; keywords_flag = (VARG_M_KEYWORDS & flags[i]) != 0; separator_flag = (VARG_M_SEPARATOR & flags[i]) != 0; date_flag = (VARG_M_DATE & flags[i]) != 0; append_flag = (VARG_M_APPEND & flags[i]) != 0; help_flag = (VARG_M_HELP & flags[i]) != 0; /* Check if the qualifier or parameter is present */ qual_desc.dsc$w_length = strlen(vms_arg[i]); qual_desc.dsc$a_pointer = vms_arg[i]; present = cli$present(&qual_desc) & 1; /* if the qualifier is present, and there is a positive translation, then replace the VMS qualifier by its Unix equivalent. Note that if the Unix equivalent starts with a '$', then it is a parameter and we omit the qualifier name, only putting in the value. */ qual_template[0] = 0; /* zero string initially */ if (present && affirm_flag) { if (unix_arg[i][0] != '$') strcpy(qual_template, unix_arg[i]); } if (!(present & 1) && negative_flag) /* NOT present AND negative_flag */ { strcpy(qual_template, unix_narg[i]); } /* Get the first value (if any). We may have to catenate this with the qualifier keyword, or build up multiple values in a single argv element. */ if (present) { value_desc.dsc$w_length = QUAL_LENGTH; status = cli$get_value(&qual_desc, &value_desc, &length); if ((status & 1) != 1) length = 0; value[length] = 0; /* NULL terminator */ more_flag = status == CLI$_COMMA; } else { length = 0; } /* if the /APPEND qualifier was used, then the qualifier and its value are in the same argv element. */ if (append_flag) { strcpy(value_template, qual_template); } else { /* Allocate a fresh argv element and load the Unix keyword into it. */ q_length = strlen(qual_template); if (q_length != 0) { Increment(arg_count); newargv[arg_count] = malloc(q_length + 1); if (newargv[arg_count] == NULL) sys$exit(LIB$_INSVIRMEM); strcpy(newargv[arg_count], qual_template); } } multivalue = more_flag; /* Get all the various values and either append them with appropriate separators to the current template, or load them in successive argv elements. */ while (affirm_flag && (length != 0)) { /* if a keyword list is involved, get the corresponding field from the Unix equivalent. */ if (keywords_flag) { index = varg_get_index(value, vms_key[i]); varg_set_index(value, unix_key[i], index); } /* if the /DATE qualifier was present, we interpret the value as a VMS date/time specification, and convert it to the equivalent Unix type string. */ if (date_flag) varg_convert_date(value, pattern[i]); /* Add the current value to the template so far. Add a separator character if we need one. */ strcat(value_template, value); if (separator_flag) { if (more_flag) strcat(value_template, separator[i]); } else { /* Each value should have its own argv element. */ Increment(arg_count); newargv[arg_count] = malloc(strlen(value_template) + 1); if (newargv[arg_count] == NULL) sys$exit(LIB$_INSVIRMEM); strcpy(newargv[arg_count], value_template); value_template[0] = 0; } /* Get the next value from the DCL parser. */ value_desc.dsc$w_length = QUAL_LENGTH; /* reset string */ status = cli$get_value(&qual_desc, &value_desc, &length); if ((status & 1) != 1) length = 0; value[length] = 0; more_flag = status == CLI$_COMMA; } /* All the values are in for this qualifier - if there were being stacked up then load them all into an argv element. */ if (separator_flag & multivalue) { Increment(arg_count); newargv[arg_count] = malloc(strlen(value_template) + 1); if (newargv[arg_count] == NULL) sys$exit(LIB$_INSVIRMEM); strcpy(newargv[arg_count], value_template); value_template[0] = 0; } /* Check to see if this is a HELP directive. if so, then the help library name is stored in pattern[i] and the initial help string in unix_arg[i] */ if ((present &1) && help_flag) { varg_do_help(pattern[i], unix_arg[i]); } /* And around for the next qualifier. */ } /* We've built the argument vector. Now lets find out what we're supposed to do with it. */ if ((action_flags & VARGACT_M_RETURN)) { /* We should return the result to the caller. Set the corresponding argc & argv variables in the caller to point at these. Make sure the new argv contains the same [0] element as the old one (program name). */ *argc = arg_count + 1; newargv[0] = (*argv)[0]; *argv = newargv; return 1; } /* We must convert the argv elements into an arg string. */ arg_string[0] = 0; special_chars = default_special; for (i = 1; i <= arg_count; i++) { varg_protect_string(newargv[i], arg_element, action_flags, special_chars); strcat(arg_string, arg_element); if (i != arg_count) strcat(arg_string, " "); } status = varg_do_exit(action_flags, arg_symbol, arg_string, image_name, outverb); /* if we got this far then exit to DCL. */ sys$exit(status); }