- Timestamp:
- 2010-03-27T14:31:03Z (15 years ago)
- Branches:
- master
- Children:
- 2f53ada
- Parents:
- 9b69eb7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
irc.c
r9b69eb7 rb919363 52 52 irc->nick_user_hash = g_hash_table_new( g_str_hash, g_str_equal ); 53 53 irc->watches = g_hash_table_new( g_str_hash, g_str_equal ); 54 55 strcpy( irc->umode, UMODE );56 54 57 55 irc->iconv = (GIConv) -1; … … 599 597 g_free( iu ); 600 598 601 irc->umode[0] = '\0';602 /*irc_umode_set( irc, "+" UMODE, 1 );*/603 604 599 if( global.conf->runmode == RUNMODE_FORKDAEMON || global.conf->runmode == RUNMODE_DAEMON ) 605 600 ipc_to_master_str( "CLIENT %s %s :%s\r\n", irc->user->host, irc->user->nick, irc->user->fullname ); … … 619 614 irc_send_login( irc ); 620 615 616 irc->umode[0] = '\0'; 617 irc_umode_set( irc, "+" UMODE, TRUE ); 618 621 619 ic = irc_channel_new( irc, ROOT_CHAN ); 622 620 irc_channel_set_topic( ic, CONTROL_TOPIC, irc->root ); … … 631 629 return 0; 632 630 } 631 } 632 633 void irc_umode_set( irc_t *irc, const char *s, gboolean allow_priv ) 634 { 635 /* allow_priv: Set to 0 if s contains user input, 1 if you want 636 to set a "privileged" mode (+o, +R, etc). */ 637 char m[128], st = 1; 638 const char *t; 639 int i; 640 char changes[512], *p, st2 = 2; 641 char badflag = 0; 642 643 memset( m, 0, sizeof( m ) ); 644 645 for( t = irc->umode; *t; t ++ ) 646 if( *t < sizeof( m ) ) 647 m[(int)*t] = 1; 648 649 p = changes; 650 for( t = s; *t; t ++ ) 651 { 652 if( *t == '+' || *t == '-' ) 653 st = *t == '+'; 654 else if( ( st == 0 && ( !strchr( UMODES_KEEP, *t ) || allow_priv ) ) || 655 ( st == 1 && strchr( UMODES, *t ) ) || 656 ( st == 1 && allow_priv && strchr( UMODES_PRIV, *t ) ) ) 657 { 658 if( m[(int)*t] != st) 659 { 660 if( st != st2 ) 661 st2 = st, *p++ = st ? '+' : '-'; 662 *p++ = *t; 663 } 664 m[(int)*t] = st; 665 } 666 else 667 badflag = 1; 668 } 669 *p = '\0'; 670 671 memset( irc->umode, 0, sizeof( irc->umode ) ); 672 673 for( i = 'A'; i <= 'z' && strlen( irc->umode ) < ( sizeof( irc->umode ) - 1 ); i ++ ) 674 if( m[i] ) 675 irc->umode[strlen(irc->umode)] = i; 676 677 if( badflag ) 678 irc_send_num( irc, 501, ":Unknown MODE flag" ); 679 if( *changes ) 680 irc_write( irc, ":%s!%s@%s MODE %s :%s", irc->user->nick, 681 irc->user->user, irc->user->host, irc->user->nick, 682 changes ); 633 683 } 634 684
Note: See TracChangeset
for help on using the changeset viewer.