Changeset 2e0eaac
- Timestamp:
- 2010-07-11T23:14:49Z (14 years ago)
- Branches:
- master
- Children:
- 09dfb68
- Parents:
- b1f818b
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
irc.c
rb1f818b r2e0eaac 109 109 s = set_add( &b->set, "handle_unknown", "add_channel", NULL, irc ); 110 110 s = set_add( &b->set, "lcnicks", "true", set_eval_bool, irc ); 111 s = set_add( &b->set, "nick_format", "%-@handle", NULL, irc ); 111 112 s = set_add( &b->set, "offline_user_quits", "true", set_eval_bool, irc ); 112 113 s = set_add( &b->set, "ops", "both", set_eval_irc_channel_ops, irc ); -
nick.c
rb1f818b r2e0eaac 27 27 #include "bitlbee.h" 28 28 29 /* Character maps, _lc_[x] == _uc_[x] (but uppercase), according to the RFC's. 30 With one difference, we allow dashes. These are used to do uc/lc conversions 31 and strip invalid chars. */ 32 static char *nick_lc_chars = "0123456789abcdefghijklmnopqrstuvwxyz{}^`-_|"; 33 static char *nick_uc_chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ[]~`-_\\"; 34 29 35 /* Store handles in lower case and strip spaces, because AIM is braindead. */ 30 36 static char *clean_handle( const char *orig ) … … 73 79 strncpy( nick, found_nick, MAX_NICK_LENGTH ); 74 80 } 81 else if( ( found_nick = nick_gen( bu ) ) ) 82 { 83 strncpy( nick, found_nick, MAX_NICK_LENGTH ); 84 g_free( found_nick ); 85 } 75 86 else 76 87 { 88 /* Keep this fallback since nick_gen() can return NULL in some cases. */ 77 89 char *s; 78 90 … … 97 109 char *nick_gen( bee_user_t *bu ) 98 110 { 99 return NULL; 111 gboolean ok = FALSE; /* Set to true once the nick contains something unique. */ 112 GString *ret = g_string_new( "" ); 113 char *fmt = set_getstr( &bu->ic->acc->set, "nick_format" ) ? : 114 set_getstr( &bu->bee->set, "nick_format" ); 115 116 while( fmt && *fmt && ret->len < MAX_NICK_LENGTH ) 117 { 118 char *part, chop = '\0'; 119 120 if( *fmt != '%' ) 121 { 122 g_string_append_c( ret, *fmt ); 123 fmt ++; 124 continue; 125 } 126 127 fmt ++; 128 while( *fmt ) 129 { 130 /* -char means chop off everything from char */ 131 if( *fmt == '-' ) 132 { 133 chop = fmt[1]; 134 if( chop == '\0' ) 135 return NULL; 136 fmt += 2; 137 } 138 else if( g_strncasecmp( fmt, "handle", 6 ) == 0 ) 139 { 140 part = bu->handle; 141 fmt += 6; 142 ok |= TRUE; 143 break; 144 } 145 else if( g_strncasecmp( fmt, "full_name", 9 ) == 0 ) 146 { 147 part = bu->fullname; 148 fmt += 9; 149 ok |= part && *part; 150 break; 151 } 152 else if( g_strncasecmp( fmt, "first_name", 10 ) == 0 ) 153 { 154 part = bu->fullname; 155 fmt += 10; 156 ok |= part && *part; 157 chop = ' '; 158 break; 159 } 160 else 161 { 162 return NULL; 163 } 164 } 165 166 while( part && *part && *part != chop ) 167 { 168 if( strchr( nick_lc_chars, *part ) || 169 strchr( nick_uc_chars, *part ) ) 170 g_string_append_c( ret, *part ); 171 172 part ++; 173 } 174 } 175 176 /* This returns NULL if the nick is empty or otherwise not ok. */ 177 return g_string_free( ret, ret->len == 0 || !ok ); 100 178 } 101 179 … … 163 241 164 242 165 /* Character maps, _lc_[x] == _uc_[x] (but uppercase), according to the RFC's.166 With one difference, we allow dashes. */167 168 static char *nick_lc_chars = "0123456789abcdefghijklmnopqrstuvwxyz{}^`-_|";169 static char *nick_uc_chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ[]~`-_\\";170 171 243 void nick_strip( char *nick ) 172 244 { -
protocols/account.c
rb1f818b r2e0eaac 53 53 54 54 s = set_add( &a->set, "auto_reconnect", "true", set_eval_bool, a ); 55 56 s = set_add( &a->set, "nick_format", NULL, NULL, a ); 55 57 56 58 s = set_add( &a->set, "nick_source", "handle", NULL, a );
Note: See TracChangeset
for help on using the changeset viewer.