[srvx-commits] CVS: services/src mini-tools.c,NONE,1.1 Makefile.am,1.49,1.50 checkdb.c,1.5,1.6 expnh
Brought to you by:
entrope
|
From: Entrope <en...@us...> - 2002-07-08 15:44:03
|
Update of /cvsroot/srvx/services/src
In directory usw-pr-cvs1:/tmp/cvs-serv25350/src
Modified Files:
Makefile.am checkdb.c expnhelp.c main.c
Added Files:
mini-tools.c
Log Message:
hoist tools_init() before ever reading config file
add new mini-tools.c so checkdb, expnhelp can link more easily
start replacing strcase* with irccase*
--- NEW FILE ---
static unsigned char irc_tolower[256];
int
irccasecmp(const unsigned char *stra, const unsigned char *strb) {
while (*stra && (irc_tolower[*stra] == irc_tolower[*strb])) stra++, strb++;
return irc_tolower[*stra] - irc_tolower[*strb];
}
int
ircncasecmp(const unsigned char *stra, const unsigned char *strb, unsigned int len) {
while (*stra && (irc_tolower[*stra] == irc_tolower[*strb]) && len) stra++, strb++, len--;
return irc_tolower[*stra] - irc_tolower[*strb];
}
const unsigned char *
irccasestr(const unsigned char *haystack, const unsigned char *needle) {
unsigned int hay_len = strlen(haystack), needle_len = strlen(needle), pos;
if (hay_len < needle_len) return 0;
for (pos=0; pos<hay_len+1-needle_len; ++pos) {
if ((irc_tolower[haystack[pos]] == irc_tolower[*needle])
&& !ircncasecmp(haystack+pos, needle, needle_len)) return haystack+pos;
}
return 0;
}
void
tools_init(void)
{
unsigned int upr, lwr;
for (lwr=0; lwr<256; ++lwr) irc_tolower[lwr] = lwr;
for (upr='A', lwr='a'; lwr <= 'z'; ++upr, ++lwr) irc_tolower[upr] = lwr;
#ifdef WITH_PROTOCOL_P10
for (upr='[', lwr='{'; lwr <= '~'; ++upr, ++lwr) irc_tolower[upr] = lwr;
for (upr=0xc0, lwr=0xe0; lwr <= 0xf6; ++upr, ++lwr) irc_tolower[upr] = lwr;
for (upr=0xd8, lwr=0xf8; lwr <= 0xfe; ++upr, ++lwr) irc_tolower[upr] = lwr;
#endif
}
Index: Makefile.am
===================================================================
RCS file: /cvsroot/srvx/services/src/Makefile.am,v
retrieving revision 1.49
retrieving revision 1.50
diff -C2 -r1.49 -r1.50
*** Makefile.am 26 Jun 2002 11:45:28 -0000 1.49
--- Makefile.am 8 Jul 2002 15:43:57 -0000 1.50
***************
*** 40,46 ****
tools.c
! expnhelp_SOURCES = expnhelp.c compat.c compat.h common.h dict-splay.c dict.h recdb.c recdb.h log.c log.h
! checkdb_SOURCES = checkdb.c recdb.c recdb.h dict-splay.c dict.h log.h
! globtest_SOURCES = tools.c globtest.c common.h dict-splay.c
globtest_CFLAGS = -DGLOBTEST
--- 40,46 ----
tools.c
! expnhelp_SOURCES = expnhelp.c compat.c compat.h common.h dict-splay.c dict.h recdb.c recdb.h log.c log.h mini-tools.c
! checkdb_SOURCES = checkdb.c recdb.c recdb.h dict-splay.c dict.h log.h mini-tools.c
! globtest_SOURCES = tools.c globtest.c common.h dict-splay.c mini-tools.c
globtest_CFLAGS = -DGLOBTEST
Index: checkdb.c
===================================================================
RCS file: /cvsroot/srvx/services/src/checkdb.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** checkdb.c 8 Jul 2002 01:36:09 -0000 1.5
--- checkdb.c 8 Jul 2002 15:43:59 -0000 1.6
***************
*** 48,51 ****
--- 48,52 ----
}
+ tools_init();
if (!strcmp(argv[1], "-")) {
infile = "/dev/stdin";
Index: expnhelp.c
===================================================================
RCS file: /cvsroot/srvx/services/src/expnhelp.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** expnhelp.c 6 May 2002 23:33:12 -0000 1.2
--- expnhelp.c 8 Jul 2002 15:43:59 -0000 1.3
***************
*** 46,52 ****
switch (rd->type) {
case RECDB_QSTRING:
! if ((strcasestr(key, "enable")
! || (strcasestr(key, "disable"))
! || (strcasestr(key, "require")))
&& enabled_string(rd->d.qstring)) {
char *new_arg;
--- 46,52 ----
switch (rd->type) {
case RECDB_QSTRING:
! if ((irccasestr(key, "enable")
! || (irccasestr(key, "disable"))
! || (irccasestr(key, "require")))
&& enabled_string(rd->d.qstring)) {
char *new_arg;
***************
*** 74,77 ****
--- 74,78 ----
dict_t cfg_db;
+ tools_init();
init_logs();
time(&now);
Index: main.c
===================================================================
RCS file: /cvsroot/srvx/services/src/main.c,v
retrieving revision 1.127
retrieving revision 1.128
diff -C2 -r1.127 -r1.128
*** main.c 8 Jul 2002 15:21:17 -0000 1.127
--- main.c 8 Jul 2002 15:43:59 -0000 1.128
***************
*** 169,173 ****
XXX: May want to include the bind_address in the equivalence test. */
! if(cManager.uplink && enabled && !strcasecmp(uplink->host, cManager.uplink->host) && uplink->port == cManager.uplink->port)
{
uplink->state = cManager.uplink->state;
--- 169,176 ----
XXX: May want to include the bind_address in the equivalence test. */
! if(cManager.uplink
! && enabled
! && !irccasecmp(uplink->host, cManager.uplink->host)
! && uplink->port == cManager.uplink->port)
{
uplink->state = cManager.uplink->state;
***************
*** 307,311 ****
}
! if(name && strcasecmp(uplink->name, name))
{
/* If we were told to connect to a specific uplink, don't stop
--- 310,314 ----
}
! if(name && irccasecmp(uplink->name, name))
{
/* If we were told to connect to a specific uplink, don't stop
***************
*** 666,669 ****
--- 669,673 ----
daemon = 1;
silent = 1;
+ tools_init();
/* set up some signal handlers */
***************
*** 808,812 ****
tmp = conf_server_ping_timeout();
if (tmp != -1) ping_timeout = tmp;
- tools_init();
timeq_init();
sendmail_init();
--- 812,815 ----
|