aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2006-07-01 21:17:42 +0200
committerWilmer van der Gaast <wilmer@gaast.net>2006-07-01 21:17:42 +0200
commitfef6116e89bb0651c72454effbb51e04e9e1b8dc (patch)
tree6859fde6e4b65e501e66c8b00a78a1fe1d10faa9
parent5100caa16bb707d89f1873aca99b5f87abc1dd56 (diff)
parent3f9440db856c1b1cde54eb919543cfc23ea09983 (diff)
Fixed check in set_eval_account() and merging from main (better NAMES replies).
-rw-r--r--account.c2
-rw-r--r--irc.c69
-rw-r--r--set.h1
3 files changed, 36 insertions, 36 deletions
diff --git a/account.c b/account.c
index 4e399e8a..186565dd 100644
--- a/account.c
+++ b/account.c
@@ -71,7 +71,7 @@ char *set_eval_account( set_t *set, char *value )
account_t *acc = set->data;
/* Double-check: We refuse to edit on-line accounts. */
- if( acc->gc )
+ if( set->flags & ACC_SET_OFFLINE_ONLY && acc->gc )
return NULL;
if( strcmp( set->key, "username" ) == 0 )
diff --git a/irc.c b/irc.c
index d93fbe44..bac91198 100644
--- a/irc.c
+++ b/irc.c
@@ -648,57 +648,56 @@ void irc_write_all( int now, char *format, ... )
void irc_names( irc_t *irc, char *channel )
{
- user_t *u = irc->users;
- char *s;
- int control = ( g_strcasecmp( channel, irc->channel ) == 0 );
+ user_t *u;
+ char namelist[385] = "";
struct conversation *c = NULL;
- if( !control )
- c = conv_findchannel( channel );
-
/* RFCs say there is no error reply allowed on NAMES, so when the
channel is invalid, just give an empty reply. */
- if( control || c ) while( u )
+ if( g_strcasecmp( channel, irc->channel ) == 0 )
{
- if( u->online )
+ for( u = irc->users; u; u = u->next ) if( u->online )
{
- if( u->gc && control )
+ if( strlen( namelist ) + strlen( u->nick ) > sizeof( namelist ) - 4 )
{
- if( set_getint( &irc->set, "away_devoice" ) && !u->away )
- s = "+";
- else
- s = "";
-
- irc_reply( irc, 353, "= %s :%s%s", channel, s, u->nick );
- }
- else if( !u->gc )
- {
- if( strcmp( u->nick, irc->mynick ) == 0 && ( strcmp( set_getstr( &irc->set, "ops" ), "root" ) == 0 || strcmp( set_getstr( &irc->set, "ops" ), "both" ) == 0 ) )
- s = "@";
- else if( strcmp( u->nick, irc->nick ) == 0 && ( strcmp( set_getstr( &irc->set, "ops" ), "user" ) == 0 || strcmp( set_getstr( &irc->set, "ops" ), "both" ) == 0 ) )
- s = "@";
- else
- s = "";
-
- irc_reply( irc, 353, "= %s :%s%s", channel, s, u->nick );
+ irc_reply( irc, 353, "= %s :%s", channel, namelist );
+ *namelist = 0;
}
+
+ if( u->gc && !u->away && set_getbool( &irc->set, "away_devoice" ) )
+ strcat( namelist, "+" );
+
+ strcat( namelist, u->nick );
+ strcat( namelist, " " );
}
-
- u = u->next;
}
-
- /* For non-controlchannel channels (group conversations) only root and
- you are listed now. Time to show the channel people: */
- if( !control && c )
+ else if( ( c = conv_findchannel( channel ) ) )
{
GList *l;
+ char *ops = set_getstr( &irc->set, "ops" );
- for( l = c->in_room; l; l = l->next )
- if( ( u = user_findhandle( c->gc, l->data ) ) )
- irc_reply( irc, 353, "= %s :%s%s", channel, "", u->nick );
+ /* root and the user aren't in the channel userlist but should
+ show up in /NAMES, so list them first: */
+ sprintf( namelist, "%s%s %s%s ", strcmp( ops, "root" ) == 0 || strcmp( ops, "both" ) ? "@" : "", irc->mynick,
+ strcmp( ops, "user" ) == 0 || strcmp( ops, "both" ) ? "@" : "", irc->nick );
+
+ for( l = c->in_room; l; l = l->next ) if( ( u = user_findhandle( c->gc, l->data ) ) )
+ {
+ if( strlen( namelist ) + strlen( u->nick ) > sizeof( namelist ) - 4 )
+ {
+ irc_reply( irc, 353, "= %s :%s", channel, namelist );
+ *namelist = 0;
+ }
+
+ strcat( namelist, u->nick );
+ strcat( namelist, " " );
+ }
}
+ if( *namelist )
+ irc_reply( irc, 353, "= %s :%s", channel, namelist );
+
irc_reply( irc, 366, "%s :End of /NAMES list", channel );
}
diff --git a/set.h b/set.h
index 4731f80a..48bc8145 100644
--- a/set.h
+++ b/set.h
@@ -44,6 +44,7 @@ set_t *set_add( set_t **head, char *key, char *def, void *eval, void *data );
set_t *set_find( set_t **head, char *key );
G_MODULE_EXPORT char *set_getstr( set_t **head, char *key );
G_MODULE_EXPORT int set_getint( set_t **head, char *key );
+G_MODULE_EXPORT int set_getbool( set_t **head, char *key );
int set_setstr( set_t **head, char *key, char *value );
int set_setint( set_t **head, char *key, int value );
void set_del( set_t **head, char *key );