]> git.pond.sub.org Git - empserver/commitdiff
Document, in particular use of UTF-8. Simplify code in a couple of
authorMarkus Armbruster <armbru@pond.sub.org>
Mon, 13 Jun 2005 19:02:49 +0000 (19:02 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Mon, 13 Jun 2005 19:02:49 +0000 (19:02 +0000)
places, but no functional changes.

17 files changed:
include/misc.h
include/player.h
include/prototypes.h
src/lib/commands/flash.c
src/lib/commands/play.c
src/lib/commands/rea.c
src/lib/commands/shut.c
src/lib/commands/tele.c
src/lib/commands/turn.c
src/lib/gen/getstring.c
src/lib/gen/parse.c
src/lib/player/dispatch.c
src/lib/player/empdis.c
src/lib/player/player.c
src/lib/subs/getele.c
src/lib/subs/pr.c
src/lib/subs/wu.c

index a6d4e2d25b2654802456640aaa3a8cfe432210c4..a3de937f02e334e98874bee215d9764cc907255d 100644 (file)
@@ -144,8 +144,7 @@ extern s_char *iesplur(int n);
 extern s_char *plur(int n, s_char *no, s_char *yes);
 extern char *getstarg(char *input, char *prompt, char buf[]);
 extern char *getstring(char *prompt, char buf[]);
-extern char *ugetstring(char *prompt, char buf[]
-                       /* buf is message text */);
+extern char *ugetstring(char *prompt, char buf[]);
              
 extern s_char *prbuf(s_char *format, ...)
     ATTRIBUTE((format (printf, 1, 2)));
index dbf0904f2eb5d0bef045d2e3d848bc5a09a157ba..a7807ae0bd6c9a6473bb67ef0dc721f72ec23a0d 100644 (file)
@@ -58,8 +58,8 @@ struct player {
     struct cmndstr *command;
     struct iop *iop;
     char combuf[1024];         /* command input buffer, UTF-8 */
-    s_char *argp[128];
-    s_char *condarg;
+    char *argp[128];           /* arguments, ASCII */
+    char *condarg;             /* conditional, ASCII */
     time_t lasttime;
     int ncomstat;
     int minleft;
index 91699e4b50f82c1d2ad7e0abd85bad3f391a0744..788d5943f2bd7306853865f7d71633d69bd8489c 100644 (file)
@@ -63,8 +63,7 @@ extern void finish_server(void);
  */
 extern int check_market(void);
 extern void set_coastal(struct sctstr *);
-extern int sendmessage(struct natstr *, struct natstr *, char *message
-                      /* message is message text */, int);
+extern int sendmessage(struct natstr *, struct natstr *, char *message, int);
 extern void gift(int, int, s_char *, int, s_char *);
 extern int display_mark(i_type, int);
 extern int want_to_abandon(struct sctstr *, i_type, int, struct lndstr *);
@@ -592,32 +591,29 @@ extern int pln_identchance(struct plnstr *, int, int);
 extern void pln_set_tech(struct plnstr *, int);
 /* pr.c */
 extern void pr(char *, ...) ATTRIBUTE((format (printf, 1, 2)));
-extern void uprnf(char *buf /* buf is message text */);
-extern void pr_id(struct player *, int, s_char *, ...)
+extern void uprnf(char *buf);
+extern void pr_id(struct player *, int, char *, ...)
                ATTRIBUTE((format (printf, 3, 4)));
-extern void pr_flash(struct player *, char *format
-                    /* format is message text */, ...)
+extern void pr_flash(struct player *, char *format, ...)
                ATTRIBUTE((format (printf, 2, 3)));
-extern void pr_inform(struct player *, s_char *, ...)
+extern void pr_inform(struct player *, char *, ...)
                ATTRIBUTE((format (printf, 2, 3)));
-extern void pr_wall(s_char *, ...)
+extern void pr_wall(char *, ...)
                ATTRIBUTE((format (printf, 1, 2)));
 extern void pr_player(struct player *pl, int id, s_char *buf);
-extern void upr_player(struct player *pl, int id, char *buf
-                                 /* buf is message text */);
+extern void upr_player(struct player *pl, int id, char *buf);
 extern void pr_hilite(s_char *buf);
-extern void prredir(s_char *redir);
-extern void prexec(s_char *file);
+extern void prredir(char *redir);
+extern void prexec(char *file);
 extern void prprompt(int min, int btu);
 extern int prmptrd(char *prompt, char *str, int size);
-extern int uprmptrd(char *prompt, char *str /* str is message text */,
-                   int size);
+extern int uprmptrd(char *prompt, char *str, int size);
 extern void prdate(void);
-extern void prxy(s_char *format, coord x, coord y, natid country);
-extern void PR(int, s_char *, ...) ATTRIBUTE((format (printf, 2, 3)));
+extern void prxy(char *format, coord x, coord y, natid country);
+extern void PR(int, char *, ...) ATTRIBUTE((format (printf, 2, 3)));
 extern void PRdate(natid cn);
 extern void pr_beep(void);
-extern void mpr(int, s_char *, ...) ATTRIBUTE((format (printf, 2, 3)));
+extern void mpr(int, char *, ...) ATTRIBUTE((format (printf, 2, 3)));
 extern size_t copy_ascii_no_funny(char *, char *);
 extern size_t copy_utf8_no_funny(char *, char *);
 extern size_t copy_utf8_to_ascii_no_funny(char *, char *);
index f7f37eb4349b0d869c3d108db7ffaaa375f152c7..e4103ff0aa788f43079c514e07d799fdb969822f 100644 (file)
@@ -74,7 +74,7 @@ flash(void)
     }
 
     if (player->argp[2]) {
-       for (sp = &player->combuf[0]; *sp && *sp != ' '; ++sp) ;
+       for (sp = player->combuf; *sp && *sp != ' '; ++sp) ;
        for (++sp; *sp && *sp != ' '; ++sp) ;
        buf[0] = ':';
        if (player->flags & PF_UTF8)
@@ -103,7 +103,7 @@ wall(void)
 
     us = getnatp(player->cnum);
     if (player->argp[1]) {
-       for (sp = &player->combuf[0]; *sp && *sp != ' '; ++sp) ;
+       for (sp = player->combuf; *sp && *sp != ' '; ++sp) ;
        buf[0] = ':';
        if (player->flags & PF_UTF8)
            strcpy(buf+1, sp);
@@ -122,23 +122,28 @@ wall(void)
     return RET_OK;
 }
 
+/*
+ * Send flash message MESSAGE from US to TO.
+ * MESSAGE is UTF-8.  Long messages are broken into several parts.
+ * A header identifying US is prepended to each part.  The first
+ * header is more verbose if ONESHOT.
+ */
 int
-sendmessage(struct natstr *us, struct natstr *to, char *message
-           /* message is message text */, int oneshot)
+sendmessage(struct natstr *us, struct natstr *to, char *message, int oneshot)
 {
     struct player *other;
     struct tm *tm;
     time_t now;
     int sent = 0;
     struct natstr *wto;
-    char c; /* c is message text */
+    char c;
     int pos;
 
     pos = ufindpfx(message, 60);
     c = message[pos];
     if (c)
         message[pos] = '\0';
-    
+
     time(&now);
     tm = localtime(&now);
     for (other = player_next(0); other != 0; other = player_next(other)) {
index 0350919b5888878bf5abe2e53f00d2864123407b..51d8b3263c3b6c5eb48b09bb0e3fb191f293e663 100644 (file)
@@ -70,7 +70,7 @@ static int
 play_list(struct player *joe)
 {
     time_t now;
-    char com[1 + 6*20 + 2];    /* user text */
+    char com[1 + 6*20 + 2];    /* UTF-8 */
     struct natstr *natp;
     struct natstr *us;
     int n;
index ccf405c357ac3e4473602e372754ec3af70c9f71..3d942d22fb34fe888057b0c5fd695b9f252ca8b4 100644 (file)
@@ -64,7 +64,7 @@ rea(void)
     int size;
     unsigned int nbytes;
     char buf[1024];
-    char msgbuf[4096];         /* message text */
+    char msgbuf[4096];         /* UTF-8 */
     int lasttype;
     int lastcnum;
     time_t lastdate;
index 20073ee516e9ab357c2595d165e42f8cc1a6abe4..94cbc4cd75764cd931e1faeb13e36ce63044075d 100644 (file)
@@ -47,9 +47,9 @@ shut(void)
     int shutdown_minutes;
     int shutdown_was_pending;
     char buf[1024];
-    s_char msgbuf[100];                /* user text */
+    char msgbuf[100];
     struct natstr *us;
-    s_char *p;
+    char *p;
 
     if (update_pending) {
        pr("Update is pending\n");
index a0a13feb2ce2828beb3e778b156d4a327e9ee7c3..a8da53fd637d0f3726c1b8600e3ededc2de36355 100644 (file)
@@ -46,8 +46,7 @@ tele(void)
 {
     natid to;
     struct natstr *natp;
-    int teltype;
-    s_char buf[MAXTELSIZE + 1];
+    char buf[MAXTELSIZE + 1];  /* UTF-8 */
     int n;
 
     natp = getnatp(player->cnum);
@@ -113,8 +112,7 @@ tele(void)
                pr("%s is rejecting your telegrams.\n", cname(to));
                return RET_SYN;
            }
-           teltype = /* player->god ? TEL_BULLETIN : */ TEL_NORM;
-           if (typed_wu(player->cnum, to, buf, teltype) < 0) {
+           if (typed_wu(player->cnum, to, buf, TEL_NORM) < 0) {
                logerror("tele: typed_wu failed to #%d", n);
                return RET_FAIL;
            }
index d55228aae1fddfe79308ed9f8301c97d5651938b..3e8c13de3f7a525752bf50f229f8d09ae788ca13 100644 (file)
@@ -50,7 +50,7 @@ turn(void)
     struct telstr tgm;
     char *p;
     char buf[1024];
-    char msgbuf[MAXTELSIZE + 1]; /* message text */
+    char msgbuf[MAXTELSIZE + 1]; /* UTF-8 */
     char *msgfilepath;
 
     p = getstarg(player->argp[1], "on, off or motd? ", buf);
index 0938cddfc223e3f395bc926292608b0b1002e309..309183f71f4ac1e74048017a01ce8c942623b196 100644 (file)
@@ -44,19 +44,19 @@ getstring(char *prompt, char *buf)
 {
     *buf = '\0';
     if (prmptrd(prompt, buf, 1024) < 0)
-       return 0;
+       return NULL;
     return buf;
 }
 
 /*
- * Print sub-prompt PROMPT, receive a line of UTF8 input into BUF[1024].
+ * Print sub-prompt PROMPT, receive a line of UTF-8 input into BUF[1024].
  * Return BUF on success, else NULL.
  */
 char *
-ugetstring(char *prompt, char *buf /* buf is message text */)
+ugetstring(char *prompt, char *buf)
 {
     *buf = '\0';
     if (uprmptrd(prompt, buf, 1024) < 0)
-       return 0;
+       return NULL;
     return buf;
 }
index d9551613d0a95a2722bcddc630dc5541fb6b54e1..b29cd4797661144fc639b956d056dbe33d1dd318 100644 (file)
@@ -37,7 +37,7 @@
 
 /*
  * Parse user command in BUF.
- * BUF is user text.
+ * BUF is UTF-8.
  * Set ARG[0] to point to the command name.
  * Set ARG[1..N] to point to arguments, where N is the number of
  * arguments.  Set ARG[N+1..127] to NULL.
@@ -45,9 +45,8 @@
  * set *CONDP to the conditional argument if present, else NULL.
  * Command name and arguments are copied into SPACE[], whose size must
  * be at least strlen(BUF) + 1.
- * If *REDIR is not null, recognize the redirection syntax, and set
- * *REDIR to redirection string if present, else NULL.  The
- * redirection string is user text.
+ * If *REDIR is not null, recognize redirection syntax, and set *REDIR
+ * to UTF-8 redirection string if present, else NULL.
  * Return number of slots used in ARG[], or -1 on error.
  */
 int
index 5d5454ba8987292a616e4d93ff5edb38c370c9b3..3b9fa2e0903745f7b2a5368b8b32096ecb36bfac 100644 (file)
 
 /*
  * Execute command named by player->argp[0].
- * BUF is the raw command line (user text).  It should have been
- * passed to parse() to set up player->argp.
- * If REDIR is not null, it's the command's redirection; it is user
- * text.
+ * BUF is the raw UTF-8 command line.  It should have been passed to
+ * parse() to set up player->argp.
+ * If REDIR is not null, it's the command's redirection, in UTF-8.
  * Return -1 if the command is not unique or doesn't exist, else 0.
  */
 int
index 9ad05d6d4a2df6500ce27305e9686ac379b07718..9a516f91c585392308de20a3385629915ecb0fc3 100644 (file)
@@ -165,7 +165,7 @@ gamedown(void)
 {
     FILE *down_fp;
     struct telstr tgm;
-    char buf[MAXTELSIZE + 1];  /* message text */
+    char buf[MAXTELSIZE + 1];  /* UTF-8 */
 
     if (player->god)
        return 0;
index 88d600b6ac00bf05011038f695783e93f1211e49..abf188784a573389db39be3c6a07a3bfdfac8373 100644 (file)
@@ -158,7 +158,7 @@ int
 command(void)
 {
     unsigned int x;
-    char *redir;
+    char *redir;               /* UTF-8 */
     char scanspace[1024];
 
     if (getcommand(player->combuf) < 0)
@@ -306,18 +306,20 @@ execute(void)
     char buf[1024];
     int failed;
     char *p;
-    char *redir;
+    char *redir;               /* UTF-8 */
     char scanspace[1024];
 
     failed = 0;
-    redir = 0;
+    redir = NULL;
 
     p = getstarg(player->argp[1], "File? ", buf);
 
     if (p == NULL || *p == '\0')
        return RET_SYN;
 
+    /* FIXME should use raw argument here, to support UTF-8 file names */
     prexec(player->argp[1]);
+
     while (!failed && status()) {
        if (recvclient(buf, sizeof(buf)) < 0)
            break;
@@ -326,7 +328,7 @@ execute(void)
            failed = 1;
            continue;
        }
-       if (redir == 0)
+       if (redir == NULL)
            pr("\nExecute : %s\n", buf);
        if (dispatch(buf, redir) < 0)
            failed = 1;
@@ -334,7 +336,7 @@ execute(void)
     if (failed) {
        while (recvclient(buf, sizeof(buf)) >= 0) ;
     }
-    if (redir == 0)
+    if (redir == NULL)
        pr("Execute : %s\n", failed ? "aborted" : "terminated");
     return RET_OK;
 }
@@ -344,7 +346,7 @@ show_motd(void)
 {
     FILE *motd_fp;
     struct telstr tgm;
-    char buf[MAXTELSIZE + 1];  /* message text */
+    char buf[MAXTELSIZE + 1];  /* UTF-8 */
 
     if ((motd_fp = fopen(motdfil, "rb")) == NULL) {
        if (errno == ENOENT)
index 1fe4825a7415c976695b231db96e2d7524477c18..8e1a6192203203aefdfecdb8f5cd55d034b95856 100644 (file)
 static int tilde_escape(char *s);
 
 /*
- * Read a telegram for RECIPIENT into BUF.
+ * Read a telegram for RECIPIENT into BUF, in UTF-8.
  * BUF must have space for MAXTELSIZE+1 characters.
  * Return telegram length, or -1 on error.
- * Note: telegrams are message text (see doc/unicode).
  */
 int
 getele(char *recipient, char *buf)
 {
     char *bp;
     size_t len;
-    char buffer[MAXTELSIZE + 2]; /* message text */
+    char buffer[MAXTELSIZE + 2]; /* UTF-8 */
     char left[16];
 
     pr("Enter telegram for %s\n", recipient);
index 9c84549f74ed23dcebbdc42225a37196a62f52a6..8a4e72800325376f5782b662a1ae379b7a26811d 100644 (file)
 
 static void outid(struct player *pl, int n);
 
-/*VARARGS*/
+/*
+ * Print to current player similar to printf().
+ * Use printf-style FORMAT with the optional arguments.
+ * Note: `to print' without further qualifications means sending
+ * C_DATA text.
+ */
 void
 pr(char *format, ...)
 {
@@ -68,8 +73,10 @@ pr(char *format, ...)
     (void)vsprintf(buf, format, ap);
     va_end(ap);
     if (player->flags & PF_UTF8)
+       /* normal text needs to be converted to user text */
        upr_player(player, C_DATA, buf);
     else
+       /* normal text and user text are identical */
         pr_player(player, C_DATA, buf);
 }
 
@@ -90,11 +97,19 @@ uprnf(char *buf)
        pr_player(player, C_DATA, buf);
 }
 
-/*VARARGS*/
+/*
+ * Send some text to P with id ID, line-buffered.
+ * Format text to send using printf-style FORMAT and optional
+ * arguments.  It is assumed to be already user text.  Plain ASCII and
+ * text received from the same player are fine, for anything else the
+ * caller has to deal with output filtering.
+ * If a partial line with different id is buffered, terminate it with
+ * a newline first.
+ */
 void
-pr_id(struct player *p, int id, s_char *format, ...)
+pr_id(struct player *p, int id, char *format, ...)
 {
-    s_char buf[4096];
+    char buf[4096];
     va_list ap;
 
     if (p->curid >= 0) {
@@ -107,11 +122,15 @@ pr_id(struct player *p, int id, s_char *format, ...)
     pr_player(p, id, buf);
 }
 
+/*
+ * Send C_FLASH text to PL.
+ * Format text to send using printf-style FORMAT and optional
+ * arguments.  It is assumed to be UTF-8.
+ */
 void
-pr_flash(struct player *pl, char *format
-        /* format is message text */, ...)
+pr_flash(struct player *pl, char *format, ...)
 {
-    char buf[4096]; /* buf is message text */
+    char buf[4096];            /* UTF-8 */
     va_list ap;
 
     if (pl->state != PS_PLAYING)
@@ -125,10 +144,15 @@ pr_flash(struct player *pl, char *format
     io_output(pl->iop, IO_NOWAIT);
 }
 
+/*
+ * Send C_INFORM text to PL.
+ * Format text to send using printf-style FORMAT and optional
+ * arguments.  It is assumed to be plain ASCII.
+ */
 void
-pr_inform(struct player *pl, s_char *format, ...)
+pr_inform(struct player *pl, char *format, ...)
 {
-    s_char buf[4096];
+    char buf[4096];
     va_list ap;
 
     if (pl->state != PS_PLAYING)
@@ -140,10 +164,15 @@ pr_inform(struct player *pl, s_char *format, ...)
     io_output(pl->iop, IO_NOWAIT);
 }
 
+/*
+ * Send C_FLASH text to everyone.
+ * Format text to send using printf-style FORMAT and optional
+ * arguments.  It is assumed to be plain ASCII.
+ */
 void
-pr_wall(s_char *format, ...)
+pr_wall(char *format, ...)
 {
-    s_char buf[4096];
+    char buf[4096];            /* UTF-8 */
     struct player *p;
     va_list ap;
 
@@ -158,12 +187,18 @@ pr_wall(s_char *format, ...)
     }
 }
 
+/*
+ * Send ID text BUF to PL, line-buffered.
+ * BUF is user text.
+ * If a partial line with different id is buffered, terminate it with
+ * a newline first.
+ */
 void
-pr_player(struct player *pl, int id, s_char *buf)
+pr_player(struct player *pl, int id, char *buf)
 {
-    register s_char *p;
-    register s_char *bp;
-    register int len;
+    char *p;
+    char *bp;
+    int len;
 
     bp = buf;
     while (*bp != '\0') {
@@ -174,7 +209,7 @@ pr_player(struct player *pl, int id, s_char *buf)
        if (pl->curid == -1)
            outid(pl, id);
        p = strchr(bp, '\n');
-       if (p != 0) {
+       if (p != NULL) {
            len = (p - bp) + 1;
            if (pl->command && (pl->command->c_flags & C_MOD))
                io_write(pl->iop, bp, len, IO_NOWAIT);
@@ -189,13 +224,17 @@ pr_player(struct player *pl, int id, s_char *buf)
     }
 }
 
+/*
+ * Send ID text BUF to PL, line-buffered.
+ * If a partial line with different id is buffered, terminate it with
+ * a newline first.
+ */
 void
-upr_player(struct player *pl, int id, char *buf
-                      /* buf is message text */)
+upr_player(struct player *pl, int id, char *buf)
 {
-    register char *bp; /* bp is message text */
-    register int standout = 0;
-    char printbuf[2]; /* bp is message text */
+    char *bp;
+    int standout = 0;
+    char printbuf[2];
     char ch;
 
     printbuf[0] = '\0';
@@ -258,7 +297,8 @@ pr_hilite(s_char *buf)
 }
 
 /*
- * output hex code + space
+ * Send id N to PL.
+ * This runs always at the beginning of a line.
  */
 static void
 outid(struct player *pl, int n)
@@ -278,58 +318,89 @@ outid(struct player *pl, int n)
     pl->curid = n;
 }
 
+/*
+ * Send redirection request REDIR to the current player.
+ * REDIR is UTF-8, but non-ASCII characters can occur only if the
+ * player sent them.  Therefore, it is also user text.
+ */
 void
-prredir(s_char *redir)
+prredir(char *redir)
 {
     pr_id(player, *redir == '>' ? C_REDIR : C_PIPE, "%s\n", redir);
 }
 
+/*
+ * Send script execute request FILE to the current player.
+ * REDIR is UTF-8, but non-ASCII characters can occur only if the
+ * player sent them.  Therefore, it is also user text.
+ */
 void
-prexec(s_char *file)
+prexec(char *file)
 {
     pr_id(player, C_EXECUTE, "%s\n", file);
 }
 
+/*
+ * Send a command prompt to the current player.
+ */
 void
 prprompt(int min, int btu)
 {
     pr_id(player, C_PROMPT, "%d %d\n", min, btu);
 }
 
+/*
+ * Prompt for a line of non-command input.
+ * Send C_FLUSH prompt PROMPT to the current player.
+ * Read a line of input into BUF[SIZE] and convert it to ASCII.
+ * Return number of bytes in BUF[], not counting the terminating 0,
+ * or -1 on error.
+ */
 int
-prmptrd(char *prompt, char *str, int size)
+prmptrd(char *prompt, char *buf, int size)
 {
     int r;
     char *cp;
 
     pr_id(player, C_FLUSH, "%s\n", prompt);
-    if ((r = recvclient(str, size)) < 0)
+    if ((r = recvclient(buf, size)) < 0)
        return r;
     time(&player->curup);
-    if (*str == 0)
+    if (*buf == 0)
        return 1;
     if (player->flags & PF_UTF8)
-       return copy_utf8_to_ascii_no_funny(str, str);
-    return copy_ascii_no_funny(str, str);
+       return copy_utf8_to_ascii_no_funny(buf, buf);
+    return copy_ascii_no_funny(buf, buf);
 }
 
+/*
+ * Prompt for a line of non-command, UTF-8 input.
+ * Send C_FLUSH prompt PROMPT to the current player.
+ * Read a line of input into BUF[SIZE], replacing funny characters by
+ * '?'.  The result is UTF-8.
+ * Return number of bytes in BUF[], not counting the terminating 0,
+ * or -1 on error.
+ */
 int
-uprmptrd(char *prompt, char *str /* str is message text */, int size)
+uprmptrd(char *prompt, char *buf, int size)
 {
     int r;
-    char *cp; /* cp is message text */
+    char *cp;
 
     pr_id(player, C_FLUSH, "%s\n", prompt);
-    if ((r = recvclient(str, size)) < 0)
+    if ((r = recvclient(buf, size)) < 0)
        return r;
     time(&player->curup);
-    if (*str == 0)
+    if (*buf == 0)
        return 1;
     if (player->flags & PF_UTF8)
-       return copy_utf8_no_funny(str, str);
-    return copy_ascii_no_funny(str, str);
+       return copy_utf8_no_funny(buf, buf);
+    return copy_ascii_no_funny(buf, buf);
 }
 
+/*
+ * Print the current time in ctime() format.
+ */
 void
 prdate(void)
 {
@@ -340,12 +411,14 @@ prdate(void)
 }
 
 /*
- * print x,y formatting as country
+ * Print coordinates X, Y for COUNTRY.
+ * FORMAT must be a printf-style format string that converts exactly
+ * two int values.
  */
 void
-prxy(s_char *format, coord x, coord y, natid country)
+prxy(char *format, coord x, coord y, natid country)
 {
-    s_char buf[255];
+    char buf[255];
     struct natstr *np;
 
     np = getnatp(country);
@@ -353,15 +426,23 @@ prxy(s_char *format, coord x, coord y, natid country)
     pr(buf);
 }
 
-/*VARARGS*/
+/*
+ * Print to country CN similar to printf().
+ * Use printf-style FORMAT with the optional arguments.
+ * Output is buffered until a newline arrives.
+ * If CN is the current player, print just like pr().
+ * Else print into a bulletin.
+ * Because printing like pr() requires normal text, and bulletins
+ * require user text, only plain ASCII is allowed.
+ */
 void
-PR(int cn, s_char *format, ...)
+PR(int cn, char *format, ...)
 {
     /* XXX should really do this on a per-nation basis */
-    static s_char longline[MAXNOC][512];
+    static char longline[MAXNOC][512];
     int newline;
     va_list ap;
-    s_char buf[1024];
+    char buf[1024];
 
     va_start(ap, format);
     (void)vsprintf(buf, format, ap);
@@ -377,6 +458,11 @@ PR(int cn, s_char *format, ...)
     }
 }
 
+/*
+ * Print the current time in ctime() format to country CN.
+ * If CN is the current player, print like prdate().
+ * Else print into a bulletin.
+ */
 void
 PRdate(natid cn)
 {
@@ -386,6 +472,9 @@ PRdate(natid cn)
     PR(cn, ctime(&now));
 }
 
+/*
+ * Sound the current player's bell.
+ */
 void
 pr_beep(void)
 {
@@ -395,10 +484,18 @@ pr_beep(void)
        pr("\07");
 }
 
+/*
+ * Print to country CN similar to printf().
+ * Use printf-style FORMAT with the optional arguments.
+ * If CN is the current player, print just like pr().
+ * Else print into a bulletin.
+ * Because printing like pr() requires normal text, and bulletins
+ * require user text, only plain ASCII is allowed.
+ */
 void
-mpr(int cn, s_char *format, ...)
+mpr(int cn, char *format, ...)
 {
-    s_char buf[4096];
+    char buf[4096];
     va_list ap;
 
     va_start(ap, format);
index 21377d365030937d6675c272636a852ceaa9a815..b92e74c3b981172159e1309bc24ae959997ec9b8 100644 (file)
@@ -80,8 +80,8 @@ telegram_is_new(natid to, struct telstr *tel)
 
 /*
  * Send a telegram from FROM to TO.
- * Format text to send under control of printf-style FORMAT using
- * optional arguments.  It is plain ASCII.
+ * Format text to send using printf-style FORMAT and optional
+ * arguments.  It is plain ASCII.
  * If running from the update, telegram type is TEL_UPDATE.
  * Else if FROM is a deity, type is TEL_BULLETIN.
  * Else it is TEL_NORM.
@@ -108,7 +108,7 @@ wu(natid from, natid to, char *format, ...)
 
 /*
  * Send a telegram from FROM to TO.
- * MESSAGE is the text to send, encoded as message text.
+ * MESSAGE is the text to send, in UTF-8.
  * TYPE is the telegram type.
  * Return 0 on success, -1 on error.
  */