home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / syslog.zip / fix_env.c < prev    next >
Text File  |  1994-06-04  |  528b  |  28 lines

  1. #include <string.h>
  2. #include <malloc.h>
  3. #include <stdlib.h>
  4.  
  5. char *fix_env(char *s1, char *s2)
  6. {
  7.   char *etc, *help1, *help2, *help3;
  8.  
  9.   help1=malloc(strlen(s1)+1);
  10.   strcpy(help1,s1);
  11.   help2=help1;
  12.   while (*help2)
  13.   {
  14.     if((*help2=='/')||(*help2=='\\'))
  15.       help3=++help2;
  16.     else help2++;
  17.   }
  18.   if ((etc = getenv(s2)) != NULL)
  19.   {
  20.     strcpy(s1,etc);
  21.     if ((s1[strlen(s1)-1]!='/') &&(s1[strlen(s1)-1]!='\\'))
  22.       strcat(s1,"\\");
  23.     strcat(s1,help3);
  24.   }
  25.   free(help1);
  26.   return(s1);
  27. }
  28.