-+-+-+-+-+-+-+-+ START OF PART 235 -+-+-+-+-+-+-+-+ X s`5Bi`5D = tolower(s`5Bi`5D); X `7D X`7D /* make_lower_case */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void interpreter() X/* X** description: There are two drastic exit labels: for faults which require` V20 X** that the function finish for good, jump to label 99 at this level. X** For other faults which mean 'finish this level of recursion', eg X** 'unable to open file', jump to label 90 declared in 'interpreter'.`20 X** input params:`20 X** output params:`20 X** return value:`20 X*/ X`7B X /* process the script on file 'ifn' */ X Pchar name`5B201`5D, errstr`5B256`5D, defname`5B255`5D; /* extracted fun Vction name */ X ptkephigsnames phigsname; /* the namelist index of a function */ X ptkboolean quit, process; X X /* initialisation */ X quit = FALSE; X process = TRUE; X lno = 0; /* initialise the current line number */ X /* open the input script file */ X X /* loop through the whole file, processing comment lines, null lines X ** and function calls`20 X */ X while (!quit)`20 X `7B `20 X /* loop */ X lno++; /* up current line number */ X if (readfunction(name))`20 X `7B `20 X /* Non-blank line */ X switch (name`5B0`5D)`20 X `7B X X case EOF: quit = TRUE; X break; X X case '!': process_comment_line(name); X break; X X case 'q': make_lower_case(name); X if (strcmp(name, "quit") == 0) X `7B`20 X quit = TRUE; X if (writingscript) X phinprintf(PTKEOUTPUT, "quit\n"); X break; X `7D X X case 'e': make_lower_case(name); X if (strcmp(name, "exit") == 0) X `7B`20 X quit = TRUE; X if (writingscript) X phinprintf(PTKEOUTPUT, "quit\n"); X break; X `7D X X case '#': make_lower_case(name); X if ((strcmp(name, "#if") == 0) `7C`7C`20 X (strcmp(name, "#ifdef") == 0)) X`09`09`7B X readstring(defname, "macro name"); X if (strcmp(defname, "SUN") == 0) X#ifdef SUN X process = TRUE; X#endif `20 X#ifdef VMS X process = FALSE; X#endif `20 X else X if (strcmp(defname, "VMS") == 0) X#ifdef VMS X process = TRUE; X#endif `20 X#ifdef SUN X process = FALSE; X#endif `20 X break; X `7D X else X if (strcmp(name, "#endif") == 0) X`09`09`7B X process = TRUE; `20 X break; X `7D `20 X X default: /* looks like a function call */ X /* now look it up */ X if (process) X`09`09 `7B X make_lower_case(name); X if (substrinlist(phigsnamelist, MAXPHIGSNAMES, name,`20 X &phigsname)) X process_phigs_function(phigsname); X else`20 X `7B X /* unknown function */ X sprintf(errstr, "ignoring unknown function, %s.\n",`20 X name);`20 X phintererror(2, errstr, INFORM); X `7D X `7D X break; X `7D X `7D /* readword test */ X if (!interactive) X if (feof(inputscript)) X quit = TRUE; X `7D /* loop */ X setjmp(POPJMP); X`7D /* interpreter */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void sayhello() X`7B X phinprintf(PTKESTDOUT, "This is phinter, version %.1f%s\n",`20 X (Pfloat)CURRENTVERSION, phintermessage); X`7D /* sayhello */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_phinter(C(FILE *) input, C(FILE *) output, C(FILE *) inform) XPreANSI(FILE *input) XPreANSI(FILE *output) XPreANSI(FILE *inform) X/* X** \parambegin X** \param`7BFILE *`7D`7Binput`7D`7Bfile pointer for input script`7D`7BIN`7D X** \param`7BFILE *`7D`7Boutput`7D`7Bfile pointer for output script`7D`7BOUT` V7D X** \param`7BFILE *`7D`7Binform`7D`7Bfile pointer for information such as res Vults of X** inquiry calls.`7D`7BOUT`7D X** \paramend X** \blurb`7BThis function reads a PHIGS script from a file or from standard X** input. If `7B\tt stdin`7D is passed as the input file pointer then X** phinter becomes interactive and prompts are given for function X** parameters. The other file pointers are used for writing an output`20 X** script and for writing data which X** results from inquiry calls and so on.`7D X*/ X`7B X fileswitch = TRUE; X inputscript = input; X if (input == stdin) X interactive = TRUE; X else X interactive = FALSE; X outputscript = output; X if (output == NULL) X writingscript = FALSE; `20 X else X writingscript = TRUE; `20 X informscript = inform; X if (inform == NULL) X writeinform = FALSE; `20 X else X writeinform = TRUE; `20 X sayhello(); X interpreter(); X setjmp(EXITJMP); X`7D /* ptk_phinter */ X X/*-------------------------------------------------------------------------* V/ X X/*function:external*/ Xextern void ptk_strphinter(C(Pint) wsid, C(Plimit *) echoarea,`20 X C(Pint) outputterminal, C(Pint) informterminal) XPreANSI(Pint wsid) XPreANSI(Plimit *echoarea) XPreANSI(Pint outputterminal) XPreANSI(Pint informterminal) X/* X** \parambegin X** \param`7BPint`7D`7Bwsid`7D`7Bworkstation identifier`7D`7BIN`7D X** \param`7BPlimit *`7D`7Becho area`7D`7Becho area for string device`7D`7BIN V`7D X** \param`7BPint`7D`7Boutputterminal`7D`7Bterminal window identifier for wri Vting X** output script to`7D`7BIN`7D X** \param`7BPint`7D`7Binformterminal`7D`7Bterminal window identifier for wri Vting X** information data`7D`7BIN`7D X** \paramend X** \blurb`7BThis function redirects the input of phinter to the PHIGS string V`20 X** device (number 1). Strphinter is always interactive and output is directe Vd X** to terminal windows instead of files so that it may be displayed in the X** PHIGS workstation window.`7D X*/ X`7B X ptkewindowtype type; X Pint err; X X fileswitch = FALSE; X phinws = wsid; X phinecho = *echoarea; X outputterm = outputterminal; X informterm = informterminal; X interactive = TRUE; X ptk_inqwindowtype(outputterm, &type, &err); X if (type == PTKETERMINALWINDOW) X writingscript = TRUE; `20 X else X writingscript = FALSE; `20 X ptk_inqwindowtype(informterm, &type, &err); X if (type == PTKETERMINALWINDOW) X writeinform = TRUE; `20 X else X writeinform = FALSE; `20 X sayhello(); X interpreter(); X setjmp(EXITJMP); X`7D /* ptk_strphinter */ X X/*-------------------------------------------------------------------------* V/ X Xstatic void writestruct(C(FILE *) fileptr, C(Pint) stid) XPreANSI(FILE *fileptr) XPreANSI(Pint stid) X`7B X Pint numelems, i, err, size; X Pchar *buffer, str`5B100`5D; X ptkselcontent elcont; X X fileswitch = TRUE; X outputscript = fileptr; X numelems = ptk_elemcount(stid); X fprintf(fileptr, "open_structure "); X if (ptk_hashtableused("structureid")) X `7B X ptk_inttostring("structureid", stid, 100, str, &size); X if (size > 0) X fprintf(fileptr,"\"%s\"\n", str); X else X writeinteger(fileptr, stid); X `7D X else X writeinteger(fileptr, stid); X for (i = 1; i <= numelems; i++) X `7B X ptk_inqelemtypesizecontent(stid, i, &err, &buffer, &elcont); X writeelemcontent(PTKEOUTPUT, &elcont); X free(buffer); X `7D `20 X fprintf(fileptr, "close_structure"); X`7D /* writestruct */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void writestructnet(C(FILE *) fileptr, C(Pint) stid) XPreANSI(FILE *fileptr) XPreANSI(Pint stid) X`7B X Pintlst stnetids; X Pint i, totsize; X X ptk_inqstructnetids(stid, 0, &stnetids, &totsize); X stnetids.integers = (Pint *)calloc(totsize, sizeof(Pint)); X ptk_inqstructnetids(stid, totsize, &stnetids, &totsize); `20 X for (i = 0; i < stnetids.number; i++) X `7B X writestruct(fileptr, stnetids.integers`5Bi`5D); X fprintf(fileptr, "\n\n"); X `7D X`7D /* writestructnet */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern ptkboolean ptk_readphinterscript(C(Pchar *) scriptname, C(FILE *) out Vput,`20 X C(FILE *) inform) XPreANSI(Pchar *scriptname) XPreANSI(FILE *output) XPreANSI(FILE *inform) X/* X** \parambegin X** \param`7BPchar *`7D`7Bscriptname`7D`7Bscript filename`7D`7BIN`7D X** \param`7BFILE *`7D`7Boutput`7D`7Boutput script file pointer`7D`7BOUT`7D X** \param`7BFILE *`7D`7Binform`7D`7Binformation script file pointer`7D`7BOUT V`7D X** \paramend X** \blurb`7BThis function reads a PHIGS script from the file specified X** by `7B\tt scriptname`7D. The file is automatically opened and closed X** and the function returns TRUE if a PHIGS script has been successfully`20 X** read.`7D X*/ X`7B X FILE *inputfile; X X inputfile = fopen(scriptname, "r"); X if (inputfile == NULL) X return FALSE; X rewind(inputfile); X ptk_phinter(inputfile, output, inform); X fclose(inputfile); X return TRUE; `20 X`7D /* ptk_readphinterscript */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_writestruct(C(FILE *) fileptr, C(Pintlst *) stids) XPreANSI(FILE *fileptr) XPreANSI(Pintlst *stids) X/* X** \parambegin X** \param`7BFILE *`7D`7Bfileptr`7D`7Bpointer to file`7D`7BOUT`7D X** \param`7BPintlst *`7D`7Bstids`7D`7Bstructure identifier list`7D`7BIN`7D X** \paramend X** \blurb`7BThis function writes the contents of a list of structures`20 X** to a file. The structures are written in the PHIGS script format so that X** they may be read in again using `7B\tt ptk\_phinter`7D.`7D X*/ X`7B X Pint i; X X if (fileptr != NULL) X `7B X for (i = 0; i < stids->number; i++) X `7B X writestruct(fileptr, stids->integers`5Bi`5D); X fprintf(fileptr, "\n\n"); X `7D X `7D X`7D /* ptk_writestruct */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_writestructnet(C(FILE *) fileptr, C(Pintlst *) stids) XPreANSI(FILE *fileptr) XPreANSI(Pintlst *stids) X/* X** \parambegin X** \param`7BFILE *`7D`7Bfileptr`7D`7Bpointer to file`7D`7BOUT`7D X** \param`7BPintlst *`7D`7Bstids`7D`7Bstructure network identifier list`7D`7 VBIN`7D X** \paramend X** \blurb`7BThis function writes the contents of a list of structure network Vs`20 X** to a file. The structures are written in the PHIGS script format so that X** they may be read in again using `7B\tt ptk\_phinter`7D.`7D X*/ X`7B X Pint i; X X if (fileptr != NULL) X `7B X for (i = 0; i < stids->number; i++) X `7B X writestructnet(fileptr, stids->integers`5Bi`5D); X fprintf(fileptr, "\n\n"); X `7D X `7D X`7D /* ptk_writestructnet */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_writeallstruct(C(FILE *) fileptr) XPreANSI(FILE *fileptr) X/* X** \parambegin X** \param`7BFILE *`7D`7Bfileptr`7D`7Bpointer to file`7D`7BOUT`7D X** \paramend X** \blurb`7BThis function writes the contents of all the structures in the X** PHIGS CSS to a file. The structures are written in the PHIGS script`20 X** format so that they may be read in again using `7B\tt ptk\_phinter`7D.`7D X*/ X`7B X Pint err, totlength, i; X Pintlst stids; X X if (fileptr != NULL) X `7B X pinqstructids(0, 0, &err, &stids, &totlength); X stids.integers = (Pint *)calloc(totlength, sizeof(Pint)); X stids.number = totlength; X pinqstructids(totlength, 0, &err, &stids, &totlength); X for (i = 0; i < stids.number; i++) X `7B X writestruct(fileptr, stids.integers`5Bi`5D); X fprintf(fileptr, "\n\n"); X `7D X free(stids.integers); `20 X `7D X`7D /* ptk_writeallstruct */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_readelem(C(Pint) ws, C(Plimit *) echoarea, C(Peltype) eltype V) XPreANSI(Pint ws) XPreANSI(Plimit *echoarea) XPreANSI(Peltype eltype) X/* X** \parambegin X** \param`7BPint`7D`7Bwsid`7D`7Bworkstation identifier`7D`7BIN`7D X** \param`7BPlimit *`7D`7Becho area`7D`7Becho area for string device`7D`7BIN V`7D X** \param`7BPeltype`7D`7Beltype`7D`7Belement type to read in`7D`7BIN`7D X** \paramend X** \blurb`7BThis function reads the contents of a PHIGS element from the`20 X** PHIGS string device (number 1). Prompts are given for the required data X** depending on the element type. An element with the input data is inserted X** into the currently open structure at the current editing position.`7D X*/ X`7B X fileswitch = FALSE; X phinws = ws; X phinecho = *echoarea; X writingscript = FALSE; X writeinform = FALSE; X switch (eltype) X `7B X case PEL_NIL: X break; X X case PEL_POLYLINE3: do_ppolyline3(); X break; X X case PEL_POLYMARKER3: do_ppolymarker3(); X break; X X case PEL_FILL_AREA3: do_pfillarea3(); X break; X X case PEL_POLYLINE: do_ppolyline(); X break; X X case PEL_POLYMARKER: do_ppolymarker(); X break; X X case PEL_FILL_AREA: do_pfillarea(); X break; X X case PEL_TEXT3: do_ptext3(); X break; X X case PEL_TEXT: do_ptext(); X break; X X case PEL_ANNOTATION_TEXT_RELATIVE3: do_pannotationtextrelative3(); X break; X X case PEL_ANNOTATION_TEXT_RELATIVE: do_pannotationtextrelative(); X break; X X case PEL_FILL_AREA_SET3: do_pfillareaset3(); X break; X X case PEL_FILL_AREA_SET: do_pfillareaset(); X break; X X case PEL_CELL_ARRAY3: do_pcellarray3(); X break; X X case PEL_CELL_ARRAY: do_pcellarray(); +-+-+-+-+-+-+-+- END OF PART 235 +-+-+-+-+-+-+-+-