bool ask_for_conditional(WINDOW *askW,char edCAns) { char cond_exp ; cond_exp = EOS; if (conditional_str == NULL) conditional_str = SEP_MEalloc(SEP_ME_TAG_NODEL, TEST_LINE+1, TRUE, (STATUS *) NULL); if (conditional_old == NULL) conditional_old = SEP_MEalloc(SEP_ME_TAG_NODEL, TEST_LINE+1, TRUE, (STATUS *) NULL); if (conditional_prompt == NULL) conditional_prompt = SEP_MEalloc(SEP_ME_TAG_NODEL, TEST_LINE+1, TRUE, (STATUS *) NULL); if ((*conditional_str == EOS) && (SEP_IF_EXPRESSION != NULL) && (*SEP_IF_EXPRESSION != EOS)) STcopy(SEP_IF_EXPRESSION, conditional_str); STcopy(conditional_str, conditional_old); #ifdef NT_GENERIC STprintf(conditional_prompt,ERx(" IF (%s) >"),conditional_str); #else STprintf(conditional_prompt,ERx("%s%s%s%s%s IF (%s) >%s"),REG_CHAR, ATTR_OFF, PROMPT_POS, DEL_EOL, REV_VIDEO, conditional_str, ATTR_OFF); #endif if (edCAns == EOS) get_string(askW, conditional_prompt, conditional_str); if ((conditional_str == NULL) || (*conditional_str == EOS)) { if (*conditional_old == EOS) { if (edCAns == EOS) put_message(askW, ERx("No conditional expression for this Canon.")); return (FALSE); } else { STcopy(conditional_old, conditional_str); } } else if (STskipblank(conditional_str, STlength(conditional_str)) == NULL) { *conditional_str = EOS; *conditional_old = EOS; if (edCAns == EOS) put_message(askW, ERx("No conditional expression for this Canon.")); return (FALSE); } STpolycat(3, ERx(" IF ("), conditional_str, ERx(") "), conditional_prompt); return (TRUE); }
STATUS page_down(i4 update) { struct page_chain *newpage = NULL ; char junk ; if ( (myPages) && (myPages->final_page) ) { disp_prompt(ERx("EOF reached"),&junk,NULL); return(OK); } if ( (myPages == NULL) || (myPages->next == NULL) ) { newpage = (struct page_chain *) SEP_MEalloc(SEP_ME_TAG_PAGES, sizeof(struct page_chain), TRUE, (STATUS *) NULL); newpage->file_pos = SIftell(diffPtr ); newpage->final_page = FALSE; newpage->next = NULL; if (myPages) { newpage->previous = myPages; myPages->next = newpage; } else newpage->previous = NULL; myPages = newpage; } else myPages = myPages->next; TDerase(diffW); return(display_lines()); } /* page_down */
VOID get_string(WINDOW *wndow,char *question,char *ansbuff) { char *prompt = NULL ; char tempBuffer [TERM_LINE] ; char *cp = ansbuff ; char *cptr = NULL ; i4 clen ; register i4 i ; prompt = SEP_MEalloc(SEP_ME_TAG_NODEL, STlength(question)+5, TRUE, (STATUS *) NULL); STprintf(prompt, ERx("%s "), question); put_message(wndow, prompt); getstr(wndow, tempBuffer, FALSE); /* check if continuation character was entered */ cptr = SEP_CMlastchar(tempBuffer,0); if (CMcmpcase(cptr,cont_char) == 0) { *cptr = EOS; STcopy(tempBuffer,cp); clen = SEP_CMstlen(tempBuffer,0); for (i=0; i<clen; i++) CMnext(cp); TDerase(wndow); STprintf(tempBuffer, ERx("%s%s"), prompt, ansbuff); SEPprintw(wndow, PROMPT_ROW - 1, PROMPT_COL, tempBuffer); STprintf(prompt, ERx("%s%s"), question, cont_char); SEPprintw(wndow, PROMPT_ROW, PROMPT_COL, prompt); TDrefresh(wndow); getstr(wndow,tempBuffer,FALSE); /* check if continuation character was entered */ cptr = SEP_CMlastchar(tempBuffer,0); if (CMcmpcase(cptr,cont_char) == 0) { i4 temp; *cptr = EOS; STprintf(prompt, ERx("%s %s"), question, tempBuffer); SEPprintw(wndow, PROMPT_ROW, PROMPT_COL, prompt); STcopy(tempBuffer, cp); STprintf(prompt, ERx("%s%s"), question, cont_char); SEPprintw(wndow, PROMPT_ROW + 1, PROMPT_COL, prompt); /* ** ugly fix to prevent the screen from scrolling when ** typing to the last line of the screen. It will hopefully ** be changed in the future for a more elegant solution */ temp = LINES; LINES++; TDrefresh(wndow); getstr(wndow, tempBuffer, FALSE); disp_prompt((char *)NULLSTR, (char *)NULL, (char *)NULL); LINES = temp; } } MEfree(prompt); STcopy(tempBuffer, cp); TDerase(wndow); TDrefresh(wndow); }
STATUS Run_SED_on_file(SEPFILE **Sep_file,LOCATION *Sep_Loc) { STATUS ret_val ; CL_ERR_DESC cl_err; LOCATION *sedtmploc = NULL ; LOCATION *filtmploc = NULL ; char *SEDbuffer = NULL ; char *sedtmp = NULL ; char *filtmp = NULL ; char *cmd_line = NULL ; char *sed_dev = NULL ; char *sed_path = NULL ; char *sed_name = NULL ; char *sed_type = NULL ; char *sed_vers = NULL ; char *fptr1 = NULL ; char *fptr2 = NULL ; FILE *SEDfptr = NULL ; FILE *fptr = NULL ; bool Sep_file_empty ; sed_dev = SEP_MEalloc(SEP_ME_TAG_SED, LO_DEVNAME_MAX+1, TRUE, NULL); sed_path = SEP_MEalloc(SEP_ME_TAG_SED, LO_PATH_MAX+1, TRUE, NULL); sed_name = SEP_MEalloc(SEP_ME_TAG_SED, LO_FPREFIX_MAX+1, TRUE, NULL); sed_type = SEP_MEalloc(SEP_ME_TAG_SED, LO_FSUFFIX_MAX+1, TRUE, NULL); sed_vers = SEP_MEalloc(SEP_ME_TAG_SED, LO_FVERSION_MAX+1, TRUE, NULL); SEDbuffer = SEP_MEalloc(SEP_ME_TAG_SED, SCR_LINE+1, TRUE, NULL); /* ** Create Sed output file names. */ sedtmploc = (LOCATION *)SEP_MEalloc(SEP_ME_TAG_SED, sizeof(LOCATION), TRUE, NULL); filtmploc = (LOCATION *)SEP_MEalloc(SEP_ME_TAG_SED, sizeof(LOCATION), TRUE, NULL); sedtmp = SEP_MEalloc(SEP_ME_TAG_TOKEN, MAX_LOC+1, TRUE, NULL); filtmp = SEP_MEalloc(SEP_ME_TAG_TOKEN, MAX_LOC+1, TRUE, NULL); LOtos(Sep_Loc, &fptr2); STcopy(fptr2, sedtmp); STcopy(fptr2, filtmp); LOfroms(FILENAME & PATH, sedtmp, sedtmploc); LOfroms(FILENAME & PATH, filtmp, filtmploc); LOdetail(sedtmploc, sed_dev, sed_path, sed_name, sed_type, sed_vers); STcopy(ERx("sed"),sed_type); SEP_LOcompose(sed_dev, sed_path, sed_name, sed_type, sed_vers, sedtmploc); STcopy(ERx("sdr"),sed_type); SEP_LOcompose(sed_dev, sed_path, sed_name, sed_type, sed_vers, filtmploc); /* ** Copy Sep SI_RACC file to a SI_TXT file. */ SEPrewind(*Sep_file, FALSE); if ((ret_val = SIfopen(filtmploc,ERx("w"), SI_TXT, SCR_LINE, &fptr)) != OK) return(ret_val); for (Sep_file_empty = TRUE; (ret_val = SEPgetrec(SEDbuffer, *Sep_file)) == OK; SIputrec(SEDbuffer, fptr)) if (Sep_file_empty) Sep_file_empty = FALSE; SIclose(fptr); if (Sep_file_empty == FALSE) { /* ** Create command line for sed command. */ LOtos(SED_loc, &fptr1); LOtos(filtmploc, &fptr2); cmd_line = SEP_MEalloc(SEP_ME_TAG_TOKEN, MAX_LOC+1, TRUE, NULL); IISTprintf(cmd_line, "sed -f %s %s", fptr1, fptr2); /* ** Close Sep file and run the SED. */ SEPclose(*Sep_file); ret_val = PCcmdline(NULL, cmd_line, PC_WAIT, sedtmploc, &cl_err); if(ret_val != OK) { SEPopen(Sep_Loc, SCR_LINE, Sep_file); del_floc(sedtmploc); del_floc(filtmploc); MEtfree(SEP_ME_TAG_SED); return(1); } /* ** Recreate Sep file. */ #ifdef NT_GENERIC LOdelete(Sep_Loc); #else del_floc(Sep_Loc); #endif if ((ret_val = SIfopen(Sep_Loc, ERx("w"), SI_RACC, SCR_LINE, &fptr)) != OK) return(ret_val); SIclose(fptr); SEPopen(Sep_Loc, SCR_LINE, Sep_file); /* ** Open Sed output file. */ if ((ret_val = SIfopen(sedtmploc, ERx("r"), SI_TXT, SCR_LINE, &SEDfptr)) != OK) return(ret_val); /* ** Copy the Sed output file to the Sep file. */ while((ret_val = SIgetrec(SEDbuffer, SCR_LINE, SEDfptr)) == OK) SEPputrec(SEDbuffer, *Sep_file); SEPclose(*Sep_file); SIclose(SEDfptr); /* ** Reopen the sep file. */ SEPopen(Sep_Loc, SCR_LINE, Sep_file); /* ** Clean up. */ del_floc(sedtmploc); } del_floc(filtmploc); MEtfree(SEP_ME_TAG_SED); return(OK); }
STATUS getLocation(char *string,char *newstr,LOCTYPE *typeOfLoc) { STATUS ret_val ; LOCATION aLoc ; LOCATION bLoc ; LOCATION *Locptr1 = NULL ; LOCATION *Locptr2 = NULL ; LOCATION *Locptr3 = NULL ; char *cptr = NULL ; char *cptr2 = NULL ; char *next = NULL ; char *start = NULL ; char *tmpBuf = NULL ; char *tmpBuf2 = NULL ; char *gl_dev = NULL ; char *gl_path [128] ; char *gl_file = NULL ; char *resultPtr = NULL ; char *tmpaLocStr = NULL ; char *tmpbLocStr = NULL ; i4 i ; ret_val = OK; for ( i=0; i<128; i++) gl_path[i] = NULL; tmpaLocStr = SEP_MEalloc(SEP_ME_TAG_GETLOC, MAX_LOC+1, TRUE, (STATUS *)NULL); tmpbLocStr = SEP_MEalloc(SEP_ME_TAG_GETLOC, MAX_LOC+1, TRUE, (STATUS *)NULL); LOfroms(FILENAME & PATH, tmpaLocStr, &aLoc); LOfroms(FILENAME & PATH, tmpbLocStr, &bLoc); if (tracing&TRACE_PARM) { SIfprintf(traceptr, ERx("getLocation00> string = %s\n"), string); SIfprintf(traceptr, ERx("getLocation01> newstr = %s\n"), newstr); } tmpBuf = SEP_MEalloc(SEP_ME_TAG_GETLOC, MAX_LOC+1, TRUE, (STATUS *)NULL); STcopy(string, tmpBuf); if (!(start = STindex(tmpBuf, ERx("("), 0))) { MEtfree(SEP_ME_TAG_GETLOC); return(FAIL); } MEfree(tmpaLocStr); MEfree(tmpbLocStr); aLoc.string = SEP_MEalloc(SEP_ME_TAG_GETLOC, MAX_LOC+1, TRUE, (STATUS *)NULL); bLoc.string = SEP_MEalloc(SEP_ME_TAG_GETLOC, MAX_LOC+1, TRUE, (STATUS *)NULL); next = start; CMnext(next); if (typeOfLoc) *typeOfLoc = NULL; if (CMcmpcase(next, ERx(","))) { /* There's a device specification */ cptr = next; if ((next = STindex(cptr, ERx(","), 0)) == NULL) { if ((next = STindex(cptr, ERx(")"), 0)) == NULL) ret_val = FAIL; else { /* ** This is really a file name in the form, @file(filename.type) */ *next = EOS; gl_file = SEP_MEalloc(SEP_ME_TAG_GETLOC, ((i4)(next-cptr))+2, TRUE, (STATUS *)NULL); STcopy(cptr, gl_file); if (tracing&TRACE_PARM) SIfprintf(traceptr, ERx("getLocation02> file = %s\n"), gl_file); if (typeOfLoc) *typeOfLoc = FILENAME; } } else { *next = EOS; gl_dev = SEP_MEalloc(SEP_ME_TAG_GETLOC, ((i4)(next-cptr))+2, TRUE, (STATUS *)NULL); #ifdef UNIX STpolycat(2,ERx("$"),cptr, gl_dev); cptr2 = gl_dev; SEP_NMgtAt(CMnext(cptr2), &tmpBuf2, SEP_ME_TAG_GETLOC); if ((tmpBuf2 == NULL)||(*tmpBuf2 == EOS)) { switch (i = SEP_CMwhatcase(cptr2)) { case 0: break; case 1: for (cptr2 = gl_dev; *cptr2 != EOS; CMnext(cptr2)) CMtolower(cptr2,cptr2); break; case -1: for (cptr2 = gl_dev; *cptr2 != EOS; CMnext(cptr2)) CMtoupper(cptr2,cptr2); break; } if (i != 0) { cptr2 = gl_dev; SEP_NMgtAt(CMnext(cptr2), &tmpBuf2, SEP_ME_TAG_GETLOC); } } if (tmpBuf2 != NULL) if (*tmpBuf2 != EOS) { MEfree(gl_dev); gl_dev = SEP_MEalloc(SEP_ME_TAG_GETLOC, (STlength(tmpBuf2)*2)+2, TRUE,(STATUS *)NULL); STcopy(tmpBuf2,gl_dev); } #else #ifdef MPE STpolycat(2,ERx("!"),cptr, gl_dev); for (cptr2 = gl_dev; *cptr2 != EOS; CMnext(cptr2)) CMtoupper(cptr2,cptr2); #else /* Probably VMS */ STcopy(cptr, gl_dev); #endif #endif if (tracing&TRACE_PARM) SIfprintf(traceptr, ERx("getLocation03> dev = %s\n"), gl_dev); if (typeOfLoc) *typeOfLoc = PATH; } } cptr = CMnext(next); next = STindex(cptr, ERx(","), 0); for (i = 0; next; ) /* do the paths */ { *next = EOS; gl_path[i] = SEP_MEalloc(SEP_ME_TAG_GETLOC, (int)(next-cptr+2), TRUE, (STATUS *)NULL); STcopy(cptr, gl_path[i]); if (tracing&TRACE_PARM) SIfprintf(traceptr, ERx("getLocation04> path = %s\n"), gl_path[i]); if (typeOfLoc) *typeOfLoc = PATH; cptr = CMnext(next); next = STindex(cptr, ERx(","), 0); i++; } gl_path[i] = NULL; Locptr1 = &aLoc; Locptr2 = &bLoc; #ifndef MPE if (gl_dev || gl_path[0]) { if (tracing&TRACE_PARM) SIfprintf(traceptr, ERx("getLocation05> SEP_LOcompose()\n")); ret_val = SEP_LOcompose(gl_dev, gl_path[0], NULL, NULL, NULL, Locptr1); #ifdef UNIX cptr2 = SEP_CMlastchar(Locptr1->string,0); if (*cptr2 == '/') *cptr2 = EOS; Locptr1->path = Locptr1->string; #endif } for (i=1; (gl_path[i] != NULL)&&(ret_val == OK); i++) { if (tracing&TRACE_PARM) SIfprintf(traceptr, ERx("getLocation06> LOfaddpath()\n")); if ((ret_val = LOfaddpath(Locptr1, gl_path[i], Locptr2)) != OK) continue; Locptr3 = Locptr1; Locptr1 = Locptr2; Locptr2 = Locptr3; } #endif if ((gl_file != NULL)&&(ret_val == OK)) { /* ** This first case catches the instance of: @file(filenane.type). ** This was caught above in looking for a device (gl_dev). */ if (tracing&TRACE_PARM) SIfprintf(traceptr, ERx("getLocation07> LOfroms()\n")); ret_val = LOfroms( FILENAME, gl_file, Locptr1); } else if ((CMcmpcase(cptr, ERx(")")) != 0)&&(ret_val == OK)) { /* There is a filename */ next = STindex(cptr, ERx(")"), 0); *next = EOS; gl_file = SEP_MEalloc(SEP_ME_TAG_GETLOC, (int)(next-cptr+2), TRUE, (STATUS *)NULL); STcopy(cptr, gl_file); if (tracing&TRACE_PARM) SIfprintf(traceptr, ERx("getLocation08> file = %s\n"), gl_file); if (typeOfLoc) *typeOfLoc = PATH & FILENAME; if (gl_dev || gl_path[0]) { #ifdef MPE if (gl_dev) { if (tracing&TRACE_PARM) SIfprintf(traceptr, ERx("getLocation09> MPE's LOfroms ()\n")); char *tmpMPE = NULL ; tmpMPE = SEP_MEalloc(SEP_ME_TAG_GETLOC, (STlength(gl_file)+STlength(gl_dev)+1)*2, TRUE, (STATUS *)NULL); STpolycat(3, gl_file, ERx("."), gl_dev, tmpMPE); LOfroms(FILENAME & PATH, tmpMPE, Locptr1); } #else if (tracing&TRACE_PARM) SIfprintf(traceptr, ERx("getLocation09> LOfstfile()\n")); LOfstfile(gl_file, Locptr1); #endif } else { if (tracing&TRACE_PARM) SIfprintf(traceptr, ERx("getLocation10> LOfroms()\n")); LOfroms( FILENAME, gl_file, Locptr1); } } if (ret_val == OK) { if (tracing&TRACE_PARM) SIfprintf(traceptr, ERx("getLocation11> LOtos()\n")); LOtos(Locptr1, &resultPtr); STcopy(resultPtr, newstr); } MEtfree(SEP_ME_TAG_GETLOC); if (tracing&TRACE_PARM) { if (ret_val != OK) SIfprintf(traceptr,ERx("getLocation12> ret_val = %d\n"),ret_val); else SIfprintf(traceptr,ERx("getLocation13> newstr = %s\n"),newstr); } return(ret_val); }
STATUS Trans_SEPfile(char **Token,LOCTYPE *typeOfLoc,bool Dont_free,i2 ME_tag) { STATUS syserr ; char *newstr = NULL ; char *temp_ptr = NULL ; char *tmp_buffer1 = NULL ; char *tmp_buffer2 = NULL ; char *tmp_ptr1 = NULL ; char *tmp_ptr2 = NULL ; char *tmp_ptr3 = NULL ; char *token_ptr = NULL ; char *tmp_token = NULL ; if (ME_tag == SEP_ME_TAG_NODEL && Dont_free != TRUE) Dont_free = TRUE; if (tracing&TRACE_PARM) { SIfprintf(traceptr,ERx("Trans_SEPfile> *Token = %s\n"),*Token); if (Dont_free) SIfprintf(traceptr,ERx(" Dont_free = TRUE\n")); else SIfprintf(traceptr,ERx(" Dont_free = FALSE\n")); } tmp_token = *Token; if ((token_ptr = FIND_SEPstring(tmp_token,ERx("@FILE("))) == NULL) { if (tracing&TRACE_PARM) SIfprintf(traceptr,ERx("Trans_SEPfile> FIND_SEPstring is FALSE\n")); return (FALSE); } if (tracing&TRACE_PARM) SIfprintf(traceptr,ERx("Trans_SEPfile> FIND_SEPstring is TRUE\n")); tmp_buffer1 = SEP_MEalloc(SEP_ME_TAG_MISC, 128, TRUE, (STATUS *) NULL); tmp_buffer2 = SEP_MEalloc(SEP_ME_TAG_MISC, 128, TRUE, (STATUS *) NULL); if (token_ptr != tmp_token) { for (tmp_ptr1 = tmp_buffer1, tmp_ptr2 = tmp_token; tmp_ptr2 != token_ptr; ) CMcpyinc(tmp_ptr2,tmp_ptr1); } else { tmp_ptr2 = token_ptr; } for (tmp_ptr3 = tmp_buffer2; CMcmpcase(tmp_ptr2,ERx(")")); ) CMcpyinc(tmp_ptr2,tmp_ptr3); CMcpychar(tmp_ptr2,tmp_ptr3); CMnext(tmp_ptr2); newstr = SEP_MEalloc(SEP_ME_TAG_MISC, 128, TRUE, (STATUS *) NULL); if ((syserr = getLocation(tmp_buffer2,newstr,typeOfLoc)) == OK) { if (tracing&TRACE_PARM) { SIfprintf(traceptr,ERx("Trans_SEPfile> newstr = %s\n"),newstr); SIfprintf(traceptr,ERx("Trans_SEPfile> tmp_buffer1 = %s\n"), tmp_buffer1); SIfprintf(traceptr,ERx("Trans_SEPfile> tmp_buffer2 = %s\n"), tmp_buffer2); } STcat(tmp_buffer1, newstr); STcat(tmp_buffer1, tmp_ptr2); if (tracing&TRACE_PARM) SIfprintf(traceptr,ERx("Trans_SEPfile> tmp_buffer1 = %s\n"), tmp_buffer1); temp_ptr = *Token; *Token = STtalloc(ME_tag,tmp_buffer1); if (Dont_free != TRUE) MEfree(temp_ptr); } MEfree(tmp_buffer1); MEfree(tmp_buffer2); MEfree(newstr); if (tracing&TRACE_PARM) SIfprintf(traceptr,ERx("Trans_SEPfile> *Token = %s\n"),*Token); return (syserr); }