home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 2.ddi / CLIB2.ZIP / PARSFNM.CAS < prev    next >
Encoding:
Text File  |  1990-06-07  |  2.4 KB  |  74 lines

  1. /*-----------------------------------------------------------------------*
  2.  * filename - parsfnm.cas
  3.  *
  4.  * function(s)
  5.  *        parsfnm - parses file name
  6.  *-----------------------------------------------------------------------*/
  7.  
  8. /*[]------------------------------------------------------------[]*/
  9. /*|                                                              |*/
  10. /*|     Turbo C Run Time Library - Version 3.0                   |*/
  11. /*|                                                              |*/
  12. /*|                                                              |*/
  13. /*|     Copyright (c) 1987,1988,1990 by Borland International    |*/
  14. /*|     All Rights Reserved.                                     |*/
  15. /*|                                                              |*/
  16. /*[]------------------------------------------------------------[]*/
  17.  
  18. #pragma inline
  19. #include <asmrules.h>
  20. #include <dos.h>
  21. #include <stddef.h>
  22.  
  23.  
  24. /*-----------------------------------------------------------------------*
  25.  
  26. Name        parsfnm - parses file name
  27.  
  28. Usage        #include <dos.h>
  29.         char *parsfnm(const char *cmdline, struct fcb *fcbptr,
  30.                            int option);
  31.  
  32. Prototype in    dos.h
  33.  
  34. Description    parsfnm parses a string, normally a command line,
  35.         pointed to by *cmdline for a file name. The file name
  36.         is placed in an FCB as a drive, file name, and extension.
  37.         The FCB is pointed to by fcbptr.
  38.  
  39.         The option parameter is the value documented for AL in
  40.         the DOS parse system call. See the MS-DOS Programmer's
  41.         Reference Manual under system call 0x29 for a description
  42.         of the parsing operations performed on the file name.
  43.  
  44. Return value    On successfully completing the parse of a file
  45.         name, parsfnm returns a pointer to the next byte after
  46.         the end of the file name. If there is any error in
  47.         parsing the file name, parsfnm returns 0.
  48.  
  49. *------------------------------------------------------------------------*/
  50. char *parsfnm(const char *cmdline, struct fcb *fcb, int opt)
  51. {
  52. #if !(LDATA)
  53.         _ES = _DS;
  54. #endif
  55.         pushDS_
  56. asm     LDS_    si, cmdline
  57. asm     LES_    di, fcb
  58. asm     mov     al, opt
  59. asm     mov     ah, 29h
  60. asm     int     21h
  61.         popDS_
  62. asm     cmp     al, 0ffh
  63. asm     jne     parsret
  64.         return NULL;
  65.  
  66. parsret:
  67. #if (LDATA)
  68. asm     mov     es, W1(cmdline)
  69.         return (char _es *) _SI;
  70. #else
  71.         return (char *) _SI;
  72. #endif
  73. }
  74.