aboutsummaryrefslogtreecommitdiffstats
path: root/chat.c
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2008-08-30 23:26:45 +0100
committerWilmer van der Gaast <wilmer@gaast.net>2008-08-30 23:26:45 +0100
commit131c6b640e9921844fcf528de1a74682cfc6c768 (patch)
tree535762256919fe887e890d46bb2a729d78e012b4 /chat.c
parenta9a7287a9698aa6038958da5074da1169d63ea9d (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.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/chat.c b/chat.c
index b4b87117..8c201216 100644
--- a/chat.c
+++ b/chat.c
@@ -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 ) )