[mw-devel] MW3 r1057 - trunk/src
firefury at sucs.org
firefury at sucs.org
Wed Oct 8 15:08:13 BST 2008
Author: firefury
Date: 2008-10-08 15:08:13 +0100 (Wed, 08 Oct 2008)
New Revision: 1057
Modified:
trunk/src/edit.c
trunk/src/main.c
trunk/src/proto.h
trunk/src/who.c
Log:
Add -what commandline option and allow !user doing to clear statuses
Modified: trunk/src/edit.c
===================================================================
--- trunk/src/edit.c 2008-10-07 11:27:39 UTC (rev 1056)
+++ trunk/src/edit.c 2008-10-08 14:08:13 UTC (rev 1057)
@@ -348,6 +348,13 @@
printf(_("New status set.\n"));
broadcast(3, "%s has just changed %s's status to %s.", user->name, usr.name, doing);
mwlog("CHANGE(STATUS) of %s to %s", usr.name, doing);
+ } else {
+ *(usr.doing) = 0;
+ usr.dowhen = 0;
+ ipc_send_to_username(usr.name, IPC_DOING, usr.doing);
+ printf(_("New status set.\n"));
+ broadcast(3, "%s has just cleared %s's status.", user->name, usr.name);
+ mwlog("CHANGE(STATUS) cleared %s", usr.name, doing);
}
}else
if (stringcmp(args,"timeout",1))
Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c 2008-10-07 11:27:39 UTC (rev 1056)
+++ trunk/src/main.c 2008-10-08 14:08:13 UTC (rev 1057)
@@ -275,6 +275,7 @@
int tty_timeout = 500; /* milliseconds */
int view_new = 0;
int view_who = 0;
+ int view_what = 0;
int view_help = 0;
int inet_mode = 0;
int view_since = 0;
@@ -319,6 +320,7 @@
if (match_arg_str(argv[al], "quiet")) qflag = 1;
if (match_arg_str(argv[al], "new")) view_new = 1;
if (match_arg_str(argv[al], "who")) view_who = 1;
+ if (match_arg_str(argv[al], "what")) view_what = 1;
if (match_arg_str(argv[al], "i")) inet_mode = 1;
if (match_arg_str(argv[al], "since")) view_since = 1;
@@ -377,6 +379,7 @@
printf(_(" -new Summary of new messages and quit\n"));
printf(_(" -since Lists people logged on between now and when you last logged on\n"));
printf(_(" -who Show a list of users logged on and quit\n"));
+ printf(_(" -what Show a list of what users are doing\n"));
/*
printf(" -quiet Don't announce your login to board or talker\n");
printf(" -X <user> Display messages for that user\n");
@@ -414,6 +417,18 @@
}else
printf(_("Username not permitted.\n"));
}
+ if (view_what)
+ {
+ char *b;
+ b=(char *)getmylogin();
+ if (b!=NULL && strcmp(b,"bbs"))
+ {
+ /* try and load user - dont care if it fails */
+ is_old(user,b,&userposn);
+ what_list();
+ }else
+ printf(_("Username not permitted.\n"));
+ }
if (view_since)
{
char *b;
@@ -431,7 +446,7 @@
}
/* if any 'view and quit' options specified, then quit */
- if (view_new || view_who || view_since)
+ if (view_new || view_who || view_since || view_what)
{
free(user);
free(fold);
Modified: trunk/src/proto.h
===================================================================
--- trunk/src/proto.h 2008-10-07 11:27:39 UTC (rev 1056)
+++ trunk/src/proto.h 2008-10-08 14:08:13 UTC (rev 1057)
@@ -221,6 +221,7 @@
void who_delete(int pid);
void copy(char *a, char *b);
void who_list(int mode);
+void what_list(void);
int get_pid(char *name);
void check_copies(int32_t where);
char *itime(unsigned long t);
Modified: trunk/src/who.c
===================================================================
--- trunk/src/who.c 2008-10-07 11:27:39 UTC (rev 1056)
+++ trunk/src/who.c 2008-10-08 14:08:13 UTC (rev 1057)
@@ -66,6 +66,26 @@
close(bf);
}
+void what_list(void) {
+ struct person u;
+ int ufile;
+ time_t t;
+ char * timestr;
+
+ ufile=openuserfile(O_RDONLY);
+ if (ufile < 0) return; /* whoops */
+
+ while (read(ufile, &u, sizeof(u))) {
+ if (! u_del(u.status)) {
+ t = (time_t) u.dowhen;
+ timestr = ctime(&t);
+ timestr[strlen(timestr) - 1] = 0; // Strip the \n
+ if (u.dowhen && u.doing[0] != 0) printf("%s | %s %s (%s ago)\n", timestr, u.name, u.doing, itime(time(0)-u.dowhen));
+ }
+ }
+ close(ufile);
+}
+
void who_list(int mode)
{
struct person u;
More information about the mw-devel
mailing list