home *** CD-ROM | disk | FTP | other *** search
/ Unix System Administration Handbook 1997 October / usah_oct97.iso / news / cnews.tar / libcnews / str3save.c < prev    next >
C/C++ Source or Header  |  1993-11-20  |  607b  |  33 lines

  1. #include <stdio.h>
  2. #include <sys/types.h>
  3. #include <string.h>
  4. #include "libc.h"
  5. #include "news.h"
  6.  
  7. /*
  8.  - str3save - malloc space for 3 strings, concatenated, and concatenate them
  9.  * This may seem kind of ad-hoc, but it's just right for filename work.
  10.  */
  11. char *
  12. str3save(s1, s2, s3)
  13. char *s1;
  14. char *s2;
  15. char *s3;
  16. {
  17.     register char *p;
  18.     static char *empty = "";
  19.  
  20.     if (s1 == NULL)
  21.         s1 = empty;
  22.     if (s2 == NULL)
  23.         s2 = empty;
  24.     if (s3 == NULL)
  25.         s3 = empty;
  26.  
  27.     p = nemalloc((unsigned)(strlen(s1) + strlen(s2) + strlen(s3) + 1));
  28.     (void) strcpy(p, s1);
  29.     (void) strcat(p, s2);
  30.     (void) strcat(p, s3);
  31.     return(p);
  32. }
  33.