+2003-01-11 Thomas Helvey <tom.helvey@cox.net>
+ * include/channel.h, include/ircd_alloc.h, ircd/channel.c,
+ ircd/client.c, ircd/gline.c, ircd/ircd_alloc.c,
+ ircd/ircd_events.c, ircd/ircd_log.c, ircd/ircd_parser.y,
+ ircd/ircd_snprintf.c, ircd/listener.c, ircd/m_nick.c,
+ ircd/m_opmode.c, ircd/m_whois.c, ircd/motd.c,
+ ircd/s_auth.c, ircd/s_bsd.c, ircd/uping.c: Server compiles
+ with g++ again, type safety, const correctness fixes,
+ remove C++ keywords again :/
2003-01-11 Thomas Helvey <tom.helvey@cox.net>
* ircd/client.c, ircd/ircd_feature.c: Bugfix, the feature
table data was in a different order than the feature data
extern int is_chan_op(struct Client *cptr, struct Channel *chptr);
extern int is_zombie(struct Client *cptr, struct Channel *chptr);
extern int has_voice(struct Client *cptr, struct Channel *chptr);
-extern int IsInvited(struct Client* cptr, struct Channel* chptr);
+/*
+ NOTE: pointer is compared, and not dereferenced, called by
+ add_target with a void*, since targets could be anything,
+ this function can't make any assumptions that it has a channel
+*/
+extern int IsInvited(struct Client* cptr, const void* chptr);
extern void send_channel_modes(struct Client *cptr, struct Channel *chptr);
extern char *pretty_mask(char *mask);
extern void del_invite(struct Client *cptr, struct Channel *chptr);
* go ahead and write it).
*/
-extern void *malloc_tmp;
/* First version: fast non-debugging macros... */
#ifndef MDEBUG
extern OutOfMemoryHandler noMemHandler;
#define DoFree(x, file, line) do { free((x)); (x) = 0; } while(0)
+extern void* DoMalloc(size_t len, const char*, const char*, int);
+extern void* DoMallocZero(size_t len, const char*, const char*, int);
+#if 0
+extern void *malloc_tmp;
+/*
+ Bleah, this is silly, the function call overhead for doing
+ the RightThing(tm) well worth the cost of avoiding this
+ non-reentrant mess of this macro, and accompanying global.
+*/
#define DoMalloc(size, type, file, line) \
(\
(malloc_tmp = malloc(size), \
- (malloc_tmp == NULL) ? noMemHandler() : 0), \
+ (malloc_tmp == NULL) ? (*noMemHandler)() : 0), \
malloc_tmp)
#define DoMallocZero(size, type, file, line) \
(DoMalloc(size, type, file, line), \
memset(malloc_tmp, 0, size)), \
malloc_tmp)
+#endif
/* Second version: slower debugging versions... */
#else /* defined(MDEBUG) */
* of course, str2 is not NULL)
*/
static void
-build_string(char *strptr, int *strptr_i, char *str1, char *str2, char c)
+build_string(char *strptr, int *strptr_i, const char *str1,
+ const char *str2, char c)
{
if (c)
strptr[(*strptr_i)++] = c;
}
/* Returns TRUE (1) if client is invited, FALSE (0) if not */
-int IsInvited(struct Client* cptr, struct Channel* chptr)
+int IsInvited(struct Client* cptr, const void* chptr)
{
struct SLink *lp;
}
}
+enum FeatureFlag {
+ FEATFLAG_NULL,
+ FEATFLAG_DISABLES_PRIV,
+ FEATFLAG_ENABLES_PRIV,
+ FEATFLAG_GLOBAL_OPERS,
+ FEATFLAG_LOCAL_OPERS,
+ FEATFLAG_ALL_OPERS
+};
+
static struct
{
enum Priv priv;
enum Feature feat;
- enum
- {
- FEATFLAG_DISABLES_PRIV,
- FEATFLAG_ENABLES_PRIV,
- FEATFLAG_GLOBAL_OPERS,
- FEATFLAG_LOCAL_OPERS,
- FEATFLAG_ALL_OPERS
- } flag;
+ enum FeatureFlag flag;
} feattab[] =
{
{ PRIV_WHOX, FEAT_LAST_F, FEATFLAG_ALL_OPERS },
{ PRIV_SEE_CHAN, FEAT_LOCOP_SEE_IN_SECRET_CHANNELS, FEATFLAG_LOCAL_OPERS },
{ PRIV_WIDE_GLINE, FEAT_LOCOP_WIDE_GLINE, FEATFLAG_LOCAL_OPERS },
- { PRIV_LAST_PRIV, FEAT_LAST_F, 0 }
+ { PRIV_LAST_PRIV, FEAT_LAST_F, FEATFLAG_NULL }
};
/* client_set_privs(struct Client* client)
if (IsLocOp(client))
PrivSet(&cli_privs(client), feattab[i].priv);
continue;
+ default:
+ continue; /* ?? */
}
}
DupString(gline->gl_host, host);
if (check_if_ipmask(host)) { /* mark if it's an IP mask */
- int class;
+ int c_class;
char ipname[16];
int ad[4] = { 0 };
int bits2 = 0;
- class = sscanf(host,"%d.%d.%d.%d/%d",
+ c_class = sscanf(host,"%d.%d.%d.%d/%d",
&ad[0],&ad[1],&ad[2],&ad[3], &bits2);
- if (class!=5) {
- gline->bits=class*8;
+ if (c_class!=5) {
+ gline->bits=c_class*8;
}
else {
gline->bits=bits2;
#include "s_debug.h"
#include <assert.h>
+#include <string.h>
static void nomem_handler(void);
{
noMemHandler = handler;
}
+
+void* DoMalloc(size_t size, const char* x, const char* y, int z)
+{
+ void* t = malloc(size);
+ if (!t)
+ (*noMemHandler)();
+ return t;
+}
+
+void* DoMallocZero(size_t size, const char* x, const char* y, int z)
+{
+ void* t = malloc(size);
+ if (!t)
+ (*noMemHandler)();
+ memset(t, 0, size);
+ return t;
+}
+
+
#define NM(name) { #name, name }
-#define NE { 0, 0 }
+#define NE { 0 }
const char*
state_to_name(enum SocketState state)
void
log_debug_init(int usetty)
{
- logInfo.dbfile = MyMalloc(sizeof(struct LogFile));
+ logInfo.dbfile = (struct LogFile*) MyMalloc(sizeof(struct LogFile));
logInfo.dbfile->next = 0; /* initialize debugging filename */
logInfo.dbfile->prev_p = 0;
vector[0].iov_base = timebuf;
vector[1].iov_base = buf;
- vector[2].iov_base = "\n"; /* terminate lines with a \n */
+ vector[2].iov_base = (void*) "\n"; /* terminate lines with a \n */
vector[2].iov_len = 1;
/* write it out to the log file */
tmp = logInfo.freelist;
logInfo.freelist = tmp->next;
} else /* allocate a new one */
- tmp = MyMalloc(sizeof(struct LogFile));
+ tmp = (struct LogFile*) MyMalloc(sizeof(struct LogFile));
tmp->fd = -1; /* initialize the structure */
tmp->ref = 1;
#include "support.h"
#include "sys.h"
#include <stdlib.h>
+#include <stdio.h>
#include <string.h>
#include <arpa/inet.h>
#define MAX_STRINGS 80 /* Maximum number of feature params. */
int stringno;
char *name, *pass, *host;
char *stringlist[MAX_STRINGS];
- struct ConnectionClass *class;
+ struct ConnectionClass *c_class;
struct ConfItem *aconf;
struct DenyConf *dconf;
struct ServerConf *sconf;
connectblock: CONNECT
{
name = pass = host = NULL;
- class = NULL;
+ c_class = NULL;
port = 0;
} '{' connectitems '}'
{
- if (name != NULL && pass != NULL && host != NULL && class != NULL &&
+ if (name != NULL && pass != NULL && host != NULL && c_class != NULL &&
/*ccount < MAXCONFLINKS &&*/ !strchr(host, '*') &&
!strchr(host, '?'))
{
aconf->status = CONF_SERVER;
aconf->name = name;
aconf->passwd = pass;
- aconf->conn_class = class;
+ aconf->conn_class = c_class;
aconf->port = port;
aconf->status = CONF_SERVER;
aconf->host = host;
};
connectclass: CLASS '=' QSTRING ';'
{
- class = find_class(yylval.text);
+ c_class = find_class(yylval.text);
};
connecthost: HOST '=' QSTRING ';'
{
serverblock: SERVER
{
- aconf = MyMalloc(sizeof(*aconf));
+ aconf = (struct ConfItem*) MyMalloc(sizeof(*aconf));
memset(aconf, 0, sizeof(*aconf));
} '{' serveritems '}'
{
operblock: OPER
{
- aconf = MyMalloc(sizeof(*aconf));
+ aconf = (struct ConfItem*) MyMalloc(sizeof(*aconf));
memset(aconf, 0, sizeof(*aconf));
aconf->status = CONF_OPERATOR;
} '{' operitems '}' ';'
if (!strchr(yylval.text, '@'))
{
int uh_len;
- char *b = MyMalloc((uh_len = strlen(yylval.text)+3));
+ char *b = (char*) MyMalloc((uh_len = strlen(yylval.text)+3));
ircd_snprintf(0, b, uh_len, "*@%s", yylval.text);
aconf->host = b;
}
clientblock: CLIENT
{
- aconf = MyMalloc(sizeof(*aconf));
+ aconf = (struct ConfItem*) MyMalloc(sizeof(*aconf));
memset(aconf, 0, sizeof(*aconf));
aconf->status = CONF_CLIENT;
} '{' clientitems '}'
killblock: KILL
{
- dconf = MyMalloc(sizeof(*dconf));
+ dconf = (struct DenyConf*) MyMalloc(sizeof(*dconf));
memset(dconf, 0, sizeof(*dconf));
} '{' killitems '}'
{
struct CRuleNode *node;
if (host != NULL && pass != NULL && (node=crule_parse(pass)) != NULL)
{
- struct CRuleConf *p = MyMalloc(sizeof(*p));
+ struct CRuleConf *p = (struct CRuleConf*) MyMalloc(sizeof(*p));
p->hostmask = host;
p->rule = pass;
p->type = tconn;
quarantineblock: QUARANTINE '{'
{
if (qconf != NULL)
- qconf = MyMalloc(sizeof(*qconf));
+ qconf = (struct qline*) MyMalloc(sizeof(*qconf));
else
{
if (qconf->chname != NULL)
{
log_write(LS_CONFIG, L_ERROR, 0, "quarantine blocks need a channel name "
"and a reason.");
- return;
+ return 0;
}
qconf->next = GlobalQuarantineList;
GlobalQuarantineList = qconf;
vdata->vd_overflow = SNP_MAX(buf_s.buf_overflow, buf_s.overflow);
} else if ((fld_s.flags & CONV_MASK) == CONV_CLIENT) {
struct Client *cptr = (struct Client*) fld_s.value.v_ptr;
- char *str1 = 0, *str2 = 0, *str3 = 0;
+ const char *str1 = 0, *str2 = 0, *str3 = 0;
int slen1 = 0, slen2 = 0, slen3 = 0, elen = 0, plen = 0;
/* &me is used if it's not a definite server */
assert(0 != ev_socket(ev));
assert(0 != s_data(ev_socket(ev)));
- listener = s_data(ev_socket(ev));
+ listener = (struct Listener*) s_data(ev_socket(ev));
if (ev_type(ev) == ET_DESTROY) /* being destroyed */
free_listener(listener);
char nick[NICKLEN + 2];
time_t lastnick = 0;
int differ = 1;
- char *type;
+ const char *type;
assert(0 != cptr);
assert(0 != sptr);
#include "numeric.h"
#include "numnicks.h"
#include "send.h"
+#include "s_conf.h"
#include <assert.h>
{
struct Channel *chptr = 0;
struct ModeBuf mbuf;
- char *chname, *qreason;
+ char *chname;
+ const char *qreason;
int force = 0;
struct Membership *member;
{
struct Client *acptr; /* Current client we're concidering */
struct User *user; /* the user portion of the client */
- char *name; /* the name of this client */
+ const char *name; /* the name of this client */
struct Membership* chan;
int invis; /* does +i apply? */
int member; /* Is this user on any channels? */
motd_lookup(struct Client *cptr)
{
struct Motd *ptr;
- char *class = NULL;
+ char *c_class = NULL;
assert(0 != cptr);
if (!MyUser(cptr)) /* not my user, always return remote motd */
return MotdList.remote;
- class = get_client_class(cptr);
+ c_class = get_client_class(cptr);
/* check the motd blocks first */
for (ptr = MotdList.other; ptr; ptr = ptr->next)
{
if (ptr->type == MOTD_CLASS &&
- !match(ptr->hostmask, class))
+ !match(ptr->hostmask, c_class))
return ptr;
- else if (ptr->type == MOTD_HOSTMASK && class != NULL &&
+ else if (ptr->type == MOTD_HOSTMASK && c_class != NULL &&
!match(ptr->hostmask, cli_sockhost(cptr)))
return ptr;
}
assert(0 != ev_timer(ev));
assert(0 != t_data(ev_timer(ev)));
- auth = t_data(ev_timer(ev));
+ auth = (struct AuthRequest*) t_data(ev_timer(ev));
if (ev_type(ev) == ET_DESTROY) { /* being destroyed */
auth->flags &= ~AM_TIMEOUT;
assert(0 != ev_socket(ev));
assert(0 != s_data(ev_socket(ev)));
- auth = s_data(ev_socket(ev));
+ auth = (struct AuthRequest*) s_data(ev_socket(ev));
switch (ev_type(ev)) {
case ET_DESTROY: /* being destroyed */
assert(0 != ev_socket(ev));
assert(0 != s_data(ev_socket(ev)));
- con = s_data(ev_socket(ev));
+ con = (struct Connection*) s_data(ev_socket(ev));
assert(0 != con_client(con) || ev_type(ev) == ET_DESTROY);
assert(0 != t_data(ev_timer(ev)));
assert(ET_DESTROY == ev_type(ev) || ET_EXPIRE == ev_type(ev));
- con = t_data(ev_timer(ev));
+ con = (struct Connection*) t_data(ev_timer(ev));
assert(0 != con_client(con) || ev_type(ev) == ET_DESTROY);
assert(0 != ev_socket(ev));
assert(0 != s_data(ev_socket(ev)));
- pptr = s_data(ev_socket(ev));
+ pptr = (struct UPing*) s_data(ev_socket(ev));
Debug((DEBUG_SEND, "uping_read_callback called, %p (%d)", pptr,
ev_type(ev)));
assert(0 != ev_timer(ev));
assert(0 != t_data(ev_timer(ev)));
- pptr = t_data(ev_timer(ev));
+ pptr = (struct UPing*) t_data(ev_timer(ev));
Debug((DEBUG_SEND, "uping_sender_callback called, %p (%d)", pptr,
ev_type(ev)));
assert(0 != ev_timer(ev));
assert(0 != t_data(ev_timer(ev)));
- pptr = t_data(ev_timer(ev));
+ pptr = (struct UPing*) t_data(ev_timer(ev));
Debug((DEBUG_SEND, "uping_killer_callback called, %p (%d)", pptr,
ev_type(ev)));