home *** CD-ROM | disk | FTP | other *** search
/ AMIGA PD 1 / AMIGA-PD-1.iso / Aminet / Aminet / util / cli / CLI_Tools.lha / Suffix.c < prev    next >
C/C++ Source or Header  |  1995-02-03  |  2KB  |  106 lines

  1.  
  2. /******************************************************************************
  3.  
  4.     MODULE
  5.     Suffix.c
  6.  
  7.     DESCRIPTION
  8.     Get one string on Commandline
  9.     and write its Suffix to StdOut
  10.  
  11.     NOTES
  12.     Kickstart 2.0+ required
  13.     compiles w/ Dice 2.07R - inline-pragmas required
  14.     compiles w/ SAS/C v6.51
  15.  
  16.     BUGS
  17.     none known
  18.  
  19.     TODO
  20.  
  21.     EXAMPLES
  22.     > suffix ram:t/jabba.bak
  23.     bak
  24.  
  25.     SEE ALSO
  26.     FilePart, PathPart
  27.  
  28.     INDEX
  29.  
  30.     HISTORY
  31.     01-08-93 b_noll created
  32.  
  33.     AUTHOR
  34.     Bernd Noll, Brunnenstrasse 55, D-67661 Kaiserslautern
  35.     b_noll@informatik.uni-kl.de
  36.  
  37. ******************************************************************************/
  38.  
  39. /**************************************
  40.         Includes
  41. **************************************/
  42.  
  43. #ifndef   EXEC_LIBRARIES_H
  44. # include <exec/libraries.h>
  45. #endif /* EXEC_LIBRARIES_H */
  46.  
  47. #ifndef   CLIB_EXEC_PROTOS_H
  48. # include <clib/exec_protos.h>
  49. #endif /* CLIB_EXEC_PROTOS_H */
  50.  
  51. #ifndef   DOS_DOS_H
  52. # include <dos/dos.h>
  53. #endif /* DOS_DOS_H */
  54.  
  55. #ifndef   CLIB_DOS_PROTOS_H
  56. # include <clib/dos_protos.h>
  57. #endif /* CLIB_DOS_PROTOS_H */
  58.  
  59. #include <proto/dos.h>
  60. #include <proto/exec.h>
  61.  
  62. /**************************************
  63.         Global Variables
  64. **************************************/
  65.  
  66.  
  67. /**************************************
  68.         Implementation
  69. **************************************/
  70.  
  71. long _main (void)
  72. {
  73.     const char* version = "$VER: Suffix 1.0 (23.8.93)";
  74.     long retval = 20;
  75.     struct Library* SysBase = *((struct Library**)4L);
  76.     struct Library* DOSBase;
  77.  
  78.     if (DOSBase = OpenLibrary (DOSNAME, 37)) {
  79.     STRPTR argv[2] = { NULL, NULL };
  80.     APTR   args;
  81.     retval     = 10;
  82.     if (args = (void*)ReadArgs("FILE/A", (LONG*)argv, NULL)) {
  83.         STRPTR p;
  84.         p = argv[0];
  85.         retval = 5;
  86.         if (p && *p) {
  87.         while (*p) ++p;
  88.         --p;
  89.         while ((p != argv[0]) && (*p != '.') && (*p != ':') && (*p != '/')) --p;
  90.         if (*p == '.') {
  91.             if (PutStr (p+1) == 0) retval = 0;
  92.         } /* if */
  93.         } /* if */
  94.         PutStr("\n");
  95.         FreeArgs (args);
  96.     } /* if */
  97.     CloseLibrary (DOSBase);
  98.     } /* if */
  99.     return (retval);
  100. } /* _main */
  101.  
  102. /******************************************************************************
  103. *****  END Suffix.c
  104. ******************************************************************************/
  105.  
  106.