home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / xtrapv33.zip / extensions / lib / xtrap / XEStrMap.c < prev    next >
C/C++ Source or Header  |  1992-09-14  |  9KB  |  260 lines

  1. /*****************************************************************************
  2. Copyright 1987, 1988, 1989, 1990, 1991, 1992 by Digital Equipment Corp., 
  3. Maynard, MA
  4.  
  5. Permission to use, copy, modify, and distribute this software and its 
  6. documentation for any purpose and without fee is hereby granted, 
  7. provided that the above copyright notice appear in all copies and that
  8. both that copyright notice and this permission notice appear in 
  9. supporting documentation, and that the name of Digital not be
  10. used in advertising or publicity pertaining to distribution of the
  11. software without specific, written prior permission.  
  12.  
  13. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  14. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  15. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  16. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  17. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  18. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  19. SOFTWARE.
  20.  
  21. *****************************************************************************/
  22. #include <stdio.h>
  23. #include "Xlib.h"
  24. #include "xtraplib.h"
  25. #include "xtraplibp.h"
  26.  
  27. static char *eventName[] = {
  28.     "", "",
  29.     "KeyPress",         "KeyRelease",       "ButtonPress",
  30.     "ButtonRelease",    "MotionNotify",     "EnterNotify",
  31.     "LeaveNotify",      "FocusIn",          "FocusOut",
  32.     "KeymapNotify",     "Expose",           "GraphicsExpose",
  33.     "NoExpose",         "VisibilityNotify", "CreateNotify",
  34.     "DestroyNotify",    "UnmapNotify",      "MapNotify",
  35.     "MapRequest",       "ReparentNotify",   "ConfigureNotify",
  36.     "ConfigureRequest", "GravityNotify",    "ResizeRequest",
  37.     "CirculateNotify",  "CirculateRequest", "PropertyNotify",
  38.     "SelectionClear",   "SelectionRequest", "SelectionNotify",
  39.     "ColormapNotify",   "ClientMessage",    "MappingNotify",
  40.     "LASTEvent",
  41. };
  42.  
  43. static char *requestName[] = {
  44.     "Invalid",
  45.     "X_CreateWindow",           "X_ChangeWindowAttributes",
  46.     "X_GetWindowAttributes",    "X_DestroyWindow",
  47.     "X_DestroySubwindows",      "X_ChangeSaveSet",
  48.     "X_ReparentWindow",         "X_MapWindow",
  49.     "X_MapSubwindows",          "X_UnmapWindow",
  50.     "X_UnmapSubwindows",        "X_ConfigureWindow",
  51.     "X_CirculateWindow",        "X_GetGeometry",
  52.     "X_QueryTree",              "X_InternAtom",
  53.     "X_GetAtomName",            "X_ChangeProperty",
  54.     "X_DeleteProperty",         "X_GetProperty",
  55.     "X_ListProperties",         "X_SetSelectionOwner",
  56.     "X_GetSelectionOwner",      "X_ConvertSelection",
  57.     "X_SendEvent",              "X_GrabPointer",
  58.     "X_UngrabPointer",          "X_GrabButton",
  59.     "X_UngrabButton",           "X_ChangeActivePointerGrab",
  60.     "X_GrabKeyboard",           "X_UngrabKeyboard",
  61.     "X_GrabKey",                "X_UngrabKey",
  62.     "X_AllowEvents",            "X_GrabServer",
  63.     "X_UngrabServer",           "X_QueryPointer",
  64.     "X_GetMotionEvents",        "X_TranslateCoords",
  65.     "X_WarpPointer",            "X_SetInputFocus",
  66.     "X_GetInputFocus",          "X_QueryKeymap",
  67.     "X_OpenFont",               "X_CloseFont",
  68.     "X_QueryFont",              "X_QueryTextExtents",
  69.     "X_ListFonts",              "X_ListFontsWithInfo",
  70.     "X_SetFontPath",            "X_GetFontPath",
  71.     "X_CreatePixmap",           "X_FreePixmap",
  72.     "X_CreateGC",               "X_ChangeGC",
  73.     "X_CopyGC",                 "X_SetDashes",
  74.     "X_SetClipRectangles",      "X_FreeGC",
  75.     "X_ClearArea",              "X_CopyArea",
  76.     "X_CopyPlane",              "X_PolyPoint",
  77.     "X_PolyLine",               "X_PolySegment",
  78.     "X_PolyRectangle",          "X_PolyArc", 
  79.     "X_FillPoly",               "X_PolyFillRectangle",
  80.     "X_PolyFillArc",            "X_PutImage",
  81.     "X_GetImage",               "X_PolyText8",
  82.     "X_PolyText16",             "X_ImageText8",
  83.     "X_ImageText16",            "X_CreateColormap",
  84.     "X_FreeColormap",           "X_CopyColormapAndFree",
  85.     "X_InstallColormap",        "X_UninstallColormap",
  86.     "X_ListInstalledColormaps", "X_AllocColor",
  87.     "X_AllocNamedColor",        "X_AllocColorCells",
  88.     "X_AllocColorPlanes",       "X_FreeColors",
  89.     "X_StoreColors",            "X_StoreNamedColor",
  90.     "X_QueryColors",            "X_LookupColor",
  91.     "X_CreateCursor",           "X_CreateGlyphCursor",
  92.     "X_FreeCursor",             "X_RecolorCursorSize",
  93.     "X_QueryBestSize",          "X_QueryExtension",
  94.     "X_ListExtensions",         "X_ChangeKeyboardMapping",
  95.     "X_GetKeyboardMapping",     "X_ChangeKeyboardControl",
  96.     "X_GetKeyboardControl",     "X_Bell",
  97.     "X_ChangePointerControl",   "X_GetPointerControl",
  98.     "X_SetScreenSaver",         "X_GetScreenSaver",
  99.     "X_ChangeHosts",            "X_ListHosts",
  100.     "X_SetAccessControl",       "X_SetCloseDownMode",
  101.     "X_KillClient",             "X_RotateProperties",
  102.     "X_ForceScreenSaver",       "X_SetPointerMapping",
  103.     "X_GetPointerMapping",      "X_SetModifierMapping",
  104.     "X_GetModifierMapping",     "Invalid", 
  105.     "Invalid",                  "Invalid", 
  106.     "Invalid",                  "Invalid",
  107.     "Invalid",                  "Invalid",
  108.     "X_NoOperation",
  109. };
  110.  
  111. char **extensionName = NULL;
  112. int numExtension;
  113.  
  114. static struct _pf_tbl {CARD32 id; char *str;} pf_tbl[] =
  115. {
  116.     {PF_Apollo,         "Apollo"},
  117.     {PF_ATT,            "ATT"},
  118.     {PF_Cray1,          "Cray1"},
  119.     {PF_Cray2,          "Cray2"},
  120.     {PF_DECUltrix,      "DECUltrix"},
  121.     {PF_DECVMS,         "DECVMS"},
  122.     {PF_DECELN,         "DECELN"},
  123.     {PF_DECOSF1,        "DECOSF1"},
  124.     {PF_DECVT1000,      "DECVT1000"},
  125.     {PF_DECXTerm,       "DECXTerm"},
  126.     {PF_HP9000s800,     "HP9000s800"},
  127.     {PF_HP9000s300,     "HP9000s300"},
  128.     {PF_IBMAT,          "IBMAT"},
  129.     {PF_IBMRT,          "IBMRT"},
  130.     {PF_IBMPS2,         "IBMPS2"},
  131.     {PF_IBMRS,          "IBMRS"},
  132.     {PF_MacII,          "MacII"},
  133.     {PF_Pegasus,        "Pegasus"},
  134.     {PF_SGI,            "SGI"},
  135.     {PF_Sony,           "Sony"},
  136.     {PF_Sun3,           "Sun3"},
  137.     {PF_Sun386i,        "Sun386i"},
  138.     {PF_SunSparc,       "SunSparc"},
  139.     {PF_Other,          "Other"}        /* always the last one! */
  140. };
  141.  
  142. static char unknown[] = "unknown";
  143.  
  144. #define ASize(array) (sizeof(array)/sizeof((array)[0]))
  145.  
  146. #ifdef FUNCTION_PROTOS
  147. static INT16 _StringToID(register char *match, register char **strings,
  148.     INT16 nstrings)
  149. #else
  150. static INT16 _StringToID(match,strings,nstrings)
  151.     register char *match;
  152.     register char **strings;
  153.     INT16 nstrings;
  154. #endif
  155. {
  156.     register INT16 id = nstrings;
  157.  
  158.     if (match && *match)
  159.     { while ((--id >= 0L) && (strcmp(match,strings[id]) != 0L)); }
  160.     else
  161.     { id = -1L; }
  162.  
  163.     return(id);
  164. }
  165.  
  166. #ifdef FUNCTION_PROTOS
  167. INT16 XEEventStringToID(register char *string)
  168. #else
  169. INT16 XEEventStringToID(string)
  170.     register char *string;
  171. #endif
  172. {
  173.     return(_StringToID(string,eventName,ASize(eventName)));
  174. }
  175.  
  176. #ifdef FUNCTION_PROTOS
  177. INT16 XERequestStringToID(register char *string)
  178. #else
  179. INT16 XERequestStringToID(string)
  180.     register char *string;
  181. #endif
  182. {
  183.     return(_StringToID(string,requestName,ASize(requestName)));
  184. }
  185.  
  186. #ifdef FUNCTION_PROTOS
  187. CARD32 XEPlatformStringToID(register char *string)
  188. #else
  189. CARD32 XEPlatformStringToID(string)
  190.     register char *string;
  191. #endif
  192. {
  193.     struct _pf_tbl *ptr = &(pf_tbl[0]);
  194.     while(ptr->id != PF_Other)
  195.     {
  196.         if (!strncmp(ptr->str, string, strlen(ptr->str)))
  197.         {
  198.             return(ptr->id);
  199.         }
  200.         ptr++;
  201.     }
  202.     return((!strncmp(ptr->str,string,strlen(ptr->str))) ? ptr->id : -1L);
  203. }
  204.  
  205. #ifdef FUNCTION_PROTOS
  206. char *XEEventIDToString(register CARD8 id)
  207. #else
  208. char *XEEventIDToString(id)
  209.     register CARD8 id;
  210. #endif
  211. {
  212.     return((id >= 0 && id < ASize(eventName)) ? eventName[id] : unknown);
  213. }
  214.  
  215. #ifdef FUNCTION_PROTOS
  216. char *XERequestIDToExtString(register CARD8 id)
  217. #else
  218. char *XERequestIDToExtString(id)
  219.     register CARD8 id;
  220. #endif
  221. {
  222.     int extid;
  223.  
  224.     extid = id - ASize(requestName);
  225.  
  226.     return((extid >=0 && extid < numExtension) ? 
  227.         extensionName[extid] : unknown);
  228. }
  229.  
  230.  
  231. #ifdef FUNCTION_PROTOS
  232. char *XERequestIDToString(register CARD8 id)
  233. #else
  234. char *XERequestIDToString(id)
  235.     register CARD8 id;
  236. #endif
  237. {
  238.     return((id >= 0 && id < ASize(requestName)) ? requestName[id] :
  239.         XERequestIDToExtString(id));
  240. }
  241.  
  242. #ifdef FUNCTION_PROTOS
  243. char *XEPlatformIDToString(register CARD32 id)
  244. #else
  245. char *XEPlatformIDToString(id)
  246.     register CARD32 id;
  247. #endif
  248. {
  249.     struct _pf_tbl *ptr = &(pf_tbl[0]);
  250.     while((ptr->id != PF_Other) || (id == ptr->id))
  251.     {
  252.         if (id == ptr->id)
  253.         {
  254.             return(ptr->str);
  255.         }
  256.         ptr++;
  257.     }
  258.     return(unknown);
  259. }
  260.