Changeset 36562b0
- Timestamp:
- 2010-06-07T00:44:45Z (14 years ago)
- Branches:
- master
- Children:
- 0d9d53e
- Parents:
- 92cb8c4
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
irc.h
r92cb8c4 r36562b0 220 220 irc_channel_t *irc_channel_new( irc_t *irc, const char *name ); 221 221 irc_channel_t *irc_channel_by_name( irc_t *irc, const char *name ); 222 irc_channel_t *irc_channel_get( irc_t *irc, char *id ); 222 223 int irc_channel_free( irc_channel_t *ic ); 223 224 int irc_channel_add_user( irc_channel_t *ic, irc_user_t *iu ); -
irc_channel.c
r92cb8c4 r36562b0 49 49 irc_channel_user_set_mode( ic, irc->root, IRC_CHANNEL_USER_OP ); 50 50 51 irc->channels = g_slist_ prepend( irc->channels, ic );51 irc->channels = g_slist_append( irc->channels, ic ); 52 52 53 53 set_add( &ic->set, "type", "control", set_eval_channel_type, ic ); … … 69 69 irc_channel_t *ic = l->data; 70 70 71 if( name[0] == ic->name[0] && nick_cmp( name + 1, ic->name + 1) == 0 )71 if( g_strcasecmp( name, ic->name ) == 0 ) 72 72 return ic; 73 73 } 74 74 75 75 return NULL; 76 } 77 78 irc_channel_t *irc_channel_get( irc_t *irc, char *id ) 79 { 80 irc_channel_t *ic, *ret = NULL; 81 GSList *l; 82 int nr; 83 84 if( sscanf( id, "%d", &nr ) == 1 && nr < 1000 ) 85 { 86 for( l = irc->channels; l; l = l->next ) 87 { 88 ic = l->data; 89 if( ( nr-- ) == 0 ) 90 return ic; 91 } 92 93 return NULL; 94 } 95 96 /* Exact match first: Partial match only sucks if there's a channel 97 #aa and #aabb */ 98 if( ( ret = irc_channel_by_name( irc, id ) ) ) 99 return ret; 100 101 for( l = irc->channels; l; l = l->next ) 102 { 103 ic = l->data; 104 105 if( strstr( ic->name, id ) ) 106 { 107 /* Make sure it's a unique match. */ 108 if( !ret ) 109 ret = ic; 110 else 111 return NULL; 112 } 113 } 114 115 return ret; 76 116 } 77 117 -
root_commands.c
r92cb8c4 r36562b0 522 522 irc_channel_t *ic; 523 523 524 if( ( ic = irc_channel_ by_name( irc, id ) ) )524 if( ( ic = irc_channel_get( irc, id ) ) ) 525 525 return &ic->set; 526 526 else … … 535 535 536 536 cmd_set_real( irc, cmd + 1, cmd_channel_set_findhead, NULL ); 537 } 538 else if( g_strcasecmp( cmd[1], "list" ) == 0 ) 539 { 540 GSList *l; 541 int i = 0; 542 543 if( strchr( irc->umode, 'b' ) ) 544 irc_usermsg( irc, "Channel list:" ); 545 546 for( l = irc->channels; l; l = l->next ) 547 { 548 irc_channel_t *ic = l->data; 549 550 irc_usermsg( irc, "%2d. %s, %s channel%s", i, ic->name, 551 set_getstr( &ic->set, "type" ), 552 ic->flags & IRC_CHANNEL_JOINED ? " (joined)" : "" ); 553 554 i ++; 555 } 556 irc_usermsg( irc, "End of channel list" ); 537 557 } 538 558 else
Note: See TracChangeset
for help on using the changeset viewer.