1 /* -------------------------------------------------------------------- */
2 /* strfcat.c */
3 /* */
4 /* Copyright (C) 1997,1998 Angelo Masci */
5 /* */
6 /* This library is free software; you can redistribute it and/or */
7 /* modify it under the terms of the GNU Library General Public */
8 /* License as published by the Free Software Foundation; either */
9 /* version 2 of the License, or (at your option) any later version. */
10 /* */
11 /* This library is distributed in the hope that it will be useful, */
12 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
13 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
14 /* Library General Public License for more details. */
15 /* */
16 /* You should have received a copy of the GNU Library General Public */
17 /* License along with this library; if not, write to the Free */
18 /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19 /* */
20 /* You can contact the author at this e-mail address: */
21 /* */
22 /* angelo@styx.demon.co.uk */
23 /* */
24 /* -------------------------------------------------------------------- */
25 /* $Id$
26 -------------------------------------------------------------------- */
27
28 #include <stdio.h>
29
30 #include "common.h"
31
32 /* -------------------------------------------------------------------- */
33 /* Add a file/directory name to a pathname. If the path */
34 /* does not end with '/' append one before adding the other */
35 /* file/dir. */
36 /* -------------------------------------------------------------------- */
libcommon_strfcat(char * path,char * src)37 char *libcommon_strfcat(char *path, char *src)
38 {
39 char *dst,
40 *lptr;
41
42
43 lptr = NULL;
44 dst = path;
45 while (*dst != '\0')
46 {
47 lptr = dst;
48 dst++;
49 }
50
51 if ((lptr != NULL) && (*lptr == '/'))
52 {
53 dst = lptr;
54 }
55
56 *dst++ = '/';
57
58
59 if (*src == '/')
60 { src++;
61 }
62
63 while (*src != '\0')
64 {
65 *dst = *src;
66
67 dst++;
68 src++;
69 }
70
71 *dst = '\0';
72
73 return path;
74 }
75