home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / extensions / server / mitmisc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-17  |  3.3 KB  |  145 lines

  1. /************************************************************
  2. Copyright 1989 by The Massachusetts Institute of Technology
  3.  
  4. Permission to use, copy, modify, and distribute this
  5. software and its documentation for any purpose and without
  6. fee is hereby granted, provided that the above copyright
  7. no- tice appear in all copies and that both that copyright
  8. no- tice and this permission notice appear in supporting
  9. docu- mentation, and that the name of MIT not be used in
  10. advertising or publicity pertaining to distribution of the
  11. software without specific prior written permission.
  12. M.I.T. makes no representation about the suitability of
  13. this software for any purpose. It is provided "as is"
  14. without any express or implied warranty.
  15.  
  16. ********************************************************/
  17.  
  18. /* RANDOM CRUFT! THIS HAS NO OFFICIAL X CONSORTIUM BLESSING */
  19.  
  20. /* $XConsortium: mitmisc.c,v 1.4 91/06/17 11:36:15 rws Exp $ */
  21.  
  22. #include "X.h"
  23. #include "Xproto.h"
  24. #include "misc.h"
  25. #include "os.h"
  26. #include "dixstruct.h"
  27. #include "extnsionst.h"
  28. #define _MITMISC_SERVER_
  29. #include "mitmiscstr.h"
  30.  
  31. extern Bool permitOldBugs;
  32.  
  33. static unsigned char MITReqCode;
  34. static int ProcMITDispatch(), SProcMITDispatch();
  35. static void MITResetProc();
  36.  
  37. void
  38. MITMiscExtensionInit()
  39. {
  40.     ExtensionEntry *extEntry, *AddExtension();
  41.  
  42.     if (extEntry = AddExtension(MITMISCNAME, 0, 0,
  43.                  ProcMITDispatch, SProcMITDispatch,
  44.                  MITResetProc, StandardMinorOpcode))
  45.     MITReqCode = (unsigned char)extEntry->base;
  46. }
  47.  
  48. /*ARGSUSED*/
  49. static void
  50. MITResetProc (extEntry)
  51. ExtensionEntry    *extEntry;
  52. {
  53. }
  54.  
  55. static int
  56. ProcMITSetBugMode(client)
  57.     register ClientPtr client;
  58. {
  59.     REQUEST(xMITSetBugModeReq);
  60.  
  61.     REQUEST_SIZE_MATCH(xMITSetBugModeReq);
  62.     if ((stuff->onOff != xTrue) && (stuff->onOff != xFalse))
  63.     {
  64.     client->errorValue = stuff->onOff;
  65.     return BadValue;
  66.     }
  67.     permitOldBugs = stuff->onOff;
  68.     return(client->noClientException);
  69. }
  70.  
  71. static int
  72. ProcMITGetBugMode(client)
  73.     register ClientPtr client;
  74. {
  75.     REQUEST(xMITGetBugModeReq);
  76.     xMITGetBugModeReply rep;
  77.     register int n;
  78.  
  79.     REQUEST_SIZE_MATCH(xMITGetBugModeReq);
  80.     rep.type = X_Reply;
  81.     rep.length = 0;
  82.     rep.sequenceNumber = client->sequence;
  83.     rep.onOff = permitOldBugs;
  84.     if (client->swapped) {
  85.         swaps(&rep.sequenceNumber, n);
  86.         swapl(&rep.length, n);
  87.     }
  88.     WriteToClient(client, sizeof(xMITGetBugModeReply), (char *)&rep);
  89.     return(client->noClientException);
  90. }
  91.  
  92. static int
  93. ProcMITDispatch (client)
  94.     register ClientPtr    client;
  95. {
  96.     REQUEST(xReq);
  97.     switch (stuff->data)
  98.     {
  99.     case X_MITSetBugMode:
  100.     return ProcMITSetBugMode(client);
  101.     case X_MITGetBugMode:
  102.     return ProcMITGetBugMode(client);
  103.     default:
  104.     return BadRequest;
  105.     }
  106. }
  107.  
  108. static int
  109. SProcMITSetBugMode(client)
  110.     register ClientPtr    client;
  111. {
  112.     register int n;
  113.     REQUEST(xMITSetBugModeReq);
  114.  
  115.     swaps(&stuff->length, n);
  116.     return ProcMITSetBugMode(client);
  117. }
  118.  
  119. static int
  120. SProcMITGetBugMode(client)
  121.     register ClientPtr    client;
  122. {
  123.     register int n;
  124.     REQUEST(xMITGetBugModeReq);
  125.  
  126.     swaps(&stuff->length, n);
  127.     return ProcMITGetBugMode(client);
  128. }
  129.  
  130. static int
  131. SProcMITDispatch (client)
  132.     register ClientPtr    client;
  133. {
  134.     REQUEST(xReq);
  135.     switch (stuff->data)
  136.     {
  137.     case X_MITSetBugMode:
  138.     return SProcMITSetBugMode(client);
  139.     case X_MITGetBugMode:
  140.     return SProcMITGetBugMode(client);
  141.     default:
  142.     return BadRequest;
  143.     }
  144. }
  145.