home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff218.lzh / Scanner / scanner.c < prev    next >
C/C++ Source or Header  |  1989-06-04  |  33KB  |  1,221 lines

  1. /* scanner.c */
  2.  
  3. #include <exec/types.h>
  4. #include <exec/memory.h>
  5. #include <intuition/intuitionbase.h>
  6. #include <proto/exec.h>
  7. #include <proto/graphics.h>
  8. #include <proto/intuition.h>
  9. #include <string.h>
  10. #include <stdio.h>
  11.  
  12. #include "scanner.h"
  13.  
  14. #define VERSION "1.0"
  15.  
  16. static struct structList structlist[MAXSTRUCTURE];
  17.  
  18.  
  19. void main(argc, argv)
  20. int argc;
  21. BYTE *argv[];
  22. {
  23.   extern struct GfxBase *GfxBase;
  24.   extern struct IntuitionBase *IntuitionBase;
  25.  
  26.   GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 1);
  27.   IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 1);
  28.  
  29.   ScanScreens(IntuitionBase->FirstScreen);
  30.  
  31.   ListBitMaps();
  32.   ListBoolInfos();
  33.   ListBorders();
  34.   ListGadgets();
  35.   ListImages();
  36.   ListIntuiMessages();
  37.   ListIntuiTexts();
  38.   ListKeyMaps();
  39.   ListLayers();
  40.   ListMenus();
  41.   ListMsgPorts();
  42.   ListPropInfos();
  43.   ListRastPorts();
  44.   ListRequesters();
  45.   ListScreens();
  46.   ListStringInfos();
  47.   ListTextFonts();
  48.   ListWindows();
  49.  
  50.   EraseStructList();
  51.  
  52.   CloseLibrary((struct Library *)IntuitionBase);
  53.   CloseLibrary((struct Library *)GfxBase);
  54. }
  55.  
  56.  
  57. void ScanBitMaps(bitmap)
  58. register struct BitMap *bitmap;
  59. {
  60.   WORD bitmapno;
  61.  
  62.   if (bitmap != NULL)
  63.     bitmapno = BitMapNumber(bitmap);
  64. }
  65.  
  66.  
  67. void ScanBoolInfos(boolinfo)
  68. register struct BoolInfo *boolinfo;
  69. {
  70. }
  71.  
  72.  
  73. void ScanBorders(border)
  74. register struct Border *border;
  75. {
  76.   WORD borderno;
  77.  
  78.   while (border != NULL)
  79.   {
  80.     borderno = BorderNumber(border);
  81.  
  82.     border = border->NextBorder;
  83.   }
  84. }
  85.  
  86.  
  87. void ScanGadgets(gadget)
  88. register struct Gadget *gadget;
  89. {
  90.   WORD gadgetno, gadgetrenderno, selectrenderno,
  91.       gadgettextno, specialinfono, gadgettype;
  92.  
  93.   while (gadget != NULL)
  94.   {
  95.     gadgetno = GadgetNumber(gadget);
  96.  
  97.     if (gadget->Flags & GADGIMAGE)
  98.     {
  99.       gadgetrenderno = ImageNumber(gadget->GadgetRender);
  100.       selectrenderno = ImageNumber(gadget->SelectRender);
  101.     }
  102.     else
  103.     {
  104.       gadgetrenderno = BorderNumber(gadget->GadgetRender);
  105.       selectrenderno = BorderNumber(gadget->SelectRender);
  106.     }
  107.     gadgettextno = IntuiTextNumber(gadget->GadgetText);
  108.     gadgettype = gadget->GadgetType & 0x0F;
  109.     if (gadgettype == GADGET0002)
  110.       specialinfono = BoolInfoNumber(gadget->SpecialInfo);
  111.     else if (gadgettype == PROPGADGET)
  112.       specialinfono = PropInfoNumber(gadget->SpecialInfo);
  113.     else if (gadgettype == STRGADGET)
  114.       specialinfono = StringInfoNumber(gadget->SpecialInfo);
  115.     else
  116.       specialinfono = 0;
  117.  
  118.     if (gadget->Flags & GADGIMAGE)
  119.     {
  120.       if (Fresh(gadgetrenderno)) ScanImages((struct Image *)gadget->GadgetRender);
  121.       if (Fresh(selectrenderno)) ScanImages((struct Image *)gadget->SelectRender);
  122.     }
  123.     else
  124.     {
  125.       if (Fresh(gadgetrenderno)) ScanBorders((struct Border *)gadget->GadgetRender);
  126.       if (Fresh(selectrenderno)) ScanBorders((struct Border *)gadget->SelectRender);
  127.     }
  128.     if (Fresh(gadgettextno)) ScanIntuiTexts(gadget->GadgetText);
  129.     if (Fresh(specialinfono))
  130.     {
  131.       if (gadgettype == GADGET0002)
  132.         ScanBoolInfos((struct BoolInfo *)gadget->SpecialInfo);
  133.       else if (gadgettype == PROPGADGET)
  134.         ScanPropInfos((struct PropInfo *)gadget->SpecialInfo);
  135.       else if (gadgettype == STRGADGET)
  136.         ScanStringInfos((struct StringInfo *)gadget->SpecialInfo);
  137.     }
  138.  
  139.     gadget = gadget->NextGadget;
  140.   }
  141. }
  142.  
  143.  
  144. void ScanImages(image)
  145. register struct Image *image;
  146. {
  147.   WORD imageno;
  148.  
  149.   while (image != NULL)
  150.   {
  151.     imageno = ImageNumber(image);
  152.  
  153.     image = image->NextImage;
  154.   }
  155. }
  156.  
  157.  
  158. void ScanIntuiMessages(intuimessage)
  159. register struct IntuiMessage *intuimessage;
  160. {
  161. }
  162.  
  163.  
  164. void ScanIntuiTexts(intuitext)
  165. register struct IntuiText *intuitext;
  166. {
  167.   WORD intuitextno, itextfontno;
  168.  
  169.   while (intuitext != NULL)
  170.   {
  171.     intuitextno = IntuiTextNumber(intuitext);
  172.  
  173.     itextfontno = TextAttrNumber(intuitext->ITextFont);
  174.  
  175.     if (Fresh(itextfontno)) ScanTextAttrs(intuitext->ITextFont);
  176.  
  177.     intuitext = intuitext->NextText;
  178.   }
  179. }
  180.  
  181.  
  182. void ScanKeyMaps(keymap)
  183. register struct KeyMap *keymap;
  184. {
  185. }
  186.  
  187.  
  188. void ScanLayers(layer)
  189. register struct Layer *layer;
  190. {
  191. }
  192.  
  193.  
  194. void ScanMenus(menu)
  195. register struct Menu *menu;
  196. {
  197. }
  198.  
  199.  
  200. void ScanMsgPorts(msgport)
  201. register struct MsgPort *msgport;
  202. {
  203. }
  204.  
  205.  
  206. void ScanPropInfos(propinfo)
  207. register struct PropInfo *propinfo;
  208. {
  209. }
  210.  
  211.  
  212. void ScanRastPorts(rastport)
  213. register struct RastPort *rastport;
  214. {
  215. }
  216.  
  217.  
  218. void ScanRequesters(requester)
  219. register struct Requester *requester;
  220. {
  221.   WORD requesterno, olderrequestno, reqgadgetno, reqborderno, reqtextno,
  222.       reqlayerno, imagebmapno, rwindowno;
  223.  
  224.   if (requester != NULL)
  225.   {
  226.     requesterno = RequesterNumber(requester);
  227.  
  228.     olderrequestno = RequesterNumber(requester->OlderRequest);
  229.     reqgadgetno = GadgetNumber(requester->ReqGadget);
  230.     reqborderno = BorderNumber(requester->ReqBorder);
  231.     reqtextno = IntuiTextNumber(requester->ReqText);
  232.     reqlayerno = LayerNumber(requester->ReqLayer);
  233.     imagebmapno = BitMapNumber(requester->ImageBMap);
  234.     rwindowno = WindowNumber(requester->RWindow);
  235.  
  236.     if (Fresh(olderrequestno)) ScanRequesters(requester->OlderRequest);
  237.     if (Fresh(reqgadgetno)) ScanGadgets(requester->ReqGadget);
  238.     if (Fresh(reqborderno)) ScanBorders(requester->ReqBorder);
  239.     if (Fresh(reqtextno)) ScanIntuiTexts(requester->ReqText);
  240.     if (Fresh(reqlayerno)) ScanLayers(requester->ReqLayer);
  241.     if (Fresh(imagebmapno)) ScanBitMaps(requester->ImageBMap);
  242.     if (Fresh(rwindowno)) ScanWindows(requester->RWindow);
  243.   }
  244. }
  245.  
  246.  
  247. void ScanScreens(screen)
  248. register struct Screen *screen;
  249. {
  250.   WORD screenno, windowno;
  251.  
  252.   while (screen != NULL)
  253.   {
  254.     screenno = ScreenNumber(screen);
  255.  
  256.     windowno = WindowNumber(screen->FirstWindow);
  257.  
  258.     if (Fresh(windowno)) ScanWindows(screen->FirstWindow);
  259.  
  260.     screen = screen->NextScreen;
  261.   }
  262. }
  263.  
  264.  
  265. void ScanStringInfos(stringinfo)
  266. register struct StringInfo *stringinfo;
  267. {
  268.   WORD stringinfono, layerptrno, altkeymapno;
  269.  
  270.   if (stringinfo != NULL)
  271.   {
  272.     stringinfono = StringInfoNumber(stringinfo);
  273.  
  274.     layerptrno = LayerNumber(stringinfo->LayerPtr);
  275.     altkeymapno = KeyMapNumber(stringinfo->AltKeyMap);
  276.  
  277.     if (Fresh(layerptrno)) ScanLayers(stringinfo->LayerPtr);
  278.     if (Fresh(altkeymapno)) ScanKeyMaps(stringinfo->AltKeyMap);
  279.   }
  280. }
  281.  
  282.  
  283. void ScanTextAttrs(textattr)
  284. register struct TextAttr *textattr;
  285. {
  286. }
  287.  
  288.  
  289. void ScanTextFonts(textfont)
  290. register struct TextFont *textfont;
  291. {
  292. }
  293.  
  294.  
  295. void ScanWindows(window)
  296. register struct Window *window;
  297. {
  298.   WORD windowno, menustripno, firstrequestno, dmrequestno, rportno,
  299.       borderrportno, firstgadgetno, parentwindowno, descendantwindowno,
  300.       userportno, windowportno, messagekeyno, checkmarkno, wlayerno,
  301.       ifontno, wscreenno;
  302.  
  303.   while (window != NULL)
  304.   {
  305.     windowno = WindowNumber(window);
  306.  
  307.     menustripno = MenuNumber(window->MenuStrip);
  308.     firstrequestno = RequesterNumber(window->FirstRequest);
  309.     dmrequestno = RequesterNumber(window->DMRequest);
  310.     wscreenno = ScreenNumber(window->WScreen);
  311.     rportno = RastPortNumber(window->RPort);
  312.     borderrportno = RastPortNumber(window->BorderRPort);
  313.     firstgadgetno = GadgetNumber(window->FirstGadget);
  314.     parentwindowno = WindowNumber(window->Parent);
  315.     descendantwindowno = WindowNumber(window->Descendant);
  316.     userportno = MsgPortNumber(window->UserPort);
  317.     windowportno = MsgPortNumber(window->WindowPort);
  318.     messagekeyno = IntuiMessageNumber(window->MessageKey);
  319.     checkmarkno = ImageNumber(window->CheckMark);
  320.     wlayerno = LayerNumber(window->WLayer);
  321.     ifontno = TextFontNumber(window->IFont);
  322.  
  323.     if (Fresh(menustripno)) ScanMenus(window->MenuStrip);
  324.     if (Fresh(firstrequestno)) ScanRequesters(window->FirstRequest);
  325.     if (Fresh(dmrequestno)) ScanRequesters(window->DMRequest);
  326.     if (Fresh(wscreenno)) ScanScreens(window->WScreen);
  327.     if (Fresh(rportno)) ScanRastPorts(window->RPort);
  328.     if (Fresh(borderrportno)) ScanRastPorts(window->BorderRPort);
  329.     if (Fresh(firstgadgetno)) ScanGadgets(window->FirstGadget);
  330.     if (Fresh(parentwindowno)) ScanWindows(window->Parent);
  331.     if (Fresh(descendantwindowno)) ScanWindows(window->Descendant);
  332.     if (Fresh(userportno)) ScanMsgPorts(window->UserPort);
  333.     if (Fresh(windowportno)) ScanMsgPorts(window->WindowPort);
  334.     if (Fresh(messagekeyno)) ScanIntuiMessages(window->MessageKey);
  335.     if (Fresh(checkmarkno)) ScanImages(window->CheckMark);
  336.     if (Fresh(wlayerno)) ScanLayers(window->WLayer);
  337.     if (Fresh(ifontno)) ScanTextFonts(window->IFont);
  338.  
  339.     window = window->NextWindow;
  340.   }
  341. }
  342.  
  343.  
  344. BYTE Fresh(number)
  345. register WORD number;
  346. {
  347.   register BYTE fresh;
  348.  
  349.   fresh = (number != 0 && ((number & FOUND) == 0));
  350.  
  351.   return(fresh);
  352. }
  353.  
  354.  
  355. WORD structNumber(structure, structurekind)
  356. register APTR structure;
  357. register WORD structurekind;
  358. {
  359.   register WORD number;
  360.   register BYTE found;
  361.   register struct structList *structitem;
  362.   struct structList *newstruct;
  363.   extern struct structList structlist[MAXSTRUCTURE];
  364.  
  365.   if (structure == NULL)
  366.     number = 0;
  367.   else
  368.   {
  369.     structitem = structlist[structurekind].next;
  370.     found = FALSE;
  371.     while (structitem != NULL && !found)
  372.     {
  373.       if (structitem->structure == structure)
  374.         found = TRUE;
  375.       else
  376.         structitem = structitem->next;
  377.     }
  378.  
  379.     if (found)
  380.       number = structitem->number | FOUND;
  381.     else
  382.     {
  383.       number = ++(structlist[structurekind].number);
  384.  
  385.       newstruct = (struct structList *)AllocMem(
  386.           sizeof(struct structList), MEMF_PUBLIC);
  387.       newstruct->next = structlist[structurekind].next;
  388.       newstruct->structure = (APTR)structure;
  389.       newstruct->number = number;
  390.       structlist[structurekind].next = newstruct;
  391.     }
  392.   }
  393.  
  394.   return(number);
  395. }
  396.  
  397.  
  398. void EraseStructList()
  399. {
  400.   register WORD structurekind;
  401.   register struct structList *structitem, *nextstructitem;
  402.   extern struct structList structlist[MAXSTRUCTURE];
  403.  
  404.   for (structurekind = 0; structurekind < MAXSTRUCTURE; structurekind++)
  405.   {
  406.     structitem = structlist[structurekind].next;
  407.     while (structitem != NULL)
  408.     {
  409.       nextstructitem = structitem->next;
  410.       FreeMem((BYTE *)structitem, sizeof(struct structList));
  411.       structitem = nextstructitem;
  412.     }
  413.   }
  414. }
  415.  
  416.  
  417. UBYTE *APTRName(name)
  418. register UBYTE *name;
  419. {
  420.   static UBYTE string[40];
  421.  
  422.   if (strcmp(name, "NULL") == 0)
  423.     strcpy(string, name);
  424.   else
  425.   {
  426.     strcpy(string, "(APTR)");
  427.     strcat(string, name);
  428.   }
  429.  
  430.   return(string);
  431. }
  432.  
  433.  
  434. UBYTE *structName(number, structurekind)
  435. register WORD number, structurekind;
  436. {
  437.   static UBYTE string[40];
  438.   static UBYTE *structname[MAXSTRUCTURE] =
  439.   {
  440.     "bitmap",
  441.     "boolinfo",
  442.     "border",
  443.     "gadget",
  444.     "image",
  445.     "intuimessage",
  446.     "intuitext",
  447.     "keymap",
  448.     "layer",
  449.     "menu",
  450.     "msgport",
  451.     "propinfo",
  452.     "rastport",
  453.     "requester",
  454.     "screen",
  455.     "stringinfo",
  456.     "textattr",
  457.     "textfont",
  458.     "window"
  459.   };
  460.  
  461.   if (number == 0)
  462.     strcpy(string, "NULL");
  463.   else
  464.     sprintf(string, "&%s%d", structname[structurekind], NUMBER(number));
  465.  
  466.   return(string);
  467. }
  468.  
  469.  
  470. UBYTE *TitleName(title)
  471. register UBYTE *title;
  472. {
  473.   static UBYTE string[100];
  474.  
  475.   if (string == NULL)
  476.     strcpy(string, "NULL");
  477.   else
  478.     sprintf(string, "\"%s\"", title);
  479.  
  480.   return(string);
  481. }
  482.  
  483.  
  484. UBYTE *MemoryName(memorypos)
  485. register APTR memorypos;
  486. {
  487.   static UBYTE string[20];
  488.  
  489.   if (memorypos == NULL)
  490.     strcpy(string, "NULL");
  491.   else
  492.     sprintf(string, "0x%X", memorypos);
  493.  
  494.   return(string);
  495. }
  496.  
  497.  
  498. void ListBitMaps()
  499. {
  500.   register struct BitMap *bitmap;
  501.   register struct structList *structitem;
  502.   register WORD plane;
  503.   WORD bitmapno;
  504.   extern struct structList structlist[MAXSTRUCTURE];
  505.  
  506.   structitem = structlist[BITMAP_KIND].next;
  507.  
  508.   while (structitem != NULL)
  509.   {
  510.     bitmap = (struct BitMap *)structitem->structure;
  511.     bitmapno = structitem->number;
  512.  
  513.     printf("struct BitMap bitmap%d =\n", bitmapno);
  514.     printf("{\n");
  515.     printf("  %d,\011/* BytesPerRow */\n", bitmap->BytesPerRow);
  516.     printf("  %d,\011/* Rows */\n", bitmap->Rows);
  517.     printf("  0x%X,\011/* Flags */\n", bitmap->Flags);
  518.     printf("  %d,\011/* Depth */\n", bitmap->Depth);
  519.     printf("  %d,\011/* Pad */\n", bitmap->pad);
  520.     printf("  {\011/* Planes */\n");
  521.     for (plane = 0; plane < 7; plane++)
  522.       printf("    %s,\n", MemoryName((APTR)(bitmap->Planes[plane])));
  523.     printf("    %s\n", MemoryName((APTR)(bitmap->Planes[7])));
  524.     printf("  }\n");
  525.     printf("};\n\n");
  526.  
  527.     structitem = structitem->next;
  528.   }
  529. }
  530.  
  531.  
  532. void ListBoolInfos()
  533. {
  534.   register struct BoolInfo *boolinfo;
  535.   register struct structList *structitem;
  536.   WORD boolinfono;
  537.   extern struct structList structlist[MAXSTRUCTURE];
  538.  
  539.   structitem = structlist[BOOLINFO_KIND].next;
  540.  
  541.   while (structitem != NULL)
  542.   {
  543.     boolinfo = (struct BoolInfo *)structitem->structure;
  544.     boolinfono = structitem->number;
  545.  
  546.     printf("struct BoolInfo boolinfo%d =\n", boolinfono);
  547.     printf("{\n");
  548.     printf("};\n\n");
  549.  
  550.     structitem = structitem->next;
  551.   }
  552. }
  553.  
  554.  
  555. void ListBorders()
  556. {
  557.   register struct Border *border;
  558.   register struct structList *structitem;
  559.   WORD borderno, xyno, nextborderno;
  560.   extern struct structList structlist[MAXSTRUCTURE];
  561.  
  562.   structitem = structlist[BORDER_KIND].next;
  563.  
  564.   while (structitem != NULL)
  565.   {
  566.     border = (struct Border *)structitem->structure;
  567.     borderno = structitem->number;
  568.  
  569.     xyno = NUMBER(borderno);
  570.     nextborderno = BorderNumber(border->NextBorder);
  571.  
  572.     if (border->XY != NULL)
  573.     {
  574.       printf("WORD xypair%d[%d] =\n", xyno, 2 * border->Count);
  575.       PrintWords("%d", "  ", "{", border->XY, "};", (WORD)(2 * border->Count), 8);
  576.     }
  577.  
  578.     printf("struct Border border%d =\n", borderno);
  579.     printf("{\n");
  580.     printf("  %d, %d,\011/* LeftEdge, TopEdge */\n", border->LeftEdge,
  581.         border->TopEdge);
  582.     printf("  %d, %d,\011/* FrontPen, BackPen */\n", border->FrontPen,
  583.         border->BackPen);
  584.     printf("  0x%X,\011/* DrawMode */\n", border->DrawMode);
  585.     printf("  %d,\011/* Count */\n", border->Count);
  586.     if (border->XY == NULL)
  587.       printf("  NULL");
  588.     else
  589.       printf("  &xypair%d[0]", xyno);
  590.     printf(",\011/* XY */\n");
  591.     printf("  %s\011/* NextBorder */\n", BorderName(nextborderno));
  592.     printf("};\n\n");
  593.  
  594.     structitem = structitem->next;
  595.   }
  596. }
  597.  
  598.  
  599. void ListGadgets()
  600. {
  601.   register struct Gadget *gadget;
  602.   register struct structList *structitem;
  603.   WORD gadgetno, nextgadgetno, gadgetrenderno, selectrenderno,
  604.       gadgettextno, specialinfono, gadgettype;
  605.   UBYTE *name;
  606.   extern struct structList structlist[MAXSTRUCTURE];
  607.  
  608.   structitem = structlist[GADGET_KIND].next;
  609.  
  610.   while (structitem != NULL)
  611.   {
  612.     gadget = (struct Gadget *)structitem->structure;
  613.     gadgetno = structitem->number;
  614.  
  615.     nextgadgetno = GadgetNumber(gadget->NextGadget);
  616.     if (gadget->Flags & GADGIMAGE)
  617.     {
  618.       gadgetrenderno = ImageNumber(gadget->GadgetRender);
  619.       selectrenderno = ImageNumber(gadget->SelectRender);
  620.     }
  621.     else
  622.     {
  623.       gadgetrenderno = BorderNumber(gadget->GadgetRender);
  624.       selectrenderno = BorderNumber(gadget->SelectRender);
  625.     }
  626.     gadgettextno = IntuiTextNumber(gadget->GadgetText);
  627.     gadgettype = gadget->GadgetType & 0x0F;
  628.     if (gadgettype == GADGET0002)
  629.       specialinfono = BoolInfoNumber(gadget->SpecialInfo);
  630.     else if (gadgettype == PROPGADGET)
  631.       specialinfono = PropInfoNumber(gadget->SpecialInfo);
  632.     else if (gadgettype == STRGADGET)
  633.       specialinfono = StringInfoNumber(gadget->SpecialInfo);
  634.     else
  635.       specialinfono = 0;
  636.  
  637.     printf("struct Gadget gadget%d =\n", gadgetno);
  638.     printf("{\n");
  639.     printf("  %s,\011/* NextGadget */\n", GadgetName(nextgadgetno));
  640.     printf("  %d, %d,\011/* LeftEdge, TopEdge */\n", gadget->LeftEdge,
  641.         gadget->TopEdge);
  642.     printf("  %d, %d,\011/* Width, Height */\n",gadget->Width, gadget->Height);
  643.     printf("  0x%X,\011/* Flags */\n", gadget->Flags);
  644.     printf("  0x%X,\011/* Activation */\n", gadget->Activation);
  645.     printf("  0x%X,\011/* GadgetType */\n", gadget->GadgetType);
  646.     if (gadget->Flags & GADGIMAGE)
  647.       name = ImageName(gadgetrenderno);
  648.     else
  649.       name = BorderName(gadgetrenderno);
  650.     printf("  %s,\011/* GadgetRender */\n", APTRName(name));
  651.     if (gadget->Flags & GADGIMAGE)
  652.       name = ImageName(selectrenderno);
  653.     else
  654.       name = BorderName(selectrenderno);
  655.     printf("  %s,\011/* SelectRender */\n", APTRName(name));
  656.     printf("  %s,\011/* GadgetText */\n", IntuiTextName(gadgettextno));
  657.     printf("  0x%X,\011/* MutualExclude */\n", gadget->MutualExclude);
  658.     if (gadgettype == GADGET0002)
  659.       name = BoolInfoName(specialinfono);
  660.     else if (gadgettype == PROPGADGET)
  661.       name = PropInfoName(specialinfono);
  662.     else if (gadgettype == STRGADGET)
  663.       name = StringInfoName(specialinfono);
  664.     else
  665.       name = MemoryName(gadget->SpecialInfo);
  666.     printf("  %s,\011/* SpecialInfo */\n", APTRName(name));
  667.     printf("  %d,\011/* GadgetID */\n", gadget->GadgetID);
  668.     printf("  %s\011/* UserData */\n", MemoryName(gadget->UserData));
  669.     printf("};\n\n");
  670.  
  671.     structitem = structitem->next;
  672.   }
  673. }
  674.  
  675.  
  676. void ListImages()
  677. {
  678.   register struct Image *image;
  679.   register struct structList *structitem;
  680.   register WORD count;
  681.   WORD imageno, imagedatano, nextimageno;
  682.   extern struct structList structlist[MAXSTRUCTURE];
  683.  
  684.   structitem = structlist[IMAGE_KIND].next;
  685.  
  686.   while (structitem != NULL)
  687.   {
  688.     image = (struct Image *)structitem->structure;
  689.     imageno = structitem->number;
  690.  
  691.     imagedatano = NUMBER(imageno);
  692.     nextimageno = ImageNumber(image->NextImage);
  693.  
  694.     if (image->ImageData != NULL)
  695.     {
  696.       count = image->Depth * image->Height * ((image->Width + 15) / 16);
  697.       printf("UWORD imagedata%d[%d] =\n", imagedatano, count);
  698.       PrintWords("0x%X", "  ", "{", image->ImageData, "};", count, 8);
  699.     }
  700.  
  701.     printf("struct Image image%d =\n", imageno);
  702.     printf("{\n");
  703.     printf("  %d, %d,\011/* LeftEdge, TopEdge */\n", image->LeftEdge,
  704.         image->TopEdge);
  705.     printf("  %d, %d,\011/* Width, Height */\n", image->Width, image->Height);
  706.     printf("  %d,\011/* Depth */\n", image->Depth);
  707.     if (image->ImageData == NULL)
  708.       printf("  NULL");
  709.     else
  710.       printf("  &imagedata%d[0]", imagedatano);
  711.     printf("\011/* ImageData */\n");
  712.     printf("};\n\n");
  713.  
  714.     structitem = structitem->next;
  715.   }
  716. }
  717.  
  718.  
  719. void ListIntuiMessages()
  720. {
  721.   register struct IntuiMessage *intuimessage;
  722.   register struct structList *structitem;
  723.   WORD intuimessageno;
  724.   extern struct structList structlist[MAXSTRUCTURE];
  725.  
  726.   structitem = structlist[INTUIMESSAGE_KIND].next;
  727.  
  728.   while (structitem != NULL)
  729.   {
  730.     intuimessage = (struct IntuiMessage *)structitem->structure;
  731.     intuimessageno = structitem->number;
  732.  
  733.     printf("struct IntuiMessage intuimessage%d =\n", intuimessageno);
  734.     printf("{\n");
  735.     printf("};\n\n");
  736.  
  737.     structitem = structitem->next;
  738.   }
  739. }
  740.  
  741.  
  742. void ListIntuiTexts()
  743. {
  744.   register struct IntuiText *intuitext;
  745.   register struct structList *structitem;
  746.   WORD intuitextno, itextfontno, nexttextno;
  747.   extern struct structList structlist[MAXSTRUCTURE];
  748.  
  749.   structitem = structlist[INTUITEXT_KIND].next;
  750.  
  751.   while (structitem != NULL)
  752.   {
  753.     intuitext = (struct IntuiText *)structitem->structure;
  754.     intuitextno = structitem->number;
  755.  
  756.     itextfontno = TextAttrNumber(intuitext->ITextFont);
  757.     nexttextno = IntuiTextNumber(intuitext->NextText);
  758.  
  759.     printf("struct IntuiText intuitext%d =\n", intuitextno);
  760.     printf("{\n");
  761.     printf("  %d, %d,\011/* FrontPen, BackPen */\n", intuitext->FrontPen,
  762.         intuitext->BackPen);
  763.     printf("  0x%X,\011/* DrawMode */\n", intuitext->DrawMode);
  764.     printf("  %d, %d,\011/* LeftEdge, TopEdge */\n", intuitext->LeftEdge,
  765.         intuitext->TopEdge);
  766.     printf("  %s,\011/* ITextFont */\n", TextAttrName(itextfontno));
  767.     printf("  %s,\011/* IText */\n", TitleName(intuitext->IText));
  768.     printf("  %s\011/* NextText */\n", IntuiTextName(nexttextno));
  769.     printf("};\n\n");
  770.  
  771.     structitem = structitem->next;
  772.   }
  773. }
  774.  
  775.  
  776. void ListKeyMaps()
  777. {
  778.   register struct KeyMap *keymap;
  779.   register struct structList *structitem;
  780.   WORD keymapno;
  781.   extern struct structList structlist[MAXSTRUCTURE];
  782.  
  783.   structitem = structlist[KEYMAP_KIND].next;
  784.  
  785.   while (structitem != NULL)
  786.   {
  787.     keymap = (struct KeyMap *)structitem->structure;
  788.     keymapno = structitem->number;
  789.  
  790.     printf("struct KeyMap keymap%d =\n", keymapno);
  791.     printf("{\n");
  792.     printf("};\n\n");
  793.  
  794.     structitem = structitem->next;
  795.   }
  796. }
  797.  
  798.  
  799. void ListLayers()
  800. {
  801.   register struct Layer *layer;
  802.   register struct structList *structitem;
  803.   WORD layerno;
  804.   extern struct structList structlist[MAXSTRUCTURE];
  805.  
  806.   structitem = structlist[LAYER_KIND].next;
  807.  
  808.   while (structitem != NULL)
  809.   {
  810.     layer = (struct Layer *)structitem->structure;
  811.     layerno = structitem->number;
  812.  
  813.     printf("struct Layer layer%d =\n", layerno);
  814.     printf("{\n");
  815.     printf("};\n\n");
  816.  
  817.     structitem = structitem->next;
  818.   }
  819. }
  820.  
  821.  
  822. void ListMenus()
  823. {
  824.   register struct Menu *menu;
  825.   register struct structList *structitem;
  826.   WORD menuno;
  827.   extern struct structList structlist[MAXSTRUCTURE];
  828.  
  829.   structitem = structlist[MENU_KIND].next;
  830.  
  831.   while (structitem != NULL)
  832.   {
  833.     menu = (struct Menu *)structitem->structure;
  834.     menuno = structitem->number;
  835.  
  836.     printf("struct Menu menu%d =\n", menuno);
  837.     printf("{\n");
  838.     printf("};\n\n");
  839.  
  840.     structitem = structitem->next;
  841.   }
  842. }
  843.  
  844.  
  845. void ListMsgPorts()
  846. {
  847.   register struct MsgPort *msgport;
  848.   register struct structList *structitem;
  849.   WORD msgportno;
  850.   extern struct structList structlist[MAXSTRUCTURE];
  851.  
  852.   structitem = structlist[MSGPORT_KIND].next;
  853.  
  854.   while (structitem != NULL)
  855.   {
  856.     msgport = (struct MsgPort *)structitem->structure;
  857.     msgportno = structitem->number;
  858.  
  859.     printf("struct MsgPort msgport%d =\n", msgportno);
  860.     printf("{\n");
  861.     printf("};\n\n");
  862.  
  863.     structitem = structitem->next;
  864.   }
  865. }
  866.  
  867.  
  868. void ListPropInfos()
  869. {
  870.   register struct PropInfo *propinfo;
  871.   register struct structList *structitem;
  872.   WORD propinfono;
  873.   extern struct structList structlist[MAXSTRUCTURE];
  874.  
  875.   structitem = structlist[PROPINFO_KIND].next;
  876.  
  877.   while (structitem != NULL)
  878.   {
  879.     propinfo = (struct PropInfo *)structitem->structure;
  880.     propinfono = structitem->number;
  881.  
  882.     printf("struct PropInfo propinfo%d =\n", propinfono);
  883.     printf("{\n");
  884.     printf("};\n\n");
  885.  
  886.     structitem = structitem->next;
  887.   }
  888. }
  889.  
  890.  
  891. void ListRastPorts()
  892. {
  893.   register struct RastPort *rastport;
  894.   register struct structList *structitem;
  895.   WORD rastportno;
  896.   extern struct structList structlist[MAXSTRUCTURE];
  897.  
  898.   structitem = structlist[RASTPORT_KIND].next;
  899.  
  900.   while (structitem != NULL)
  901.   {
  902.     rastport = (struct RastPort *)structitem->structure;
  903.     rastportno = structitem->number;
  904.  
  905.     printf("struct RastPort rastport%d =\n", rastportno);
  906.     printf("{\n");
  907.     printf("};\n\n");
  908.  
  909.     structitem = structitem->next;
  910.   }
  911. }
  912.  
  913.  
  914. void ListRequesters()
  915. {
  916.   register struct Requester *requester;
  917.   register struct structList *structitem;
  918.   WORD requesterno, olderrequestno, reqgadgetno, reqborderno, reqtextno,
  919.       reqlayerno, imagebmapno, rwindowno;
  920.   extern struct structList structlist[MAXSTRUCTURE];
  921.  
  922.   structitem = structlist[REQUESTER_KIND].next;
  923.  
  924.   while (structitem != NULL)
  925.   {
  926.     requester = (struct Requester *)structitem->structure;
  927.     requesterno = structitem->number;
  928.  
  929.     olderrequestno = RequesterNumber(requester->OlderRequest);
  930.     reqgadgetno = GadgetNumber(requester->ReqGadget);
  931.     reqborderno = BorderNumber(requester->ReqBorder);
  932.     reqtextno = IntuiTextNumber(requester->ReqText);
  933.     reqlayerno = LayerNumber(requester->ReqLayer);
  934.     imagebmapno = BitMapNumber(requester->ImageBMap);
  935.     rwindowno = WindowNumber(requester->RWindow);
  936.  
  937.     printf("struct Requester requester%d =\n", requesterno);
  938.     printf("{\n");
  939.     printf("  %s,\011/* OlderRequest */\n", RequesterName(requesterno));
  940.     printf("  %d, %d,\011/* LeftEdge, TopEdge */\n", requester->LeftEdge,
  941.         requester->TopEdge);
  942.     printf("  %d, %d,\011/* Width, Height */\n", requester->Width,
  943.         requester->Height);
  944.     printf("  %d, %d,\011/* RelLeft, RelTop */\n", requester->RelLeft,
  945.         requester->RelTop);
  946.     printf("  %s,\011/* ReqGadget */\n", GadgetName(reqgadgetno));
  947.     printf("  %s,\011/* ReqBorder */\n", BorderName(reqborderno));
  948.     printf("  %s,\011/* ReqText */\n", IntuiTextName(reqtextno));
  949.     printf("  0x%X,\011/* Flags */\n", requester->Flags);
  950.     printf("  %d,\011/* BackFill */\n", requester->BackFill);
  951.     printf("  %s,\011/* ReqLayer */\n", LayerName(reqlayerno));
  952.     PrintBytes("    ", "  {\011/* ReqPad1 */", requester->ReqPad1, "  },",
  953.         32, 8);
  954.     printf("  %s,\011/* ImageBMap */\n", BitMapName(imagebmapno));
  955.     printf("  %s,\011/* RWindow */\n", WindowName(rwindowno));
  956.     PrintBytes("    ", "  {\011/* ReqPad2 */", requester->ReqPad2, "  }",
  957.        36, 9);
  958.     printf("};\n\n");
  959.  
  960.     structitem = structitem->next;
  961.   }
  962. }
  963.  
  964.  
  965. void ListScreens()
  966. {
  967.   register struct Screen *screen;
  968.   register struct structList *structitem;
  969.   WORD screenno;
  970.   extern struct structList structlist[MAXSTRUCTURE];
  971.  
  972.   structitem = structlist[SCREEN_KIND].next;
  973.  
  974.   while (structitem != NULL)
  975.   {
  976.     screen = (struct Screen *)structitem->structure;
  977.     screenno = structitem->number;
  978.  
  979.     printf("struct Screen screen%d =\n", screenno);
  980.     printf("{\n");
  981.     printf("};\n\n");
  982.  
  983.     structitem = structitem->next;
  984.   }
  985. }
  986.  
  987.  
  988. void ListStringInfos()
  989. {
  990.   register struct StringInfo *stringinfo;
  991.   register struct structList *structitem;
  992.   WORD stringinfono, layerptrno, altkeymapno;
  993.   extern struct structList structlist[MAXSTRUCTURE];
  994.  
  995.   structitem = structlist[STRINGINFO_KIND].next;
  996.  
  997.   while (structitem != NULL)
  998.   {
  999.     stringinfo = (struct StringInfo *)structitem->structure;
  1000.     stringinfono = structitem->number;
  1001.  
  1002.     layerptrno = LayerNumber(stringinfo->LayerPtr);
  1003.     altkeymapno = KeyMapNumber(stringinfo->AltKeyMap);
  1004.  
  1005.     printf("struct StringInfo stringinfo%d =\n", stringinfono);
  1006.     printf("{\n");
  1007.     printf("  %s,\011/* Buffer */\n", TitleName(stringinfo->Buffer));
  1008.     printf("  %s,\011/* UndoBuffer */\n", TitleName(stringinfo->UndoBuffer));
  1009.     printf("  %d,\011/* BufferPos */\n", stringinfo->BufferPos);
  1010.     printf("  %d,\011/* MaxChars */\n", stringinfo->MaxChars);
  1011.     printf("  %d,\011/* DispPos */\n", stringinfo->DispPos);
  1012.     printf("  %d,\011/* UndoPos */\n", stringinfo->UndoPos);
  1013.     printf("  %d,\011/* NumChars */\n", stringinfo->NumChars);
  1014.     printf("  %d,\011/* DispCount */\n", stringinfo->DispCount);
  1015.     printf("  %d, %d,\011/* CLeft, CTop */\n", stringinfo->CLeft,
  1016.         stringinfo->CTop);
  1017.     printf("  %s,\011/* LayerPtr */\n", LayerName(layerptrno));
  1018.     printf("  %d,\011/* LongInt */\n", stringinfo->LongInt);
  1019.     printf("  %s\011/* AltKeyMap */\n", KeyMapName(altkeymapno));
  1020.     printf("};\n\n");
  1021.  
  1022.     structitem = structitem->next;
  1023.   }
  1024. }
  1025.  
  1026.  
  1027. void ListTextAttrs()
  1028. {
  1029.   register struct TextAttr *textattr;
  1030.   register struct structList *structitem;
  1031.   WORD textattrno;
  1032.   extern struct structList structlist[MAXSTRUCTURE];
  1033.  
  1034.   structitem = structlist[TEXTATTR_KIND].next;
  1035.  
  1036.   while (structitem != NULL)
  1037.   {
  1038.     textattr = (struct TextAttr *)structitem->structure;
  1039.     textattrno = structitem->number;
  1040.  
  1041.     printf("struct TextAttr textattr%d =\n", textattrno);
  1042.     printf("{\n");
  1043.     printf("};\n\n");
  1044.  
  1045.     structitem = structitem->next;
  1046.   }
  1047. }
  1048.  
  1049.  
  1050. void ListTextFonts()
  1051. {
  1052.   register struct TextFont *textfont;
  1053.   register struct structList *structitem;
  1054.   WORD textfontno;
  1055.   extern struct structList structlist[MAXSTRUCTURE];
  1056.  
  1057.   structitem = structlist[TEXTFONT_KIND].next;
  1058.  
  1059.   while (structitem != NULL)
  1060.   {
  1061.     textfont = (struct TextFont *)structitem->structure;
  1062.     textfontno = structitem->number;
  1063.  
  1064.     printf("struct TextFont textfont%d =\n", textfontno);
  1065.     printf("{\n");
  1066.     printf("};\n\n");
  1067.  
  1068.     structitem = structitem->next;
  1069.   }
  1070. }
  1071.  
  1072.  
  1073. void ListWindows()
  1074. {
  1075.   register struct Window *window;
  1076.   register struct structList *structitem;
  1077.   WORD windowno, menustripno, firstrequestno, dmrequestno, rportno,
  1078.       borderrportno, firstgadgetno, parentwindowno, descendantwindowno,
  1079.       pointerno, userportno, windowportno, messagekeyno, checkmarkno,
  1080.       wlayerno, ifontno, wscreenno, nextwindowno, count;
  1081.   extern struct structList structlist[MAXSTRUCTURE];
  1082.  
  1083.   structitem = structlist[WINDOW_KIND].next;
  1084.  
  1085.   while (structitem != NULL)
  1086.   {
  1087.     window = (struct Window *)structitem->structure;
  1088.     windowno = structitem->number;
  1089.  
  1090.     nextwindowno = WindowNumber(window->NextWindow);
  1091.     menustripno = MenuNumber(window->MenuStrip);
  1092.     firstrequestno = RequesterNumber(window->FirstRequest);
  1093.     dmrequestno = RequesterNumber(window->DMRequest);
  1094.     wscreenno = ScreenNumber(window->WScreen);
  1095.     rportno = RastPortNumber(window->RPort);
  1096.     borderrportno = RastPortNumber(window->BorderRPort);
  1097.     firstgadgetno = GadgetNumber(window->FirstGadget);
  1098.     parentwindowno = WindowNumber(window->Parent);
  1099.     descendantwindowno = WindowNumber(window->Descendant);
  1100.     pointerno = NUMBER(windowno);
  1101.     userportno = MsgPortNumber(window->UserPort);
  1102.     windowportno = MsgPortNumber(window->WindowPort);
  1103.     messagekeyno = IntuiMessageNumber(window->MessageKey);
  1104.     checkmarkno = ImageNumber(window->CheckMark);
  1105.     wlayerno = LayerNumber(window->WLayer);
  1106.     ifontno = TextFontNumber(window->IFont);
  1107.  
  1108.     if (window->Pointer != NULL)
  1109.     {
  1110.       count = 2 * window->PtrHeight;
  1111.       printf("WORD pointer%d[%d] =\n", pointerno, count);
  1112.       PrintWords("0x%X", "  ", "{", window->Pointer, "};", count, 8);
  1113.     }
  1114.  
  1115.     printf("struct Window window%d =\n", windowno);
  1116.     printf("{\n");
  1117.     printf("  %s,\011/* NextWindow */\n", WindowName(nextwindowno));
  1118.     printf("  %d, %d,\011/* LeftEdge, TopEdge */\n", window->LeftEdge,
  1119.         window->TopEdge);
  1120.     printf("  %d, %d,\011/* Width, Height */\n", window->Width, window->Height);
  1121.     printf("  %d, %d,\011/* MouseY, MouseX */\n", window->MouseY, window->MouseX);
  1122.     printf("  %d, %d,\011/* MinWidth, MinHeight */\n", window->MinWidth,
  1123.         window->MinHeight);
  1124.     printf("  %d, %d,\011/* MaxWidth, MaxHeight */\n", window->MaxWidth,
  1125.         window->MaxHeight);
  1126.     printf("  0x%X,\011/* Flags */\n", window->Flags);
  1127.     printf("  %s,\011/* MenuStrip */\n", MenuName(menustripno));
  1128.     printf("  %s,\011/* Title */\n", TitleName(window->Title));
  1129.     printf("  %s,\011/* FirstRequest */\n", RequesterName(firstrequestno));
  1130.     printf("  %s,\011/* DMRequest */\n", RequesterName(dmrequestno));
  1131.     printf("  %d,\011/* ReqCount */\n", window->ReqCount);
  1132.     printf("  %s,\011/* WScreen */\n", ScreenName(wscreenno));
  1133.     printf("  %s,\011/* RPort */\n", RastPortName(rportno));
  1134.     printf("  %d, %d,\011/* BorderLeft, BorderTop */\n", window->BorderLeft,
  1135.         window->BorderTop);
  1136.     printf("  %d, %d,\011/* BorderRight, BorderBottom */\n", window->BorderRight,
  1137.         window->BorderBottom);
  1138.     printf("  %s,\011/* BorderRPort */\n", RastPortName(borderrportno));
  1139.     printf("  %s,\011/* FirstGadget */\n", GadgetName(firstgadgetno));
  1140.     printf("  %s,\011/* Parent */\n", WindowName(parentwindowno));
  1141.     printf("  %s,\011/* Descendant */\n", WindowName(descendantwindowno));
  1142.     if (window->Pointer == NULL)
  1143.       printf("  NULL");
  1144.     else
  1145.       printf("  &pointer%d", pointerno);
  1146.     printf(",\011/* Pointer */\n");
  1147.     printf("  %d, %d,\011/* PtrHeight, PtrWidth */\n", window->PtrHeight,
  1148.         window->PtrWidth);
  1149.     printf("  %d, %d,\011/* XOffset, YOffset */\n", window->XOffset,
  1150.         window->YOffset);
  1151.     printf("  0x%X,\011/* IDCMPFlags */\n", window->IDCMPFlags);
  1152.     printf("  %s,\011/* UserPort */\n", MsgPortName(userportno));
  1153.     printf("  %s,\011/* WindowPort */\n", MsgPortName(windowportno));
  1154.     printf("  %s,\011/* MessageKey */\n", IntuiMessageName(messagekeyno));
  1155.     printf("  %d, %d,\011/* DetailPen, BlockPen */\n", window->DetailPen,
  1156.         window->BlockPen);
  1157.     printf("  %s,\011/* CheckMark */\n", ImageName(checkmarkno));
  1158.     printf("  %s,\011/* ScreenTitle */\n", TitleName(window->ScreenTitle));
  1159.     printf("  %d, %d,\011/* GZZMouseX, GZZMouseY */\n", window->GZZMouseX,
  1160.         window->GZZMouseY);
  1161.     printf("  %d, %d,\011/* GZZWidth, GZZHeight */\n", window->GZZWidth,
  1162.         window->GZZHeight);
  1163.     printf("  %s,\011/* ExtData */\n", MemoryName((APTR)window->ExtData));
  1164.     printf("  %s,\011/* UserData */\n", MemoryName((APTR)window->UserData));
  1165.     printf("  %s,\011/* WLayer */\n", LayerName(wlayerno));
  1166.     printf("  %s\011/* IFont */\n", TextFontName(ifontno));
  1167.     printf("};\n\n");
  1168.  
  1169.     structitem = structitem->next;
  1170.   }
  1171. }
  1172.  
  1173.  
  1174. void PrintBytes(indenttext, text1, bytes, text2, length, rowlength)
  1175. register UBYTE *indenttext, *text1, *bytes, *text2;
  1176. register WORD length, rowlength;
  1177. {
  1178.   register WORD byte;
  1179.  
  1180.   printf("%s\n", text1);
  1181.  
  1182.   for (byte = 0; byte < length; byte++)
  1183.   {
  1184.     if (byte % rowlength == 0)
  1185.       printf("    ");
  1186.     printf("%d", bytes[byte]);
  1187.  
  1188.     if (byte != (length - 1))
  1189.       printf(", ");
  1190.     if ((byte + 1) % rowlength == 0 || byte == (length - 1))
  1191.       printf("\n");
  1192.   }
  1193.  
  1194.   printf("%s\n", text2);
  1195. }
  1196.  
  1197.  
  1198. void PrintWords(format, indenttext, text1, words, text2, length, rowlength)
  1199. register UBYTE *format, *indenttext, *text1, *text2;
  1200. register UWORD *words;
  1201. register WORD length, rowlength;
  1202. {
  1203.   register WORD word;
  1204.  
  1205.   printf("%s\n", text1);
  1206.  
  1207.   for (word = 0; word < length; word++)
  1208.   {
  1209.     if (word % rowlength == 0)
  1210.       printf("    ");
  1211.     printf(format, words[word]);
  1212.  
  1213.     if (word != (length - 1))
  1214.       printf(", ");
  1215.     if ((word + 1) % rowlength == 0 || word == (length - 1))
  1216.       printf("\n");
  1217.   }
  1218.  
  1219.   printf("%s\n", text2);
  1220. }
  1221.