aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2013-04-20 23:50:31 +0100
committerWilmer van der Gaast <wilmer@gaast.net>2013-04-20 23:50:31 +0100
commite277e80022e9cad3f7a3dbadbc25a6a2da9bf40d (patch)
treed5b01e4edfecc2f002d2de1b89bbef37d4e47694
parentdd95ce431b5c85eb6d74e501a7796e8a6016ec70 (diff)
Add irc_t* argument to all relevant nick_*() functions.
-rw-r--r--ipc.c4
-rw-r--r--irc_commands.c8
-rw-r--r--irc_im.c2
-rw-r--r--irc_user.c6
-rw-r--r--nick.c27
-rw-r--r--nick.h10
-rw-r--r--root_commands.c4
-rw-r--r--storage_xml.c6
8 files changed, 32 insertions, 35 deletions
diff --git a/ipc.c b/ipc.c
index 8388214a..0356ad75 100644
--- a/ipc.c
+++ b/ipc.c
@@ -151,7 +151,7 @@ void ipc_master_cmd_identify( irc_t *data, char **cmd )
{
old = l->data;
if( child != old &&
- old->nick && nick_cmp( old->nick, child->nick ) == 0 &&
+ old->nick && nick_cmp( NULL, old->nick, child->nick ) == 0 &&
old->password && strcmp( old->password, child->password ) == 0 )
break;
}
@@ -297,7 +297,7 @@ static void ipc_child_cmd_kill( irc_t *irc, char **cmd )
if( !( irc->status & USTATUS_LOGGED_IN ) )
return;
- if( nick_cmp( cmd[1], irc->user->nick ) != 0 )
+ if( nick_cmp( NULL, cmd[1], irc->user->nick ) != 0 )
return; /* It's not for us. */
irc_write( irc, ":%s!%s@%s KILL %s :%s", irc->root->nick, irc->root->nick, irc->root->host, irc->user->nick, cmd[2] );
diff --git a/irc_commands.c b/irc_commands.c
index 740d3eb2..3db243bf 100644
--- a/irc_commands.c
+++ b/irc_commands.c
@@ -79,7 +79,7 @@ static void irc_cmd_nick( irc_t *irc, char **cmd )
{
irc_send_num( irc, 433, "%s :This nick is already in use", cmd[1] );
}
- else if( !nick_ok( cmd[1] ) )
+ else if( !nick_ok( NULL, cmd[1] ) )
{
/* [SH] Invalid characters. */
irc_send_num( irc, 432, "%s :This nick contains invalid characters", cmd[1] );
@@ -290,7 +290,7 @@ static void irc_cmd_mode( irc_t *irc, char **cmd )
}
else
{
- if( nick_cmp( cmd[1], irc->user->nick ) == 0 )
+ if( nick_cmp( NULL, cmd[1], irc->user->nick ) == 0 )
{
if( cmd[2] )
irc_umode_set( irc, cmd[2], 0 );
@@ -391,7 +391,7 @@ static void irc_cmd_notice( irc_t *irc, char **cmd )
/* At least for now just echo. IIRC some IRC clients use self-notices
for lag checks, so try to support that. */
- if( nick_cmp( cmd[1], irc->user->nick ) == 0 )
+ if( nick_cmp( NULL, cmd[1], irc->user->nick ) == 0 )
irc_send_msg( irc->user, "NOTICE", irc->user->nick, cmd[2], NULL );
else if( ( iu = irc_user_by_name( irc, cmd[1] ) ) )
iu->f->privmsg( iu, cmd[2] );
@@ -592,7 +592,7 @@ static void irc_cmd_watch( irc_t *irc, char **cmd )
break;
nick = g_strdup( cmd[i] + 1 );
- nick_lc( nick );
+ nick_lc( irc, nick );
iu = irc_user_by_name( irc, nick );
diff --git a/irc_im.c b/irc_im.c
index 6f221280..bc1ce91d 100644
--- a/irc_im.c
+++ b/irc_im.c
@@ -696,7 +696,7 @@ static gboolean bee_irc_chat_name_hint( bee_t *bee, struct groupchat *c, const c
stripped[MAX_NICK_LENGTH] = '\0';
irc_channel_name_strip( stripped );
if( set_getbool( &bee->set, "lcnicks" ) )
- nick_lc( stripped );
+ nick_lc( irc, stripped );
if( stripped[0] == '\0' )
return FALSE;
diff --git a/irc_user.c b/irc_user.c
index 8ff9243c..94dcf4aa 100644
--- a/irc_user.c
+++ b/irc_user.c
@@ -35,7 +35,7 @@ irc_user_t *irc_user_new( irc_t *irc, const char *nick )
iu->user = iu->host = iu->fullname = iu->nick;
iu->key = g_strdup( nick );
- nick_lc( iu->key );
+ nick_lc( irc, iu->key );
/* Using the hash table for speed and irc->users for easy iteration
through the list (since the GLib API doesn't have anything sane
for that.) */
@@ -106,7 +106,7 @@ irc_user_t *irc_user_by_name( irc_t *irc, const char *nick )
char key[strlen(nick)+1];
strcpy( key, nick );
- if( nick_lc( key ) )
+ if( nick_lc( irc, key ) )
return g_hash_table_lookup( irc->nick_user_hash, key );
else
return NULL;
@@ -120,7 +120,7 @@ int irc_user_set_nick( irc_user_t *iu, const char *new )
GSList *cl;
strcpy( key, new );
- if( iu == NULL || !nick_lc( key ) ||
+ if( iu == NULL || !nick_lc( irc, key ) ||
( ( new_iu = irc_user_by_name( irc, new ) ) && new_iu != iu ) )
return 0;
diff --git a/nick.c b/nick.c
index 8268d4a7..aa9466f9 100644
--- a/nick.c
+++ b/nick.c
@@ -50,11 +50,12 @@ static char *clean_handle( const char *orig )
void nick_set_raw( account_t *acc, const char *handle, const char *nick )
{
char *store_handle, *store_nick = g_malloc( MAX_NICK_LENGTH + 1 );
+ irc_t *irc = (irc_t *) acc->bee->ui_data;
store_handle = clean_handle( handle );
store_nick[MAX_NICK_LENGTH] = '\0';
strncpy( store_nick, nick, MAX_NICK_LENGTH );
- nick_strip( store_nick );
+ nick_strip( irc, store_nick );
g_hash_table_replace( acc->nicks, store_handle, store_nick );
}
@@ -68,6 +69,7 @@ char *nick_get( bee_user_t *bu )
{
static char nick[MAX_NICK_LENGTH+1];
char *store_handle, *found_nick;
+ irc_t *irc = (irc_t *) bu->bee->ui_data;
memset( nick, 0, MAX_NICK_LENGTH + 1 );
@@ -93,9 +95,9 @@ char *nick_get( bee_user_t *bu )
while( *s )
*(s++) = 0;
- nick_strip( nick );
+ nick_strip( irc, nick );
if( set_getbool( &bu->bee->set, "lcnicks" ) )
- nick_lc( nick );
+ nick_lc( irc, nick );
}
g_free( store_handle );
@@ -229,7 +231,7 @@ void nick_dedupe( bee_user_t *bu, char nick[MAX_NICK_LENGTH+1] )
/* Now, find out if the nick is already in use at the moment, and make
subtle changes to make it unique. */
- while( !nick_ok( nick ) ||
+ while( !nick_ok( irc, nick ) ||
( ( iu = irc_user_by_name( irc, nick ) ) && iu->bu != bu ) )
{
if( strlen( nick ) < ( MAX_NICK_LENGTH - 1 ) )
@@ -286,7 +288,7 @@ void nick_del( bee_user_t *bu )
}
-void nick_strip( char *nick )
+void nick_strip( irc_t *irc, char *nick )
{
int i, j;
@@ -312,7 +314,7 @@ void nick_strip( char *nick )
nick[j++] = '\0';
}
-int nick_ok( const char *nick )
+int nick_ok( irc_t *irc, const char *nick )
{
const char *s;
@@ -327,7 +329,7 @@ int nick_ok( const char *nick )
return( 1 );
}
-int nick_lc( char *nick )
+int nick_lc( irc_t *irc, char *nick )
{
static char tab[128] = { 0 };
int i;
@@ -350,7 +352,7 @@ int nick_lc( char *nick )
return( 1 );
}
-int nick_uc( char *nick )
+int nick_uc( irc_t *irc, char *nick )
{
static char tab[128] = { 0 };
int i;
@@ -373,13 +375,13 @@ int nick_uc( char *nick )
return( 1 );
}
-int nick_cmp( const char *a, const char *b )
+int nick_cmp( irc_t *irc, const char *a, const char *b )
{
char aa[1024] = "", bb[1024] = "";
strncpy( aa, a, sizeof( aa ) - 1 );
strncpy( bb, b, sizeof( bb ) - 1 );
- if( nick_lc( aa ) && nick_lc( bb ) )
+ if( nick_lc( irc, aa ) && nick_lc( irc, bb ) )
{
return( strcmp( aa, bb ) );
}
@@ -388,8 +390,3 @@ int nick_cmp( const char *a, const char *b )
return( -1 ); /* Hmm... Not a clear answer.. :-/ */
}
}
-
-char *nick_dup( const char *nick )
-{
- return g_strndup( nick, MAX_NICK_LENGTH );
-}
diff --git a/nick.h b/nick.h
index e1b506e1..47adbab5 100644
--- a/nick.h
+++ b/nick.h
@@ -30,10 +30,10 @@ char *nick_gen( bee_user_t *bu );
void nick_dedupe( bee_user_t *bu, char nick[MAX_NICK_LENGTH+1] );
int nick_saved( bee_user_t *bu );
void nick_del( bee_user_t *bu );
-void nick_strip( char *nick );
-int nick_ok( const char *nick );
-int nick_lc( char *nick );
-int nick_uc( char *nick );
-int nick_cmp( const char *a, const char *b );
+void nick_strip( irc_t *irc, char *nick );
+int nick_ok( irc_t *irc, const char *nick );
+int nick_lc( irc_t *irc, char *nick );
+int nick_uc( irc_t *irc, char *nick );
+int nick_cmp( irc_t *irc, const char *a, const char *b );
char *nick_dup( const char *nick );
diff --git a/root_commands.c b/root_commands.c
index 77f40060..0bd16163 100644
--- a/root_commands.c
+++ b/root_commands.c
@@ -701,7 +701,7 @@ static void cmd_add( irc_t *irc, char **cmd )
if( cmd[3] )
{
- if( !nick_ok( cmd[3] ) )
+ if( !nick_ok( irc, cmd[3] ) )
{
irc_rootmsg( irc, "The requested nick `%s' is invalid", cmd[3] );
return;
@@ -843,7 +843,7 @@ static void cmd_rename( irc_t *irc, char **cmd )
{
irc_rootmsg( irc, "Use /nick to change your own nickname" );
}
- else if( !nick_ok( cmd[2] ) )
+ else if( !nick_ok( irc, cmd[2] ) )
{
irc_rootmsg( irc, "Nick `%s' is invalid", cmd[2] );
}
diff --git a/storage_xml.c b/storage_xml.c
index 1f2d4a51..3ee8ae1d 100644
--- a/storage_xml.c
+++ b/storage_xml.c
@@ -180,7 +180,7 @@ static storage_status_t xml_load_real( irc_t *irc, const char *my_nick, const ch
xd->irc = irc;
strncpy( xd->given_nick, my_nick, MAX_NICK_LENGTH );
xd->given_nick[MAX_NICK_LENGTH] = '\0';
- nick_lc( xd->given_nick );
+ nick_lc( NULL, xd->given_nick );
xd->given_pass = (char*) password;
fn = g_strconcat( global.conf->configdir, xd->given_nick, ".xml", NULL );
@@ -367,7 +367,7 @@ static storage_status_t xml_save( irc_t *irc, int overwrite )
int fd;
path2 = g_strdup( irc->user->nick );
- nick_lc( path2 );
+ nick_lc( NULL, path2 );
g_snprintf( path, sizeof( path ) - 20, "%s%s%s", global.conf->configdir, path2, ".xml" );
g_free( path2 );
@@ -423,7 +423,7 @@ static storage_status_t xml_remove( const char *nick, const char *password )
return status;
lc = g_strdup( nick );
- nick_lc( lc );
+ nick_lc( NULL, lc );
g_snprintf( s, 511, "%s%s%s", global.conf->configdir, lc, ".xml" );
g_free( lc );