Re: Who MOTD

From: Mike Breuer (
Date: 11/09/01

From: "Ramsey Stone" <ramseystone@HOTMAIL.COM>

The others made some good points, but I'm not sure if all of the issues were
addressed clearly.  In particular, even if you properly declare whomessage
and properly reference it in your functions, you are potentially using it
before it is initialized, since you have no guarantee that do_whomessage
will be called before do_who.  Here's a quick fix that should do what you

Near the top:
char *whomessage = NULL;

in ACMD(do_who):
+if (whomessage)
+  sprintf(buf + strlen(buf), "&R[&r%s&R]&n\n", whomessage);

And then:
+ACMD(do_whomessage) {
+  one_argument(argument, arg);
+  if (whomessage) {
+    free(whomessage);
+    whomessage = NULL;
+  }
+  if (*arg) whomessage = str_dup(arg);

You also need to add do_whomessage to the big array in interpreter.c.

Also, I agree with George that you should pick up a good C book.  This is
not a flame, just a simple truth.  I have taught C programming
professionally, and I know whereof I speak.


   | FAQ: |
   | Archives: |

This archive was generated by hypermail 2b30 : 12/06/01 PST