/* INCLUDES */ #define PROMPT_LENGTH 9 #define MAX_LINE_LENGTH 79 #define QUAL_LENGTH 7 #define TRUE 1 #define FALSE 0 #define NEGATED -1 /************* Only the following PARMS are looked for************/ #define NOLISTSHIFT 1 #define NODIAGSHIFT 2 #define NOCHECKSHIFT 4 #define NOARRAYSHIFT 5 #define NOTRACESHIFT 6 #define OPTSHIFT 16 #define MAPSHIFT 17 #define CODESHIFT 14 #define NOLINESHIFT 23 #define PARMZSHIFT 26 #define PARMYSHIFT 27 #define PARMXSHIFT 28 #define MAXDICTSHIFT 8 /* in COMREG(28) */ /************* Only the preceding PARMS are looked for************/ #define SOURCEFILELEN 39 #define DEFAULTMALLOC 0X40000 #define MAXDICTMALLOC 0X100000 #include secdef #include stdio.h #include rms #include stdio #include ssdef #include iodef #include jpidef #include syidef #include prvdef #include fibdef #include lnmdef #include descrip #include libdef #include rmsdef #include climsgdef #include file struct string_descriptor { unsigned short length; /* length of data item in bytes */ unsigned char dtype; /* data type code */ unsigned char class; /* descriptor class code */ char *address;/* .. of first byte of data storage */ }; struct general_descriptor { long length; long address; }; struct xabrdt {unsigned int a, b;}; /* to get date/time */ extern long SYS$EXIT(); extern long CLI$DCL_PARSE(); extern long CLI$GET_VALUE(); extern long CLI$DISPATCH(); extern long LIB$GET_INPUT(); extern long LIB$GET_GETFOREIGN(); globalref long imp80_table; char sourcefile[39]; char objectfile[39]; char listingfile[39]; long comreg[64]; main() { long status; char prompt_string[PROMPT_LENGTH] = "Source:"; char command_line[MAX_LINE_LENGTH]; struct string_descriptor line_desc = {MAX_LINE_LENGTH, DSC$K_DTYPE_T, DSC$K_CLASS_S, command_line}; struct string_descriptor prompt_desc = {PROMPT_LENGTH, DSC$K_DTYPE_T, DSC$K_CLASS_S, prompt_string}; get_foreign(&line_desc, &prompt_desc); status = CLI$DCL_PARSE(&line_desc, &imp80_table, &LIB$GET_INPUT, &LIB$GET_INPUT, 0); if (status == CLI$_NORMAL) { status = CLI$DISPATCH(); if (status != SS$_NORMAL) status = SYS$EXIT(SS$_NORMAL); } else status = SYS$EXIT(SS$_NORMAL); } /* end of main*/ /* -------------------- map comreg ------------------ */ extern S_COMREGMAP(i) int i; { return(&comreg[i]); } /* -------------------- present ------------------ */ long present(qualifier) char (*qualifier)[]; { /* This function tests whether the qualifier specified by the string pointed to by "qualifier" is present on the command line. It returns one of three values. a) TRUE if the qualifier is present b) NEGATED if the qualifier is present but is negated c) FALSE otherwise */ long status; struct general_descriptor qual; qual.length = strlen(*qualifier); qual.address = qualifier; status = CLI$PRESENT(&qual); switch(status) { case CLI$_PRESENT: return(TRUE); case CLI$_NEGATED: return(NEGATED); case CLI$_ABSENT: return(FALSE); default: return(FALSE); } } /* end of present */ /* ------------------ get_value ------------------ */ long get_value(entity, answer, answer_length) char (*entity)[]; char (*answer)[]; short answer_length; { /* This function attempts to retrieve the value ascribed to an entity on the command line, once it has been verified that the entity is present. The function returns the entity value in the string pointed to by ANSWER if possible. ANSWER_LENGTH specifies the max length of the string pointed to by ANSWER. The function returns a) TRUE if the value is successfully retrieved. b) FALSE otherwise. */ long status; short return_length; struct general_descriptor ent, ans; ent.length = strlen(*entity); ent.address = entity; ans.length = answer_length; ans.address = answer; status = CLI$GET_VALUE(&ent, &ans, &return_length); switch(status) { case CLI$_COMMA: case CLI$_CONCAT: case SS$_NORMAL: (*answer)[return_length] = 0; return(TRUE); case CLI$_ABSENT: strcpy((*answer), "\0"); return(FALSE); default: return(FALSE); } } /* end of get_value */ /* ------------------ get-Foreign ---------------- */ long get_foreign(get_str_desc, user_prompt_desc) struct string_descriptor *get_str_desc; /* in - address of descriptor */ struct string_descriptor *user_prompt_desc; /* in - address of descriptor */ { long status; long force; unsigned short len; len = 0; force = 0; while (TRUE) { status = LIB$GET_FOREIGN( get_str_desc, user_prompt_desc, &len, &force); if (status == SS$_NORMAL) { if (len > 0) { get_str_desc->address[len] = '\0'; return(TRUE); } else force = 1; /* loop again */ } else if (status == LIB$_INPSTRTRU) { printf("\nCommand too long. Please abbreviate.\n"); force = 1; } else if (status == RMS$_EOF) status = SYS$EXIT(SS$_NORMAL); else status = LIB$STOP(status); } } /* ------------------ imp_command ---------------- */ IMP_COMMAND() { long status, j; long parm1 = 0; int start, end, ifi; char type[39]; char stem[39]; char qual[QUAL_LENGTH]; char prompt_string[PROMPT_LENGTH] = "PIM>"; char command_line[MAX_LINE_LENGTH]; char SOURCEFILE[11] = "SOURCEFILE"; long com14; long *ptr; if ((comreg[28] & MAXDICTSHIFT) != 0) j=MAXDICTMALLOC; else j=DEFAULTMALLOC; com14=malloc(j); comreg[14]=com14; ptr=com14+4; *ptr=32; ptr=ptr+1; *ptr=j; comreg[22]= 0; /* stdin*/ comreg[23]=1; /* stdout*/ comreg[40]= 2; /* stderr */ comreg[20]=stdin; comreg[21]=stdout; /* so IOCP can find them */ strcpy(qual, "LIST"); if (present(&qual)==NEGATED) parm1 = parm1 | (1< s2 . (s3) . s4 */ /* return(0) for success */ char *s1; char *s2; char *s3; char *s4; { int len1, len3, i, j, p; len1 = strlen(s1); len3 = strlen(s3); if (len3 == 0) return(1); if (len3 > len1) return(2); for(i=0;;++i){ if (i > (len1-len3)) return(3); for(j=0;;++j) { if (s3[j] == 0) { /* success */ if (i>0) strncpy(s2,s1,i); s2[i]=0; p=0; while ((s4[p]=s1[i+j+p]) != 0) ++p; return(0); } if (s3[j] != s1[i+j]) break; } } } /* strres */