string.c revision 935000aa6e2b9d08f363b2e698a258a458a5a7cf
/*
* Copyright (C) 1999-2001 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: string.c,v 1.7 2003/04/10 04:46:27 marka Exp $ */
#include <config.h>
#include <ctype.h>
static char digits[] = "0123456789abcdefghijklmnoprstuvwxyz";
char *s = source;
char *o;
char c;
return (0);
}
s++;
if (*s == '+' /* || *s == '-' */)
s++;
if (base == 0) {
if (*s == '0' && (*(s+1) == 'X' || *(s+1) == 'x')) {
s += 2;
base = 16;
} else if (*s == '0')
base = 8;
else
base = 10;
}
if (*s == 0) {
return (0);
}
overflow = ~0;
tmp = 0;
while ((c = *s) != 0) {
c = tolower(c);
/* end ? */
*end = s;
return (tmp);
}
/* end ? */
*end = s;
return (tmp);
}
/* overflow ? */
return (0);
}
/* overflow ? */
return (0);
}
s++;
}
*end = s;
return (tmp);
}
char *
char *s;
const char *d;
return (NULL);
*s++ = '\0';
*stringp = s;
return (string);
}
return (string);
}
{
char *d = dst;
const char *s = src;
/* Copy as many bytes as will fit */
if (n != 0 && --n != 0) {
do {
if ((*d++ = *s++) == 0)
break;
} while (--n != 0);
}
/* Not enough room in dst, add NUL and traverse rest of src */
if (n == 0) {
if (size != 0)
*d = '\0'; /* NUL-terminate dst */
while (*s++)
;
}
}
{
char *d = dst;
const char *s = src;
/* Find the end of dst and adjust bytes left but don't go past end */
while (n-- != 0 && *d != '\0')
d++;
if (n == 0)
while (*s != '\0') {
if (n != 1) {
*d++ = *s;
n--;
}
s++;
}
*d = '\0';
}