home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / asm / fdtools11.lha / addext.c next >
Encoding:
C/C++ Source or Header  |  1994-03-08  |  465 b   |  28 lines

  1. /* addext.c - add filename extension function */
  2.  
  3. #include <exec/types.h>
  4.  
  5. void addext(STRPTR buff,LONG len,STRPTR orig,STRPTR xt)
  6.  
  7. {
  8.   STRPTR s;
  9.   BOOL hasext = FALSE;
  10.  
  11.   for(s = buff;*orig && s-buff < len;*(s++) = *(orig++));
  12.   *s = '\0';
  13.  
  14.   orig = s;
  15.  
  16.   for(--s;s != buff && *s != '/' && *s != ':';s--) {
  17.     if(*s == '.') {
  18.       hasext = TRUE;
  19.       break;
  20.     }
  21.   }
  22.  
  23.   if(!hasext) {
  24.     for(s = orig;*xt && s-buff <len;*(s++) = *(xt++));
  25.     *s = '\0';
  26.   }
  27. }
  28.