Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!ll-xn!ames!amdahl!kim From: kim@amdahl.UUCP (Kim DeVaughn) Newsgroups: comp.sys.amiga Subject: Structure Browser (part 1 of 2, the sources) Message-ID: <6468@amdahl.UUCP> Date: Mon, 4-May-87 16:05:30 EDT Article-I.D.: amdahl.6468 Posted: Mon May 4 16:05:30 1987 Date-Received: Tue, 5-May-87 04:55:26 EDT Organization: Amdahl Corporation, Sunnyvale, CA 94086 Lines: 1395 Keywords: structure browser menus intuition Transactor source [ For all you do ... this line's for you ... ] I came across this tool on one of the local BBS's over the weekend. It was originally published in the Transactor magazine, and from the comments (in the printed, magazine version), it is freely redistributable. Since there have been a few utilities posted here recently that "twiddle" various structures in running applications to modify menus, and such, I thought y'all might find it useful. The article in the Transactor has alot of useful supplementary material as well. BTW, this magazine is about 80% oriented toward the C-68/128 machines, but the 20% coverage they're devoting to the Amiga truly makes it worthwhile for Amiga hackers ... very good, *technical* articles, source, etc. (the current July '87 issue has Bryce Nesbitt's "Pop To Front" program [in assembler] for the currently active window, for example). Hi, Bryce, and thanks! Anyhow, if you're interested in the Transactor, their addresses are: U.S.: Transactor Canada: Transactor PO Box 338 Station 'C' 501 Alden Road Buffalo, NY 14209-990 PO Box 3250 Markham Industrial Park Markham, Ontario L3R 9Z9 Subscriptions are $15 for 6 issues (US or Canadian), and as of the July issue, will ONLY be available by subscription (pity ... you should see what the Postal Carrier does to my magazines :-( )! The Structure Browser article was in the May 1987 issue, and back issues are available ($4.50), as are disks. I know, I know, the above is a bit commercial, but these people are providing quality information, and seem to be rather "obscure" ... hence, the plug! (And no, I'm not affiliated with them in any way ... wish they were 80/20 the other way with their Amiga coverage, though!) So without further verbosity, here is the Structure Browser (the uuencoded executable will be along in part 2). Watch for the .signature at the end ... if it ain't there, you didn't get everything! /kim # This is a shell archive. Remove anything before this line, then # unpack it by saving it in a file and typing "sh file". (Files # unpacked will be owned by you and have default permissions.) # # This archive contains: # sb.c sb.doc sb.h sb.lnk sbGadget.c sbGraphics.c sbIntuiText.c sbMsgPort.c sbNode.c sbScreen.c sbTextAttr.c sbWindow.c sbio.c echo x - sb.c cat > "sb.c" << '//E*O*F sb.c//' /* The Transactor Structure Browser (SB) V1.0 * From Transactor Magazine, Volume 7, Issue 6 * * By Nick Sullivan and Chris Zamara (AHA!) (c) 1986 * * SB displays system structures via pointers found * in other structures. You start from IntuitionBase. * * Structures implemented in V1.0: * IntuitionBase, Window, Screen, RastPort, BitMap, Gadget * * Usage is through Intuition, clicking on a structure member * names to display info or a new structure. * * ***** THIS PROGRAM MAY BE FREELY DISTRIBUTED ***** */ /* include not needed for Aztec C using provided makefile */ /* I keep all the files in directory sb on df1: * To keep the system happy, I 'ASSIGN SB: DF1:SB' then 'CD SB:'. GG. */ #include "sb:sb.h" #define MIN(x,y) ((x)<(y)?(x):(y)) #define FLAGFIELDS 4 extern struct IntuitionBase *IntuitionBase; extern struct IntuiText ChoiceText[], BackIText; APTR OpenLibrary (); int level = 0; /* current level of nesting */ static char textlines[MAXGADG + 1][80]; extern void PrIntuiBase(), HexLine(); void main() { int choice = -1; SetupGadg(); OpenStuff(); /* open intuition library & window */ while (choice) { putHeader("Choose a library structure", NULL); ChoiceText[0].IText = (UBYTE *)" Intuition struct Library"; BackIText.IText = (UBYTE *)" Quit Program"; switch (choice = GetChoice(1)) { case 1: PrIntuiBase ("The IntuitionBase structure", IntuitionBase); break; } } CloseOut(); } void PrIntuiBase (string, IBase) char *string; struct IntuitionBase *IBase; { static struct StructData structdata[] = { { "(LibMode", "struct Library)", 0, SZ(Library) }, { "(ViewLord", "struct View)", 0, SZ(View) }, { " ActiveWindow", "struct Window *", 5, PTRSIZE }, { " ActiveScreen", "struct Screen *", 5, PTRSIZE }, { " FirstScreen", "struct Screen *", 5, PTRSIZE } }; int sum, choice = -1; level++; while (choice) { sum = SetOptionText(string, structdata, (APTR)IBase, DATASIZE, 0); switch (choice = GetChoice(DATASIZE)) { case 3: if (IBase->ActiveWindow) PrWindow("The currently active window", IBase->ActiveWindow); break; case 4: PrScreen("The currently active screen", IBase->ActiveScreen); break; case 5: PrScreen("The first screen on Intuition's list", IBase->FirstScreen); break; } } level--; } void put (option, stuff, base, offset) int option; struct StructData *stuff; char *base; int offset; { register long lnum; register int inum; char buf[40]; int i; sprintf(textlines[option], "%-16s%-24s", stuff->membername, stuff->membertype); switch (stuff->printtype) { case 0: /* don't print anything */ buf[0] = '\0'; break; case 1: /* print a long */ lnum = *(long *)(base + offset); sprintf(buf, "$%8lx %0ld", lnum, lnum); break; case 2: /* print an int */ inum = *(short *)(base + offset); sprintf(buf, "$%8x %10d", inum, inum); break; case 3: /* print a byte */ inum = *(base + offset); sprintf(buf, "$%8x %10d", inum, inum); break; case 4: /* print a string */ if (!(lnum = *(long *)(base + offset) )) sprintf(buf, "NULL"); else { for (i = 0; i < 30 && *((char *)lnum + i); i++) buf[i + 1] = *((char *)lnum + i); buf[0] = buf[i + 1] = '\"'; buf[i + 2] = '\0'; if (*((char *)lnum + i)) strcat(buf, "..."); } break; case 5: /* print a pointer */ if (!(lnum = *(long *)(base + offset) )) sprintf(buf, "NULL"); else sprintf(buf, "$%8lx %10ld", lnum, lnum); break; case 11: /* print a long */ lnum = *(long *)(base + offset); sprintf(buf, "$%8lx %10lu", lnum, lnum); break; case 12: /* print an int */ inum = *(short *)(base + offset); sprintf(buf, "$%8x %10u", inum, inum); break; case 13: /* print a byte */ inum = *(base + offset); sprintf(buf, "$%8x %10u", inum, inum); break; } strcat(textlines[option], buf); ChoiceText[option].IText = (UBYTE *)textlines[option]; } void FlagPrint(string, names, flags) char *string, **names; ULONG flags; { int i, line, fields = FLAGFIELDS; char buf[32]; SetBackText(1); /* 'prev level' */ for (i = 0; i < 8; i++) { strcpy(textlines[i], "-"); ChoiceText[i].IText = (UBYTE *)textlines[i]; } putHeader(string, NULL); for (i = line = 0; i < 32; i++) { if ((flags & (1L << i)) && names[i]) { sprintf(buf, "%-19s", names[i]); strcat(textlines[line], buf); if (!--fields) { ChoiceText[line].IText = (UBYTE *)textlines[line]; line++; fields = FLAGFIELDS; } } } if (fields < FLAGFIELDS) ChoiceText[line].IText = (UBYTE *)textlines[line]; while (GetChoice(line + 1)) ; } void HexDump(string, address, unit, size) char *address, *string; int unit; long size; { int line = 0, c; char *buf[80]; BackIText.IText = (UBYTE *)" Exit Hex Dump "; if (size == -1) size = 0x7ffff; do { sprintf(buf, "%s from %lx (%ld)", string, address, address); putHeader(buf, NULL); if (line == MAXGADG) line = 0; while (line < MAXGADG && size > 0) { HexLine(address, unit, line++, size); size -= 16; address += 16; } c = GetChoice(size > 0 ? MAXGADG + 1 : line); } while (size > 0 && c == MOREGADG); } void HexLine (address, unit, line, size) UBYTE *address; int unit, line; long size; { USHORT i, j; char buf[80]; static char hexdigit[] = "0123456789ABCDEF"; sprintf(textlines[line], "-%6lx: ", address); for (i = 0; i < MIN(size, 16); i += unit) { switch (unit) { case BYTESIZE: j = *(address + i); sprintf(buf, "%c%c ", hexdigit[j / 16], hexdigit[j % 16]); break; case INTSIZE: sprintf(buf, "%04x ", *(short *)(address + i)); break; case PTRSIZE: sprintf(buf, "%08lx ", *(long *)(address + i)); break; } strcat(textlines[line], buf); } ChoiceText[line].IText = (UBYTE *)textlines[line]; } int SetOptionText (hdrtext, data, object, size, offset) char *hdrtext; struct StructData *data; APTR object; int size, offset; { int i, sum; SetBackText( offset ? 1 : 0); putHeader(hdrtext, object); for (i = sum = 0; i < size; i++) { put(i, &data[i], object, sum + offset); sum += data[i].datasize; } return (sum + offset); } void PrString(heading, string) char *heading, *string; { char *newstring, *malloc(); putHeader(heading, NULL); newstring = malloc(strlen(string) + 1); *newstring = '-'; strcpy(newstring + 1, string); ChoiceText[0].IText = (UBYTE *)newstring; GetChoice(1); free(newstring); } //E*O*F sb.c// echo x - sb.doc cat > "sb.doc" << '//E*O*F sb.doc//' Panorama Librarian: Please read note at bottom ********************* CUT HERE ********************* Structure Browser The Transactor, May 1987, Volume 7, Issue 6 There are two changes from the original listings for Lattice C. One relates to the size of an integer in the defines. The size of an integer in Aztec is sixteen bits, however, Lattice uses thirty-two. I changed the define to SHORT. The other change is in one of the structure definitions where a BYTESIZE definition needed to be padded to sixteen bits by calling it INTSIZE for proper alignment purposes. These are all the changes I can remember I had to do. I also have added a few additional structure definitions and will be adding more as I find spare time. One thing to remember when traversing linked structures... the Amiga is constantly in action and what may have been a valid pointer when it was displayed but may be pointing to garbage by the time you actually look at the data it was pointing to. Anybody interested in looking at the nitty-gritties of the system should find this program interesting and possibly even enlightening. Please buy a copy of the magazine to help support the publishing of additional excellent programs like this one. There are also two other Amiga articles in the same issue. The first gives some insight into the infamous GURU messages and the other describes Amiga file structures. ********************** CUT HERE *********************** Panorama Librarian: Please confirm we can release this without violating any copyright notices. The fine print on page 2 states... "All material is copyright by Transactor Publications Inc. Reproduction in any form without permission is in violation of applicable laws." //E*O*F sb.doc// echo x - sb.h cat > "sb.h" << '//E*O*F sb.h//' /* Lattice C Ver 3.1 */ #include #include #include #include #define SZ(x) sizeof(struct x) #define DATASIZE ( sizeof(structdata) / sizeof(struct StructData) ) #define PTRSIZE sizeof(APTR) /* for Aztec C make the following 'sizeof(int)' */ #define INTSIZE sizeof(short) #define BYTESIZE sizeof(char) #define MAXGADG 16 #define MOREGADG 25 /* id of "more" gadget */ struct StructData { char *membername; char *membertype; int printtype; int datasize; }; //E*O*F sb.h// echo x - sb.lnk cat > "sb.lnk" << '//E*O*F sb.lnk//' FROM LIB:c.o+ sb.o+ sbGadget.o+ sbGraphics.o+ sbio.o+ sbScreen.o+ sbWindow.o+ sbIntuiText.o+ sbTextAttr.o+ sbMsgPort.o+ sbNode.o TO sb LIB LIB:lc.lib+ LIB:amiga.lib MAP sb.map //E*O*F sb.lnk// echo x - sbGadget.c cat > "sbGadget.c" << '//E*O*F sbGadget.c//' /* include not needed for Aztec C using provided makefile */ #include "sb:sb.h" extern int level; void PrGadget(string, gadget) char *string; struct Gadget *gadget; { static struct StructData structdata[] = { { " NextGadget", "struct Gadget *", 5, PTRSIZE }, { "-LeftEdge", "SHORT", 2, INTSIZE }, { "-TopEdge", "SHORT", 2, INTSIZE }, { "-Width", "SHORT", 2, INTSIZE }, { "-Height", "SHORT", 2, INTSIZE }, { " Flags", "USHORT", 12, INTSIZE }, { " Activation", "USHORT", 12, INTSIZE }, { " GadgetType", "USHORT", 12, INTSIZE }, { "(GadgetRender", "APTR)", 5, PTRSIZE }, { "(SelectRender", "APTR)", 5, PTRSIZE }, { " GadgetText", "struct IntuiText *", 5, PTRSIZE }, { "-MutualExclude","LONG", 1, PTRSIZE }, { "(SpecialInfo", "APTR)", 5, PTRSIZE }, { "-GadgetID", "USHORT", 12, INTSIZE }, { "-UserData", "APTR", 5, PTRSIZE } }; static char *flagnames[16] = { "GADGHBOX", "GADGHIMAGE", "GADGIMAGE", "GRELBOTTOM", "GRELRIGHT", "GRELWIDTH", "GRELHEIGHT", "SELECTED", "GADGDISABLED" }; static char *activatenames[16] = { "RELVERIFY", "GADGIMMEDIATE", "ENDGADGET", "FOLLOWMOUSE", "RIGHTBORDER", "LEFTBORDER", "TOPBORDER", "BOTTOMBORDER", "TOGGLESELECT", "STRINGCENTER", "STRINGRIGHT", "LONGINT", "ALTKEYMAP", "BOOLEXTEND" }; static char *systypenames[16] = { "SIZING", "WDRAGGING", "SDRAGGING", "WUPFRONT", "SUPFRONT", "WDOWNBACK", "SDOWNBACK", "CLOSE", NULL, NULL, NULL, NULL, "REQGADGET", "GZZGADGET", "SCRGADGET", "SYSGADET" }; static char *applitypenames[16] = { "BOOLGADGET", "GADGET0002", "PROPGADGET", "STRGADGET", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "REQGADGET", "GZZGADGET", "SCRGADGET", "SYSGADGET" }; int sum, choice = -1; USHORT bits; level++; while (choice) { sum = SetOptionText(string, structdata, (APTR)gadget, DATASIZE, 0); switch (choice = GetChoice(DATASIZE)) { case 1: if (gadget->NextGadget) PrGadget("The next gadget in Intuition's list", gadget->NextGadget); break; case 6: bits = gadget->Flags; switch (bits & GADGHIGHBITS) { case 0: flagnames[0] = "GADGHCOMP"; bits |= 0x01; break; case 1: flagnames[0] = "GADGHBOX"; break; case 2: flagnames[1] = "GADGHIMAGE"; break; case 3: flagnames[1] = "GADGHNONE"; bits ^= 0x01; break; } FlagPrint("Flags set for this gadget", flagnames, (ULONG)bits); break; case 7: FlagPrint("Activation flags set for this gadget", activatenames, (ULONG)gadget->Activation); break; case 8: bits = gadget->GadgetType; if (bits & SYSGADGET) { bits = (bits & 0xff00) | (1 << (((bits & 0xf0) >> 4) - 1)); FlagPrint("Gadget type flags set for this gadget", systypenames, (ULONG)bits); } else { bits = (bits & 0xff00) | (1 << ((bits & 0x0f) - 1)); FlagPrint("Gadget type flags set for this gadget", applitypenames, (ULONG)bits); } break; case 11: if (gadget->GadgetText) PrIntuiText("The gadget's first text (IntuiText structure)", gadget->GadgetText); break; } } level--; } //E*O*F sbGadget.c// echo x - sbGraphics.c cat > "sbGraphics.c" << '//E*O*F sbGraphics.c//' /* include not needed for Aztec C using provided makefile */ #include "sb:sb.h" extern int level; extern void PrPlanes(), PrRastPort2(); void PrBitMap(string, bitmap) char *string; struct BitMap *bitmap; { static struct StructData structdata[] = { { "-BytesPerRow", "UWORD", 12, INTSIZE }, { "-Rows", "UWORD", 12, INTSIZE }, { "-Flags", "UBYTE", 13, BYTESIZE }, { "-Depth", "UBYTE", 13, BYTESIZE }, { "-Pad", "UWORD", 12, INTSIZE }, { " Planes[8]", "PLANEPTR", 5, PTRSIZE * 8} }; int sum, choice = -1; level++; while (choice) { sum = SetOptionText(string, structdata, (APTR)bitmap, DATASIZE, 0); if ((choice = GetChoice(DATASIZE)) == 6) PrPlanes("BitPlanes belong to the BitMap", bitmap->Planes, bitmap->Rows, bitmap->BytesPerRow); } level--; } void PrPlanes(string, planes, rows, bytes) char *string; PLANEPTR planes[]; UWORD rows, bytes; { static struct StructData structdata[] = { {" BitPlabe[0]", "PLANEPTR", 5, PTRSIZE }, {" BitPlabe[1]", "PLANEPTR", 5, PTRSIZE }, {" BitPlabe[2]", "PLANEPTR", 5, PTRSIZE }, {" BitPlabe[3]", "PLANEPTR", 5, PTRSIZE }, {" BitPlabe[4]", "PLANEPTR", 5, PTRSIZE }, {" BitPlabe[5]", "PLANEPTR", 5, PTRSIZE }, {" BitPlabe[6]", "PLANEPTR", 5, PTRSIZE }, {" BitPlabe[7]", "PLANEPTR", 5, PTRSIZE } }; int sum, choice = -1; level++; while (choice) { sum = SetOptionText(string, structdata, (APTR)planes, DATASIZE, 0); choice = GetChoice(8); if (choice >= 1 && choice <= 8 && planes[choice - 1]) HexDump(structdata[choice - 1].membername, planes[choice - 1], PTRSIZE, (long)(rows * bytes)); } level--; } void PrRastPort(string, rastport) char *string; struct RastPort *rastport; { static struct StructData structdata[] = { { "(Layer", "struct Layer *)", 5, PTRSIZE }, { " BitMap", "struct BitMap *", 5, PTRSIZE }, { "-Area Ptrn", "USHORT *", 5, PTRSIZE }, { "(TmpRas", "struct TmpRas *)", 5, PTRSIZE }, { "(AreaInfo", "struct AreaInfo *)", 5, PTRSIZE }, { "(GelsInfo", "struct GelsInfo *)", 5, PTRSIZE }, { "-Mask", "UBYTE", 13, BYTESIZE }, { "-FgPen", "BYTE", 3, BYTESIZE }, { "-BgPen", "BYTE", 3, BYTESIZE }, { "-AOlPen", "BYTE", 3, BYTESIZE }, { "-DrawMode", "BYTE", 3, BYTESIZE }, { "-AreaPtSize", "BYTE", 3, BYTESIZE }, { "-linpatcnt", "BYTE", 3, BYTESIZE }, { "-dummy", "BYTE", 3, BYTESIZE }, { "(Flags", "USHORT", 12, INTSIZE }, { "-LinePtrn", "USHORT", 12, INTSIZE } }; int sum, choice = -1; level++; while (choice) { sum = SetOptionText(string, structdata, (APTR)rastport, DATASIZE, 0); switch (choice = GetChoice(MAXGADG + 1)) { case 2: if (rastport->BitMap) PrBitMap("The BitMap for the RastPort", rastport->BitMap); break; case MOREGADG: PrRastPort2("More RastPort members", rastport, sum); break; } } level--; } void PrRastPort2(string, rastport, offset) char *string; struct RastPort *rastport; int offset; { static struct StructData structdata[] = { {"-cp_x", "SHORT", 2, INTSIZE }, {"-cp_y", "SHORT", 2, INTSIZE }, {" minterms[8]", "UBYTE", 0, BYTESIZE * 8}, {"-PenWidth", "SHORT", 2, INTSIZE }, {"-PenHeight", "SHORT", 2, INTSIZE }, {"(TextFont", "struct Font *)", 5, PTRSIZE }, {"-AlgoStyle", "UBYTE", 13, BYTESIZE }, {"(TxFlags", "UBYTE", 13, BYTESIZE }, {"-TxHeight", "UWORD", 12, INTSIZE }, {"-TxWidth", "UWORD", 12, INTSIZE }, {"-TxBaseLine", "UWORD", 12, INTSIZE }, {"-TxSpacing", "WORD", 2, INTSIZE }, {"-RP_User", "WORD", 2, INTSIZE }, {" wordreserved[7]", "UWORD", 0, INTSIZE * 7 }, {" longreserved[2]", "ULONG", 0, PTRSIZE * 2 }, {" reserved[8]", "UBYTE", 0, BYTESIZE * 8} }; int sum, choice = -1; level++; while (choice) { sum = SetOptionText(string, structdata, (APTR)rastport, DATASIZE, offset); switch (choice = GetChoice(DATASIZE)) { case 3: HexDump("Hexdump of RastPort minterms bytes", &rastport->minterms[0], BYTESIZE, (long)BYTESIZE * 8); break; case 14: HexDump("Hexdump of reserved RastPort words", &rastport->wordreserved[0], INTSIZE, (long)INTSIZE * 7); break; case 15: HexDump("Hexdump of reserved RastPort longwords", &rastport->longreserved[0], PTRSIZE, (long)PTRSIZE * 2); break; case 16: HexDump("Hexdump of reserved RastPort bytes", &rastport->reserved[0], BYTESIZE, (long)BYTESIZE * 8); break; } } level--; } //E*O*F sbGraphics.c// echo x - sbIntuiText.c cat > "sbIntuiText.c" << '//E*O*F sbIntuiText.c//' /* module written by G. Gagnon, Mar 24, 1987 */ #include "sb:sb.h" extern int level; void PrIntuiText(string, intuitext) char *string; struct IntuiText *intuitext; { static struct StructData structdata[] = { { "-FrontPen", "UBYTE", 3, BYTESIZE }, { "-BackPen", "UBYTE", 3, BYTESIZE }, { "-DrawMode", "UBYTE", 3, INTSIZE }, { "-LeftEdge", "SHORT", 2, INTSIZE }, { "-TopEdge", "SHORT", 2, INTSIZE }, { " ITextFont", "struct TextAttr *", 5, PTRSIZE }, { " IText", "UBYTE *", 4, PTRSIZE }, { " NextText", "struct IntuiText *", 5, PTRSIZE } }; int sum, choice = -1; level++; while (choice) { sum = SetOptionText(string, structdata, (APTR)intuitext, DATASIZE, 0); switch (choice = GetChoice(DATASIZE)) { case 6: if (intuitext->ITextFont) PrTextAttr("Structure TextAttr",intuitext->ITextFont); break; case 7: PrString("The text pointed to by IText", intuitext->IText); break; case 8: if (intuitext->NextText) PrIntuiText("The next IntuiText in Intuition's list", intuitext->NextText); break; } } level--; } //E*O*F sbIntuiText.c// echo x - sbMsgPort.c cat > "sbMsgPort.c" << '//E*O*F sbMsgPort.c//' /* module written by G. Gagnon, Mar 24, 1987 */ #include "sb:sb.h" extern int level; void PrMsgPort(string, msgport) char *string; struct MsgPort *msgport; { static struct StructData structdata[] = { { "-mp_Node", "Node structure", 0, 0 }, { " .ln_Succ", "struct Node *", 5, PTRSIZE }, { " .ln_Pred", "struct Node *", 5, PTRSIZE }, { "- .ln_Type", "UBYTE", 13, BYTESIZE }, { "- .ln_Pri", "BYTE", 3, BYTESIZE }, { " .ln_Name", "CHAR *", 4, PTRSIZE }, { "-mp_Flags", "UBYTE", 13, BYTESIZE }, { "-mp_SigBit", "UBYTE", 13, BYTESIZE }, { "(mp_SigTask", "struct Task *)", 5, PTRSIZE }, { "-mp_MsgList", "List structure", 0, 0 }, { " .lh_Head", "struct Node *", 5, PTRSIZE }, { " .lh_Tail", "struct Node *", 5, PTRSIZE }, { " .lh_TailPred", "struct Node *", 5, PTRSIZE }, { "- .lh_Type", "UBYTE", 13, BYTESIZE }, { "- .l_pad", "UBYTE", 13, BYTESIZE } }; int sum, choice = -1; level++; while (choice) { sum = SetOptionText(string, structdata, (APTR)msgport, DATASIZE, 0); switch (choice = GetChoice(DATASIZE)) { case 2: if (msgport->mp_Node.ln_Succ) PrNode("MsgPort->mp_Node.ln_Succ", msgport->mp_Node.ln_Succ); break; case 3: if (msgport->mp_Node.ln_Pred) PrNode("MsgPort->mp_Node.ln_Pred", msgport->mp_Node.ln_Pred); break; case 6: PrString("mp_Node->ln_Name",msgport->mp_Node.ln_Name); break; case 11: if (msgport->mp_MsgList.lh_Head) PrNode("MsgPort->mp_MsgList.lh_Head", msgport->mp_MsgList.lh_Head); break; case 12: if (msgport->mp_MsgList.lh_Tail) PrNode("MsgPort->mp_MsgList.lh_Tail", msgport->mp_MsgList.lh_Tail); break; case 13: if (msgport->mp_MsgList.lh_TailPred) PrNode("MsgPort->mp_MsgList.lh_TailPred", msgport->mp_MsgList.lh_TailPred); break; } } level--; } //E*O*F sbMsgPort.c// echo x - sbNode.c cat > "sbNode.c" << '//E*O*F sbNode.c//' /* module written by G. Gagnon, Mar 24, 1987 */ #include "sb:sb.h" extern int level; void PrNode(string, node) char *string; struct Node *node; { static struct StructData structdata[] = { { " ln_Succ", "struct Node *", 5, PTRSIZE }, { " ln_Pred", "struct Node *", 5, PTRSIZE }, { "-ln_Type", "UBYTE", 4, BYTESIZE }, { "-ln_Pri", "BYTE", 3, BYTESIZE }, { " ln_Name", "UBYTE *", 4, PTRSIZE } }; int sum, choice = -1; level++; while (choice) { sum = SetOptionText(string, structdata, (APTR)node, DATASIZE, 0); switch (choice = GetChoice(DATASIZE)) { case 1: if (node->ln_Succ) PrNode("Node->ln_Succ", node->ln_Succ); break; case 2: if (node->ln_Pred) PrNode("Node->ln_Pred", node->ln_Pred); break; case 5: PrString("ln_Name",node->ln_Name); break; } } level--; } //E*O*F sbNode.c// echo x - sbScreen.c cat > "sbScreen.c" << '//E*O*F sbScreen.c//' /* include not needed for Aztec C using provided makefile */ #include "sb:sb.h" extern int level; extern void PrScreen2(); void PrScreen(string, screen) char *string; struct Screen *screen; { static struct StructData structdata[] = { { " NextScreen", "struct Screen *", 5, PTRSIZE }, { " FirstWindow", "struct Window *", 5, PTRSIZE }, { "-LeftEdge", "SHORT", 2, INTSIZE }, { "-TopEdge", "SHORT", 2, INTSIZE }, { "-Width", "SHORT", 2, INTSIZE }, { "-Height", "SHORT", 2, INTSIZE }, { "-MouseY", "SHORT", 2, INTSIZE }, { "-MouseX", "SHORT", 2, INTSIZE }, { " Flags", "USHORT", 12, INTSIZE }, { " Title", "UBYTE *", 4, PTRSIZE }, { " DefaultTitle", "UBYTE *", 4, PTRSIZE }, { "-BarHeight", "BYTE", 3, BYTESIZE }, { "-BarVBorder", "BYTE", 3, BYTESIZE }, { "-BarHBorder", "BYTE", 3, BYTESIZE }, { "-MenuVBorder", "BYTE", 3, BYTESIZE }, { "-MenuHBorder", "BYTE", 3, BYTESIZE } }; static char *flagnames[8] = { "WBENCHSCREEN", "CUSTOMSCREEN", NULL, NULL, "SHOWTITLE", "BEEPING", "CUSTOMBITMAP", NULL }; int sum, choice = -1; ULONG bits; level++; while (choice) { sum = SetOptionText(string, structdata, (APTR)screen, DATASIZE, 0); switch (choice = GetChoice(MAXGADG + 1)) { case 1: if (screen->NextScreen) PrScreen("The next screen in Intuition's list", screen->NextScreen); break; case 2: if (screen->FirstWindow) PrWindow("The screen's first window", screen->FirstWindow); break; case 9: if ((bits = screen->Flags) & 2) bits ^= 1; FlagPrint("The screen's flags", flagnames, bits); break; case 10: PrString("The Screen's Title", screen->Title); break; case 11: PrString("The Screen's Default Title", screen->DefaultTitle); break; case MOREGADG: PrScreen2("Screen members (page 2)", screen, sum); break; } } level--; } void PrScreen2(string, screen, offset) char *string; struct Screen *screen; int offset; { static struct StructData structdata[] = { { "-WBorTop", "BYTE", 3, BYTESIZE }, { "-WBorLeft", "BYTE", 3, BYTESIZE }, { "-WBorLeft", "BYTE", 3, BYTESIZE }, { "-WBorBottom", "BYTE", 3, INTSIZE }, { " Font", "struct TextAttr *", 5, PTRSIZE }, { "(ViewPort", "struct ViewPort)", 0, SZ(ViewPort) }, { " RastPort", "struct RastPort ", 0, SZ(RastPort) }, { " BitMap", "struct BitMap", 0, SZ(BitMap) }, { "(LayerInfo", "struct Layer_Info)", 0, SZ(Layer_Info)}, { " FirstGadget", "struct Gadget *", 5, PTRSIZE }, { "-DetailPen", "UBYTE", 13, BYTESIZE }, { "-BlockPen", "UBYTE", 13, BYTESIZE }, { "-SaveColor0", "USHORT", 12, INTSIZE }, { "(BarLayer", "struct Layer *)", 5, PTRSIZE }, { "(ExtData", "UBYTE *)", 5, PTRSIZE }, { "(UserData", "UBYTE *)", 5, PTRSIZE }, }; int sum, choice = -1; level++; while (choice) { sum = SetOptionText(string, structdata, (APTR)screen, DATASIZE, offset); switch (choice = GetChoice(DATASIZE)) { case 5: if (screen->Font) PrTextAttr("Structure TextAttr",screen->Font); break; case 7: PrRastPort("The screen's RastPort", &screen->RastPort); break; case 8: PrBitMap("The screen's BitMap", &screen->BitMap); break; case 10: if (screen->FirstGadget) PrGadget("The screen's first gadget", screen->FirstGadget); break; } } level--; } //E*O*F sbScreen.c// echo x - sbTextAttr.c cat > "sbTextAttr.c" << '//E*O*F sbTextAttr.c//' /* module written by G. Gagnon, Mar 24, 1987 */ #include "sb:sb.h" extern int level; void PrTextAttr(string, textattr) char *string; struct TextAttr *textattr; { static struct StructData structdata[] = { { " ta_Name", "UBYTE *", 4, PTRSIZE }, { "-ta_YSize", "UWORD", 2, INTSIZE }, { "-ta_Style", "UBYTE", 3, BYTESIZE }, { "-ta_Flags", "UBYTE", 3, BYTESIZE } }; int sum, choice = -1; level++; while (choice) { sum = SetOptionText(string, structdata, (APTR)textattr, DATASIZE, 0); switch (choice = GetChoice(DATASIZE)) { case 1: PrString("ta_Name",textattr->ta_Name); break; } } level--; } //E*O*F sbTextAttr.c// echo x - sbWindow.c cat > "sbWindow.c" << '//E*O*F sbWindow.c//' /* include not needed for Aztec C using provided makefile */ #include "sb:sb.h" extern int level; extern void PrWindow2(), PrWindow3(); void PrWindow(string, window) char *string; struct Window *window; { static struct StructData structdata[] = { { " NextWindow", "struct Window *", 5, PTRSIZE }, { "-LeftEdge", "SHORT", 2, INTSIZE }, { "-TopEdge", "SHORT", 2, INTSIZE }, { "-Width", "SHORT", 2, INTSIZE }, { "-Height", "SHORT", 2, INTSIZE }, { "-MouseY", "SHORT", 2, INTSIZE }, { "-MouseX", "SHORT", 2, INTSIZE }, { "-MinWidth", "SHORT", 2, INTSIZE }, { "-MinHeight", "SHORT", 2, INTSIZE }, { "-MaxWidth", "SHORT", 2, INTSIZE }, { "-MaxHeight", "SHORT", 2, INTSIZE }, { " Flags", "ULONG", 11, PTRSIZE }, { "(MenuStrip", "struct Menu *)", 5, PTRSIZE }, { " Title", "UBYTE *", 4, PTRSIZE }, { "(FirstRequest", "struct Requester *)", 5, PTRSIZE }, { "(DMRequest", "struct Requester *)", 5, PTRSIZE } }; static char *flagnames[32] = { "WINDOWSIZING", "WINDOWDRAG", "WINDOWDEPTH", "WINDOWCLOSE", "SIZEBRIGHT", "SIZEBOTTOM", "SIMPLE_REFRESH", "OTHER_REFRESH", "BACKDROP", "REPORTMOUSE", "GIMMEZEROZERO", "BORDERLESS", "ACTIVATE", "WINDOWACTIVE", "INREQUEST", "MENUSTATE", "RMBTRAP", "NOCAREREFRESH", NULL, NULL, NULL, NULL, NULL, NULL, "WINDOWREFRESH", "WBENCHWINDOW", "WINDOWTICKED" }; int sum, choice = -1; ULONG bits; level++; while (choice) { sum = SetOptionText(string, structdata, (APTR)window, DATASIZE, 0); switch (choice = GetChoice(MAXGADG + 1)) { case 1: if (window->NextWindow) PrWindow("The next window in Intuition's list", window->NextWindow); break; case 12: bits = window->Flags & ~SUPER_UNUSED; switch ((bits & REFRESHBITS) >> 6) { case 0: flagnames[6] = "SMART_REFRESH"; bits |= 0x40; break; case 1: flagnames[6] = "SIMPLE_REFRESH"; break; case 2: flagnames[7] = "SUPER_BITMAP"; break; case 3: flagnames[7] = "OTHER_REFRESH"; bits ^= 0x40; break; } FlagPrint("Flags set in this window", flagnames, bits); break; case 14: PrString("The Window's Title", window->Title); break; case MOREGADG: PrWindow2("Window menbers (page 2)", window, sum); break; } } level--; } void PrWindow2(string, window, offset) char *string; struct Window *window; int offset; { static struct StructData structdata[] = { { "-ReqCount", "SHORT", 2, INTSIZE }, { " WScreen", "struct Screen *", 5, PTRSIZE }, { " RPort", "struct RastPort *", 5, PTRSIZE }, { "-BorderLeft", "BYTE", 3, BYTESIZE }, { "-BorderTop", "BYTE", 3, BYTESIZE }, { "-BorderRight", "BYTE", 3, BYTESIZE }, { "-BorderBottom", "BYTE", 3, BYTESIZE }, { " BorderRPort", "struct RastPort *", 5, PTRSIZE }, { " FirstGadget", "struct Gadget *", 5, PTRSIZE }, { " Parent", "struct Window *", 5, PTRSIZE }, { " Descendant", "struct Window *", 5, PTRSIZE }, { "(Pointer", "USHORT *", 5, PTRSIZE }, { "-PtrHeight", "BYTE", 3, BYTESIZE }, { "-PtrWidth", "BYTE", 3, BYTESIZE }, { "-XOffset", "BYTE", 3, BYTESIZE }, { "-YOffset", "BYTE", 3, BYTESIZE } }; int sum, choice = -1; level++; while (choice) { sum = SetOptionText(string, structdata, (APTR)window, DATASIZE, offset); switch (choice = GetChoice(MAXGADG + 1)) { case 2: if (window->WScreen) PrScreen("The screen referenced in the window structure", window->WScreen); break; case 3: if (window->RPort) PrRastPort("The window's RPort (RastPort)", window->RPort); break; case 8: if (window->BorderRPort) PrRastPort("The window's BorderRPort", window->BorderRPort); break; case 9: if (window->FirstGadget) PrGadget("The window's first gadget", window->FirstGadget); break; case 12: printf("Sorry, selection not implemented\n\n"); break; case 10: if (window->Parent) PrWindow("The 'parent' window", window->Parent); break; case 11: if (window->Descendant) PrWindow("The 'descendent' window", window->Descendant); break; case MOREGADG: PrWindow3("Window members (page 3)", window, sum); break; } } level--; } void PrWindow3(string, window, offset) char *string; struct Window *window; int offset; { static struct StructData structdata[] = { { " IDCMPFlags", "ULONG", 1, PTRSIZE }, { " UserPort", "struct MsgPort *", 5, PTRSIZE }, { " WindowPort", "struct MsgPort *", 5, PTRSIZE }, { "(MessageKey", "struct IntuiMessage *)", 5, PTRSIZE }, { "-DetailPen", "UBYTE", 13, BYTESIZE }, { "-BlockPen", "UBYTE", 13, BYTESIZE }, { "(CheckMark", "struct Image *)", 5, PTRSIZE }, { " ScreenTitle", "UBYTE", 4, PTRSIZE }, { "-GZZMouseX", "SHORT", 2, INTSIZE }, { "-GZZMouseY", "SHORT", 2, INTSIZE }, { "-GZZWidth", "SHORT", 2, INTSIZE }, { "-GZZHeight", "SHORT", 2, INTSIZE }, { "(ExtData", "UBYTE *)", 5, PTRSIZE }, { "(UserData", "BYTE *)", 5, PTRSIZE }, { "(WLayer", "struct Layer *)", 5, PTRSIZE } }; static char *IDCMPnames[32] = { "SIZEVERIFY", "NEWSIZE", "REFRESHWINDOW", "MOUSEBUTTONS", "MOUSEMOVE", "GADGETDOWN", "GADGETUP", "REQSET", "MENUPICK", "CLOSEWINDOW", "RAWKEY", "REQVERIFY", "REQCLEAR", "MENUVERIFY", "NEWPREFS", "DISKINSERTED", "DISKREMOVED", "WBENCHMESSAGE", "ACTIVATEWINDOW", "INACTIVEWINDOW", "DELTAMOVE", "VANILLAKEY", "INTUITICKS", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "LONELYMESSAGE" }; int sum, choice = -1; level++; while (choice) { sum = SetOptionText(string, structdata, (APTR)window, DATASIZE, offset); switch (choice = GetChoice(DATASIZE)) { case 1: FlagPrint("IDCMP flags set in this window", IDCMPnames, window->IDCMPFlags); break; case 2: if (window->UserPort) PrMsgPort("Window->UserPort",window->UserPort); break; case 3: if (window->WindowPort) PrMsgPort("Window->WindowPort",window->WindowPort); break; case 8: PrString("The screen title when this window is activated", window->ScreenTitle); break; } } level--; } //E*O*F sbWindow.c// echo x - sbio.c cat > "sbio.c" << '//E*O*F sbio.c//' /* include not needed for Aztec C using provided makefile */ #include "sb:sb.h" #define CHOICEWIDTH 280 #define CHOICEHEIGHT 8 #define SPACING 9 #define TOPGADG 30 #define PUTTEXT(text, x, y) { Move(rp, (long)x, (long)y); \ Text(rp, text, (long)strlen(text)); } struct IntuitionBase *IntuitionBase = NULL; struct GfxBase *GfxBase = NULL; struct Window *OpenWindow(), *MainWindow = NULL; struct RastPort *rp; extern int level; APTR OpenLibrary(); struct IntuiText ChoiceText[MAXGADG + 1]; struct Gadget ChoiceGadg[MAXGADG + 1]; extern void CloseOut(), Redisplay(); struct IntuiText BackIText = { 3, 2, JAM2, 5, 2, NULL, NULL, NULL }; struct IntuiText MoreIText = { 2, 3, JAM2, 5, 2, NULL, (UBYTE *)"(MORE)", NULL }; struct Gadget BackGadg = { NULL, 10, -12, 140, 12, GADGHCOMP | GRELBOTTOM, RELVERIFY, BOOLGADGET, NULL, NULL, &BackIText, NULL, NULL, 0, NULL /* gadget ID is zero */ }; struct Gadget MoreGadg = { NULL, 300, -12, 59, 12, GADGHCOMP | GRELBOTTOM, RELVERIFY, BOOLGADGET, NULL, NULL, &MoreIText, NULL, NULL, MOREGADG, NULL }; struct NewWindow NWindow = { 0, 10, 640, 189, /* left, top, width, height */ -1, -1, /* use screen colours */ GADGETUP /* IDCMP flags */ | CLOSEWINDOW, WINDOWDEPTH /* window flags */ | WINDOWCLOSE | WINDOWDRAG | RMBTRAP | ACTIVATE | NOCAREREFRESH | SMART_REFRESH, &BackGadg, /* first gadget in list */ NULL, (UBYTE *)"The Transactor Structure Browser V 1.0", NULL, NULL, 0, 0, 0, 0, /* sizing limits (non-resizable) */ WBENCHSCREEN }; void SetupGadg() { int i; for (i = 0; i < MAXGADG; i++) { ChoiceText[i].BackPen = 0; ChoiceText[i].DrawMode = JAM2; ChoiceText[i].LeftEdge = 0; ChoiceText[i].TopEdge = 0; ChoiceText[i].ITextFont = NULL; ChoiceText[i].IText = NULL; ChoiceText[i].NextText = NULL; ChoiceGadg[i].LeftEdge = 20; ChoiceGadg[i].TopEdge = i * SPACING + TOPGADG; ChoiceGadg[i].Width = CHOICEWIDTH; ChoiceGadg[i].Height = CHOICEHEIGHT; ChoiceGadg[i].Flags = GADGHCOMP; ChoiceGadg[i].Activation = RELVERIFY; ChoiceGadg[i].GadgetType = BOOLGADGET; ChoiceGadg[i].GadgetText = &ChoiceText[i]; ChoiceGadg[i].GadgetID = i + 1; /* gadget IDs start at 1 */ } } int GetChoice (num) int num; { struct IntuiMessage *GetMsg(), *message; ULONG msgclass; /* message class from IDCMP */ APTR IAddr; /* pointer to gadget from IDCMP */ Redisplay(num); /* put up choices in windows */ FOREVER { /*** main event loop ***/ Wait (1L << MainWindow->UserPort->mp_SigBit); while (message = GetMsg(MainWindow->UserPort)) { /* get what we need from the message port */ msgclass = message->Class; IAddr = message->IAddress; ReplyMsg(message); /* reply to message right away */ /* check for gadget selected */ if (msgclass == GADGETUP) return ( (int)((struct Gadget *)IAddr)->GadgetID ); /* finish up if the close gadget is clicked */ else if (msgclass == CLOSEWINDOW) CloseOut(); /* clean up and exit */ } } return(0); /* dummy to stop warning */ } void putHeader(string, ptr) char *string; APTR ptr; /* put title and pointer at top of screen - * if ptr is NULL, put string only. */ { char buf[80]; SetAPen(rp, 0L); RectFill(rp, 1L, 10L, (long)MainWindow->Width-25, 27L); SetAPen(rp, 3L); if (ptr) { sprintf(buf, "%d: %s (address $%lx):", level, string, ptr); PUTTEXT( " Member Type Value (hex/decimal)", 20L, 10L + 2 * rp->TxHeight); } else sprintf(buf, "%d: %s:", level, string); PUTTEXT(buf, 20L, 10L + rp->TxHeight); } void OpenStuff () { /* open intuition & graphics libraries and window */ if (!(IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 0L) ) ) CloseOut(); if (!(GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 0L) ) ) CloseOut(); /* now attempt to open the main window */ if (!(MainWindow = OpenWindow(&NWindow)) ) CloseOut(); rp = MainWindow->RPort; /* rastport for graphics routines */ } void CloseOut() { /* close everything up before ending */ if (MainWindow) CloseWindow(MainWindow); if (IntuitionBase) CloseLibrary(IntuitionBase); if (GfxBase) CloseLibrary(GfxBase); exit(0); /* exit program - we may be deeply nested */ } void Redisplay(num) int num; /* clear window, remove old gadgets, prepare and add new ones */ { struct Gadget *gadg; BOOL MoreFlag = FALSE; int i, c; SetAPen(rp, 0L); /* rectfill with background colour to clear */ RectFill(rp, 1L, (long)TOPGADG, (long)MainWindow->Width - 2, (long)MainWindow->Height - 2); if (num > MAXGADG) { num = MAXGADG; MoreFlag = TRUE; /* put up "more" gadget */ } /* remove all choice gadgets */ gadg = &BackGadg; while (gadg = gadg->NextGadget) RemoveGadget(MainWindow, gadg); /* render gadgets according to single-digit code at * the start of the gadget's intuitext */ for (i = 0; i < num; i++) { ChoiceText[i].FrontPen = 1; if ((c = *ChoiceText[i].IText) == '-' || c == '(') { if (c == '-') { *ChoiceText[i].IText = ' '; ChoiceText[i].FrontPen = 2; } PrintIText(rp, &ChoiceText[i], (long)ChoiceGadg[i].LeftEdge, (long)ChoiceGadg[i].TopEdge); } else AddGadget(MainWindow, &ChoiceGadg[i], -1L); } if (MoreFlag) AddGadget(MainWindow, &MoreGadg, -1L); /* display gadget imagery (the text) */ RefreshGadgets(&BackGadg, MainWindow, NULL); } void SetBackText (sflag) int sflag; { BackIText.IText = (UBYTE *)(sflag ? " Previous Page " : " Previous Level "); } //E*O*F sbio.c// echo Possible errors detected by \'wc\' [hopefully none]: temp=/tmp/shar$$ trap "rm -f $temp; exit" 0 1 2 3 15 cat > $temp <<\!!! 249 941 6869 sb.c 43 278 1747 sb.doc 24 68 551 sb.h 15 19 201 sb.lnk 104 381 3947 sbGadget.c 142 578 5368 sbGraphics.c 40 141 1351 sbIntuiText.c 60 210 2176 sbMsgPort.c 38 112 1005 sbNode.c 108 435 4154 sbScreen.c 28 86 754 sbTextAttr.c 195 747 7555 sbWindow.c 211 773 6176 sbio.c 1257 4769 41854 total !!! wc sb.c sb.doc sb.h sb.lnk sbGadget.c sbGraphics.c sbIntuiText.c sbMsgPort.c sbNode.c sbScreen.c sbTextAttr.c sbWindow.c sbio.c | sed 's=[^ ]*/==' | diff -b $temp - exit 0 -- UUCP: kim@amdahl.amdahl.com or: {sun,decwrl,hplabs,pyramid,ihnp4,seismo,oliveb,cbosgd}!amdahl!kim DDD: 408-746-8462 USPS: Amdahl Corp. M/S 249, 1250 E. Arques Av, Sunnyvale, CA 94086 CIS: 76535,25 [ Any thoughts or opinions which may or may not have been expressed ] [ herein are my own. They are not necessarily those of my emplodic al