Changeset dc135ad in rtems for cpukit/pppd


Ignore:
Timestamp:
Mar 24, 2003, 10:11:20 AM (17 years ago)
Author:
Ralf Corsepius <ralf.corsepius@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
6285bc8
Parents:
434b8ea1
Message:

Merger from rtems-4-6-branch.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/pppd/utils.c

    r434b8ea1 rdc135ad  
    6161    int len;
    6262};
    63 
    64 /*
    65  * strlcpy - like strcpy/strncpy, doesn't overflow destination buffer,
    66  * always leaves destination null-terminated (for len > 0).
    67  */
    68 size_t
    69 strlcpy(dest, src, len)
    70     char *dest;
    71     const char *src;
    72     size_t len;
    73 {
    74     size_t ret = strlen(src);
    75 
    76     if (len != 0) {
    77         if (ret < len)
    78             strcpy(dest, src);
    79         else {
    80             strncpy(dest, src, len - 1);
    81             dest[len-1] = 0;
    82         }
    83     }
    84     return ret;
    85 }
    86 
    87 /*
    88  * strlcat - like strcat/strncat, doesn't overflow destination buffer,
    89  * always leaves destination null-terminated (for len > 0).
    90  */
    91 size_t
    92 strlcat(dest, src, len)
    93     char *dest;
    94     const char *src;
    95     size_t len;
    96 {
    97     size_t dlen = strlen(dest);
    98 
    99     return dlen + strlcpy(dest + dlen, src, (len > dlen? len - dlen: 0));
    100 }
    101 
    10263
    10364/*
Note: See TracChangeset for help on using the changeset viewer.