2 ****************************************************************************
3 * Copyright IBM Corporation 1988, 1989 - All Rights Reserved *
5 * Permission to use, copy, modify, and distribute this software and its *
6 * documentation for any purpose and without fee is hereby granted, *
7 * provided that the above copyright notice appear in all copies and *
8 * that both that copyright notice and this permission notice appear in *
9 * supporting documentation, and that the name of IBM not be used in *
10 * advertising or publicity pertaining to distribution of the software *
11 * without specific, written prior permission. *
13 * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL *
14 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL IBM *
15 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY *
16 * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER *
17 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING *
18 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *
19 ****************************************************************************
22 #include <afs/param.h>
27 /* Just like strncpy but shift-case in transit and forces null termination */
28 char *lcstring (char *d, char *s, int n)
29 { char *original_d = d;
32 if ((s == 0) || (d == 0)) return 0; /* just to be safe */
35 if (isupper(c)) c = tolower(c);
37 if (c == 0) break; /* quit after transferring null */
38 if (--n == 0) *(d-1) = 0; /* make sure null terminated */
43 char *ucstring (char *d, char *s, int n)
44 { char *original_d = d;
47 if ((s == 0) || (d == 0)) return 0;
50 if (islower(c)) c = toupper(c);
53 if (--n == 0) *(d-1) = 0; /* make sure null terminated */
58 /* strcompose - concatenate strings passed to it.
60 * buf: storage for the composed string. Any data in it will be lost.
61 * len: length of the buffer.
62 * ...: variable number of string arguments. The last argument must be
64 * Returns buf or NULL if the buffer was not sufficiently large.
66 char *strcompose(char *buf, size_t len, ...)
69 size_t spaceleft = len - 1;
73 if (buf == NULL || len <= 0)
78 str = va_arg(ap, char *);
81 if (spaceleft < slen) /* not enough space left */
87 str = va_arg(ap, char *);