- Timestamp:
- Mar 4, 2014, 5:09:42 PM (11 years ago)
- Branches:
- master
- Children:
- b7bc432
- Parents:
- 8ef8c4e
- git-author:
- Mike Belopuhov <mike@…> (03/04/14 17:09:08)
- git-committer:
- Mike Belopuhov <mike@…> (03/04/14 17:09:42)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cmd.c
r8ef8c4e r626f420 22 22 #include <syslog.h> 23 23 #include <unistd.h> 24 #include <vis.h> 24 25 #include <event.h> 25 26 … … 79 80 struct icb_group *ig = is->group; 80 81 struct icb_session *s; 82 char whom[ICB_MAXNICKLEN]; 81 83 82 84 if (strlen(arg) == 0) { … … 85 87 } 86 88 89 icb_vis(whom, arg, ICB_MAXNICKLEN); 90 87 91 LIST_FOREACH(s, &ig->sess, entry) { 88 if (strcmp(s->nick, arg) == 0)92 if (strcmp(s->nick, whom) == 0) 89 93 break; 90 94 } 91 95 if (s == NULL) { 92 icb_status(is, STATUS_NOTIFY, "%s is not signed on", arg);96 icb_status(is, STATUS_NOTIFY, "%s is not signed on", whom); 93 97 return; 94 98 } … … 110 114 struct icb_group *ig; 111 115 struct icb_session *s; 116 char whom[ICB_MAXNICKLEN]; 112 117 113 118 /* to boot or not to boot, that is the question */ … … 119 124 } 120 125 126 if (strlen(whom) == 0) { 127 icb_error(is, "Invalid user"); 128 return; 129 } 130 131 icb_vis(whom, arg, ICB_MAXNICKLEN); 132 121 133 /* who would be a target then? */ 122 134 LIST_FOREACH(s, &ig->sess, entry) { 123 if (strcmp(s->nick, arg) == 0)135 if (strcmp(s->nick, whom) == 0) 124 136 break; 125 137 } … … 140 152 struct icb_group *ig; 141 153 struct icb_session *s; 154 char group[ICB_MAXGRPLEN]; 142 155 int changing = 0; 143 156 … … 147 160 } 148 161 162 icb_vis(group, arg, ICB_MAXGRPLEN); 163 149 164 LIST_FOREACH(ig, &groups, entry) { 150 if (strcmp(ig->name, arg) == 0)165 if (strcmp(ig->name, group) == 0) 151 166 break; 152 167 } … … 156 171 return; 157 172 } else { 158 if ((ig = icb_addgroup(is, arg, NULL)) == NULL) {173 if ((ig = icb_addgroup(is, group, NULL)) == NULL) { 159 174 icb_error(is, "Can't create group"); 160 175 return; 161 176 } 162 177 icb_log(NULL, LOG_DEBUG, "%s created group %s", 163 is->nick, arg);178 is->nick, group); 164 179 } 165 180 } … … 208 223 struct icb_group *ig = is->group; 209 224 struct icb_session *s; 225 char nick[ICB_MAXNICKLEN]; 210 226 211 227 if (strlen(arg) == 0) { … … 221 237 if (strlen(arg) > ICB_MAXNICKLEN) 222 238 arg[ICB_MAXNICKLEN - 1] = '\0'; 239 icb_vis(nick, arg, ICB_MAXNICKLEN); 223 240 LIST_FOREACH(s, &ig->sess, entry) { 224 if (strcmp(s->nick, arg) == 0) {241 if (strcmp(s->nick, nick) == 0) { 225 242 icb_error(is, "Nick is already in use"); 226 243 return; … … 228 245 } 229 246 icb_status_group(ig, NULL, STATUS_NAME, 230 "%s changed nickname to %s", is->nick, arg);231 strlcpy(is->nick, arg, sizeof is->nick);247 "%s changed nickname to %s", is->nick, nick); 248 strlcpy(is->nick, nick, sizeof is->nick); 232 249 } 233 250 … … 284 301 struct icb_group *ig = is->group; 285 302 struct icb_session *s; 303 char whom[ICB_MAXNICKLEN]; 286 304 287 305 if (!ig->mod) { /* if there is no mod, let anyone grab it */ … … 294 312 return; 295 313 } 314 icb_vis(whom, arg, ICB_MAXNICKLEN); 296 315 LIST_FOREACH(s, &ig->sess, entry) { 297 if (strcmp(s->nick, arg) == 0)316 if (strcmp(s->nick, whom) == 0) 298 317 break; 299 318 } … … 311 330 { 312 331 struct icb_group *ig = is->group; 332 char topic[ICB_MAXTOPICLEN]; 313 333 314 334 if (strlen(arg) == 0) { /* querying the topic */ … … 324 344 return; 325 345 } 326 strlcpy(ig->topic, arg, sizeof ig->topic); 346 icb_vis(topic, arg, ICB_MAXTOPICLEN); 347 strlcpy(ig->topic, topic, sizeof ig->topic); 327 348 icb_status_group(ig, NULL, STATUS_TOPIC, 328 349 "%s changed the topic to \"%s\"", is->nick, ig->topic); … … 334 355 { 335 356 struct icb_group *ig; 357 char group[ICB_MAXGRPLEN]; 336 358 337 359 if (strlen(arg) == 0) 338 360 return icb_who(is, NULL); 339 361 362 icb_vis(group, arg, ICB_MAXGRPLEN); 340 363 LIST_FOREACH(ig, &groups, entry) { 341 if (strcmp(ig->name, arg) == 0)364 if (strcmp(ig->name, group) == 0) 342 365 break; 343 366 } 344 367 if (ig == NULL) { 345 icb_error(is, "The group %s doesn't exist.", arg);368 icb_error(is, "The group %s doesn't exist.", group); 346 369 return; 347 370 }
Note:
See TracChangeset
for help on using the changeset viewer.