home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / drdobbs / c_spec / execute / mydos.h < prev    next >
C/C++ Source or Header  |  1986-02-20  |  4KB  |  115 lines

  1. /*----------------------------------------------------------------------+
  2.  *                                    |
  3.  *     MYDOS.H    Various defines for talking to dos        |
  4.  *                                    |
  5.  *----------------------------------------------------------------------+
  6.  *
  7.  *    Typdefs for using dos(). Note that this structure can be used
  8.  *    by the various routines supplied by Lattice (intdos, bdos etc.)
  9.  *    but dos() can't use the structure defined in Lattice's dos.h.
  10.  *
  11.  *    Since "REGS" and "byte" are both also defined in dos.h, you
  12.  *    shouldn't #include both of them in the same place.
  13.  */
  14.  
  15. typedef short    word;
  16. typedef char    byte;
  17.  
  18. struct LREG { word  ax,    bx,    cx,    dx,     si, di, es, cs, ss, ds;};
  19. struct SREG { byte  al,ah, bl,bh, cl,ch, dl,dh;                };
  20.  
  21. typedef union
  22. {
  23.     struct LREG    x ;
  24.     struct SREG    h ;
  25. }
  26. REGS;
  27.  
  28. /*----------------------------------------------------------------------
  29.  *    Stuff needed to get a directory from MSDOS
  30.  *
  31.  *  The FILE_INFO type structure is filled by a find first or find
  32.  *  next command (dos system calls 0x4e and 0x4f).
  33.  */
  34.  
  35. typedef struct
  36. {
  37.     char    fi_resv[21];    /* Bytes 0-20    Reserved by DOS          */
  38.     char    fi_attrib;    /* Byte  21    File attribute          */
  39.     short    fi_time;    /* Bytes 22-23    Create/update time    */
  40.     short    fi_date;    /* Bytes 24-25    Create/update date    */
  41.     long    fi_fsize;    /* Bytes 26-27    File size in bytes    */
  42.     char    fi_name[13];    /* Bytes 28-40  File name & extension */
  43. }
  44. FILE_INFO;
  45.  
  46. /*----------------------------------------------------------------------
  47.  * This kludge is needed because the IBM assembler won't recognize
  48.  * lower-case names. If you're using the new (ver 4.x) Microsoft
  49.  * assembler then these #defines aren't necessary.
  50.  */
  51.  
  52. #ifdef IBM
  53.  
  54. #define    gregs(x)    GREGS(x)
  55. #define    mydos(x)    MYDOS(x)
  56.  
  57. #endif
  58.  
  59. /*----------------------------------------------------------------------*/
  60.  
  61. /*
  62.  *   Macros to extract information from a FILE_INFO. In all these macros
  63.  *   the argument "p" is a poshorter to a FILE_INFO structure. Note that
  64.  *   the C_YEAR and C_SEC macros compensate for MSDOS wierdnessess.
  65.  *
  66.  * IS_READONLY(p)    File is read only.
  67.  * IS_HIDDEN(p)        File is invisible in normal directory searches
  68.  * IS_SYSTEM(p)        File is a system file
  69.  * IS_LABEL(p)        Info is a volume label, not a file.
  70.  * IS_SUBDIR(p)        File is a directory
  71.  * IS_DIRTY(p)        True when file is written to and closed, set to
  72.  *            False by the program backup.
  73.  * C_HR(p)        Hour of last update or create    (0-23)
  74.  * C_MIN(p)        Minute of last update or create    (0-59)
  75.  * C_SEC(p)        Second of last update or create    (0-59)
  76.  * C_YEAR(p)        Year of last update or create    (1980-2099)
  77.  * C_MONTH(p)        Month of last update or create    (1-12)
  78.  * C_DAY(p)        Day of last update or create    (1-31)
  79.  */
  80.  
  81. #define READONLY    0x01        /* Attribute bits    */
  82. #define HIDDEN        0x02
  83. #define SYSTEM        0x04
  84. #define LABEL        0x08
  85. #define SUBDIR        0x10
  86. #define DIRTY        0x20
  87.  
  88. #define ALL         (READONLY | DIRTY | SYSTEM | HIDDEN | SUBDIR | LABEL)
  89. #define ALL_FILES    (READONLY | DIRTY | SYSTEM | HIDDEN )
  90. #define NORM_FILES   (READONLY | DIRTY )
  91.  
  92. #define    IS_READONLY(p)    ((p)->fi_attrib & READONLY    )
  93. #define    IS_HIDDEN(p)    ((p)->fi_attrib & HIDDEN    )
  94. #define    IS_SYSTEM(p)    ((p)->fi_attrib & SYSTEM    )
  95. #define    IS_LABEL(p)    ((p)->fi_attrib & LABEL        )
  96. #define    IS_SUBDIR(p)    ((p)->fi_attrib & SUBDIR    )
  97. #define    IS_DIRTY(p)    ((p)->fi_attrib & DIRTY        )
  98.  
  99. #define C_HR(p)        ( ((p)->fi_time >> 11) & 0x1f )
  100. #define C_MIN(p)    ( ((p)->fi_time >>  5) & 0x3f )
  101. #define C_SEC(p)    ( ((p)->fi_time <<  1) & 0x3e )
  102. #define C_YEAR(p)    ((((p)->fi_date >>  9) & 0x7f ) + 1980)
  103. #define C_MONTH(p)    ( ((p)->fi_date >>  5) & 0x0f )
  104. #define C_DAY(p)    ( ((p)->fi_date      ) & 0x1f )
  105.  
  106. /*----------------------------------------------------------------------
  107.  *    Directory related BDOS function numbers
  108.  */
  109.  
  110. #define FINDFIRST    0x4e
  111. #define FINDNEXT    0x4f
  112. #define SETDTA        0x1a
  113. #define GETDTA        0x2f
  114. #define CARRY        0x01    /* Mask for carry bit    */
  115.