libsrc/test.cxx

Go to the documentation of this file.
00001 /**********************************************************************
00002  * Copyright 2002 Jeff Rush <jrush@taupro.com>
00003  * Original Copyright 1979-2002 Udanax.com
00004  *
00005  * This file is part of the Udanax xanalogical storage system.
00006  *
00007  * Udanax is free software; you can redistribute it and/or modify it
00008  * under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or
00010  * (at your option) any later version.
00011  *
00012  * Udanax is distributed in the hope that it will be useful, but
00013  * WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with Udanax; if not, write to the Free Software Foundation,
00019  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  **********************************************************************/
00021 
00030 /* Modification History:
00031  * $Log: test.cxx,v $
00032  * Revision 1.14  2004/09/11 13:59:21  jrush
00033  * Changed all fprintf's to stderr to use the Nana library L() macro.  Also
00034  * removed a 2-3 minor compiler warnings.
00035  *
00036  * Revision 1.13  2004/09/04 16:02:18  jrush
00037  * Added Doxygen headers before each and every function definition.
00038  *
00039  * Revision 1.12  2002/07/26 04:33:47  jrush
00040  * Replaced gerror() with assert()
00041  *
00042  * Revision 1.11  2002/05/28 04:22:29  jrush
00043  * Adjusted source files to comply with GPL licensing.
00044  *
00045  * Revision 1.10  2002/05/28 02:48:03  jrush
00046  * Removed unused extern variable declarations.
00047  *
00048  * Revision 1.9  2002/04/12 11:56:43  jrush
00049  * Reorganized include file layout, renamed xanadu.h to udanax.h and
00050  * typecontext/typecrumcontext to C++ class Context/CrumContext.
00051  *
00052  * Revision 1.8  2002/04/09 21:45:46  jrush
00053  * Renamed class 'tumbler' to 'Tumbler', for consistency with Python sources,
00054  * and changed typeisa from typedef to a subclass, in preparation for cleaning
00055  * up the type/class tree.
00056  *
00057  * Revision 1.7  2002/04/07 14:03:48  jrush
00058  * Moved console-interactive functions examine(), showorgl() and showenfilades()
00059  * from libsrc/test.cxx to server/fns.cxx.
00060  *
00061  * Revision 1.6  2002/04/06 17:05:57  jrush
00062  * Switched from referring to 'task' for a client connection to 'session',
00063  * and converted the typetask typedef/struct into a Session C++ class.
00064  *
00065  * Revision 1.5  2002/04/06 15:01:17  jrush
00066  * Changed INT to just 'int'.
00067  *
00068  * Revision 1.4  2002/04/06 14:11:46  jrush
00069  * Added functions to graph POOMs and tweaked DOT settings.
00070  *
00071  * Revision 1.3  2002/04/02 18:45:48  jrush
00072  * Defined functions to output graphs of enfilades, and uncommented existing
00073  * code that verifies an enfilade tree is valid, for further testing.
00074  *
00075  * Revision 1.2  2002/02/14 09:27:43  jrush
00076  * Cleaned up source:
00077  *
00078  * 1. ran thru the indent tool to achieve a standard look,
00079  * 2. added structured comments at top for use with DOxygen reporting
00080  *    as well as CVS keywords,
00081  * 3. fixed compiler warnings re ambiguous assign/compares,
00082  *    needed casts and unused/uninitialized variables,
00083  * 4. fixed funcs that didn't specify a return type,
00084  * 5. centralized prototypes in protos.h, removing incomplete ones,
00085  * 6. cleaned up use of bool/BOOLEAN type to suit C++ type,
00086  * 7. fixed initializer nesting in tumbler constants,
00087  * 8. renamed vars that conflict with C++ keywords (new, this),
00088  * 9. fixed global/extern confusion re some global vars.
00089  *
00090  */
00091 
00092 /* 
00093  *      testenf.c -- a file of functions written to test
00094  *      Two dimensional enfilades
00095  *      created 79/11/12
00096  *      modified as intest.c to test
00097  *      2d, Span and Gran enfilades
00098  *      on 80/10/12
00099  */
00100 
00101 #include <unistd.h>
00102 #include <memory.h>
00103 #include <stdlib.h>
00104 #include <fcntl.h>
00105 #include <ctype.h>
00106 #include "udanax.h"
00107 
00108 extern typecorecrum *grimreaper;
00109 extern int reservnumber;
00110 int numfoo = NUMDISKBLOCKSINLOAF;
00111 int debug;
00112 
00113 //UNUSED extern char end;        /* lower limit (pointers should be into alloc space */
00114 //UNUSED extern char etext;      /* as another lower limit on valid pointers */
00115 
00116 extern long nolread;
00117 static long nowread;
00118 
00119 void graphpoom(FILE *fd, typecorecrum *ptr);
00120 void graphcrum(FILE *fd, typecorecrum *ptr, typedsp *offsetptr, char *indent);
00121 void graphwid(FILE *fd, typewid *widptr, int enftype);
00122 void graphdsp(FILE *fd, typewid *dspptr, int enftype);
00123 void graphoffset(FILE *fd, typedsp *dspptr, int enftype);
00124 char *nodeid(typecorecrum *ptr, char *s);
00125 
00133     void
00134 foo(
00135     char *msg)
00136 {
00137 #ifndef DISTRIBUTION
00138     if (debug)
00139         L(msg);
00140 #endif
00141 }
00142 
00150     void
00151 foospan(
00152     char     *msg,
00153     typespan *span)
00154 {
00155 #ifndef DISTRIBUTION
00156     if (debug) {
00157         L(msg);
00158         dumpspan(span);
00159     }
00160 #endif
00161 }
00162 
00170     void
00171 foospanset(
00172     char     *msg,
00173     typespan *spanset)
00174 {
00175 #ifndef DISTRIBUTION
00176     if (debug) {
00177         L(msg);
00178         if (!spanset) {
00179             L("null spanset\n");
00180         } else {
00181             for (; spanset; spanset = spanset->next) {
00182                 dumpspan(spanset);
00183             }
00184         }
00185     }
00186 #endif
00187 }
00188 
00196     void
00197 dumpspanset(
00198     typespan *spanset)
00199 {
00200 #ifndef DISTRIBUTION
00201     if (!spanset) {
00202         L("null spanset\n");
00203     } else {
00204         for (; spanset; spanset = spanset->next) {
00205             dumpspan(spanset);
00206         }
00207     }
00208 #endif
00209 }
00210 
00218     void
00219 foocrum(
00220     char         *msg,
00221     typecorecrum *crumptr)
00222 {
00223 #ifndef DISTRIBUTION
00224     if (debug) {
00225         L(msg);
00226         dump(crumptr);
00227     }
00228 #endif
00229 }
00230 
00238     void
00239 foohex(
00240     char *msg,
00241     int   num)
00242 {
00243 #ifndef DISTRIBUTION
00244     if (debug)
00245         L("%s %x\n", msg, num);
00246 #endif
00247 }
00248 
00256     void
00257 foodec(
00258     char *msg,
00259     int   num)
00260 {
00261 #ifndef DISTRIBUTION
00262     if (debug)
00263         L("%s %d\n", msg, num);
00264 #endif
00265 }
00266 
00274     void
00275 foocontext(
00276     char    *msg,
00277     Context *context)
00278 {
00279 #ifndef DISTRIBUTION
00280     if (debug) {
00281         L(msg);
00282         dumpcontext(context);
00283     }
00284 #endif
00285 }
00286 
00294     void
00295 foocontextlist(
00296     char    *msg,
00297     Context *context)
00298 {
00299 #ifndef DISTRIBUTION
00300     if (debug) {
00301         L(msg);
00302         dumpcontextlist(context);
00303     }
00304 #endif
00305 }
00306 
00314     void
00315 fooitemset(
00316     char        *msg,
00317     typeitemset  iptr)
00318 {
00319 #ifndef DISTRIBUTION
00320     if (debug) {
00321         L(msg);
00322         dumpitemset(iptr);
00323     }
00324 #endif
00325 }
00326 
00334     void
00335 fooitem(
00336     char     *msg,
00337     typeitem *iptr)
00338 {
00339 #ifndef DISTRIBUTION
00340     if (debug) {
00341         L(msg);
00342         dumpitem(iptr);
00343         L("\n");
00344     }
00345 #endif
00346 }
00347 
00355     void
00356 footumbler(
00357     char    *msg,
00358     Tumbler *tptr)
00359 {
00360 #ifndef DISTRIBUTION
00361     if (debug) {
00362         L(msg);
00363         if (tptr)
00364             puttumbler(stderr, tptr);
00365         else
00366             L("NULL");
00367         L("\n");
00368     }
00369 #endif
00370 }
00371 
00379     void
00380 foodsp(
00381     char    *msg,
00382     typedsp *dptr,
00383     int      enftype)
00384 {
00385 #ifndef DISTRIBUTION
00386     if (debug) {
00387         L(msg);
00388         if (dptr)
00389             dumpdsp(dptr, enftype);
00390         else
00391             L("NULL");
00392         L("\n");
00393     }
00394 #endif
00395 }
00396 
00404     void
00405 foowid(
00406     char    *msg,
00407     typewid *wptr,
00408     int      enftype)
00409 {
00410 #ifndef DISTRIBUTION
00411     if (debug) {
00412         L(msg);
00413         if (wptr)
00414             dumpwid(wptr, enftype);
00415         else
00416             L("NULL");
00417         L("\n");
00418     }
00419 #endif
00420 }
00421 
00429 /* pass this the fullcrum to dump the entire (incore) enfilade */
00430     void
00431 dumpsubtree(
00432     typecuc *father)
00433 {
00434 #ifndef DISTRIBUTION
00435     typecorecrum *ptr;
00436 
00437     if (father->cenftype == POOM) {
00438         dumppoomwisps((typecorecrum *) father);
00439         return;
00440     }
00441     dump((typecorecrum *) father);
00442     if (father->height <= 0)
00443         return;
00444     for (ptr = father->leftson; ptr; ptr = ptr->rightbro)
00445         dumpsubtree((typecuc *) ptr);
00446 #endif
00447 }
00448 
00456     void
00457 dumpwholesubtree(
00458     typecuc *father)
00459 {
00460 #ifndef DISTRIBUTION
00461     L("dump whole subtree");
00462 
00463     if (father->cenftype == POOM) {
00464         dumppoomwisps((typecorecrum *) father);
00465         return;
00466     }
00467 
00468     dump((typecorecrum *) father);
00469 
00470     if (father->height <= 0)
00471         return;
00472 
00473     typecorecrum *ptr;
00474     for (ptr = findleftson(father); ptr; ptr = findrightbro(ptr))
00475         dumpwholesubtree((typecuc *) ptr);
00476 #endif
00477 }
00478 
00486     void
00487 graphwholesubtree(
00488     FILE    *fd,
00489     typecuc *father,
00490     typedsp *offsetptr,
00491     char    *indent)
00492 {
00493     typecorecrum *ptr;
00494 //jrr    if (father->cenftype == POOM) {
00495 //jrr        dumppoomwisps((typecorecrum *) father);
00496 //jrr        return;
00497 //jrr    }
00498 
00499     graphcrum(fd, (typecorecrum *) father, offsetptr, indent);
00500 
00501     if (father->height <= 0)
00502         return;
00503 
00504     if (strlen(indent) == 0) {
00505         fprintf(fd, "\n  { rank=same; ");
00506 
00507         for (ptr = findleftson(father); ptr; ptr = findrightbro(ptr)) {
00508             char temp[10];
00509             fprintf(fd, "%s; ", nodeid(ptr, temp));
00510         }
00511         fprintf(fd, "} /* height = %u */\n\n", findleftson(father)->height);
00512     }
00513 
00514     for (ptr = findleftson(father); ptr; ptr = findrightbro(ptr)) {
00515         graphwholesubtree(fd, (typecuc *) ptr, offsetptr, indent);
00516     }
00517 }
00518 
00526     void
00527 assertspecisstring(
00528     typespecset  specptr,
00529     char        *string)
00530 {
00531 #ifndef DISTRIBUTION
00532     Session sessfoo;          
00533     typevstuffset vstuffset;
00534     //UNUSED int i;
00535     int savedebug;
00536 
00537     L("assertspecisstring entering \n");
00538     savedebug = debug;
00539 
00540 /* debug = false; */
00541 
00542     //Now done via a ctor:: inittask(&sessfoo);
00543 
00544     doretrievev(&sessfoo, specptr, &vstuffset);
00545 
00546 // for(i=0;(i<vstuffset->length)&&(string[i] == vstuffset->string[i]);i++) ; if(i != vstuffset->length){
00547 // L("in assertspecisstring failedstring1 =%s string2 =%s
00548 // %d\n",string,vstuffset->string,vstuffset->length); debug = true; fooitem("spec is ",specptr); fooitem("\nvstuff is
00549 // ",vstuffset); // crash bang boom // assert(0); /* assertspecisstring asserton failed \n */; } L("in
00550 // assertspecisstring succeded %s \n",string);
00551 
00552     L("in assertspecisstring string2 =%s %d\n", vstuffset->xxxtext.string, vstuffset->xxxtext.length);
00553     sessfoo.free();
00554     debug = savedebug;
00555     L("assertspecisstring leaving \n");
00556 #endif
00557 }
00558 
00566     bool
00567 asserttreeisok(
00568     typecorecrum *ptr)
00569 {
00570 //    L("--asserttreeisok is a NOP--\n");
00571 //    return (true);
00572 
00573     L("entering asserttreeisok\n");
00574     for (; !isfullcrum(ptr); ptr = (typecorecrum *) findfather(ptr)); assertsubtreeisok(ptr)
00575         ;
00576         
00577     return(true);
00578 }
00579 
00587     void
00588 assertsubtreeisok(
00589     typecorecrum *ptr)
00590 {
00591 #ifndef DISTRIBUTION
00592     typecorecrum *son;
00593 
00594     if (!ptr)
00595         assert(0); // assertsubtreeok failed null ptr
00596 
00597     assertwidsarepositive(ptr);
00598     if (!reservnumber) {
00599         if (ptr->age == RESERVED) {
00600             dump(ptr);
00601             assert(0); // incorrect reserved in assertsubtreeisok
00602         }
00603     }
00604 
00605     if (ptr->height == 0)
00606         return;
00607 
00608 // if (toomanysons(ptr)) { // dump(ptr); L("fatherhas too many sons\n"); // //assert(0); "foo"// }
00609 
00610     assertsonswispmatchesfather((typecuc *) ptr);
00611     for (son = ((typecuc *) ptr)->leftson /* findleftson//getleftson//(ptr) */ ;
00612          son; son = son->rightbro) {
00613         assertsubtreeisok(son);
00614     }
00615 #endif
00616 }
00617 
00625     void
00626 assertsonswispmatchesfather(
00627     typecuc *father)
00628 {
00629 #ifndef DISTRIBUTION
00630     //UNUSED typecorecrum *son;
00631 
00632     if (father->numberofsons == 0) {
00633         if (father->sonorigin.diskblocknumber != DISKPTRNULL)
00634             return;
00635 
00636         L("zerosons in assert\n");
00637         return;
00638     }
00639 
00640     if (setwisp((typecorecrum *) father)) {
00641         L("assert wisp matched father failed \n");
00642         dump((typecorecrum *) father);
00643         dumpwholetree((typecorecrum *) father);
00644 
00645         assert(0); // father didn't match sons wid and disp
00646     }
00647 #endif
00648 }
00649 
00657     void
00658 assertwidsarepositive(
00659     typecorecrum *ptr)
00660 {
00661 #ifndef DISTRIBUTION
00662     int nstreams, i;
00663 
00664     int enftype = ptr->cenftype;
00665 
00666     if (enftype == GRAN)
00667         return;
00668 
00669     nstreams = widsize(enftype);
00670     for (i = 0; i < nstreams; ++i) {
00671         tumblercheckptr(&(ptr->cwid.dsas[i]), (int *) ptr);
00672     }
00673 
00674     nstreams = dspsize(enftype);
00675     for (i = 0; i < nstreams; ++i) {
00676         tumblercheckptr(&(ptr->cdsp.dsas[i]), (int *) ptr);
00677     }
00678 #endif
00679 }
00680 
00688     void
00689 dumpwholetree(
00690     typecorecrum *ptr)
00691 {
00692 #ifndef DISTRIBUTION
00693     L("dump whole tree\n");
00694 
00695     for (; !isfullcrum(ptr); ptr = (typecorecrum *) findfather(ptr))
00696         ;
00697 
00698     dumpwholesubtree((typecuc *) ptr);
00699 #endif
00700 }
00701 
00709     void
00710 graphwholetree(
00711     char         *filename,
00712     typecorecrum *ptr,
00713     char         *graphlabel)
00714 {
00715     FILE *fd = fopen(filename, "w");
00716 
00717     fprintf(fd, "digraph G {\n");
00718     fprintf(fd, "    nodesep=0.40;\n");
00719     fprintf(fd, "    ranksep=\"0.40 equally\";\n");
00720     fprintf(fd, "    center=true;\n");
00721     fprintf(fd, "    page=\"8.5, 11\"; /* unit of pagination */\n");
00722     fprintf(fd, "    size=\"8.25, 10.75\";\n");
00723     fprintf(fd, "    /* ratio=auto; */\n");
00724     fprintf(fd, "    orientation=landscape;\n");
00725     fprintf(fd, "    label=\"%s\";\n", graphlabel);
00726     fprintf(fd, "    fontsize=14;\n");
00727     fprintf(fd, "    fontcolor=blue;\n");
00728     fprintf(fd, "\n");
00729     fprintf(fd, "    node [shape = record];\n");
00730     fprintf(fd, "\n");
00731 
00732     for (; !isfullcrum(ptr); ptr = (typecorecrum *) findfather(ptr))
00733         ;
00734 
00735     typedsp offset;
00736     clear(&offset, sizeof(offset));
00737 
00738     graphwholesubtree(fd, (typecuc *) ptr, &offset, "");
00739 
00740     fprintf(fd, "    A [width=0.1, height=0.1, style=invis];\n");
00741     fprintf(fd, "    B [width=0.1, height=0.1, style=invis];\n");
00742     fprintf(fd, "    C [width=0.1, height=0.1, style=invis];\n");
00743     fprintf(fd, "    A -> B [style=invis];\n");
00744     fprintf(fd, "    B -> C [style=invis];\n");
00745 
00746     fprintf(fd, "}\n");
00747     fclose(fd);
00748 }
00749 
00757     void
00758 graphpoom(
00759     FILE         *fd,
00760     typecorecrum *ptr)
00761 {
00762     fprintf(fd, "\n    subgraph cluster_%08X {\n", (int) ptr);
00763 
00764     for (; !isfullcrum(ptr); ptr = (typecorecrum *) findfather(ptr))
00765         ;
00766 
00767     typedsp offset;
00768     clear(&offset, sizeof(offset));
00769 
00770     graphwholesubtree(fd, (typecuc *) ptr, &offset, "    ");
00771 
00772     fprintf(fd, "\n");
00773     fprintf(fd, "        label = \"POOM\";\n");
00774     fprintf(fd, "        color = royalblue;\n");
00775     fprintf(fd, "        fillcolor = lightgrey;\n");
00776     fprintf(fd, "        style = filled;\n");
00777     fprintf(fd, "    }\n\n");
00778 }
00779 
00787     int
00788 checkwholesubtree(
00789     typecuc *father)
00790 {
00791 #ifndef DISTRIBUTION
00792     //UNUSED typecorecrum *ptr;
00793 
00794     return 0;
00795 
00796 #ifdef UndEfIneD
00797     if (!father)
00798         return 0;
00799 
00800     if (check(father)) {
00801         L("found something bad in checkwholesubtree\n");
00802         dumpsubtree(father);
00803 
00804         // assert(0); // in checkwholesubtree
00805         return 1;
00806     }
00807 
00808     if (father->height <= 0)
00809         return 0;
00810 
00811     for (ptr = father->leftson; ptr; ptr = ptr->rightbro)
00812         if (checkwholesubtree(ptr))
00813             return 1;
00814 
00815     return 0;
00816 #endif
00817 #endif
00818 }
00819 
00827     int
00828 check(
00829     typecuc *ptr)
00830 {
00831     return 0;
00832 
00833 #ifdef UnDeeFiNeD
00834     if (ptr->height == 0) {
00835         return 0;
00836     }
00837 
00838     if (ptr->leftson == NULL           /* &&ptr->sonorigin.diskblocknumber==-1 */
00839         && ptr->modified) {
00840         dump(ptr);
00841         assert(0); // in check
00842     } else {
00843         return 0;
00844     }
00845 
00846     assert(0); // check: can't get there
00847     return 0;
00848 #endif
00849 }
00850 
00858                /* dump a core crum */
00859     void
00860 dump(
00861     typecorecrum *ptr)
00862 {
00863 #ifndef DISTRIBUTION
00864     L("\n");
00865     dumphedr(ptr);
00866 
00867     if (ptr->height) {
00868         L("sonorigin = %x insideloaf %x  leftson = %x  #sons = %x\n",
00869                 ((typecuc *) ptr)->sonorigin.diskblocknumber, ((typecuc *) ptr)->sonorigin.insidediskblocknumber,
00870                 (int) ((typecuc *) ptr)->leftson, ((typecuc *) ptr)->numberofsons);
00871     } else {
00872         dumpinfo(&((typecbc *) ptr)->cinfo, ptr->cenftype);
00873     }
00874 #endif
00875 }
00876 
00884     char *
00885 safetext(
00886     char *s)
00887 {
00888     static char buffer[11];
00889     char *p = buffer;
00890 
00891     while (*s && p < &buffer[ sizeof(buffer)-2 ]) {
00892         if (!isalnum(*s))
00893             *p++ = '\\';
00894         *p++ = *s++;
00895     }
00896     *p = '\0';
00897     return buffer;
00898 }
00899 
00907     char *
00908 nodeid(
00909     typecorecrum *ptr,
00910     char         *s)
00911 {
00912     char c;
00913 
00914     switch (ptr->cenftype) {
00915     case GRAN:  c = 'G';  break; // GRAN
00916     case SPAN:  c = 'S';  break; // SPAN
00917     case POOM:  c = 'P';  break; // POOM
00918     default:    c = 'x';  break;
00919     }
00920     sprintf(s, "%c%08X", c, (int) ptr);
00921     return s;
00922 }
00923 
00931     char *
00932 nodecolor(
00933     typecorecrum *ptr)
00934 {
00935     switch (ptr->cenftype) {
00936     case GRAN: return "darkgreen";  break;
00937     case POOM: return "blue";       break;
00938     case SPAN: return "red";        break;
00939     default:   return "black";      break;
00940     }
00941 }
00942 
00950     char *
00951 nodefillcolor(
00952     typecorecrum *ptr)
00953 {
00954     switch (ptr->cenftype) {
00955     case GRAN: return "palegreen";  break;
00956     case POOM: return "powderblue"; break;
00957     case SPAN: return "pink";       break;
00958     default:   return "black";      break;
00959     }
00960 }
00961 
00968                /* dump a core crum */
00969     void
00970 graphcrum(
00971     FILE         *fd,
00972     typecorecrum *ptr,
00973     typedsp      *offsetptr,
00974     char         *indent)
00975 {
00976     const char *full = (ptr->isapex ? "(top)" : "");
00977     char mynodeid[10], hisnodeid[10];
00978     typecorecrum *orgl = NULL;
00979 
00980     nodeid(ptr, mynodeid);
00981 
00982     char *color     = nodecolor(ptr);
00983     char *fillcolor = nodefillcolor(ptr);
00984 
00985     // Define Attributes of This Node
00986     fprintf(fd, "%s    %s [color=%s, fillcolor=%s, style=filled, label = \"", indent, mynodeid, color, fillcolor);
00987     fprintf(fd, "{ %s\\nheight=%u %s |",
00988                 mynodeid, ptr->height, full);
00989 
00990     if (ptr->cenftype != GRAN)
00991         graphdsp(fd, &ptr->cdsp, ptr->cenftype);
00992 
00993     graphwid(fd, &ptr->cwid, ptr->cenftype);
00994     graphoffset(fd, offsetptr, ptr->cenftype);
00995 
00996     if (ptr->height == 0 && ptr->cenftype == GRAN) {
00997         int infotype = ((typecbc *) ptr)->cinfo.infotype;
00998         typegrantext *gtext;
00999         typegranorgl *gorgl;
01000         char *safe, *ellipse;
01001 
01002         switch (infotype) {
01003         case GRANTEXT:
01004             gtext = &((typecbc *) ptr)->cinfo.granstuff.textstuff;
01005             safe = safetext(gtext->textstring);
01006             if (gtext->textlength > strlen(safe)) ellipse = "...";
01007             else ellipse = "";
01008             fprintf(fd, " | TEXT[%u]\\n'%s'%s", gtext->textlength, safe, ellipse);
01009             break;
01010         case GRANORGL:
01011             gorgl = &((typecbc *) ptr)->cinfo.granstuff.orglstuff;
01012             orgl = (typecorecrum *) gorgl->orglptr; // Used Below
01013             fprintf(fd, " | ORGL");
01014             break;
01015         case GRANNULL:  fprintf(fd, " | NULL"); break;
01016         default:        fprintf(fd, " | { err=\\< ???? \\>\\l }"); break;
01017         }
01018     }
01019 
01020     if (ptr->height) {
01021         fprintf(fd, " | nsons=%u ", ((typecuc *) ptr)->numberofsons);
01022     }
01023     fprintf(fd, "}\"];\n");
01024 
01025     // Define Connections of This Node
01026     if (ptr->rightbro)
01027         fprintf(fd, "%s    %s -> %s [tailport=e, headport=w, taillabel=RBRO, labeldistance=2, labelfontname=Helvetica, labelfontsize=10, labelfontcolor=%s, color=%s];\n",
01028                     indent, mynodeid, nodeid(ptr->rightbro, hisnodeid), nodecolor(ptr->rightbro), nodecolor(ptr->rightbro));
01029 
01030     if (ptr->leftbroorfather) {
01031         if (ptr->isleftmost)
01032             fprintf(fd, "%s    %s -> %s [tailport=n, headport=s, taillabel=FATHER, labeldistance=2, labelfontname=Helvetica, labelfontsize=10, labelfontcolor=%s, color=%s];\n",
01033                         indent, mynodeid, nodeid(ptr->leftbroorfather, hisnodeid), nodecolor(ptr->leftbroorfather), nodecolor(ptr->leftbroorfather));
01034         else
01035             fprintf(fd, "%s    %s -> %s [tailport=w, headport=e, taillabel=LBRO, labeldistance=2, labelfontname=Helvetica, labelfontsize=10, labelfontcolor=%s, color=%s];\n",
01036                         indent, mynodeid, nodeid(ptr->leftbroorfather, hisnodeid), nodecolor(ptr->leftbroorfather), nodecolor(ptr->leftbroorfather));
01037     }
01038 
01039     if (orgl)
01040         fprintf(fd, "%s    %s -> %s [tailport=s, headport=n, taillabel=SON, labeldistance=2, labelfontname=Helvetica, labelfontsize=10, labelfontcolor=%s, color=%s];\n",
01041                     indent, mynodeid, nodeid(orgl, hisnodeid), nodecolor(orgl), nodecolor(orgl));
01042 
01043     if (ptr->height) {
01044         fprintf(fd, "%s    %s -> %s [tailport=s, headport=n, taillabel=SON, labeldistance=2, labelfontname=Helvetica, labelfontsize=10, labelfontcolor=%s, color=%s];\n",
01045                     indent, mynodeid, nodeid(((typecuc *) ptr)->leftson, hisnodeid), nodecolor(((typecuc *) ptr)->leftson), nodecolor(((typecuc *) ptr)->leftson));
01046     } else {
01047 //        if (ptr->cenftype == GRAN) {
01048 //            typegranbottomcruminfo *cinfo = &((typecbc *) ptr)->cinfo;
01049 //
01050 //struct structorgl {
01051 //    struct structcuc *orglptr;
01052 //    typediskloafptr diskorglptr;
01053 //};
01054 //
01055 //        } else {
01056 //        //    type2dbottomcruminfo c2dinfo;
01057 //        }
01058     }
01059 
01060 //    if (ptr->height == 0 && ptr->cenftype == GRAN) {
01061 //        int infotype = ((typecbc *) ptr)->cinfo.infotype;
01062 //        if (infotype == GRANORGL) {
01063 //            typegranorgl *gorgl = &((typecbc *) ptr)->cinfo.granstuff.orglstuff;
01064 //            graphpoom(fd, (typecorecrum *) gorgl->orglptr);
01065 //        }
01066 //    }
01067 
01068     if (orgl)
01069         graphpoom(fd, orgl);
01070 
01071 //    L("%s %scrum core location = %x\n", temp, full, (int) ptr);
01072 //    L("height = %x nextcrum = %x  modified = %x\n", ptr->height, (int) ptr->nextcrum, ptr->modified);
01073 //    L(" age = %x ", ptr->age);
01074 //    L("isleftmost = %x leftbro = %x rightbro = %x\n", ptr->isleftmost, (int) ptr->leftbroorfather, (int) ptr->rightbro);
01075 
01076 //    dumpdsp(&ptr->cdsp, ptr->cenftype);
01077 //    dumpwid(&ptr->cwid, ptr->cenftype);
01078 
01079 
01080 //    if (ptr->height) {
01081 //        L("sonorigin = %x insideloaf %x  leftson = %x  #sons = %x\n",
01082 //                ((typecuc *) ptr)->sonorigin.diskblocknumber, ((typecuc *) ptr)->sonorigin.insidediskblocknumber,
01083 //                (int) ((typecuc *) ptr)->leftson, ((typecuc *) ptr)->numberofsons);
01084 //    } else {
01085 //        dumpinfo(&((typecbc *) ptr)->cinfo, ptr->cenftype);
01086 //    }
01087 
01088     if (ptr->height == 0)
01089         dspadd(offsetptr, &ptr->cwid, offsetptr, ptr->cenftype);
01090 }
01091 
01099     void
01100 yesdump(
01101     typecorecrum *ptr)
01102 {                                      /* because dbx has a builtin dump name * * conflict */
01103 #ifndef DISTRIBUTION
01104     dump(ptr);
01105 #endif
01106 }
01107 
01115                  /* dump a corecrumhedr */
01116     void
01117 dumphedr(
01118     typecorecrumhedr *ptr)
01119 {
01120 #ifndef DISTRIBUTION
01121     char *temp;
01122 
01123     switch (ptr->cenftype) {
01124     case GRAN:  temp = "GRAN";  break;
01125     case SPAN:  temp = "SPAN";  break;
01126     case POOM:  temp = "POOM";  break;
01127     default:    temp = "????";  L(" %d ", ptr->cenftype); break;
01128     }
01129 
01130     const char *full = (ptr->isapex ? "full" : "");
01131 
01132 //                   ===GRAN fullcrum height=0
01133 //  00000000 <  coreaddr@xxxxxxxx  > 00000000
01134 //            | age=dd  modified=1  next@xxxxxxxx
01135 //            | dsp = < 0 >
01136 //            | wid = < 1.7.0.9.0.1.0.1 >
01137 //            \         v               /
01138 //                  00000000
01139 
01140 //            /--GRAN fullcrum h=0
01141 //  00000000 <  coreaddr@xxxxxxxx  > 00000000
01142 //            | age=dd  modified=1  next@xxxxxxxx
01143 //            | dsp = < 0 >
01144 //            | wid = < 1.7.0.9.0.1.0.1 >
01145 //            \         v               /
01146 //                  00000000
01147 
01148 
01149 
01150     L("%s %scrum core location = %x\n", temp, full, (int) ptr);
01151     L("height = %x nextcrum = %x  modified = %x\n", ptr->height, (int) ptr->nextcrum, ptr->modified);
01152     L(" age = %x ", ptr->age);
01153     L("isleftmost = %x leftbro = %x rightbro = %x\n", ptr->isleftmost, (int) ptr->leftbroorfather, (int) ptr->rightbro);
01154 
01155     dumpdsp(&ptr->cdsp, ptr->cenftype);
01156     dumpwid(&ptr->cwid, ptr->cenftype);
01157 #endif
01158 }
01159 
01167     void
01168 dumpwid(
01169     typewid *widptr,
01170     int      enftype)
01171 {
01172 #ifndef DISTRIBUTION
01173     int i;
01174 
01175     int nstreams = widsize(enftype);
01176     L("wid = < ");
01177     for (i = 0; i < nstreams; ++i) {
01178         if (i > 0)
01179             L(" , ");
01180         puttumbler(stderr, &widptr->dsas[i]);
01181     }
01182     L(" >\n");
01183 #endif
01184 }
01185 
01193     void
01194 graphwid(
01195     FILE    *fd,
01196     typewid *widptr,
01197     int      enftype)
01198 {
01199     int nstreams = widsize(enftype);
01200     fprintf(fd, " wid=\\<");
01201 
01202     for (int i = 0; i < nstreams; ++i) {
01203         if (i > 0)
01204             fprintf(fd, " :: ");
01205         puttumbler(fd, &widptr->dsas[i]);
01206     }
01207     fprintf(fd, "\\> \\n");
01208 }
01209 
01217     void
01218 dumpdsp(
01219     typewid *dspptr,
01220     int      enftype)
01221 {
01222 #ifndef DISTRIBUTION
01223     int i;
01224 
01225 /* if (enftype == GRAN) return; */
01226     int nstreams = dspsize(enftype);
01227     L("dsp = < ");
01228     for (i = 0; i < nstreams; ++i) {
01229         if (i > 0)
01230             L(" , ");
01231         puttumbler(stderr, &dspptr->dsas[i]);
01232     }
01233     L(" >\n");
01234 #endif
01235 }
01236 
01244     void
01245 graphdsp(
01246     FILE    *fd,
01247     typewid *dspptr,
01248     int      enftype)
01249 {
01250 /* if (enftype == GRAN) return; */
01251     int nstreams = dspsize(enftype);
01252     fprintf(fd, " dsp=\\<");
01253 
01254     for (int i = 0; i < nstreams; ++i) {
01255         if (i > 0)
01256             fprintf(fd, " :: ");
01257         puttumbler(fd, &dspptr->dsas[i]);
01258     }
01259     fprintf(fd, "\\> \\n");
01260 }
01261 
01269     void
01270 graphoffset(
01271     FILE    *fd,
01272     typedsp *dspptr,
01273     int      enftype)
01274 {
01275     int nstreams = dspsize(enftype);
01276     fprintf(fd, " isa=\\<");
01277 
01278     for (int i = 0; i < nstreams; ++i) {
01279         if (i > 0)
01280             fprintf(fd, " :: ");
01281         puttumbler(fd, &dspptr->dsas[i]);
01282     }
01283     fprintf(fd, "\\> \\n");
01284 }
01285 
01293     void
01294 dumpinfo(
01295     typegranbottomcruminfo *infoptr,
01296     int                     enftype)
01297 {
01298 #ifndef DISTRIBUTION
01299     if (enftype == GRAN) {
01300         switch (infoptr->infotype) {
01301         case GRANTEXT:
01302             L("text:  %s\n", infoptr->granstuff.textstuff.textstring);
01303             break;
01304         case GRANORGL:
01305             L(" diskorgl %x, ", infoptr->granstuff.orglstuff.diskorglptr);
01306             L("orgl %x\n ", (int) infoptr->granstuff.orglstuff.orglptr);
01307             break;
01308         case GRANNULL:
01309             L("GRANNULL info\n");
01310             break;
01311         default:
01312             L("empty infotype: %d\n", infoptr->infotype);
01313             assert(0); // bad in dumpinfo
01314         }
01315     } else {
01316         L("home document: ");
01317         puttumbler(stderr, &((type2dbottomcruminfo *) infoptr)->homedoc);
01318         L("\n");
01319     }
01320 #endif
01321 }
01322 
01330     void
01331 dumptumbler(
01332     Tumbler *tumblerptr)
01333 {
01334 #ifndef DISTRIBUTION
01335     int i;
01336 
01337     if (!tumblerptr) {
01338         L("NULL POINTER TO TUMBLER");
01339         return;
01340     }
01341 
01342     if (!debug)
01343         puttumbler(stderr, tumblerptr);
01344     else {
01345         L(" %d | ", tumblerptr->sign);
01346         L("%d | ", tumblerptr->exp);
01347         for (i = 0; i < NPLACES; ++i)
01348             L("%d ", tumblerptr->mantissa[i]);
01349         if (tumblerptr->exp > 0) {
01350             L("in dumptumbler exponent positive i.e. negative number of leading zeros!\n");
01351             assert(0); // dumptumbler
01352         }
01353     }
01354 #endif
01355 }
01356 
01364     void
01365 displaycutspm(
01366     typeknives *knivesptr)
01367 {
01368 #ifndef DISTRIBUTION
01369     int i;
01370 
01371     L("%x cuts:", knivesptr->nblades);
01372     for (i = 0; i < knivesptr->nblades; ++i) {
01373         L("\n       ");
01374         puttumbler(stderr, &knivesptr->blades[i]);
01375     }
01376     L("\n");
01377 #endif
01378 }
01379 
01387     void
01388 dumphint(
01389     typehint *hintptr)
01390 {
01391 #ifndef DISTRIBUTION
01392     L("\nHINT\n");
01393     L("  supertype: %d\n", hintptr->supertype);
01394     L("  subtype:   %d\n", hintptr->subtype);
01395     L("  atomtype:  %d\n", hintptr->atomtype);
01396     L("  isa:       ");
01397     puttumbler(stderr, &hintptr->hintisa);
01398     L("\n");
01399 #endif
01400 }
01401 
01409     void
01410 showsubtree(
01411     typecorecrum *father)
01412 {
01413 #ifndef DISTRIBUTION
01414     //UNUSED int temp;
01415 
01416 /* temp = debug; debug = 5; */
01417     dumpwholesubtree((typecuc *) father);
01418 /* debug = temp; */
01419 #endif
01420 }
01421 
01429     void
01430 showistream(
01431     typecuc *granfptr)
01432 {
01433 #ifndef DISTRIBUTION
01434     //UNUSED int temp;
01435 
01436 /* temp = debug; debug = 5; */
01437     dumpistreamgr(granfptr);
01438 /* debug = temp; */
01439 #endif
01440 }
01441 
01449     void
01450 showspanf(
01451     typecuc *spanfptr)
01452 {
01453 #ifndef DISTRIBUTION
01454     typedsp offset;
01455     clear(&offset, sizeof(typedsp));
01456 
01457     int enfheight = spanfptr->height;
01458 
01459     L("\n");
01460     doshowspanf((typecorecrum *) spanfptr, &offset, enfheight);
01461 #endif
01462 }
01463 
01471     void
01472 doshowspanf(
01473     typecorecrum *crumptr,
01474     typedsp      *offsetptr,
01475     int           enfheight)
01476 {
01477 #ifndef DISTRIBUTION
01478     typecorecrum *ptr = NULL;
01479     typedsp loffset;
01480 
01481     showspanfcrum(crumptr, offsetptr, enfheight);
01482     if (crumptr->height <= 0)
01483         return;
01484 
01485     dspadd(offsetptr, &crumptr->cdsp, &loffset, crumptr->cenftype);
01486     for (ptr = findleftson((typecuc *) crumptr); ptr; ptr = ptr->rightbro)
01487         doshowspanf(ptr, &loffset, enfheight);
01488 #endif
01489 }
01490 
01498     void
01499 showspanfcrum(
01500     typecorecrum *crumptr,
01501     typedsp      *offsetptr,
01502     int           enfheight)
01503 {
01504 #ifndef DISTRIBUTION
01505     int depth;
01506     typedsp lstream;
01507 
01508     for (depth = enfheight - crumptr->height; depth--;)
01509         L("  ");
01510 
01511     L("[spandsp");
01512     dspadd(offsetptr, &crumptr->cdsp, &lstream, crumptr->cenftype);
01513     puttumbler(stderr, &lstream.dsas[SPANRANGE]);
01514 
01515     L(" ,spanwid  ");
01516     puttumbler(stderr, &crumptr->cwid.dsas[SPANRANGE]);
01517 
01518     L("]\n");
01519     for (depth = enfheight - crumptr->height; depth--;)
01520         L("  ");
01521 
01522     L("[orgldsp ");
01523     puttumbler(stderr, &lstream.dsas[ORGLRANGE]);
01524 
01525     L(" ,orglwid  ");
01526     puttumbler(stderr, &crumptr->cwid.dsas[ORGLRANGE]);
01527 
01528     L("]   ");
01529     if (crumptr->height == 0)
01530         puttumbler(stderr, &((type2dcbc *) crumptr)->c2dinfo.homedoc);
01531 
01532     L("\n\n");
01533 #endif
01534 }
01535 
01543     void
01544 dumpmem(
01545     char     *loc,
01546     unsigned  count)
01547 {
01548 #ifndef DISTRIBUTION
01549     int i;
01550 
01551     L(" loc = %x\n", (int) loc);
01552     for (i = 0; count--; ++loc, (i + 1 < 64 ? ++i : (i = 0))) {
01553         if ((*loc & 0x7f) < ' ')
01554             L("%c", '.');
01555         else
01556             L("%c", *loc);
01557         if (i == 63)
01558             L("\n");
01559     }
01560     L("\n");
01561 #endif
01562 }
01563 
01571     bool
01572 dumpgranfwids(
01573     Session *sess)          
01574 {
01575 #ifndef DISTRIBUTION
01576     Tumbler subtreewid;
01577     //UNUSED int fullheight;
01578 
01579 /* fullheight = ((typecorecrum *)granf)->height; */
01580     showgranwids((typecorecrum *) granf, 0, &subtreewid);
01581     if (!tumblereq(&subtreewid, &((typecorecrum *) granf)->cwid.dsas[WIDTH])) {
01582 
01583         L("Granfilade fullcrum wid and widded enfilade don\'t match.\n");
01584         L("gran fullcrum wid ");
01585         puttumbler(stderr, &((typecorecrum *) granf)->cwid.dsas[WIDTH]);
01586 
01587         L("\nreturned wid from subtree ");
01588         puttumbler(stderr, &subtreewid);
01589 
01590         L("\nHit \"<return>\" to continue, \"a<return>\" to abort ");
01591         if (getc(sess->inp) == 'a')
01592             abort();
01593     }
01594     L("\n");
01595 #endif
01596     return true;
01597 }
01598 
01606     void
01607 showgranwids(
01608     typecorecrum *crum,
01609     int           down,
01610     Tumbler      *retptr)
01611 {                                      /* down is distance from top */
01612 #ifndef DISTRIBUTION
01613     typecorecrum *ptr;
01614     Tumbler subtreewid;
01615     int i;
01616 
01617     L("\n");
01618     clear(retptr, sizeof(*retptr));
01619 
01620     for (i = 0; i < down; ++i)
01621         L("        ");
01622 
01623     L("%x (%d%c) < ", (int) crum, crum->height, (crum->modified ? 'M' : '-'));
01624     puttumbler(stderr, &crum->cwid.dsas[WIDTH]);
01625     L(" >");
01626     if (crum->height != 0) {
01627         if (((typecuc *) crum)->leftson) {
01628             for (ptr = ((typecuc *) crum)->leftson; ptr; ptr = ptr->rightbro) {
01629                 tumbleradd(retptr, &ptr->cwid.dsas[WIDTH], retptr);
01630                 showgranwids(ptr, down + 1, &subtreewid);
01631                 if (!tumblereq(&subtreewid, &ptr->cwid.dsas[WIDTH])) {
01632 
01633                     L("\n%d level crum\'s wid and result from subtree don\'t match\n", crum->height);
01634                     L("father wid ");
01635                     puttumbler(stderr, &ptr->cwid.dsas[WIDTH]);
01636 
01637                     L("\nreturned wid ");
01638                     puttumbler(stderr, &subtreewid);
01639 
01640                     L("\n");
01641                 }
01642             }
01643         } else {
01644             L(" disksonloaf = %x ", ((typecuc *) crum)->sonorigin.diskblocknumber);
01645             movetumbler(&crum->cwid.dsas[WIDTH], retptr);
01646 /* so that lacking incore sons will not cause error */
01647         }
01648     } else if (((typecbc *) crum)->cinfo.infotype == GRANORGL) {
01649         if (((typecbc *) crum)->cinfo.granstuff.orglstuff.orglincore)
01650             L(" orgl %x ", (int) ((typecbc *) crum)->cinfo.granstuff.orglstuff.orglptr);
01651         else
01652             L(" diskorgl %x", ((typecbc *) crum)->cinfo.granstuff.orglstuff.diskorglptr);
01653 
01654         movetumbler(&crum->cwid.dsas[WIDTH], retptr);
01655     } else
01656         movetumbler(&crum->cwid.dsas[WIDTH], retptr);
01657 #endif
01658 }
01659 
01667     void
01668 dumppoomwisps(
01669     typecorecrum *orgl)
01670 {
01671     L("Entering dumppoomwisps\n");
01672 
01673 #ifndef DISTRIBUTION
01674     //UNUSED int fullheight;
01675 
01676 /* fullheight = orgl->height; */
01677     showpoomwisps((typecuc *) orgl, 0);
01678     L("\n");
01679 #endif
01680     L("Leaving dumppoomwisps\n");
01681 }
01682 
01690     void
01691 showpoomwisps(
01692     typecuc *crum,
01693     int      down)
01694 {                                      /* down is distance from top */
01695 #ifndef DISTRIBUTION
01696     typecorecrum *ptr;
01697     int i;
01698 
01699     L("\n");
01700 
01701     for (i = 0; i < down; ++i)
01702         L("   ");
01703 
01704     L("%x (%d%c) <Idsp ", (int) crum, crum->height, (crum->modified ? 'M' : '-'));
01705     puttumbler(stderr, &crum->cdsp.dsas[I]);
01706 
01707     L(",Vdsp ");
01708     puttumbler(stderr, &crum->cdsp.dsas[V]);
01709 
01710     L(" > <Iwid ");
01711     puttumbler(stderr, &crum->cwid.dsas[I]);
01712 
01713     L(",Vwid ");
01714     puttumbler(stderr, &crum->cwid.dsas[V]);
01715 
01716     L(" >");
01717     if (crum->height != 0) {
01718         if (crum->leftson) {
01719             for (ptr = findleftson(crum); ptr; ptr = ptr->rightbro) {
01720                 showpoomwisps((typecuc *) ptr, down + 1);
01721             }
01722         } else {
01723             L(" disksonloaf = %x ", crum->sonorigin.diskblocknumber);
01724         }
01725     }
01726 #endif
01727 }
01728 
01729 #define TABSTOP 20
01730 
01738     void
01739 dumpistreamgr(
01740     typecuc *crumptr)
01741 {
01742 #ifndef DISTRIBUTION
01743     Tumbler offset;
01744 
01745     if (debug < 5)
01746         return;
01747 
01748     tumblerclear(&offset);
01749     dodumpistreamgr(crumptr, &offset);
01750 #endif
01751 }
01752 
01760     void
01761 dodumpistreamgr(
01762     typecuc *crumptr,
01763     Tumbler *offsetptr)
01764 {
01765 #ifndef DISTRIBUTION
01766     typecorecrum *ptr;
01767 
01768     if (crumptr->height == 0) {
01769         dumpmoleculegr(offsetptr, (typecbc *) crumptr);
01770         tumbleradd(offsetptr, &crumptr->cwid.dsas[WIDTH], offsetptr);
01771         return;
01772     }
01773 
01774     for (ptr = findleftson(crumptr); ptr; ptr = ptr->rightbro)
01775         dodumpistreamgr((typecuc *) ptr, offsetptr);
01776 #endif
01777 }
01778 
01786     void
01787 dumpmoleculegr(
01788     Tumbler *offsetptr,
01789     typecbc *cbcptr)
01790 {
01791 #ifndef DISTRIBUTION
01792     //UNUSED int i;
01793     //UNUSED Tumbler localoffset;
01794 
01795 /* L("\n"); dumpisagr (offsetptr); if (cbcptr->cinfo.infotype == GRANTEXT) { if
01796  * (cbcptr->cinfo.textstring[0] == '\n') L("\\n"); else if (cbcptr->cinfo.textstring[0] == '\t')
01797  * L("\\t"); else L("%c ",cbcptr->cinfo.textstring[0]); L(" | %x ", cbcptr);
01798  * dumpwid (&cbcptr->cwid, GRAN); movetumbler (offsetptr, &localoffset); for (i = 1; i < cbcptr->cinfo.textlength;
01799  * ++i){ tumblerincrement (&localoffset, 0, 1, &localoffset); dumpisagr (&localoffset); if (cbcptr->cinfo.textstring[i]
01800  * == '\n') L("\\n"); else if (cbcptr->cinfo.textstring[i] == '\t') L("\\t"); else
01801  * L("%c ",cbcptr->cinfo.textstring[i]); L(" |\n"); } } else if (cbcptr->cinfo.infotype ==
01802  * GRANORGL) { L("%x",cbcptr->cinfo.orglptr); L(" | %x ", cbcptr); dumpwid (&cbcptr->cwid,
01803  * GRAN); } else { L(" | %x ", cbcptr); dumpwid (&cbcptr->cwid, GRAN); } */
01804 #endif
01805 }
01806 
01814     void
01815 dumpisagr(
01816     Tumbler *offsetptr)
01817 {
01818 #ifndef DISTRIBUTION
01819     int i, j, k;
01820     Tumbler offset;
01821 
01822     movetumbler(offsetptr, &offset);
01823 
01824     i = nstories(&offset) - offset.exp;
01825     i += i - 1;
01826     for (j = 0; j < NPLACES; ++j)
01827         for (k = offset.mantissa[j]; k /= 10; ++i)
01828             ;
01829 
01830     i = TABSTOP - i;
01831     if (i < 2) {
01832         L("too long");
01833         i = 8;
01834     } else
01835         puttumbler(stderr, &offset);
01836 
01837     while (i--)
01838         L(" ");
01839 #endif
01840 }
01841 
01849     typecorecrum *
01850 checkenftypes(
01851     typecuc *father,
01852     char    *message)
01853 {
01854 #ifndef DISTRIBUTION
01855     //UNUSED typecorecrum *ptr;
01856 
01857     if (grimreaper == NULL)
01858         L("grimreaper tests null");
01859 
01860     return (typecorecrum *) father;
01861 
01862 //    if (!father) {
01863 //        fputs(stderr, message);
01864 //        assert(0); // ARGH!! null father ptr
01865 //    }
01866 //    
01867 //    if (!father->height)
01868 //        return father;
01869 //      
01870 //    if (father->cenftype == SPAN) {
01871 //        if (father->cwid.dsas[ORGLRANGE].exp == 0 && father->cwid.dsas[ORGLRANGE].mantissa[0] > 2) {
01872 //            dumpsubtree(father);
01873 //            fputs(stderr, message);
01874 //            assert(0); // I think the wid is too big
01875 //        }
01876 //    }
01877 //    
01878 //    for (ptr * = father->leftson; ptr; ptr = ptr->rightbro) {
01879 //        if (ptr->cenftype != GRAN && ptr->cenftype != POOM && ptr->cenftype != SPAN) {
01880 //            fputs(stderr, message);
01881 //            assert(0); // bad enftype
01882 //        }
01883 //      
01884 //        if (ptr->cenftype != father->cenftype) {
01885 //            fputs(stderr, message);
01886 //            assert(0); // enftype mismatch
01887 //        }
01888 //      
01889 //        checkenftypes(ptr, message);
01890 //    }
01891 //    return father;
01892 #endif
01893 }
01894 
01902     typecorecrum *
01903 checkthebleedingcrum(
01904     typecorecrum *crumptr)
01905 {
01906 #ifndef DISTRIBUTION
01907     if (grimreaper == NULL)
01908         L("grimreaper tests null");
01909 
01910     return crumptr;
01911 
01912 //    assert(crumptr != NULL); // checkbleeding NULL crum
01913 //    
01914 //    if (crumptr->cenftype != GRAN && crumptr->cenftype != SPAN && crumptr->cenftype != POOM) {
01915 //        L("Bad enftype in check the bleeding crum\n\n\n");
01916 //        dump(crumptr);
01917 //        assert(0); // Bad enftype
01918 //    }
01919 //    
01920 //    if (!crumptr->isapex&&crumptr->leftbroorfather..disowned.. && crumptr->cenftype != crumptr->leftbroorfather->cenftype) {
01921 //        dump(crumptr);
01922 //        L("\n\n\n and here comes the spanf \n");
01923 //        dumpsubtree(spanf);
01924 //        dump(crumptr);
01925 //        assert(0); // Enftype mismatch
01926 //    }
01927 //    
01928 //    if (crumptr->cenftype !=GRAN) {
01929 //        if (!tumblercheck(&crumptr->cdsp.dsas[V]))
01930 //            assert(0); // cleckbleeding disp V
01931 //
01932 //        if (!tumblercheck(&crumptr->cdsp.dsas[I]))
01933 //            assert(0); // cleckbleeding disp I
01934 //    }
01935 //    return crumptr;
01936 #endif
01937 }
01938 
01946     void
01947 teststack()
01948 {
01949     //UNUSED int testloc;
01950 
01951 /* checkalloc (""); */
01952 }
01953 
01961     char *
01962 enftypestring(
01963     int type)
01964 {
01965 #ifndef DISTRIBUTION
01966     static char errbuf[60];
01967 
01968     switch (type) {
01969     case GRAN:
01970         return ("GRAN");
01971     case POOM:
01972         return ("POOM");
01973     case SPAN:
01974         return ("SPAN");
01975     default:
01976         sprintf(errbuf, "bad enftype %d", type);
01977         return ((char *)errbuf);
01978     }
01979 #endif
01980 }
01981 
01989     typecorecrum *
01990 sonoriginok(
01991     typecorecrum *father)
01992 {
01993     return father;                     /* 
01994                                         * if (!father) return (father); if
01995                                         * (father->height == 0) return
01996                                         * (father); if
01997                                         * (father->sonorigin.diskblocknumber
01998                                         * == -1) return (father); if
01999                                         * (goodblock
02000                                         * (father->sonorigin.diskblocknumber))
02001                                         * return (father); dumpsubtree
02002                                         * (father); L("enter y to
02003                                         * procede\n"); if(getchar() == 'y') {
02004                                         * getchar(); return(father); } assert(0);
02005                                         * "Bad Sonorigin"; return(NULL);// 
02006                                         * for lint// */
02007 }
02008 
02016     void
02017 dumpcontextlist(
02018     Context *context)
02019 {
02020 #ifndef DISTRIBUTION
02021     L("contextlist :\n");
02022 
02023     if (!context) {
02024         L("  contextlist NULL\n");
02025         return;
02026     }
02027 
02028     for (; context; context = (Context *) context->nextcontext) {
02029         dumpcontext(context);
02030     }
02031 #endif
02032 }
02033 
02041     void
02042 dumpcontext(
02043     Context *context)
02044 {
02045 #ifndef DISTRIBUTION
02046     L("  context %x:\n", (int) context);
02047 
02048     if (context == NULL) {
02049         L("NULL context\n");
02050         return;
02051     }
02052 
02053     L("    contexttype %s\n", enftypestring(context->contexttype));
02054     L("    totaloffset ");
02055     dumpdsp(&context->totaloffset, context->contexttype);
02056 
02057     L("    contextwid ");
02058     dumpwid(&context->contextwid, context->contexttype);
02059 
02060     if (debug > 1) {
02061         L("    contextinfo ");
02062         dumpinfo((typegranbottomcruminfo *) &context->contextinfo, context->contexttype);
02063     }
02064 #endif
02065 }
02066 
02074     void
02075 dumpitemset(
02076     typeitemset itemset)
02077 {
02078 #ifndef DISTRIBUTION
02079     if (itemset == NULL)
02080         L("  \nitemset empty\n");
02081 
02082     for (; itemset; itemset = (typeitemset) ((typeitemheader *) itemset)->next) {
02083         dumpitem(itemset);
02084         if (!
02085             (((typeitemheader *) itemset)->next && ((typeitemheader *) itemset)->itemid == TEXTID
02086              && ((typeitemheader *) itemset)->next->itemid == TEXTID))
02087             putc('\n', stderr);
02088     }
02089 #endif
02090 }
02091 
02099     void
02100 dumpitem(
02101     typeitem *itemptr)
02102 {
02103 #ifndef DISTRIBUTION
02104     int bugger = debug;
02105 
02106     debug = 0;
02107 /* checkitem ("dumpitem: ", itemptr); */
02108     L("%x ->%x:", (int) itemptr, (int) ((typeitemheader *) itemptr)->next);
02109     switch (((typeitemheader *) itemptr)->itemid) {
02110     case ISPANID:
02111         L("  ispan\n");
02112         dumpspan((typespan *) itemptr);
02113         break;
02114 
02115     case VSPANID:
02116         L("  vspan\n");
02117         dumpspan((typespan *) itemptr);
02118         break;
02119 
02120     case VSPECID:
02121         L("document: ");
02122         puttumbler(stderr, &((typevspec *) itemptr)->docisa);
02123         L("\nspans");
02124         dumpitemset((typeitem *) ((typevspec *) itemptr)->vspanset);
02125         break;
02126 
02127     case TEXTID:
02128         dumptext((typetext *) itemptr);
02129         break;
02130 
02131     case LINKID:
02132         puttumbler(stderr, &((typelink *) itemptr)->address);
02133         break;
02134 
02135     case SPORGLID:
02136         L("sporgl address: ");
02137         puttumbler(stderr, &((typesporgl *) itemptr)->sporgladdress);
02138         L("\n   sporgl origin: ");
02139         puttumbler(stderr, &((typesporgl *) itemptr)->sporglorigin);
02140         L("\n   sporgl width: ");
02141         puttumbler(stderr, &((typesporgl *) itemptr)->sporglwidth);
02142         L("\n");
02143         break;
02144 
02145     default:
02146         L("illegal item id for dumpitem ");
02147         L("%x  %d\nd", (int) itemptr, ((typeitemheader *) itemptr)->itemid);
02148         assert(0); // Illegal item in dumpitem!
02149     }
02150     debug = bugger;
02151 #endif
02152 }
02153 
02161     void
02162 dumpspan(
02163     typespan *spanptr)
02164 {
02165 #ifndef DISTRIBUTION
02166     if (!spanptr) {
02167         L("null span ptr\n");
02168         return;
02169     }
02170 
02171     L("   span address: ");
02172     puttumbler(stderr, &spanptr->stream);
02173 
02174     L("   span width: ");
02175     puttumbler(stderr, &spanptr->width);
02176 
02177     L("\n");
02178 #endif
02179 }
02180 
02188     void
02189 dumptext(
02190     typetext *textptr)
02191 {
02192 #ifndef DISTRIBUTION
02193     write(2, textptr->string, textptr->length);
02194 #endif
02195 }
02196 
02204     bool
02205 ioinfo(
02206     Session *sess)          
02207 {
02208 #ifndef DISTRIBUTION
02209     L("Total reads = %ld,  total writes = %ld\n", nolread, nowread);
02210 #endif
02211 
02212     return true;
02213 }
02214 
02222     char *
02223 itemidstring(
02224     typeitem *item)
02225 {
02226 #ifndef DISTRIBUTION
02227     switch (((typeitemheader *) item)->itemid) {
02228     case TEXTID:     return "TEXTID";
02229     case ISPANID:    return "ISPANID";
02230     case VSPANID:    return "VSPANID";
02231     case VSPECID:    return "VSPECID";
02232     case NODEID:     return "NODEID";
02233     case ADDRESSID:  return "ADDRESSID";
02234     case SPORGLID:   return "SPORGLID";
02235     case UNKNOWNID:  return "UNKNOWNID";
02236     }
02237 #endif
02238     return NULL; /* for lint ? */
02239 }
02240 
02248     void
02249 checkitem(
02250     char     *msg,
02251     typeitem *ptr)
02252 {
02253 #ifndef DISTRIBUTION
02254     //UNUSED char buf[100];
02255 
02256     checkpointer(msg, (char *) ptr);
02257     if (!ptr)
02258         return;
02259 
02260     if (debug) {
02261         L(msg);
02262         dumpitem(ptr);
02263     }
02264 
02265     if (((typeitemheader *) ptr)->itemid < TEXTID || ((typeitemheader *) ptr)->itemid > SPORGLID) {
02266         L(msg);
02267         assert(0); // Bad itemtype
02268     }
02269 
02270 /* checkpointer (sprintf (buf, "%s ptr->next: ", msg), ((typeitemheader *)ptr)->next); */
02271     if (((typeitemheader *) ptr)->itemid == VSPANID) {
02272         if (((typevspan *) ptr)->stream.mantissa[0] != 1 && ((typevspan *) ptr)->stream.mantissa[0] != 2) {
02273             L(msg);
02274             puttumbler(stderr, &((typevspan *) ptr)->stream);
02275             L("  ");
02276             assert(0); // Bad span stream address
02277         }
02278     }
02279     if (((typeitemheader *) ptr)->itemid == VSPECID) {
02280         checkitem(msg, (typeitem *) ((typevspec *) ptr)->vspanset);
02281         if (((typevspec *) ptr)->vspanset->itemid != VSPANID)
02282             assert(0); // vspanset doesn't have proper itemid
02283     }
02284 #endif
02285 }
02286 
02294     void
02295 checkpointer(
02296     char *msg,
02297     char *ptr)
02298 {
02299     return;
02300     
02301 //    if (!ptr) {
02302 //        if (debug) {
02303 //            L(msg);
02304 //            L("NULL pointer\n");
02305 //        }
02306 //        return;
02307 //    }
02308 //    
02309 //    if (((unsigned) ptr) & 1) {
02310 //        L(msg);
02311 //        assert(0); // Pointer non-aligned
02312 //    }
02313 //    
02314 //    if (ptr > (char *) 0x1bffff) {
02315 //        L(msg);
02316 //
02317 //        if (ptr < (char *) 0x1e0000)
02318 //            L("Pointer in framebuffer\n");
02319 //
02320 //        assert(0); // Pointer in high-mem
02321 //    }
02322 //      
02323 //    if (ptr < (char *) 0x40000) {
02324 //        L(msg);
02325 //        assert(0); // Pointer to hardware protected low memory
02326 //    }
02327 //      
02328 //    if (ptr < &end //etext//) {
02329 //        L(msg);
02330 //        assert(0); // Pointer below end
02331 //    }
02332 }
02333 
02341     void
02342 dumpspanpairset(
02343     typespanpairset spanpairset)
02344 {
02345 #ifndef DISTRIBUTION
02346     for (; spanpairset; spanpairset = spanpairset->nextspanpair)
02347         dumpspanpair(spanpairset);
02348 #endif
02349 }
02350 
02358     void
02359 dumpspanpair(
02360     typespanpair * spanpair)
02361 {
02362 #ifndef DISTRIBUTION
02363     L("stream1:  ");
02364     dumptumbler(&spanpair->stream1);
02365 
02366     L("\nstream2:  ");
02367     dumptumbler(&spanpair->stream2);
02368 
02369     L("\nwidth:  ");
02370     dumptumbler(&spanpair->widthofspan);
02371 
02372     L("\n");
02373 #endif
02374 }
02375 
02383     void
02384 dumphexstuff(
02385     char *ptr)
02386 {
02387 #ifndef DISTRIBUTION
02388     int i;
02389 
02390     L("\n");
02391 
02392     for (i = 0; i < 120; i++)
02393         L("%x ", *(ptr + i) & 0xff);
02394     L("\n");
02395 #endif
02396 }
02397 
02405     void
02406 checknumofsons(
02407     typecuc *ptr)
02408 {
02409 #ifndef DISTRIBUTION
02410     typecuc *np;
02411 
02412     int i = 0;
02413     if (!ptr || !ptr->height)
02414         return;
02415 
02416     for (np = (typecuc *) ptr->leftson; np; np = (typecuc *) np->rightbro, i++)
02417         ;
02418 
02419     if (i != ptr->numberofsons) {
02420         dumpsubtree(ptr);
02421         L("i = %d numberofsons = %d\n", i, ptr->numberofsons);
02422 
02423         for (np = (typecuc *) ptr->leftson; np; np = (typecuc *) np->rightbro, i++) {
02424 /* dump(np) */ ;
02425         }
02426         L("numberofson mismach in checknumofsons\n");
02427     }
02428 #endif
02429 }
02430 
02438     void
02439 nchecknumofsons(
02440     typecuc *ptr)
02441 {
02442 #ifndef DISTRIBUTION
02443     typecuc *np;
02444 
02445     int i = 0;
02446     if (!ptr || !ptr->height)
02447         return;
02448 
02449     for (np = (typecuc *) ptr->leftson; np; np = (typecuc *) np->rightbro, i++)
02450         ;
02451 
02452     if (i != ptr->numberofsons) {
02453         dumpsubtree(ptr);
02454         L("i = %d numberofsons = %d\n", i, ptr->numberofsons);
02455 
02456         for (np = (typecuc *) ptr->leftson; np; np = (typecuc *) np->rightbro, i++) {
02457 /* dump(np) */ ;
02458         }
02459         L("numberofson mismach in nchecknumofsons\n");
02460     }
02461 #endif
02462 }

Generated on Sun Aug 21 04:18:14 2005 for Udanax-Green by doxygen1.3.4