home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3998 / ioctl.c < prev    next >
C/C++ Source or Header  |  1991-09-08  |  3KB  |  112 lines

  1. #include <stdio.h>
  2. #include <sys/types.h>
  3. #include <sys/ptrace.h>
  4. #include "defs.h"
  5.  
  6. struct ioctlent {
  7.     char *doth;
  8.     char *symbol;
  9.     long code;
  10. } ioctlent[] = {
  11. /*
  12.  * `ioctlent.sorted.h' is generated from `ioctlent.h' by the auxiliary
  13.  * program `ioctlsort', such that the list is sorted by the `code' field.
  14.  * This has the side-effect of resolving the _IO.. macros into
  15.  * plain integers, eliminating the need to include here everything
  16.  * in "/usr/include/*\/*" .
  17.  */
  18. #include "ioctlent.sorted.h"
  19. };
  20.  
  21. int nioctlent = sizeof ioctlent / sizeof ioctlent[0];
  22.  
  23. static int
  24. compare(a,b)
  25. struct ioctlent *a, *b;
  26. {
  27.     return (a->code - b->code);
  28. }
  29.  
  30. char *
  31. ioctl_lookup(code)
  32. int code;
  33. {
  34.     struct ioctlent *iop, ioent;
  35.  
  36.     ioent.code = code;
  37.     iop = (struct ioctlent *)bsearch((char *)&ioent, (char *)ioctlent,
  38.             nioctlent, sizeof(struct ioctlent), compare);
  39.     if (iop == (struct ioctlent *)0)
  40.         return NULL;
  41.     return iop->symbol;
  42. }
  43.  
  44. int
  45. ioctl_decode(pid, code, arg)
  46. int pid;
  47. unsigned code, arg;
  48. {
  49. /*
  50.  * Registry of ioctl characters, culled from
  51.  *    @(#)ioccom.h 1.7 89/06/16 SMI; from UCB ioctl.h 7.1 6/4/86
  52.  *
  53.  * char    file where defined        notes
  54.  * ----    ------------------        -----
  55.  *   F    sun/fbio.h
  56.  *   G    sun/gpio.h
  57.  *   H    vaxif/if_hy.h
  58.  *   M    sundev/mcpcmd.h            *overlap*
  59.  *   M    sys/modem.h            *overlap*
  60.  *   S    sys/stropts.h
  61.  *   T    sys/termio.h            -no overlap-
  62.  *   T    sys/termios.h            -no overlap-
  63.  *   V    sundev/mdreg.h
  64.  *   a    vaxuba/adreg.h
  65.  *   d    sun/dkio.h            -no overlap with sys/des.h-
  66.  *   d    sys/des.h            (possible overlap)
  67.  *   d    vax/dkio.h            (possible overlap)
  68.  *   d    vaxuba/rxreg.h            (possible overlap)
  69.  *   f    sys/filio.h
  70.  *   g    sunwindow/win_ioctl.h        -no overlap-
  71.  *   g    sunwindowdev/winioctl.c        !no manifest constant! -no overlap-
  72.  *   h    sundev/hrc_common.h
  73.  *   i    sys/sockio.h            *overlap*
  74.  *   i    vaxuba/ikreg.h            *overlap*
  75.  *   k    sundev/kbio.h
  76.  *   m    sundev/msio.h            (possible overlap)
  77.  *   m    sundev/msreg.h            (possible overlap)
  78.  *   m    sys/mtio.h            (possible overlap)
  79.  *   n    sun/ndio.h
  80.  *   p    net/nit_buf.h            (possible overlap)
  81.  *   p    net/nit_if.h            (possible overlap)
  82.  *   p    net/nit_pf.h            (possible overlap)
  83.  *   p    sundev/fpareg.h            (possible overlap)
  84.  *   p    sys/sockio.h            (possible overlap)
  85.  *   p    vaxuba/psreg.h            (possible overlap)
  86.  *   q    sun/sqz.h
  87.  *   r    sys/sockio.h
  88.  *   s    sys/sockio.h
  89.  *   t    sys/ttold.h            (possible overlap)
  90.  *   t    sys/ttycom.h            (possible overlap)
  91.  *   v    sundev/vuid_event.h        *overlap*
  92.  *   v    sys/vcmd.h            *overlap*
  93.  *
  94.  * End of Registry
  95.  */
  96.  
  97. #ifdef someday
  98.     switch ((code >> 8) & 0xff) {
  99.     case 'r':
  100.     case 's':
  101.         sock_ioctl(pid, code, arg);
  102.         break;
  103.     case 't':
  104.         term_ioctl(pid, code, arg);
  105.         break;
  106.     default:
  107.         break;
  108.     }
  109. #endif
  110.     return 0;
  111. }
  112.