2
* Copyright (c) 2004, Nate Nielsen
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
9
* * Redistributions of source code must retain the above
10
* copyright notice, this list of conditions and the
11
* following disclaimer.
12
* * Redistributions in binary form must reproduce the
13
* above copyright notice, this list of conditions and
14
* the following disclaimer in the documentation and/or
15
* other materials provided with the distribution.
16
* * The names of contributors to this software may not be
17
* used to endorse or promote products derived from this
18
* software without specific prior written permission.
20
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
30
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
35
* Nate Nielsen <nielsen@memberwebs.com>
38
* PORTIONS FROM OPENBSD: -------------------------------------------------
40
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
41
* All rights reserved.
43
* Redistribution and use in source and binary forms, with or without
44
* modification, are permitted provided that the following conditions
46
* 1. Redistributions of source code must retain the above copyright
47
* notice, this list of conditions and the following disclaimer.
48
* 2. Redistributions in binary form must reproduce the above copyright
49
* notice, this list of conditions and the following disclaimer in the
50
* documentation and/or other materials provided with the distribution.
51
* 3. The name of the author may not be used to endorse or promote products
52
* derived from this software without specific prior written permission.
54
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
55
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
56
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
57
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
58
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
59
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
60
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
61
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
62
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
63
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
76
void* reallocf(void* ptr, size_t size)
78
void* ret = realloc(ptr, size);
102
char* strupr(char* s)
116
size_t strlcpy(char* dst, const char* src, size_t siz)
122
/* Copy as many bytes as will fit */
123
if(n != 0 && --n != 0)
127
if((*d++ = *s++) == 0)
133
/* Not enough room in dst, add NUL and traverse rest of src */
137
*d = '\0'; /* NUL-terminate dst */
142
return s - src - 1; /* count does not include NUL */
149
size_t strlcat(char* dst, const char* src, size_t siz)
156
/* Find the end of dst and adjust bytes left but don't go past end */
157
while(n-- != 0 && *d != '\0')
163
return dlen + strlen(s);
177
return dlen + (s - src); /* count does not include NUL */