Author: Kev <klmitch@mit.edu>
authorKevin L. Mitchell <klmitch@mit.edu>
Tue, 25 Apr 2000 20:33:50 +0000 (20:33 +0000)
committerKevin L. Mitchell <klmitch@mit.edu>
Tue, 25 Apr 2000 20:33:50 +0000 (20:33 +0000)
Log message:

document new %C modifiers and define a new %H modifier for channels for
possible future expansion (say, numeric channel names?)

git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@203 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
include/ircd_snprintf.h
ircd/ircd_snprintf.c

index c6ad9fc15f266d4d511030061f1e4a114af03f3b..439769e39e736d6b8e6990c4a71c2b981c15ae48 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2000-04-25  Kevin L. Mitchell  <klmitch@mit.edu>
 
+       * ircd/ircd_snprintf.c (doprintf): implement %H for possible
+       future expansion (channel numerics?)
+
+       * include/ircd_snprintf.h: added documentation to # to explain use
+       with %C; added documentation for : to explain use with %C; added
+       documentation for %H for channels
+
        * ircd/whocmds.c: use send_reply
 
        * ircd/userload.c: use sendcmdto_one
 #
 # ChangeLog for ircu2.10.11
 #
-# $Id: ChangeLog,v 1.101 2000-04-25 20:22:25 kev Exp $
+# $Id: ChangeLog,v 1.102 2000-04-25 20:33:50 kev Exp $
 #
 # Insert new changes at beginning of the change list.
 #
index 28bcc5cce4eb5c5e262cc63af80e5ceeca0eb6ac..5fa984e7d77e2c3eb4500e9216bbb3fde1e65961 100644 (file)
@@ -108,7 +108,9 @@ extern int ircd_vsnprintf(struct Client *dest, char *buf, size_t buf_len,
 **     (normally, a decimal point appears in the results of those
 **     conversions only if a digit follows).  For g and G
 **     conversions, trailing zeros are not removed from the result as
-**     they would otherwise be.
+**     they would otherwise be.  For C conversions, if the
+**     destination is local and the origin is a user, the
+**     nick!user@host form is used.
 **
 **   0 specifying zero padding.  For all conversions except n, the
 **     converted value is padded on the left with zeros rather than
@@ -129,6 +131,9 @@ extern int ircd_vsnprintf(struct Client *dest, char *buf, size_t buf_len,
 **     produced by a signed conversion.  A + overrides a space if
 **     both are used.
 **
+**   : specifying that a struct Client name should be preceded by a
+**     ':' character if the destination is a user
+**
 ** * An optional decimal digit string specifying a minimum field
 **   width.  If the converted value has fewer characters than the
 **   field width, it will be padded with spaces on the left (or right,
@@ -256,6 +261,9 @@ extern int ircd_vsnprintf(struct Client *dest, char *buf, size_t buf_len,
 **             is printed; otherwise, the client's network numeric is
 **             printed.
 **
+** H           The channel argument identifier (channel name) is
+**             printed.
+**
 ** v           The argument given must be a pointer to a struct
 **             VarData with vd_format and vd_args must be initialized
 **             appropriately.  On return, vd_chars will contain the
index 69d7db125cfeaaf605ee2f5b6c04a2ca7d0dc100..01579a6b9d4ecbc08deb65248c5f81e0abf5afd4 100644 (file)
@@ -163,9 +163,9 @@ struct FieldData {
 #define CONV_STRING    0x04000000      /* convert strings */
 #define CONV_VARARGS   0x05000000      /* convert a %v */
 #define CONV_CLIENT    0x06000000      /* convert a struct Client */
+#define CONV_CHANNEL   0x07000000      /* convert a struct Channel */
 
-#define CONV_RESERVED8 0x07000000      /* reserved for future expansion */
-#define CONV_RESERVED7 0x08000000
+#define CONV_RESERVED7 0x08000000      /* reserved for future expansion */
 #define CONV_RESERVED6 0x09000000
 #define CONV_RESERVED5 0x0a000000
 #define CONV_RESERVED4 0x0b000000
@@ -1739,6 +1739,12 @@ doprintf(struct Client *dest, struct BufData *buf_p, const char *fmt,
        fld_s.flags |= ARG_PTR | CONV_CLIENT;
        break;
 
+      case 'H': /* convert a channel name... */
+       fld_s.flags &= ~(FLAG_PLUS | FLAG_SPACE | FLAG_ALT | FLAG_ZERO |
+                        FLAG_COLON | TYPE_MASK);
+       fld_s.flags |= ARG_PTR | CONV_CHANNEL;
+       break;
+
       default: /* Unsupported, display a message and the entire format */
        adds(buf_p, -1, "(Unsupported: %");
        adds(buf_p, fmt - fstart + 1, fstart);
@@ -2054,6 +2060,21 @@ doprintf(struct Client *dest, struct BufData *buf_p, const char *fmt,
       if (str3)
        adds(buf_p, slen3, str3);
 
+      if (plen > 0 &&  (fld_s.flags & FLAG_MINUS))
+       do_pad(buf_p, plen, spaces); /* post-padding */
+    } else if ((fld_s.flags & CONV_MASK) == CONV_CHANNEL) {
+      struct Channel *chan = (struct Channel *)fld_s.value.v_ptr;
+      char *str = chan->chname;
+      int slen, plen;
+
+      slen = my_strnlen(str, fld_s.prec); /* str lengths and pad lengths */
+      plen = (fld_s.width - slen <= 0 ? 0 : fld_s.width - slen);
+
+      if (plen > 0 && !(fld_s.flags & FLAG_MINUS))
+       do_pad(buf_p, plen, spaces); /* pre-padding */
+
+      adds(buf_p, slen, str); /* add the string */
+
       if (plen > 0 &&  (fld_s.flags & FLAG_MINUS))
        do_pad(buf_p, plen, spaces); /* post-padding */
     }