home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_07_02 / v7n2064a.txt < prev    next >
Text File  |  1988-09-15  |  2KB  |  59 lines

  1. /* DOSIO.C **    MS-DOS Input/Output routines for Character Device Driver.
  2.                                                         -- R.D.Allen, 9/4/87
  3. Copyright 1987, 1988, PARS Service Partnership
  4. */
  5.  
  6. #include    <stdio.h>
  7. #include    "driver.h"                /* Function prototypes */
  8. #include    "rqh.h"                    /* Request header structure */
  9.  
  10. #define    DF_MAX        17
  11.                         /* Jump Table used only here to route DF command
  12.                             proccessing.                                    */
  13. int        (*jmp_table[DF_MAX])() = {
  14.     df_init,        /* CMD 0 -- Initialization                            */
  15.     df_noop,        /* CMD 1 --    Media Check (Block Only)                */
  16.     df_noop,        /* CMD 2 -- Build BPB (Block Only)                    */
  17.     df_ioctl,        /* CMD 3 -- I/O Control Input (Read from DOS)        */
  18.     df_read,        /* CMD 4 --    Normal Device Read                        */
  19.     df_peek,        /* CMD 5 --    Non-destructive input, no wait             */
  20.     df_rstat,        /* CMD 6 -- Read Status                             */
  21.     df_rflush,        /* CMD 7 -- Read Flush                                 */
  22.     df_write,        /* CMD 8 --    Normal Device Write                     */
  23.     df_write,        /* CMD 9 -- Write with verify (Same as write, here) */
  24.     df_wstat,        /* CMD A -- Write Status                             */
  25.     df_wflush,        /* CMD B -- Write Buffer Flush                         */
  26.     df_ioctl,        /* CMD C --    I/O Control Output (Write to DOS)         */
  27.     df_open,        /* CMD D --    Device Open (new for 3.0)                */
  28.     df_close,        /* CMD E -- Device Close (new for 3.0)                 */
  29.     df_noop,        /* CMD F --    Removable Media (Block Only)             */
  30.     df_write        /* CMD 10 -- Write until busy (Same as write, here) */
  31. };
  32.  
  33. /*********
  34. *    NAME:    DOSIO        (a far function)
  35. *     USE:    This is called directly by DOS to parse a command header.
  36. *            Use the command number passed and call the appropriate
  37. *            processor. The return value is the error flag.
  38. *   INPUT:    void (use global Request Header pointer from STARTEGY)
  39. *  OUTPUT:    void (but a non-zero result from jump table list is an
  40. *                  error value and the error status bit is set)
  41. *********/
  42.  
  43. void far dosio(void)
  44. {
  45. static int result;            /* Must be static to live after stack_new        */
  46.  
  47.     stack_new();            /* Switch to local stack for this module        */
  48.     
  49.     result = (*jmp_table[ptr.rq->command])(ptr.rq->command);
  50.  
  51.     if(result) {
  52.         ptr.rq->status.err_type = result;
  53.         ptr.rq->status.err_flag = 1;
  54.     }
  55.     ptr.rq->status.done = 1;
  56.     
  57.     stack_old();            /* Switch back to callers stack            */
  58. }
  59.