Changeset 4be8239
- Timestamp:
- 2010-03-27T02:39:08Z (15 years ago)
- Branches:
- master
- Children:
- b9e020a
- Parents:
- ebaebfe
- Files:
-
- 1 added
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
Makefile
rebaebfe r4be8239 11 11 # Program variables 12 12 #objects = bitlbee.o chat.o dcc.o help.o ipc.o irc.o irc_commands.o nick.o query.o root_commands.o set.o storage.o $(STORAGE_OBJS) 13 objects = bitlbee.o help.o ipc.o irc.o irc_c ommands.o irc_send.o irc_user.o nick.o set.o13 objects = bitlbee.o help.o ipc.o irc.o irc_channel.o irc_commands.o irc_send.o irc_user.o nick.o set.o 14 14 headers = account.h bitlbee.h commands.h conf.h config.h help.h ipc.h irc.h log.h nick.h query.h set.h sock.h storage.h user.h lib/events.h lib/ftutil.h lib/http_client.h lib/ini.h lib/md5.h lib/misc.h lib/proxy.h lib/sha1.h lib/ssl_client.h lib/url.h protocols/ft.h protocols/nogaim.h 15 15 subdirs = lib protocols -
irc.c
rebaebfe r4be8239 586 586 else 587 587 { 588 irc_channel_t *ic; 589 irc_user_t *iu = irc->user; 590 591 irc->user = irc_user_new( irc, iu->nick ); 592 irc->user->user = iu->user; 593 irc->user->fullname = iu->fullname; 594 g_free( iu->nick ); 595 g_free( iu ); 596 597 irc->umode[0] = '\0'; 598 /*irc_umode_set( irc, "+" UMODE, 1 );*/ 599 600 if( global.conf->runmode == RUNMODE_FORKDAEMON || global.conf->runmode == RUNMODE_DAEMON ) 601 ipc_to_master_str( "CLIENT %s %s :%s\r\n", irc->user->host, irc->user->nick, irc->user->fullname ); 602 603 irc->status |= USTATUS_LOGGED_IN; 604 605 /* This is for bug #209 (use PASS to identify to NickServ). */ 606 if( irc->password != NULL ) 607 { 608 char *send_cmd[] = { "identify", g_strdup( irc->password ), NULL }; 609 610 /*irc_setpass( irc, NULL );*/ 611 /*root_command( irc, send_cmd );*/ 612 g_free( send_cmd[1] ); 613 } 614 588 615 irc_send_login( irc ); 616 617 ic = irc_channel_new( irc, ROOT_CHAN ); 618 irc_channel_set_topic( ic, CONTROL_TOPIC ); 619 irc_channel_add_user( ic, irc->user ); 620 589 621 return 1; 590 622 } -
irc.h
rebaebfe r4be8239 73 73 struct account *accounts; 74 74 GSList *file_transfers; 75 struct chat *chatrooms;76 75 77 GSList *users ;76 GSList *users, *channels; 78 77 GHashTable *nick_user_hash; 79 78 GHashTable *watches; … … 106 105 } irc_user_t; 107 106 107 typedef enum 108 { 109 IRC_CHANNEL_JOINED = 1, 110 } irc_channel_flags_t; 111 112 typedef struct irc_channel 113 { 114 irc_t *irc; 115 int flags; 116 char *name; 117 char *topic; 118 char mode[8]; 119 GSList *users; 120 struct set *set; 121 } irc_channel_t; 122 108 123 #include "user.h" 109 124 … … 125 140 int irc_check_login( irc_t *irc ); 126 141 142 /* irc_channel.c */ 143 irc_channel_t *irc_channel_new( irc_t *irc, const char *name ); 144 int irc_channel_add_user( irc_channel_t *ic, irc_user_t *iu ); 145 int irc_channel_del_user( irc_channel_t *ic, irc_user_t *iu ); 146 int irc_channel_set_topic( irc_channel_t *ic, const char *topic ); 147 127 148 /* irc_commands.c */ 128 149 void irc_exec( irc_t *irc, char **cmd ); … … 132 153 void irc_send_login( irc_t *irc ); 133 154 void irc_send_motd( irc_t *irc ); 134 int irc_usermsg( irc_t *irc, char *format, ... ); 155 void irc_usermsg( irc_t *irc, char *format, ... ); 156 void irc_send_join( irc_channel_t *ic, irc_user_t *iu ); 157 void irc_send_part( irc_channel_t *ic, irc_user_t *iu, const char *reason ); 158 void irc_send_names( irc_channel_t *ic ); 159 void irc_send_topic( irc_channel_t *ic ); 135 160 136 161 /* irc_user.c */ -
irc_send.c
rebaebfe r4be8239 34 34 g_vsnprintf( text, IRC_MAX_LINE, format, params ); 35 35 va_end( params ); 36 36 37 irc_write( irc, ":%s %03d %s %s", irc->root->host, code, irc->user->nick ? : "*", text ); 37 38 return;39 38 } 40 39 41 40 void irc_send_login( irc_t *irc ) 42 41 { 43 irc_user_t *iu = irc->user;44 45 irc->user = irc_user_new( irc, iu->nick );46 irc->user->user = iu->user;47 irc->user->fullname = iu->fullname;48 g_free( iu->nick );49 g_free( iu );50 51 42 irc_send_num( irc, 1, ":Welcome to the BitlBee gateway, %s", irc->user->nick ); 52 43 irc_send_num( irc, 2, ":Host %s is running BitlBee " BITLBEE_VERSION " " ARCH "/" CPU ".", irc->root->host ); … … 57 48 CTYPES, CMODES, MAX_NICK_LENGTH - 1 ); 58 49 irc_send_motd( irc ); 59 irc->umode[0] = '\0';60 /*irc_umode_set( irc, "+" UMODE, 1 );*/61 50 62 51 irc_usermsg( irc, "Welcome to the BitlBee gateway!\n\n" … … 66 55 "If you already have an account on this server, just use the " 67 56 "\x02identify\x02 command to identify yourself." ); 68 69 if( global.conf->runmode == RUNMODE_FORKDAEMON || global.conf->runmode == RUNMODE_DAEMON )70 ipc_to_master_str( "CLIENT %s %s :%s\r\n", irc->user->host, irc->user->nick, irc->user->fullname );71 72 irc->status |= USTATUS_LOGGED_IN;73 74 /* This is for bug #209 (use PASS to identify to NickServ). */75 if( irc->password != NULL )76 {77 char *send_cmd[] = { "identify", g_strdup( irc->password ), NULL };78 79 /*irc_setpass( irc, NULL );*/80 /*root_command( irc, send_cmd );*/81 g_free( send_cmd[1] );82 }83 57 } 84 58 … … 136 110 137 111 /* FIXME/REPLACEME */ 138 intirc_usermsg( irc_t *irc, char *format, ... )112 void irc_usermsg( irc_t *irc, char *format, ... ) 139 113 { 140 114 char text[1024]; … … 148 122 fprintf( stderr, "%s\n", text ); 149 123 150 return 1;151 152 124 /*return( irc_msgfrom( irc, u->nick, text ) );*/ 153 125 } 126 127 void irc_send_join( irc_channel_t *ic, irc_user_t *iu ) 128 { 129 irc_t *irc = ic->irc; 130 131 irc_write( irc, ":%s!%s@%s JOIN :%s", iu->nick, iu->user, iu->host, ic->name ); 132 133 if( iu == irc->user ) 134 { 135 irc_write( irc, ":%s MODE %s +%s", irc->root->host, ic->name, ic->mode ); 136 irc_send_names( ic ); 137 irc_send_topic( ic ); 138 } 139 } 140 141 void irc_send_part( irc_channel_t *ic, irc_user_t *iu, const char *reason ) 142 { 143 irc_write( ic->irc, ":%s!%s@%s PART %s :%s", iu->nick, iu->user, iu->host, ic->name, reason ); 144 } 145 146 void irc_send_names( irc_channel_t *ic ) 147 { 148 GSList *l; 149 irc_user_t *iu; 150 char namelist[385] = ""; 151 struct groupchat *c = NULL; 152 char *ops = set_getstr( &ic->irc->b->set, "ops" ); 153 154 /* RFCs say there is no error reply allowed on NAMES, so when the 155 channel is invalid, just give an empty reply. */ 156 for( l = ic->users; l; l = l->next ) 157 { 158 irc_user_t *iu = l->data; 159 160 if( strlen( namelist ) + strlen( iu->nick ) > sizeof( namelist ) - 4 ) 161 { 162 irc_send_num( ic->irc, 353, "= %s :%s", ic->name, namelist ); 163 *namelist = 0; 164 } 165 166 /* 167 if( u->ic && !u->away && set_getbool( &irc->set, "away_devoice" ) ) 168 strcat( namelist, "+" ); 169 else if( ( strcmp( u->nick, irc->mynick ) == 0 && ( strcmp( ops, "root" ) == 0 || strcmp( ops, "both" ) == 0 ) ) || 170 ( strcmp( u->nick, irc->nick ) == 0 && ( strcmp( ops, "user" ) == 0 || strcmp( ops, "both" ) == 0 ) ) ) 171 strcat( namelist, "@" ); 172 */ 173 174 strcat( namelist, iu->nick ); 175 strcat( namelist, " " ); 176 } 177 178 if( *namelist ) 179 irc_send_num( ic->irc, 353, "= %s :%s", ic->name, namelist ); 180 181 irc_send_num( ic->irc, 366, "%s :End of /NAMES list", ic->name ); 182 } 183 184 void irc_send_topic( irc_channel_t *ic ) 185 { 186 if( ic->topic ) 187 irc_send_num( ic->irc, 332, "%s :%s", ic->name, ic->topic ); 188 else 189 irc_send_num( ic->irc, 331, "%s :No topic for this channel", ic->name ); 190 }
Note: See TracChangeset
for help on using the changeset viewer.