Permalink
Browse files

Handle RPL_LUSER* and the non-normative 265 and 266

265 is RPL_X_LOCALUSERS (count of users on this server)
266 is RPL_X_GLOBALUSERS (count of users on the network)
  • Loading branch information...
1 parent e7d13cf commit 3c322fa8dbbd0f664fe469101c1d5172fd42977c Sound and Fury committed Aug 15, 2010
Showing with 37 additions and 8 deletions.
  1. +1 −1 buffer.c
  2. +31 −6 irc.c
  3. +3 −1 numeric.h
  4. +2 −0 plans
View
@@ -93,7 +93,7 @@ int add_to_buffer(int buf, colour lc, char *lt)
free(ln);
lt=nl+1;
}
- while(strlen(lt)>width)
+ while(strlen(lt)>width) // should be prevented by wordline() usage; occasionally isn't
{
char *ln=strndup(lt, width);
add_to_buffer(buf, lc, ln);
View
37 irc.c
@@ -179,7 +179,6 @@ int irc_numeric(char *cmd, int b) // TODO check the strtok()s for NULLs
}
break;
case RPL_ENDOFMOTD: // 376 dest :End of MOTD command
- /* fallthrough */
case RPL_MOTDSTART: // 375 dest :- <server> Message of the day -
skip=1;
/* fallthrough */
@@ -233,12 +232,38 @@ int irc_numeric(char *cmd, int b) // TODO check the strtok()s for NULLs
}
}
break;
+ case RPL_LUSERCLIENT: // 251 <dest> :There are <integer> users and <integer> invisible on <integer> servers"
+ case RPL_LUSERME: // 255 <dest> ":I have <integer> clients and <integer> servers
+ {
+ char *rest=strtok(NULL, "");
+ buf_print(b, c_status, rest+1, true);
+ }
+ break;
+ case RPL_LUSEROP: // 252 <dest> <integer> :operator(s) online
+ case RPL_LUSERUNKNOWN: // 253 <dest> "<integer> :unknown connection(s)
+ case RPL_LUSERCHANNELS: // 254 <dest> "<integer> :channels formed
+ {
+ char *count=strtok(NULL, " ");
+ char *rest=strtok(NULL, "");
+ char lmsg[2+strlen(count)+strlen(rest)];
+ sprintf(lmsg, "%s %s", count, rest+1);
+ buf_print(b, c_status, lmsg, true);
+ }
+ break;
+ case RPL_X_LOCALUSERS: // 265 <dest> :Current Local Users: <integer>\tMax: <integer>
+ case RPL_X_GLOBALUSERS: // 266 <dest> :Current Global Users: <integer>\tMax: <integer>
+ {
+ char *rest=strtok(NULL, "");
+ buf_print(b, c_status, rest+1, true);
+ }
+ break;
default:
- ;
- char *rest=strtok(NULL, "");
- char umsg[16+strlen(dest)+strlen(rest)];
- sprintf(umsg, "<<%d? %s %s", num, dest, rest);
- buf_print(b, c_unn, umsg, true);
+ {
+ char *rest=strtok(NULL, "");
+ char umsg[16+strlen(dest)+strlen(rest)];
+ sprintf(umsg, "<<%d? %s %s", num, dest, rest);
+ buf_print(b, c_unn, umsg, true);
+ }
break;
}
return(num);
View
@@ -129,8 +129,10 @@
#define RPL_LUSEROP 252 // "<integer> :operator(s) online"
#define RPL_LUSERUNKNOWN 253 // "<integer> :unknown connection(s)"
#define RPL_LUSERCHANNELS 254 // "<integer> :channels formed"
-#define RPL_LUSERME 255 // ":I have <integer> clients and <integer> servers" In processing an LUSERS message, the server sends a set of replies from RPL_LUSERCLIENT, RPL_LUSEROP, RPL_USERUNKNOWN, RPL_LUSERCHANNELS and RPL_LUSERME. When replying, a server must send back RPL_LUSERCLIENT and RPL_LUSERME. The other replies are only sent back if a non-zero count is found for them.
+#define RPL_LUSERME 255 // ":I have <integer> clients and <integer> servers" In processing an LUSERS message, the server sends a set of replies from RPL_LUSERCLIENT, RPL_LUSEROP, RPL_LUSERUNKNOWN, RPL_LUSERCHANNELS and RPL_LUSERME. When replying, a server must send back RPL_LUSERCLIENT and RPL_LUSERME. The other replies are only sent back if a non-zero count is found for them.
#define RPL_ADMINME 256 // "<server> :Administrative info"
#define RPL_ADMINLOC1 257 // ":<admin info>"
#define RPL_ADMINLOC2 258 // ":<admin info>"
#define RPL_ADMINEMAIL 259 // ":<admin info>" When replying to an ADMIN message, a server is expected to use replies RLP_ADMINME through to RPL_ADMINEMAIL and provide a text message with each. For RPL_ADMINLOC1 a description of what city, state and country the server is in is expected, followed by details of the university and department (RPL_ADMINLOC2) and finally the administrative contact for the server (an email address here is required) in RPL_ADMINEMAIL.
+#define RPL_X_LOCALUSERS 265 // ":Current Local Users: <integer>\tMax: <integer>" Appears to count the users connected directly to the server. Non-normative.
+#define RPL_X_GLOBALUSERS 266 // ":Current Global Users: <integer>\tMax: <integer>" Appears to count the users connected to the network. Non-normative.
View
2 plans
@@ -9,3 +9,5 @@ curses. The current hardwired ANSI-escapes code for painting the screen is clum
Interface separation. The main event loop is currently chock-full of implementation details; it should just be a command parser and marshal. Some work has been done in this direction (0.4.8 changes) but there's a lot left to do.
Input editing. Should use something based on Emacs line editing keys (C-a will mean 'go to start of line', unlike now when it means 'backspace to start of line'!). May be provided by curses - investigate.
+
+word_buf_print(). Wrapper function combining wordline() and buf_print(), as this functionality is duplicated all over the code.

0 comments on commit 3c322fa

Please sign in to comment.