summaryrefslogtreecommitdiff
path: root/package/openafs/src/src/comerr/internal.c
blob: 8e0193d44f93f13a357f2015de35b96d684c23cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* Just like strncpy but shift-case in transit and forces null termination */
char *
lcstring(char *d, char *s, int n)
{
    char *original_d = d;
    char c;

    if ((s == 0) || (d == 0))
        return 0;               /* just to be safe */
    while (n) {
        c = *s++;
        if (isupper(c))
            c = tolower(c);
        *d++ = c;
        if (c == 0)
            break;              /* quit after transferring null */
        if (--n == 0)
            *(d - 1) = 0;       /* make sure null terminated */
    }
    return original_d;
}