summaryrefslogtreecommitdiff
path: root/prtype.c
diff options
context:
space:
mode:
Diffstat (limited to 'prtype.c')
-rw-r--r--prtype.c294
1 files changed, 169 insertions, 125 deletions
diff --git a/prtype.c b/prtype.c
index 7b6064e..53acb25 100644
--- a/prtype.c
+++ b/prtype.c
@@ -23,6 +23,33 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
* *
+ * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+ * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ *
* ************************************************** */
#include "scope.h"
@@ -49,7 +76,7 @@ extern int littleEndian;
/* print representation of a character for debugging */
-char *printrep (c)
+static char *printrep (c)
unsigned short c;
{
static char pr[8];
@@ -64,7 +91,7 @@ char *printrep (c)
else if (c < 127)
{
/* printing characters */
- pr[0] = c;
+ pr[0] = (char) c;
pr[1] = '\0';
}
else if (c == 127)
@@ -83,7 +110,7 @@ char *printrep (c)
else
{
/* very large number -- print as 0xffff - 4 digit hex */
- (void)sprintf(pr, "0x%04x", c);
+ sprintf(pr, "0x%04x", c);
}
return(pr);
}
@@ -108,6 +135,7 @@ char *printrep (c)
char Leader[MaxIndent + 1];
static short CurrentLevel = 0;
+void
SetIndentLevel(which)
short which;
{
@@ -128,13 +156,14 @@ SetIndentLevel(which)
CurrentLevel = which;
}
+static void
ModifyIndentLevel(amount)
short amount;
{
SetIndentLevel(CurrentLevel + amount);
}
-short SizeofLeader ()
+static short SizeofLeader ()
{
return (CurrentLevel * 8);
}
@@ -146,6 +175,7 @@ short SizeofLeader ()
/* if we want verbose enough output, we will dump the buffer in hex */
+void
DumpItem(name, fd, buf, n)
char *name;
FD fd;
@@ -166,8 +196,8 @@ DumpItem(name, fd, buf, n)
/* */
/* ************************************************************ */
-PrintINT8(buf)
- unsigned char *buf;
+int
+PrintINT8(unsigned char *buf)
{
/* print a INT8 -- 8-bit signed integer */
short n = IByte (buf);
@@ -177,8 +207,8 @@ PrintINT8(buf)
return 1;
}
-PrintINT16(buf)
- unsigned char *buf;
+int
+PrintINT16(unsigned char *buf)
{
/* print a INT16 -- 16-bit signed integer */
long n = IShort (buf);
@@ -188,8 +218,8 @@ PrintINT16(buf)
return 2;
}
-PrintINT32(buf)
- unsigned char *buf;
+int
+PrintINT32(unsigned char *buf)
{
/* print a INT32 -- 32-bit signed integer */
long n = ILong (buf);
@@ -199,17 +229,17 @@ PrintINT32(buf)
/* ************************************************************ */
-PrintCARD8(buf)
- unsigned char *buf;
+int
+PrintCARD8(unsigned char *buf)
{
/* print a CARD8 -- 8-bit unsigned integer */
- short n = IByte (buf);
+ unsigned short n = IByte (buf);
fprintf(stdout, "%02x", (unsigned)(n & 0xff));
return 1;
}
-PrintCARD16(buf)
- unsigned char *buf;
+int
+PrintCARD16(unsigned char *buf)
{
/* print a CARD16 -- 16-bit unsigned integer */
unsigned long n = IShort (buf);
@@ -217,8 +247,8 @@ PrintCARD16(buf)
return 1;
}
-PrintCARD32(buf)
- unsigned char *buf;
+int
+PrintCARD32(unsigned char *buf)
{
/* print a CARD32 -- 32-bit unsigned integer */
unsigned long n = ILong (buf);
@@ -228,8 +258,8 @@ PrintCARD32(buf)
/* ************************************************************ */
-PrintBYTE(buf)
- unsigned char *buf;
+int
+PrintBYTE(unsigned char *buf)
{
/* print a BYTE -- 8-bit value */
short n = IByte (buf);
@@ -238,8 +268,8 @@ PrintBYTE(buf)
}
-PrintCHAR8(buf)
- unsigned char *buf;
+int
+PrintCHAR8(unsigned char *buf)
{
/* print a CHAR8 -- 8-bit character */
unsigned short n = IByte (buf);
@@ -248,8 +278,8 @@ PrintCHAR8(buf)
}
-PrintSTRING16(buf)
- unsigned char *buf;
+int
+PrintSTRING16(unsigned char *buf)
{
/* print a CHAR2B -- 16-bit character which is never byte-swapped */
unsigned short n = IChar2B (buf);
@@ -257,8 +287,8 @@ PrintSTRING16(buf)
return 2 + n;
}
-PrintSTR(buf)
- unsigned char *buf;
+int
+PrintSTR(unsigned char *buf)
{
/* STR have the length (1 byte) then a string of CHAR8 */
short n;
@@ -272,8 +302,8 @@ PrintSTR(buf)
/* ************************************************************ */
-PrintWINDOW(buf)
- unsigned char *buf;
+int
+PrintWINDOW(unsigned char *buf)
{
/* print a WINDOW -- CARD32 plus 0 = None */
long n = ILong (buf);
@@ -284,8 +314,8 @@ PrintWINDOW(buf)
return(4);
}
-PrintWINDOWD(buf)
- unsigned char *buf;
+int
+PrintWINDOWD(unsigned char *buf)
{
/* print a WINDOWD -- CARD32 plus 0 = PointerWindow, 1 = InputFocus */
long n = ILong (buf);
@@ -298,8 +328,8 @@ PrintWINDOWD(buf)
return 4;
}
-PrintWINDOWNR(buf)
- unsigned char *buf;
+int
+PrintWINDOWNR(unsigned char *buf)
{
/* print a WINDOWNR -- CARD32 plus 0 = None, 1 = PointerRoot */
long n = ILong (buf);
@@ -313,8 +343,8 @@ PrintWINDOWNR(buf)
}
-PrintPIXMAP(buf)
- unsigned char *buf;
+int
+PrintPIXMAP(unsigned char *buf)
{
/* print a PIXMAP -- CARD32 plus 0 = None */
long n = ILong (buf);
@@ -325,8 +355,8 @@ PrintPIXMAP(buf)
return 4;
}
-PrintPIXMAPNPR(buf)
- unsigned char *buf;
+int
+PrintPIXMAPNPR(unsigned char *buf)
{
/* print a PIXMAPNPR -- CARD32 plus 0 = None, 1 = ParentRelative */
long n = ILong (buf);
@@ -339,8 +369,8 @@ PrintPIXMAPNPR(buf)
return 4;
}
-PrintPIXMAPC(buf)
- unsigned char *buf;
+int
+PrintPIXMAPC(unsigned char *buf)
{
/* print a PIXMAPC -- CARD32 plus 0 = CopyFromParent */
long n = ILong (buf);
@@ -352,8 +382,8 @@ PrintPIXMAPC(buf)
}
-PrintCURSOR(buf)
- unsigned char *buf;
+int
+PrintCURSOR(unsigned char *buf)
{
/* print a CURSOR -- CARD32 plus 0 = None */
long n = ILong (buf);
@@ -365,8 +395,8 @@ PrintCURSOR(buf)
}
-PrintFONT(buf)
- unsigned char *buf;
+int
+PrintFONT(unsigned char *buf)
{
/* print a FONT -- CARD32 plus 0 = None */
long n = ILong (buf);
@@ -378,8 +408,8 @@ PrintFONT(buf)
}
-PrintGCONTEXT(buf)
- unsigned char *buf;
+int
+PrintGCONTEXT(unsigned char *buf)
{
/* print a GCONTEXT -- CARD32 */
long n = ILong (buf);
@@ -388,8 +418,8 @@ PrintGCONTEXT(buf)
}
-PrintCOLORMAP(buf)
- unsigned char *buf;
+int
+PrintCOLORMAP(unsigned char *buf)
{
/* print a COLORMAP -- CARD32 plus 0 = None */
long n = ILong (buf);
@@ -400,8 +430,8 @@ PrintCOLORMAP(buf)
return(4);
}
-PrintCOLORMAPC(buf)
- unsigned char *buf;
+int
+PrintCOLORMAPC(unsigned char *buf)
{
/* print a COLORMAPC -- CARD32 plus 0 = CopyFromParent */
long n = ILong (buf);
@@ -413,8 +443,8 @@ PrintCOLORMAPC(buf)
}
-PrintDRAWABLE(buf)
- unsigned char *buf;
+int
+PrintDRAWABLE(unsigned char *buf)
{
/* print a DRAWABLE -- CARD32 */
long n = ILong (buf);
@@ -422,8 +452,8 @@ PrintDRAWABLE(buf)
return 4;
}
-PrintFONTABLE(buf)
- unsigned char *buf;
+int
+PrintFONTABLE(unsigned char *buf)
{
/* print a FONTABLE -- CARD32 */
long n = ILong (buf);
@@ -435,7 +465,7 @@ PrintFONTABLE(buf)
#define NumberofAtoms 68
-char *AtomTable[NumberofAtoms + 1] =
+static char *AtomTable[NumberofAtoms + 1] =
{
"NONE", "PRIMARY", "SECONDARY", "ARC", "ATOM", "BITMAP", "CARDINAL",
"COLORMAP", "CURSOR", "CUT_BUFFER0", "CUT_BUFFER1", "CUT_BUFFER2",
@@ -457,8 +487,8 @@ char *AtomTable[NumberofAtoms + 1] =
/* for atoms, we print the built-in atoms. We could expand to printing
the user defined ones, too. */
-PrintATOM(buf)
- unsigned char *buf;
+int
+PrintATOM(unsigned char *buf)
{
/* print a ATOM -- CARD32 plus 0 = None */
long n = ILong (buf);
@@ -469,8 +499,8 @@ PrintATOM(buf)
return(4);
}
-PrintATOMT(buf)
- unsigned char *buf;
+int
+PrintATOMT(unsigned char *buf)
{
/* print a ATOMT -- CARD32 plus 0 = AnyPropertyType */
long n = ILong (buf);
@@ -482,8 +512,8 @@ PrintATOMT(buf)
}
-PrintVISUALID(buf)
- unsigned char *buf;
+int
+PrintVISUALID(unsigned char *buf)
{
/* print a VISUALID -- CARD32 plus 0 = None */
long n = ILong (buf);
@@ -494,8 +524,8 @@ PrintVISUALID(buf)
return 4;
}
-PrintVISUALIDC(buf)
- unsigned char *buf;
+int
+PrintVISUALIDC(unsigned char *buf)
{
/* print a VISUALIDC -- CARD32 plus 0 = CopyFromParent */
long n = ILong (buf);
@@ -507,8 +537,8 @@ PrintVISUALIDC(buf)
}
-PrintTIMESTAMP(buf)
- unsigned char *buf;
+int
+PrintTIMESTAMP(unsigned char *buf)
{
/* print a TIMESTAMP -- CARD32 plus 0 as the current time */
long n = ILong (buf);
@@ -520,8 +550,8 @@ PrintTIMESTAMP(buf)
}
-PrintRESOURCEID(buf)
- unsigned char *buf;
+int
+PrintRESOURCEID(unsigned char *buf)
{
/* print a RESOURCEID -- CARD32 plus 0 = AllTemporary */
long n = ILong (buf);
@@ -533,8 +563,8 @@ PrintRESOURCEID(buf)
}
-PrintKEYSYM(buf)
- unsigned char *buf;
+int
+PrintKEYSYM(unsigned char *buf)
{
/* print a KEYSYM -- CARD32 */
long n = ILong (buf);
@@ -542,8 +572,8 @@ PrintKEYSYM(buf)
return(4);
}
-PrintKEYCODE(buf)
- unsigned char *buf;
+int
+PrintKEYCODE(unsigned char *buf)
{
/* print a KEYCODE -- CARD8 */
unsigned short n = IByte (buf);
@@ -551,8 +581,8 @@ PrintKEYCODE(buf)
return(1);
}
-PrintKEYCODEA(buf)
- unsigned char *buf;
+int
+PrintKEYCODEA(unsigned char *buf)
{
/* print a KEYCODEA -- CARD8 plus 0 = AnyKey */
long n = IByte (buf);
@@ -564,8 +594,8 @@ PrintKEYCODEA(buf)
}
-PrintBUTTON(buf)
- unsigned char *buf;
+int
+PrintBUTTON(unsigned char *buf)
{
/* print a BUTTON -- CARD8 */
unsigned short n = IByte (buf);
@@ -573,8 +603,8 @@ PrintBUTTON(buf)
return 1;
}
-PrintBUTTONA(buf)
- unsigned char *buf;
+int
+PrintBUTTONA(unsigned char *buf)
{
/* print a BUTTONA -- CARD8 plus 0 = AnyButton */
long n = IByte (buf);
@@ -588,8 +618,8 @@ PrintBUTTONA(buf)
/* this is an interesting cheat -- we call DecodeEvent to print an event */
/* should work, but its never been tried */
-PrintEVENTFORM(buf)
- unsigned char *buf;
+int
+PrintEVENTFORM(unsigned char *buf)
{
/* print an EVENT_FORM -- event format */
DecodeEvent(-1, buf, (long)-1);
@@ -598,10 +628,11 @@ PrintEVENTFORM(buf)
/* ************************************************************ */
-PrintENUMERATED(buf, length, ValueList)
- unsigned char *buf;
- short length;
- struct ValueListEntry *ValueList;
+int
+PrintENUMERATED(
+ unsigned char *buf,
+ short length,
+ struct ValueListEntry *ValueList)
{
long n;
struct ValueListEntry *p;
@@ -625,10 +656,11 @@ PrintENUMERATED(buf, length, ValueList)
/* ************************************************************ */
-PrintSET(buf, length, ValueList)
- unsigned char *buf;
- short length;
- struct ValueListEntry *ValueList;
+int
+PrintSET(
+ unsigned char *buf,
+ short length,
+ struct ValueListEntry *ValueList)
{
unsigned long n;
struct ValueListEntry *p;
@@ -678,6 +710,7 @@ PrintSET(buf, length, ValueList)
/* */
/* ************************************************************ */
+void
PrintField(buf, start, length, FieldType, name)
unsigned char *buf;
short start;
@@ -720,7 +753,7 @@ PrintField(buf, start, length, FieldType, name)
break;
}
fprintf(stdout, "\n");
- (void)fflush(stdout);
+ fflush(stdout);
}
/* ************************************************************ */
@@ -782,7 +815,7 @@ long PrintList(buf, number, ListType, name)
/* print a list of STRs. Similar to PrintList
They start at <buf>. There are <number> things in the list */
-PrintListSTR(buf, number, name)
+long PrintListSTR(buf, number, name)
unsigned char *buf;
long number;
char *name;
@@ -792,11 +825,11 @@ PrintListSTR(buf, number, name)
long sum;
if (number == 0)
- return;
+ return(0);
fprintf(stdout, "%s%20s: (%d)\n", Leader, name, number);
if (Verbose < 2)
- return;
+ return(0);
ModifyIndentLevel(1);
sum = 0;
@@ -810,7 +843,7 @@ PrintListSTR(buf, number, name)
}
ModifyIndentLevel(-1);
- return;
+ return(sum);
}
@@ -820,17 +853,18 @@ PrintListSTR(buf, number, name)
/* ************************************************************ */
-PrintBytes(buf, number, name)
- unsigned char buf[];
- long number;
- char *name;
+int
+PrintBytes(
+ unsigned char buf[],
+ long number,
+ char *name)
{
/* print a list of BYTE -- 8-bit character */
long i;
short column;
if (number == 0)
- return;
+ return(0);
fprintf(stdout, "%s%20s: ", Leader, name);
column = SizeofLeader() + 25;
@@ -848,7 +882,7 @@ PrintBytes(buf, number, name)
}
fprintf(stdout, "\n");
- return;
+ return(number);
}
@@ -860,35 +894,39 @@ PrintBytes(buf, number, name)
/* print a String of CHAR8 -- 8-bit characters */
-PrintString8(buf, number, name)
- unsigned char buf[];
- long number;
- char *name;
+int
+PrintString8(
+ unsigned char buf[],
+ int number,
+ char *name)
{
- long i;
+ short i;
if (number == 0)
- return;
+ return(0);
fprintf(stdout, "%s%20s: \"", Leader, name);
for (i = 0; i < number; i++)
fprintf(stdout, "%s", printrep(buf[i]));
fprintf(stdout, "\"\n");
+
+ return(number);
}
-/* print a String of CHAR2B -- 16-bit characters */
+/* print a String of CHAR16 -- 16-bit characters */
-PrintString16(buf, number, name)
- unsigned char buf[];
- long number;
- char *name;
+int
+PrintString16(
+ unsigned char buf[],
+ int number,
+ char *name)
{
long i;
unsigned short c;
if (number == 0)
- return;
+ return(0);
fprintf(stdout, "%s%20s: \"", Leader, name);
for (i = 0; i < number; i += 2)
@@ -897,6 +935,8 @@ PrintString16(buf, number, name)
fprintf(stdout, "%s", printrep(c));
}
fprintf(stdout, "\"\n");
+
+ return(number);
}
extern long TranslateText;
@@ -961,12 +1001,13 @@ PrintTString16(buf, number, name)
(2) A list of values.
*/
-PrintValues(control, clength, ctype, values, name)
- unsigned char *control;
- short clength;
- short ctype;
- unsigned char *values;
- char *name;
+void
+PrintValues(
+ unsigned char *control,
+ int clength,
+ int ctype,
+ unsigned char *values,
+ char *name)
{
long cmask;
struct ValueListEntry *p;
@@ -1012,10 +1053,11 @@ PrintValues(control, clength, ctype, values, name)
/* PolyText8 and PolyText16 take lists of characters with possible
font changes in them. */
-PrintTextList8(buf, length, name)
- unsigned char *buf;
- short length;
- char *name;
+int
+PrintTextList8(
+ unsigned char *buf,
+ int length,
+ char *name)
{
short n;
@@ -1039,10 +1081,11 @@ PrintTextList8(buf, length, name)
}
}
-PrintTextList16(buf, length, name)
- unsigned char *buf;
- short length;
- char *name;
+int
+PrintTextList16(
+ unsigned char *buf,
+ int length,
+ char *name)
{
short n;
@@ -1074,9 +1117,10 @@ PrintTextList16(buf, length, name)
#define MAXline 78
-DumpHexBuffer(buf, n)
- unsigned char *buf;
- long n;
+void
+DumpHexBuffer(
+ unsigned char *buf,
+ long n)
{
long i;
short column;
@@ -1086,7 +1130,7 @@ DumpHexBuffer(buf, n)
for (i = 0; i < n; i++)
{
/* get the hex representations */
- (void)sprintf(h, "%02x",(0xff & buf[i]));
+ sprintf(h, "%02x",(0xff & buf[i]));
/* check if these characters will fit on this line */
if ((column + strlen(h) + 1) > MAXline)