}
}
+ if (target->away) {
+ controlreply((nick *)sender, "Away : %s",target->away->content);
+ }
+
hooknick=(nick *)sender;
registerhook(HOOK_CONTROL_WHOISREPLY,&handlewhois);
triggerhook(HOOK_CONTROL_WHOISREQUEST,target);
#define TOPICLEN 250
#define CHANNELLEN 200
#define KEYLEN 23
+#define AWAYLEN 160
#define MAXSERVERS 4096
newuser->timestamp=getnettime();
newuser->shident=NULL;
newuser->sethost=NULL;
+ newuser->away=NULL;
newuser->marker=0;
memset(newuser->exts, 0, MAXNICKEXTS * sizeof(void *));
/* Nickname operations */
registersearchterm(reg_nicksearch, "hostmask",hostmask_parse, 0, "The user's nick!user@host; \"hostmask real\" returns nick!user@host\rreal"); /* nick only */
registersearchterm(reg_nicksearch, "realname",realname_parse, 0, "User's current realname"); /* nick only */
+ registersearchterm(reg_nicksearch, "away",away_parse, 0, "User's current away message"); /* nick only */
registersearchterm(reg_nicksearch, "authname",authname_parse, 0, "User's current authname or false"); /* nick only */
registersearchterm(reg_nicksearch, "authts",authts_parse, 0, "User's Auth timestamp"); /* nick only */
registersearchterm(reg_nicksearch, "ident",ident_parse, 0, "User's current ident"); /* nick only */
/* Nick functions (various types) */
struct searchNode *hostmask_parse(searchCtx *ctx, int argc, char **argv);
struct searchNode *realname_parse(searchCtx *ctx, int argc, char **argv);
+struct searchNode *away_parse(searchCtx *ctx, int argc, char **argv);
struct searchNode *authname_parse(searchCtx *ctx, int argc, char **argv);
struct searchNode *authts_parse(searchCtx *ctx, int argc, char **argv);
struct searchNode *ident_parse(searchCtx *ctx, int argc, char **argv);
--- /dev/null
+/*
+ * AWAY functionality
+ */
+
+#include "newsearch.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+void *away_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void away_free(searchCtx *ctx, struct searchNode *thenode);
+
+struct searchNode *away_parse(searchCtx *ctx, int argc, char **argv) {
+ struct searchNode *thenode;
+
+ if (!(thenode=(struct searchNode *)malloc(sizeof (struct searchNode)))) {
+ parseError = "malloc: could not allocate memory for this search.";
+ return NULL;
+ }
+
+ thenode->returntype = RETURNTYPE_STRING;
+ thenode->localdata = NULL;
+ thenode->exe = away_exe;
+ thenode->free = away_free;
+
+ return thenode;
+}
+
+void *away_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
+ nick *np = (nick *)theinput;
+
+ return (np->away) ? np->away->content : "";
+}
+
+void away_free(searchCtx *ctx, struct searchNode *thenode) {
+ free(thenode);
+}
+
registerserverhandler("AC",&handleaccountmsg,4);
registerserverhandler("R",&handlestatsmsg,2);
registerserverhandler("P",&handleprivmsg,2);
+ registerserverhandler("A",&handleawaymsg,1);
/* Fake the addition of our own server */
handleserverchange(HOOK_SERVER_NEWSERVER,(void *)numerictolong(mynumeric->content,2));
deregisterserverhandler("AC",&handleaccountmsg);
deregisterserverhandler("R",&handlestatsmsg);
deregisterserverhandler("P",&handleprivmsg);
+ deregisterserverhandler("A",&handleawaymsg);
}
/*
authname *auth; /* This requires User ID numbers to work */
time_t timestamp;
time_t accountts;
+ sstring *away;
patricia_node_t *ipnode;
unsigned int marker;
struct nick *next;
int handleaccountmsg(void *source, int cargc, char **cargv);
int handlestatsmsg(void *source, int cargc, char **cargv);
int handleprivmsg(void *source, int cargc, char **cargv);
+int handleawaymsg(void *source, int cargc, char **cargv);
/* These functions have been replaced by macros
nick **gethandlebynumeric(long numeric);
np->ipnode = refnode(iptree, &ipaddress, PATRICIA_MAXBITS);
node_increment_usercount(np->ipnode);
+ np->away=NULL;
np->shident=NULL;
np->sethost=NULL;
np->opername=NULL;
return CMD_OK;
}
+int handleawaymsg(void *source, int cargc, char **cargv) {
+ nick *sender;
+
+ /* Check source is a valid user */
+ if (!(sender=getnickbynumericstr(source))) {
+ return CMD_OK;
+ }
+
+ /* Done with the old away message either way */
+ freesstring(sender->away);
+ sender->away=NULL;
+
+ /* If we have an arg and it isn't an empty string, this sets a new message */
+ if (cargc > 0 && *(cargv[0])) {
+ sender->away=getsstring(cargv[0], AWAYLEN);
+ }
+
+ return CMD_OK;
+}