home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / extensions / lib / MITMisc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-01-05  |  4.2 KB  |  132 lines

  1. /*
  2.  * $XConsortium: MITMisc.c,v 1.4 91/01/05 14:46:12 rws Exp $
  3.  *
  4.  * Copyright 1989 Massachusetts Institute of Technology
  5.  *
  6.  * Permission to use, copy, modify, distribute, and sell this software and its
  7.  * documentation for any purpose is hereby granted without fee, provided that
  8.  * the above copyright notice appear in all copies and that both that
  9.  * copyright notice and this permission notice appear in supporting
  10.  * documentation, and that the name of M.I.T. not be used in advertising or
  11.  * publicity pertaining to distribution of the software without specific,
  12.  * written prior permission.  M.I.T. makes no representations about the
  13.  * suitability of this software for any purpose.  It is provided "as is"
  14.  * without express or implied warranty.
  15.  *
  16.  * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  17.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
  18.  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  19.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  20.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
  21.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22.  *
  23.  */
  24.  
  25. /* RANDOM CRUFT! THIS HAS NO OFFICIAL X CONSORTIUM BLESSING */
  26.  
  27. #define NEED_REPLIES
  28. #include "Xlibint.h"
  29. #include "MITMisc.h"
  30. #include "mitmiscstr.h"
  31. #include "Xext.h"
  32. #include "extutil.h"
  33.  
  34. static XExtensionInfo _mit_info_data;
  35. static XExtensionInfo *mit_info = &_mit_info_data;
  36. static /* const */ char *mit_extension_name = MITMISCNAME;
  37.  
  38. #define MITCheckExtension(dpy,i,val) \
  39.   XextCheckExtension (dpy, i, mit_extension_name, val)
  40.  
  41. /*****************************************************************************
  42.  *                                                                           *
  43.  *               private utility routines                          *
  44.  *                                                                           *
  45.  *****************************************************************************/
  46.  
  47. static int close_display();
  48. static /* const */ XExtensionHooks mit_extension_hooks = {
  49.     NULL,                /* create_gc */
  50.     NULL,                /* copy_gc */
  51.     NULL,                /* flush_gc */
  52.     NULL,                /* free_gc */
  53.     NULL,                /* create_font */
  54.     NULL,                /* free_font */
  55.     close_display,            /* close_display */
  56.     NULL,                /* wire_to_event */
  57.     NULL,                /* event_to_wire */
  58.     NULL,                /* error */
  59.     NULL                /* error_string */
  60. };
  61.  
  62. static XEXT_GENERATE_FIND_DISPLAY (find_display, mit_info, mit_extension_name, 
  63.                    &mit_extension_hooks, MITMiscNumberEvents,
  64.                    NULL)
  65.  
  66. static XEXT_GENERATE_CLOSE_DISPLAY (close_display, mit_info)
  67.  
  68.  
  69. /*****************************************************************************
  70.  *                                                                           *
  71.  *            public Shared Memory Extension routines                  *
  72.  *                                                                           *
  73.  *****************************************************************************/
  74.  
  75. Bool XMITMiscQueryExtension (dpy, event_basep, error_basep)
  76.     Display *dpy;
  77.     int *event_basep, *error_basep;
  78. {
  79.     XExtDisplayInfo *info = find_display (dpy);
  80.  
  81.     if (XextHasExtension(info)) {
  82.     *event_basep = info->codes->first_event;
  83.     *error_basep = info->codes->first_error;
  84.     return True;
  85.     } else {
  86.     return False;
  87.     }
  88. }
  89.  
  90.  
  91. Status XMITMiscSetBugMode(dpy, onOff)
  92.     Display *dpy;
  93.     Bool onOff;
  94. {
  95.     XExtDisplayInfo *info = find_display (dpy);
  96.     register xMITSetBugModeReq *req;
  97.  
  98.     MITCheckExtension (dpy, info, 0);
  99.  
  100.     LockDisplay(dpy);
  101.     GetReq(MITSetBugMode, req);
  102.     req->reqType = info->codes->major_opcode;
  103.     req->mitReqType = X_MITSetBugMode;
  104.     req->onOff = onOff;
  105.     UnlockDisplay(dpy);
  106.     SyncHandle();
  107.     return 1;
  108. }
  109.  
  110. Bool XMITMiscGetBugMode(dpy)
  111.     Display *dpy;
  112. {
  113.     XExtDisplayInfo *info = find_display (dpy);
  114.     register xMITGetBugModeReq *req;
  115.     xMITGetBugModeReply rep;
  116.  
  117.     MITCheckExtension (dpy, info, 0);
  118.  
  119.     LockDisplay(dpy);
  120.     GetReq(MITGetBugMode, req);
  121.     req->reqType = info->codes->major_opcode;
  122.     req->mitReqType = X_MITGetBugMode;
  123.     if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
  124.     UnlockDisplay(dpy);
  125.     SyncHandle();
  126.     return False;
  127.     }
  128.     UnlockDisplay(dpy);
  129.     SyncHandle();
  130.     return rep.onOff;
  131. }
  132.