| 19 |
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
| 20 |
|
* USA |
| 21 |
|
* |
| 22 |
< |
* $Id: irc_string.c,v 7.74 2005/09/03 11:39:21 michael Exp $ |
| 22 |
> |
* $Id$ |
| 23 |
|
*/ |
| 24 |
|
|
| 25 |
+ |
#include "config.h" |
| 26 |
+ |
#ifdef HAVE_LIBPCRE |
| 27 |
+ |
#include <pcre.h> |
| 28 |
+ |
#endif |
| 29 |
+ |
|
| 30 |
|
#include "stdinc.h" |
| 31 |
|
#include "tools.h" |
| 27 |
– |
#include "pcre.h" |
| 32 |
|
#include "irc_string.h" |
| 33 |
|
#include "sprintf_irc.h" |
| 34 |
|
#include "client.h" |
| 48 |
|
#endif |
| 49 |
|
|
| 50 |
|
|
| 47 |
– |
char * |
| 48 |
– |
xstrldup(const char *s, size_t n) |
| 49 |
– |
{ |
| 50 |
– |
size_t len = strlen(s) + 1; |
| 51 |
– |
char *p = NULL; |
| 52 |
– |
|
| 53 |
– |
if (len > n) |
| 54 |
– |
len = n; |
| 55 |
– |
return strlcpy((p = malloc(len)), s, len), p; |
| 56 |
– |
} |
| 57 |
– |
|
| 51 |
|
/* |
| 52 |
|
* myctime - This is like standard ctime()-function, but it zaps away |
| 53 |
|
* the newline from the end of that string. Also, it takes |
| 242 |
|
return buf; |
| 243 |
|
} |
| 244 |
|
|
| 245 |
< |
#ifndef HAVE_BASENAME |
| 253 |
< |
|
| 254 |
< |
/* basename() |
| 245 |
> |
/* libio_basename() |
| 246 |
|
* |
| 247 |
|
* input - i.e. "/usr/local/ircd/modules/m_whois.so" |
| 248 |
|
* output - i.e. "m_whois.so" |
| 249 |
|
* side effects - this will be overwritten on subsequent calls |
| 250 |
|
*/ |
| 251 |
< |
char * |
| 252 |
< |
basename(char *path) |
| 251 |
> |
const char * |
| 252 |
> |
libio_basename(const char *path) |
| 253 |
|
{ |
| 254 |
< |
char *s; |
| 254 |
> |
const char *s; |
| 255 |
|
|
| 256 |
|
if ((s = strrchr(path, '/')) == NULL) |
| 257 |
|
s = path; |
| 261 |
|
return s; |
| 262 |
|
} |
| 263 |
|
|
| 273 |
– |
#endif /* !HAVE_BASENAME */ |
| 274 |
– |
|
| 264 |
|
/* |
| 265 |
|
* Copyright (c) 1996-1999 by Internet Software Consortium. |
| 266 |
|
* |
| 328 |
|
* to use pointer overlays. All the world's not a VAX. |
| 329 |
|
*/ |
| 330 |
|
char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp; |
| 331 |
< |
struct { int base, len; } best, cur; |
| 331 |
> |
struct { int base, len; } best = {0,0}, cur = {0,0}; |
| 332 |
|
unsigned int words[IN6ADDRSZ / INT16SZ]; |
| 333 |
|
int i; |
| 334 |
|
|
| 531 |
|
} |
| 532 |
|
#endif |
| 533 |
|
|
| 534 |
< |
pcre * |
| 534 |
> |
#ifdef HAVE_LIBPCRE |
| 535 |
> |
void * |
| 536 |
|
ircd_pcre_compile(const char *pattern, const char **errptr) |
| 537 |
|
{ |
| 538 |
|
int erroroffset = 0; |
| 544 |
|
} |
| 545 |
|
|
| 546 |
|
int |
| 547 |
< |
ircd_pcre_exec(const pcre *code, const char *subject) |
| 547 |
> |
ircd_pcre_exec(const void *code, const char *subject) |
| 548 |
|
{ |
| 549 |
|
assert(code && subject); |
| 550 |
|
|
| 551 |
|
return pcre_exec(code, NULL, subject, strlen(subject), 0, 0, NULL, 0) < 0; |
| 552 |
|
} |
| 553 |
+ |
#endif |