home *** CD-ROM | disk | FTP | other *** search
/ PC Shareware 1999 March / PCShareware-3-99.iso / IMPLE / DJGPP.RAR / DJGPP2 / XLIB-SR0.ZIP / SRC / XLIBEMU / MISC.C < prev    next >
C/C++ Source or Header  |  1994-02-18  |  3KB  |  143 lines

  1. /* $Id: misc.c 1.4 1994/02/11 00:48:00 ulrich Exp ulrich $ */
  2. /*
  3.  * misc.c
  4.  *
  5.  * Miscellaneous X library functions.
  6.  */
  7. #include "Xlibemu.h"
  8.  
  9. int
  10. XFree (void *ptr)
  11. {
  12.   Xfree (ptr);
  13.   return 0;
  14. }
  15.  
  16. int XSync(
  17.     Display*        display,
  18.     Bool        discard)
  19. {
  20.   if (discard) {
  21.     XEvent xe;
  22.  
  23.     while (XPending (display)) {
  24.       XNextEvent (display, &xe);
  25.     }
  26.   }
  27.   return 0;
  28. }
  29.  
  30. int (*XSynchronize(
  31.     Display*        display,
  32.     Bool        onoff
  33.            ))()
  34. { return 0; };
  35.  
  36. int XSetCloseDownMode(
  37.     Display*        display,
  38.     int            close_mode)
  39. {
  40.   return 0;
  41. }
  42.  
  43. /*
  44.  * This routine can be used to (cheaply) get some memory within a single
  45.  * Xlib routine for scratch space.  It is reallocated from the same place
  46.  * each time, unless the library needs a large scratch space.
  47.  */
  48. char *_XAllocScratch (dpy, nbytes)
  49.     register Display *dpy;
  50.     unsigned long nbytes;
  51. {
  52.     if (nbytes > dpy->scratch_length) {
  53.         if (dpy->scratch_buffer) Xfree (dpy->scratch_buffer);
  54.         if (dpy->scratch_buffer = Xmalloc((unsigned) nbytes))
  55.         dpy->scratch_length = nbytes;
  56.         else dpy->scratch_length = 0;
  57.     }
  58.     return (dpy->scratch_buffer);
  59. }
  60.  
  61. /*
  62.  * _XGetHostname - similar to gethostname but allows special processing.
  63.  */
  64. int _XGetHostname (buf, maxlen)
  65.     char *buf;
  66.     int maxlen;
  67. {
  68.     int len;
  69.  
  70.     buf[0] = '\0';
  71. #ifdef HAVE_GETHOSTNAME
  72.     (void) gethostname (buf, maxlen);
  73. #else
  74.     {
  75.       char *p = getenv ("HOST");
  76.       if (p == NULL) 
  77.     p = "noname";
  78.       strncpy (buf, p, maxlen - 1);
  79.     }
  80. #endif
  81.     buf [maxlen - 1] = '\0';
  82.     len = strlen(buf);
  83.     return len;
  84. }
  85.  
  86. /* Next 3 functions from xlibint.c, referenced in xinitext.c */
  87.  
  88. Bool
  89. _XUnknownWireEvent(dpy, re, event)
  90. register Display *dpy;    /* pointer to display structure */
  91. register XEvent *re;    /* pointer to where event should be reformatted */
  92. register xEvent *event;    /* wire protocol event */
  93. {
  94. #ifdef notdef
  95.     (void) fprintf(stderr, 
  96.         "Xlib: unhandled wire event! event number = %d, display = %x\n.",
  97.             event->u.u.type, dpy);
  98. #endif
  99.     return(False);
  100. }
  101.  
  102. /*ARGSUSED*/
  103. Status
  104. _XUnknownNativeEvent(dpy, re, event)
  105. register Display *dpy;    /* pointer to display structure */
  106. register XEvent *re;    /* pointer to where event should be reformatted */
  107. register xEvent *event;    /* wire protocol event */
  108. {
  109. #ifdef notdef
  110.     (void) fprintf(stderr, 
  111.         "Xlib: unhandled native event! event number = %d, display = %x\n.",
  112.             re->type, dpy);
  113. #endif
  114.     return(0);
  115. }
  116.  
  117. Bool _XDefaultWireError(display, he, we)
  118.     Display     *display;
  119.     XErrorEvent *he;
  120.     xError      *we;
  121. {
  122.     return True;
  123. }
  124.  
  125. Bool XQueryExtension(
  126.     register Display *dpy,
  127.     _Xconst char *name,
  128.     int *major_opcode,  /* RETURN */
  129.     int *first_event,   /* RETURN */
  130.     int *first_error)    /* RETURN */
  131. {       
  132.     return False;    /* Extensions not supported */
  133. }
  134.  
  135. /* Referenced in xlcwarp.c */
  136.  
  137. #include "Xlcint.h"
  138.  
  139. XLCd _XlcDefaultLoader(char* name)
  140. {
  141.   return (XLCd) 0;
  142. }
  143.