home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c005 / 4.ddi / C / DRSNEXT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1986-08-05  |  2.0 KB  |  62 lines

  1. /**
  2. *
  3. * Name        drsnext -- Find the next matching file
  4. *
  5. * Synopsis    ercode = drsnext(pfile);
  6. *
  7. *        int   ercode      DOS function return error code
  8. *        FSPEC *pfile      File information on matching file
  9. *
  10. * Description    DRSNEXT is used in conjunction with DRSFIRST to return
  11. *        information on all files matching requirements set when
  12. *        DRSFIRST is called.  DRSFIRST must be called before
  13. *        DRSNEXT is first invoked, but then subsequent calls to
  14. *        DRSNEXT return information on remaining matching files.
  15. *        See DRSFIRST for a detailed description of the
  16. *        information returned.
  17. *
  18. *        If the value of the function is 0 (i.e., no error), then
  19. *        a file was found and DRSNEXT can be used again to find
  20. *        further files matching the name and attribute which were
  21. *        specified when DRSFIRST was called.  If the value of the
  22. *        function is 18, then no matching files were found, and
  23. *        DRSNEXT will not find any more matching files.
  24. *
  25. * Returns    ercode          DOS function error code
  26. *        *pfile          File information for the matching file
  27. *
  28. * Version    3.0  (C)Copyright Blaise Computing Inc.  1983, 1984, 1986
  29. *
  30. **/
  31.  
  32. #include <bdirect.h>
  33. #include <bfile.h>
  34.  
  35. int drsnext(pfile)
  36. FSPEC *pfile;
  37. {
  38.     ADS      dta_ads,buf_ads,file_ads;
  39.     int      ercode;
  40.     DOSREG   dos_reg;
  41.  
  42.     flretdta(&dta_ads);           /* Return DTA location, and set */
  43.     utabsptr(b_drbuffer,&buf_ads);    /* the new DTA location.          */
  44.     flsetdta(&buf_ads);
  45.  
  46.     dos_reg.ax = 0x4f00;
  47.     ercode = dos(&dos_reg);
  48.  
  49.     if (ercode == 0)              /* Found a match, now get info  */
  50.     {                      /* and move into the FSPEC      */
  51.                       /* variable.              */
  52.        utabsptr((char *) pfile,&file_ads);
  53.        buf_ads.r += 20;           /* File info is at offset 20    */
  54.        utslmove(&buf_ads,&file_ads,23);
  55.        pfile->fattr = uthibyte(pfile->fattr); /* Move attribute value */
  56.     }                      /* into the proper byte.          */
  57.  
  58.     flsetdta(&dta_ads);           /* Restore the DTA location     */
  59.  
  60.     return(ercode);
  61. }
  62.