home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / JSAGE / ZSUS / PROGPACK / CFORZ02.LBR / ZSUTIL.CZ / ZSUTIL.C
Text File  |  2000-06-30  |  2KB  |  120 lines

  1. /* Support routines for ZSDOS/ZDDOS for BDS compiler.
  2.    Version 0.1  9/28/89  Cameron W. Cotrill
  3. */
  4.  
  5. #include <stdio.h>
  6.  
  7. /* Return dos id (h)/version (l) of zs/zddos or 0 if not zs/zddos.
  8.    Call this function and be sure it returns non-zero before using
  9.    any of the routines in this module.
  10. */
  11.  
  12. int zsvers()
  13. {
  14.     int    i,j;
  15.  
  16.     if(bdos(12,0) != 0x22)
  17.         return(0);    /* screen out all but 2.2 compat */
  18.     i=bdos(48,0);
  19.     j=i>>8;
  20.     return((j == 'S' || j == 'D')? i : 0);
  21. }
  22.  
  23. /* Read clock into 6 byte buffer in ZSDOS/DateStamper format.
  24.    If no clock, returns 0's in the buffer.  Caller can determine
  25.    if time is valid by looking at the month.  It will NEVER be
  26.    0 if the clock read was done properly.
  27. */
  28.  
  29. char *rdtd(buf)
  30.     char *buf;
  31. {
  32.     int i;
  33.  
  34.     bdos(6,0xfe);    /* some clocks need a bios call first... */
  35.     if(bdos(98,buf) != 1)
  36.         for(i=0;i<6;buf[i++]='\0');
  37.     return(buf);
  38. }
  39.  
  40. /* Read file stamp.  Return 1 if ok, else 0. */
  41.  
  42. int getfs(fcb,buffer)
  43.     char *fcb, *buffer;
  44. {
  45.     int i,dma;
  46.  
  47.     dma=bdos(47,0);        /* save current dma */
  48.     bdos(26,buffer);    /* set dma for stamp read */
  49.     logud(fcb);
  50.     i=bdos(102,fcb);    /* read the stamp */
  51.     bdos(26,dma);        /* restore user dma */
  52.     return(i == 1 ? 1:0);    /* how did we do? */
  53. }
  54.  
  55. /* Write file stamp.  Return 1 if ok, else 0. */
  56.  
  57. int setfs(fcb,buffer)
  58.     char *fcb, buffer;
  59. {
  60.     int i,dma;
  61.  
  62.     dma=bdos(47,0);        /* save current dma */
  63.     bdos(26,buffer);    /* set dma */
  64.     logud(fcb);
  65.     i=bdos(103,fcb);
  66.     bdos(26,dma);        /* restore user dma */
  67.     return(i == 1 ? 1:0);    /* read stamp */
  68. }
  69.  
  70. /* Return ZSDOS flags to application */
  71.  
  72. int getflags()
  73. {
  74.     return(bdos(100,0));
  75. }
  76.  
  77. /* Set ZSDOS flags */
  78.  
  79. void setflags(flags)
  80.     int flags;
  81. {
  82.     bdos(101,flags);
  83. }
  84.  
  85. /* set drive [0..15] */
  86.  
  87. int setdrv(drive)
  88.     int    drive;
  89. {
  90.     int i;
  91.  
  92.     i = bdos(14,drive);        /* a,l may = 0xff if $$$.sub present */
  93.     return((i >> 8) ? FALSE : TRUE);    /* so look at h for error code */
  94. }
  95.  
  96. /* Set user area */
  97.  
  98. void setusr(user)
  99.     int user;
  100. {
  101.     bdos(32,user);
  102. }
  103.  
  104. /* Log drive and user from fcb.  Assumes fcb parsed by zsetfcb() or
  105.    any other fully z33 compliant parser.
  106. */
  107.  
  108. int logud(fcb)
  109.     char *fcb;
  110. {
  111.     int i,error;
  112.  
  113.     error = FALSE;
  114.     if(i = *fcb) 
  115.         error = setdrv(--i);
  116.     setusr(*(fcb+13));
  117.     return(error);
  118. }
  119.  
  120.