home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / rom / dos / pathpart.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-27  |  2.3 KB  |  127 lines

  1. /*
  2.     (C) 1995 AROS - The Amiga Replacement OS
  3.     $Id: pathpart.c,v 1.5 1997/01/27 00:36:27 ldp Exp $
  4.     $Log: pathpart.c,v $
  5.     Revision 1.5  1997/01/27 00:36:27  ldp
  6.     Polish
  7.  
  8.     Revision 1.4  1996/12/09 13:53:37  aros
  9.     Added empty templates for all missing functions
  10.  
  11.     Moved #include's into first column
  12.  
  13.     Revision 1.3  1996/11/21 10:49:47  aros
  14.     Created macros AROS_SLIB_ENTRY() for assembler files, too, to solve naming
  15.     problems.
  16.  
  17. The #includes
  18.     makedepend will ignore them (GCC works, though).
  19.  
  20.     Removed a couple of Logs
  21.  
  22.     Revision 1.2  1996/10/24 15:50:34  aros
  23.     Use the official AROS macros over the __AROS versions.
  24.  
  25.     Revision 1.1  1996/10/21 17:43:11  aros
  26.     A new function
  27.  
  28.     Desc:
  29.     Lang: english
  30. */
  31. #ifndef TEST
  32. #include "dos_intern.h"
  33. #else
  34. #define AROS_LH1(t,fn,a1,bt,bn,o,lib)     t fn (a1)
  35. #define AROS_LHA(t,n,r)                   t n
  36. #define AROS_LIBFUNC_INIT
  37. #define AROS_LIBBASE_EXT_DECL(bt,bn)
  38. #define AROS_LIBFUNC_EXIT
  39. #define CLIB_DOS_PROTOS_H
  40. #include <exec/types.h>
  41. #endif
  42.  
  43. /*****************************************************************************
  44.  
  45.     NAME */
  46. #include <proto/dos.h>
  47.  
  48.     AROS_LH1(STRPTR, PathPart,
  49.  
  50. /*  SYNOPSIS */
  51.     AROS_LHA(STRPTR, path, D1),
  52.  
  53. /*  LOCATION */
  54.     struct DosLibrary *, DOSBase, 146, Dos)
  55.  
  56. /*  FUNCTION
  57.     Returns a pointer to the character after the last
  58.     directory in path (see examples).
  59.  
  60.     INPUTS
  61.     path - Search this path.
  62.  
  63.     RESULT
  64.     A pointer to a character in path.
  65.  
  66.     NOTES
  67.  
  68.     EXAMPLE
  69.     PathPart("xxx:yyy/zzz/qqq") would return a pointer to the last '/'.
  70.     PathPart("xxx:yyy") would return a pointer to the first 'y').
  71.  
  72.     BUGS
  73.  
  74.     SEE ALSO
  75.  
  76.     INTERNALS
  77.  
  78.     HISTORY
  79.     29-10-95    digulla automatically created from
  80.                 dos_lib.fd and clib/dos_protos.h
  81.  
  82. *****************************************************************************/
  83. {
  84.     AROS_LIBFUNC_INIT
  85.     AROS_LIBBASE_EXT_DECL(struct DosLibrary *,DOSBase)
  86.     char * ptr;
  87.  
  88.     ptr = path;
  89.  
  90.     if (*ptr)
  91.     {
  92.     while (*ptr)
  93.     {
  94.         if (*ptr == '/')
  95.         path=ptr;
  96.         else if (*ptr == ':')
  97.         path=ptr+1;
  98.  
  99.         ptr ++;
  100.     }
  101.     }
  102.  
  103.     return path;
  104.     AROS_LIBFUNC_EXIT
  105. } /* PathPart */
  106.  
  107. #ifdef TEST
  108.  
  109. #include <stdio.h>
  110.  
  111. int main (int argc, char ** argv)
  112. {
  113.     UWORD i;
  114.     STRPTR s,fileptr;
  115.  
  116.     while (--argc)
  117.     {
  118.     s = *++argv;
  119.     fileptr = PathPart(s);
  120.  
  121.     printf("Pfad:  %s\nErg.: %s\n", s, fileptr);
  122.     }
  123. }
  124.  
  125. #endif /* TEST */
  126.  
  127.