*
* $Id$
*/
+#include "config.h"
+
#include "client.h"
+#include "channel.h"
#include "ircd_snprintf.h"
#include "struct.h"
#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
{
int overflow = 0;
- while (*s && s_len) { /* while the string exists and has non-zero length */
+ /* while the string exists and has non-zero length */
+ while (s_len && *s)
+ {
/* poor man's inlining; see addc(), above */
if (buf_p->limit == 0) { /* We've gone past the limit... */
buf_p->overflow++;
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);
vdata->vd_overflow = SNP_MAX(buf_s.buf_overflow, buf_s.overflow);
} else if ((fld_s.flags & CONV_MASK) == CONV_CLIENT) {
struct Client *cptr = (struct Client*) fld_s.value.v_ptr;
- char *str1 = 0, *str2 = 0, *str3 = 0;
+ const char *str1 = 0, *str2 = 0, *str3 = 0;
int slen1 = 0, slen2 = 0, slen3 = 0, elen = 0, plen = 0;
/* &me is used if it's not a definite server */
if (dest && (IsServer(dest) || IsMe(dest))) {
if (IsServer(cptr) || IsMe(cptr))
- str1 = cptr->yxx;
+ str1 = cli_yxx(cptr);
else {
- str1 = cptr->user->server->yxx;
- str2 = cptr->yxx;
+ str1 = cli_yxx(cli_user(cptr)->server);
+ str2 = cli_yxx(cptr);
}
fld_s.flags &= ~(FLAG_ALT | FLAG_COLON);
} else {
- str1 = *cptr->name ? cptr->name : "*";
+ str1 = *cli_name(cptr) ? cli_name(cptr) : "*";
if (!IsServer(cptr) && !IsMe(cptr) && fld_s.flags & FLAG_ALT) {
- assert(0 != cptr->user);
- assert(0 != *cptr->name);
- str2 = cptr->user->username;
- str3 = cptr->user->host;
+ assert(0 != cli_user(cptr));
+ assert(0 != *(cli_name(cptr)));
+ str2 = cli_user(cptr)->username;
+ str3 = cli_user(cptr)->host;
} else
fld_s.flags &= ~FLAG_ALT;
}
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 */
}