-+-+-+-+-+-+-+-+ START OF PART 248 -+-+-+-+-+-+-+-+ X `7D X i++; X `7D X return found; X`7D X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_findelemtype(C(Peltype *) eltypelst, C(Pint) lenlst, X C(Psrchdir) srchdir, C(Psrchstatus *) srchstat,`20 X C(Pint *) elptr, C(Pint *) lstnum) XPreANSI(Peltype *eltypelst) XPreANSI(Pint lenlst) XPreANSI(Psrchdir srchdir) XPreANSI(Psrchstatus *srchstat) XPreANSI(Pint *elptr) XPreANSI(Pint *lstnum) X/* X** \parambegin X** \param`7BPeltype *`7D`7Beltypelst`7D`7Blist of element types`7D`7BIN`7D X** \param`7BPint`7D`7Blenlst`7D`7Blength of element type list`7D`7BIN`7D X** \param`7BPsrchdir`7D`7Bsrchdir`7D`7Bsearch direction, forwards or backwar Vds`7D`7BIN`7D X** \param`7BPsrchstatus *`7D`7Bsrchstat`7D`7Bsearch success or failure`7D`7B VOUT`7D X** \param`7BPint *`7D`7Belptr`7D`7Bfound element pointer`7D`7BOUT`7D X** \param`7BPint *`7D`7Blstnum`7D`7Bindex of found item in list`7D`7BOUT`7D X** \paramend X** \blurb`7BThis function searches X** the currently open X** structure, starting at the current element pointer and proceeding in X** direction \pardesc`7Bsrchdir`7D, for the first element whose type X** matches any of those given in \pardesc`7Bcontentlst`7D.`7D X*/ X`7B X Pint structid, elemptr; X Pint err; X Popenstructstatus status; X Pint maxelems; X Peltype etype; X#ifdef SUN X Pint esize; X#endif X#ifdef VMS X Pelsize esize; X#endif X X pinqopenstruct(&err, &status, &structid); `20 X if (status == PSTRUCT_NONE) X `7B X /* ptk_error("no open structure"); */ X `7D X else X `7B X pinqelemptr(&err, &elemptr); X maxelems = ptk_elemcount(structid); X *srchstat = PFAILURE; X while ((*srchstat == PFAILURE) && (elemptr >= 0) X && (elemptr <= maxelems)) X `7B X psetelemptr(elemptr); `20 X pinqcurelemtypesize(&err, &etype, &esize); X if (inelemlist(eltypelst, lenlst, etype, lstnum)) X `7B X *srchstat = PSUCCESS; X *elptr = elemptr; X `7D X else X `7B X if (srchdir == PFORWARD) X elemptr++; X else X elemptr--; X `7D X `7D X `7D X`7D /* ptk_findelemtype */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern ptkboolean ptk_findnextpickid(C(Pint) stid, C(Psrchdir) srchdir, X C(Pint *) eltptr, C(Pint *) pickid) XPreANSI(Pint stid) XPreANSI(Psrchdir srchdir) XPreANSI(Pint *eltptr) XPreANSI(Pint *pickid) X/* X** \parambegin X** \param`7BPint`7D`7Bstid`7D`7Bstructure identifier`7D`7BIN`7D X** \param`7BPsrchdir`7D`7Bsrchdir`7D`7Bsearch direction`7D`7BIN`7D X** \param`7BPint *`7D`7Beltptr`7D`7Belement pointer of pick identifier`7D`7B VOUT`7D X** \param`7BPint *`7D`7Bpickid`7D`7Bpick identifier value`7D`7BOUT`7D X** \paramend X** \blurb`7BThis function searches structure \pardesc`7Bstid`7D, starting X** at element \pardesc`7Belptr`7D and proceeding in direction \pardesc`7Bsrc Vhdir`7D, X** looking for a pick identifier structure element. The function X** returns TRUE if a pick identifier was found, otherwise FALSE.`7D X*/ X`7B X Pint openst; X Popenstructstatus openstat; X Pint err, oldp; X ptkboolean result; X Pint stat; X Psrchstatus searchstat; X Peltype eltype; X Pint lenlist, lstnum; X X ptk_openstruct(stid); X psetelemptr(*eltptr); X eltype = PEL_PICK_ID; X lenlist = 1; X ptk_findelemtype(&eltype, lenlist, srchdir, &searchstat, eltptr, &lstnum); X ptk_closestruct(); X if (searchstat == PSUCCESS) X `7B X ptk_getpickid(stid, *eltptr, pickid); X result = TRUE; X `7D X else X result = FALSE; X return result; X`7D /* ptk_findnextpickid */ X X/*------------------------------------------------------------------------*/ X X/*function:external*/ Xextern ptkboolean ptk_findlabel(C(Pint) label, C(Pint *) elemptr) XPreANSI(Pint label) XPreANSI(Pint *elemptr) X/* X** \parambegin X** \param`7BPint`7D`7Blabel`7D`7Blabel value`7D`7BIN`7D X** \param`7BPint *`7D`7Belemptr`7D`7Belement pointer of label element`7D`7BI VN/OUT`7D X** \paramend X** \blurb`7BThis function searches forwards through the currently open X** structure from the current editing position X** looking for a label structure element. The function X** returns TRUE if `7B\tt label`7D was found, otherwise FALSE.`7D X*/ X`7B X ptkboolean found; X Pint err, eptr; X Pchar *buffer; X ptkselcontent elcont; X X found = FALSE; X psetelemptrlabel(label); X pinqelemptr(&err, &eptr); X if (eptr == *elemptr) X `7B X ptk_inqcurelemtypesizecontent(&err, buffer, &elcont); X if (elcont.eltype == PEL_LABEL) X if (elcont.eldata.idata = label) X found = TRUE; X `7D X else X `7B X *elemptr = eptr; X found = TRUE; X `7D X return found; X`7D /* ptk_findlabel */ X X/*------------------------------------------------------------------------*/ X X/*function:external*/ Xextern void ptk_delelemtype(C(Pint) stid, C(Pint) lenlst,`20 X C(Peltype *) eltypelst) XPreANSI(Pint stid) XPreANSI(Pint lenlst) XPreANSI(Peltype *eltypelst) X/* X** \parambegin X** \param`7BPint`7D`7Bstid`7D`7Bstructure identifier`7D`7BIN`7D X** \param`7BPint`7D`7Blenlst`7D`7Blength of element type list`7D`7BIN`7D X** \param`7BPeltype *`7D`7Beltypelst`7D`7Blist of element types to delete`7D V`7BIN`7D X** \paramend X** \blurb`7BThis function deletes every element in structure \pardesc`7Bstid V`7D, whose X** type matches one of the types in \pardesc`7Beltypelst`7D`7D. X*/ X`7B X ptkboolean finished; X Psrchstatus srchstatus; X Pint elptr, lstnum; X X finished = FALSE; X elptr = 0; X ptk_openstruct(stid); X psetelemptr(elptr); X while (!finished) X `7B X ptk_findelemtype(eltypelst, lenlst, PFORWARD, &srchstatus,`20 X &elptr, &lstnum); X if (srchstatus == PSUCCESS) X `7B X psetelemptr(elptr); `20 X pdelelem(); X `7D X else X finished = TRUE; X `7D X ptk_closestruct(); X`7D /* ptk_delelemtype */ X X/*------------------------------------------------------------------------*/ X X/*function:external*/ Xextern void ptk_delelem(C(Pint) numelems) XPreANSI(Pint numelems) X/* X** \parambegin X** \param`7BPint`7D`7Bnumelems`7D`7Bnumber of elements to delete`7D`7BIN`7D X** \paramend X** \blurb`7BThis function deletes the \pardesc`7Bnumelms`7D elements from th Ve X** open structure, starting at the element pointer. If \pardesc`7Bnumelems`7 VD is X** 0, all elements up to the end of X** the structure are deleted.`7D X*/ X`7B X Pint i, range, err, elptr, stid, maxelems; X Popenstructstatus status; X X if (numelems == 0) X `7B X pinqopenstruct(&err, &status, &stid); X pinqelemptr(&err, &elptr); X maxelems = ptk_elemcount(stid); X range = maxelems - elptr; X `7D X else X range = numelems; X for (i = 0; i < range; i++) X `7B X pdelelem(); X poffsetelemptr(1); X `7D X poffsetelemptr(-1); X`7D /* ptk_delelem */ X X/*------------------------------------------------------------------------*/ X X/*function:external*/ Xextern Pint ptk_countchildren(C(Pint) stid) XPreANSI(Pint stid) X/* X** \parambegin X** \param`7BPint`7D`7Bstid`7D`7Bstructure identifier`7D`7BIN`7D X** \paramend X** \blurb`7BThe function returns the number of structures executed by struct Vure X** \pardesc`7Bstid`7D. X** This is the number of direct execute elements in the structure.`7D X*/ X`7B X Pint e, c; X Pint err; X Psrchstatus status; X Pint foundel; X#ifdef SUN X Psrcheltypelst includelst, excludelst; X#endif X#ifdef VMS X Peltype srchlist; X Pint srchlen; X#endif X Pint numels, openst, openelem, lstnum; X Popenstructstatus openstatus; X X e = 0; X c = 0; X numels = ptk_elemcount(stid); X#ifdef SUN X includelst.number = 1; X includelst.elems = (Psrcheltype *)malloc(sizeof(Psrcheltype)); X *(includelst.elems) = PSEL_EXECUTE_STRUCTURE; X excludelst.number = 0; X excludelst.elems = NULL; X#endif X#ifdef VMS X ptk_openstruct(stid); X#endif X do`20 X `7B X#ifdef SUN X pelemsrch(stid, e, PFORWARD, &includelst, &excludelst, &err, &status,`20 X &foundel); X#endif X#ifdef VMS X srchlist = PEL_EXECUTE_STRUCTURE; X srchlen = 1; X psetelemptr(e); X ptk_findelemtype(&srchlist, srchlen, PFORWARD, &status, &foundel,`20 X &lstnum); X#endif X e = foundel + 1; X if (status == PSUCCESS)`20 X `7B X c++; X `7D X `7D while ((status != PFAILURE) && (e <= numels)); X#ifdef VMS X ptk_closestruct(); X#endif X return c; X`7D /* ptk_countchildren */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern Pint ptk_countuniqchildren(C(Pint) stid) XPreANSI(Pint stid) X/* X** \parambegin X** \param`7BPint`7D`7Bstid`7D`7Bstructure identifier`7D`7BIN`7D X** \paramend X** \blurb`7BThis function returns the number of unique children of structur Ve X** \pardesc`7Bstid`7D. Thus, if a structure executed structures A, B and C, V it would X** have 3 unique children, regardless of how many times each of A, B and C w Vere X** executed.`7D X*/ X`7B X Pint e; X Pint err; X Psrchstatus status; X Pint foundel; X#ifdef SUN X Psrcheltypelst includelst, excludelst; X#endif X#ifdef VMS X Peltype srchlist; X Pint srchlen; X#endif X Pint numels, openst, openelem; X Popenstructstatus openstatus; X Pintlst children; X Pint childstid`5B255`5D, lstnum; X Pchar *buffer; X ptkselcontent elcont;; X X e = 0; X children.number = 0; X children.integers = childstid; X numels = ptk_elemcount(stid); X#ifdef SUN X includelst.number = 1; X includelst.elems = (Psrcheltype *)malloc(sizeof(Psrcheltype)); X *(includelst.elems) = PSEL_EXECUTE_STRUCTURE; X excludelst.number = 0; X excludelst.elems = NULL; X#endif X#ifdef VMS X ptk_openstruct(stid); X#endif X do`20 X `7B X#ifdef SUN X pelemsrch(stid, e, PFORWARD, &includelst, &excludelst, &err, &status,`20 X &foundel); X#endif X#ifdef VMS X srchlist = PEL_EXECUTE_STRUCTURE; X srchlen = 1; X psetelemptr(e); X ptk_findelemtype(&srchlist, srchlen, PFORWARD, &status, &foundel,`20 X &lstnum); X#endif X e = foundel + 1; X if (status == PSUCCESS)`20 X `7B X ptk_inqelemtypesizecontent(stid, foundel, &err, &buffer, &elcont); X if (inintlst(elcont.eldata.idata, &children) == -1) X children.integers`5Bchildren.number++`5D = elcont.eldata.idata; X free(buffer); X `7D X `7D while ((status != PFAILURE) && (e <= numels)); X#ifdef VMS X ptk_closestruct(); X#endif X return children.number; X`7D /* ptk_countuniqchildren */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_inqstructnetids(C(Pint) root, C(Pint) size,`20 X C(Pintlst *) stids, C(Pint *) totalsize) XPreANSI(Pint root) XPreANSI(Pint size) XPreANSI(Pintlst *stids) XPreANSI(Pint *totalsize) X/* X** \parambegin X** \param`7BPint`7D`7Broot`7D`7Bstructure network identifer`7D`7BIN`7D X** \param`7BPint`7D`7Bsize`7D`7Bnumber of integers allocated in integer list V`7D`7BIN`7D X** \param`7BPintlst *`7D`7Bstids`7D`7Blist of structure identifiers`7D`7BOUT V`7D X** \param`7BPint *`7D`7Btotalsize`7D`7Bactual number of integers in integer V list`7D`7BOUT`7D X** \paramend X** \blurb`7BThis function returns a X** list of structure identifiers in the structure network whose`20 X** root is \pardesc`7Broot`7D.`7D`20 X*/ X`7B X Pintlst stidlist; X Pint ids`5B255`5D; X Pint err, totsize, i, j; X Ppathorder order; X Pchar *buffer; X Pexecreflstlst paths; X X stidlist.number = 0; X stidlist.integers = ids; X pinqdescstruct(root, PTOP_FIRST, 0, 0, &err, buffer, &totsize, &paths); X buffer = (Pchar *)malloc(totsize); X pinqdescstruct(root, PTOP_FIRST, 0, totsize, &err, buffer, &totsize,`20 X &paths); `20 X for (i = 0; i < paths.number; i++) X `7B X for (j = 0; j < paths.erls`5Bi`5D.number; j++) X `7B X if (inintlst(paths.erls`5Bi`5D.ers`5Bj`5D.struct_id, &stidlist) == -1) X stidlist.integers`5Bstidlist.number++`5D = paths.erls`5Bi`5D.ers`5Bj V`5D.struct_id; X `7D X `7D X free(buffer); X if (ptk_structexists(root) && (stidlist.number == 0)) X stidlist.integers`5Bstidlist.number++`5D = root; X stids->number = *totalsize = stidlist.number; X if (size >= stidlist.number) X `7B X for (i = 0; i < stidlist.number; i++) X stids->integers`5Bi`5D = stidlist.integers`5Bi`5D; X `7D X`7D /* ptk_inqstructnetids */ X X/*-------------------------------------------------------------------------- V*/ X `20 X/*function:external*/ Xextern void ptk_structsummary(C(FILE *) fileptr) XPreANSI(FILE *fileptr) X/* X** \parambegin X** \param`7BFILE *`7D`7Bfileptr`7D`7Bfile pointer`7D`7BIN`7D X** \paramend X** \blurb`7BThis function outputs a summary of all the structures in the CSS V to X** file \pardesc`7Bfileptr`7D, which should be an open writeable file. X** The structure identifier of each structure is printed, together`20 X** with its hashed string name, if it has one. The format`20 X** of the list is: `7B\tt \\ X** \ \ \ \ \ List of structures in the CSS\\ X** \ \ \ \ \ -----------------------------\\ X** \ \\ X** \ \ \ \ \ structure 1 "helicopter"\\ X** \ \ \ \ \ structure 45 \\ X** \ \ \ \ \ structure 51 "helicopter"\\ X** \ \ \ \ \ etc. `7D X** .`7D X*/ X`7B X Pint length, totallength; X Pintlst stlist; X Pint *stids; X Pint error, stringlen; X Pchar str`5B255`5D; X Pint i; X ptkboolean dostring; X X length = 0; X pinqstructids(length, 0, &error, &stlist, &totallength); X length = totallength; X stids = (Pint *)calloc(length, sizeof(Pint)); X stlist.integers = stids; X pinqstructids(length, 0, &error, &stlist, &totallength); X if (error != 0)`20 X `7B X /* ptk_error(error in ptk_structsummary) */ X return; X `7D X dostring = ptk_hashtableused("structureid");`20 X fprintf(fileptr, "List of structures in the CSS\n"); X fprintf(fileptr, "-----------------------------\n"); X for (i = 0; i < stlist.number; i++)`20 +-+-+-+-+-+-+-+- END OF PART 248 +-+-+-+-+-+-+-+-