From: Kevin L. Mitchell Date: Tue, 25 Apr 2000 20:33:50 +0000 (+0000) Subject: Author: Kev X-Git-Url: http://git.pk910.de/?a=commitdiff_plain;h=53c57c48cfb6ed24d6f82bbcb49c7aacd6a943e7;p=ircu2.10.12-pk.git Author: Kev 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 --- diff --git a/ChangeLog b/ChangeLog index c6ad9fc..439769e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2000-04-25 Kevin L. Mitchell + * 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 @@ -721,7 +728,7 @@ # # 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. # diff --git a/include/ircd_snprintf.h b/include/ircd_snprintf.h index 28bcc5c..5fa984e 100644 --- a/include/ircd_snprintf.h +++ b/include/ircd_snprintf.h @@ -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 diff --git a/ircd/ircd_snprintf.c b/ircd/ircd_snprintf.c index 69d7db1..01579a6 100644 --- a/ircd/ircd_snprintf.c +++ b/ircd/ircd_snprintf.c @@ -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 */ }