diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2008-08-30 23:26:45 +0100 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2008-08-30 23:26:45 +0100 |
commit | 131c6b640e9921844fcf528de1a74682cfc6c768 (patch) | |
tree | 535762256919fe887e890d46bb2a729d78e012b4 /chat.c | |
parent | a9a7287a9698aa6038958da5074da1169d63ea9d (diff) |
Added chat_get(), similar to account_get() (find an account by number or
other criteria).
Diffstat (limited to 'chat.c')
-rw-r--r-- | chat.c | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -85,6 +85,41 @@ struct chat *chat_bychannel( irc_t *irc, char *channel ) return c; } +struct chat *chat_get( irc_t *irc, char *id ) +{ + struct chat *c, *ret = NULL; + int nr; + + if( sscanf( id, "%d", &nr ) == 1 && nr < 1000 ) + { + for( c = irc->chatrooms; c; c = c->next ) + if( ( nr-- ) == 0 ) + return c; + + return NULL; + } + + for( c = irc->chatrooms; c; c = c->next ) + { + if( strstr( c->handle, id ) ) + { + if( !ret ) + ret = c; + else + return NULL; + } + else if( strstr( c->channel, id ) ) + { + if( !ret ) + ret = c; + else + return NULL; + } + } + + return ret; +} + int chat_chancmp( char *a, char *b ) { if( !chat_chanok( a ) || !chat_chanok( b ) ) |