~rcr/rirc

1b6f573a0563be9d53fcae3d968051e26e479f84 — Richard Robbins 23 days ago 3d6c289
add irc_strdup
M src/components/channel.c => src/components/channel.c +1 -1
@@ 54,7 54,7 @@ void
channel_key_add(struct channel *c, const char *key)
{
	free((void *)c->key);
	c->key = strdup(key);
	c->key = irc_strdup(key);
}

void

M src/components/mode.c => src/components/mode.c +1 -1
@@ 338,7 338,7 @@ mode_cfg_prefix(struct mode_cfg *cfg, const char *str)

	char *cfg_f = cfg->PREFIX.F;
	char *cfg_t = cfg->PREFIX.T;
	char *dup = strdup(str);
	char *dup = irc_strdup(str);
	char *str_f;
	char *str_t;


M src/components/server.c => src/components/server.c +11 -11
@@ 41,13 41,13 @@ server(
	if ((s = calloc(1, sizeof(*s))) == NULL)
		fatal("calloc: %s", strerror(errno));

	s->host     = strdup(host);
	s->port     = strdup(port);
	s->username = strdup(username);
	s->realname = strdup(realname);
	s->host     = irc_strdup(host);
	s->port     = irc_strdup(port);
	s->username = irc_strdup(username);
	s->realname = irc_strdup(realname);

	s->pass = (pass ? strdup(pass) : NULL);
	s->mode = (mode ? strdup(mode) : NULL);
	s->pass = (pass ? irc_strdup(pass) : NULL);
	s->mode = (mode ? irc_strdup(mode) : NULL);

	s->casemapping = CASEMAPPING_RFC1459;
	ircv3_caps(&(s->ircv3_caps));


@@ 175,7 175,7 @@ server_set_chans(struct server *s, const char *str)
	char *p2;
	size_t n_chans = 0;

	p2 = dup = strdup(str);
	p2 = dup = irc_strdup(str);

	do {
		n_chans++;


@@ 223,7 223,7 @@ server_set_nicks(struct server *s, const char *str)
	char *p2;
	size_t n_nicks = 0;

	p2 = dup = strdup(str);
	p2 = dup = irc_strdup(str);

	do {
		n_nicks++;


@@ 338,8 338,8 @@ server_set_sasl(struct server *s, const char *mech, const char *user, const char

	if (!strcasecmp(mech, "PLAIN")) {
		s->ircv3_sasl.mech = IRCV3_SASL_MECH_PLAIN;
		s->ircv3_sasl.user = (user ? strdup(user) : NULL);
		s->ircv3_sasl.pass = (pass ? strdup(pass) : NULL);
		s->ircv3_sasl.user = (user ? irc_strdup(user) : NULL);
		s->ircv3_sasl.pass = (pass ? irc_strdup(pass) : NULL);
	}
}



@@ 468,7 468,7 @@ server_nick_set(struct server *s, const char *nick)
	if (s->nick)
		free((void *)s->nick);

	s->nick = strdup(nick);
	s->nick = irc_strdup(nick);
}

void

M src/handlers/irc_send.c => src/handlers/irc_send.c +1 -1
@@ 151,7 151,7 @@ irc_send_privmsg(struct server *s, struct channel *c, char *m)
	if (!m || !*m)
		failf(c, "Usage: /privmsg <target> <message>");

	p2 = dup = strdup(target);
	p2 = dup = irc_strdup(target);

	do {
		struct channel *c_target;

M src/handlers/ircv3.c => src/handlers/ircv3.c +1 -1
@@ 326,7 326,7 @@ ircv3_recv_cap_LS(struct server *s, struct irc_message *m)
			continue;

		c->supported = 1;
		c->val = (cap_val ? strdup(cap_val) : NULL);
		c->val = (cap_val ? irc_strdup(cap_val) : NULL);

		if (c->req_auto)
			c->req = 1;

M src/io.c => src/io.c +5 -5
@@ 185,11 185,11 @@ connection(

	cx->obj = obj;
	cx->flags = flags;
	cx->host = strdup(host);
	cx->port = strdup(port);
	cx->tls_ca_file = (tls_ca_file ? strdup(tls_ca_file) : NULL);
	cx->tls_ca_path = (tls_ca_path ? strdup(tls_ca_path) : NULL);
	cx->tls_cert = (tls_cert ? strdup(tls_cert) : NULL);
	cx->host = irc_strdup(host);
	cx->port = irc_strdup(port);
	cx->tls_ca_file = (tls_ca_file ? irc_strdup(tls_ca_file) : NULL);
	cx->tls_ca_path = (tls_ca_path ? irc_strdup(tls_ca_path) : NULL);
	cx->tls_cert = (tls_cert ? irc_strdup(tls_cert) : NULL);
	cx->st_cur = IO_ST_DXED;
	cx->st_new = IO_ST_INVALID;
	PT_CF(pthread_mutex_init(&(cx->mtx), NULL));

M src/utils/utils.c => src/utils/utils.c +11 -0
@@ 286,6 286,17 @@ irc_message_split(struct irc_message *m, const char **params, const char **trail
}

char*
irc_strdup(const char *str)
{
	char *ret;

	if (!(ret = strdup(str)))
		fatal("strdup");

	return ret;
}

char*
irc_strsep(char **str)
{
	char *p;

M src/utils/utils.h => src/utils/utils.h +1 -0
@@ 69,6 69,7 @@ int irc_isnick(const char*);
int irc_pinged(enum casemapping, const char*, const char*);
int irc_strcmp(enum casemapping, const char*, const char*);
int irc_strncmp(enum casemapping, const char*, const char*, size_t);
char* irc_strdup(const char*);
char* irc_strsep(char**);
char* irc_strtrim(char**);
char* irc_strwrap(unsigned, char**, char*);

M test/components/mode.c => test/components/mode.c +1 -0
@@ 1,5 1,6 @@
#include "test/test.h"
#include "src/components/mode.c"
#include "src/utils/utils.c"

#define ALL_LOWERS "abcdefghijklmnopqrstuvwxyz"
#define ALL_UPPERS "ABCDEFGHIJKLMNOPQRSTUVWXYZ"