static void cmd_list(void) { long i; respond(ok); for (i = 0; i < msg_count; i++) { if (!msgs[i].deleted) { obuf_putu(&outbuf, i+1); obuf_putc(&outbuf, SPACE); obuf_putu(&outbuf, msgs[i].size); obuf_puts(&outbuf, CRLF); } } respond("."); }
void init_stream(stream* s) { obuf_putstream(&outbuf, s, "init ident("); obuf_putu(&outbuf, s->identlen); obuf_puts(&outbuf, ")='"); obuf_write(&outbuf, s->ident, s->identlen); obuf_puts(&outbuf, "'\n"); }
void touch_run_file(void) { obuf out; if (!obuf_open(&out, opt_run_file, OBUF_CREATE|OBUF_TRUNCATE, 0666, 0) || !obuf_putu(&out, now) || !obuf_close(&out)) die1sys(111, "Could not update run file"); }
void test(long long num, unsigned width, char pad) { char buf[FMT_ULONG_LEN]; obuf_putu(&outbuf, fmt_slldecw(0, num, width, pad)); obuf_putc(&outbuf, ':'); buf[fmt_sdecw(buf, num, width, pad)] = 0; obuf_puts(&outbuf, buf); NL(); }
static void respond_okstr(const str* s) { obuf_putu(&outbuf, s->len + 1); obuf_putc(&outbuf, ':'); obuf_putc(&outbuf, 'K'); obuf_putstr(&outbuf, s); obuf_putc(&outbuf, ','); obuf_flush(&outbuf); exit(0); }
static void test(unsigned (*fn)(char*, unsigned long, unsigned, char), unsigned long num, unsigned width, char pad) { char buf[FMT_ULONG_LEN]; obuf_putu(&outbuf, fn(0, num, width, pad)); obuf_putc(&outbuf, ':'); buf[fn(buf, num, width, pad)] = 0; obuf_puts(&outbuf, buf); NL(); }
void log_start(const char* tagstr) { obuf_puts(&errbuf, program); obuf_putc(&errbuf, '['); obuf_putu(&errbuf, getpid()); obuf_puts(&errbuf, "]: "); if (tagstr) { obuf_puts(&errbuf, tagstr); obuf_putc(&errbuf, ' '); } }
static void cmd_uidl(void) { long i; respond(ok); for (i = 0; i < msg_count; i++) { msg* m = &msgs[i]; if (!m->deleted) { const char* fn = m->filename + 4; obuf_putu(&outbuf, i+1); obuf_putc(&outbuf, SPACE); obuf_write(&outbuf, fn, m->uid_len); obuf_puts(&outbuf, CRLF); } } respond("."); }
void append_stream(stream* s, const char* buf, uint32 reclen) { obuf_putstream(&outbuf, s, "append bytes "); obuf_putu(&outbuf, reclen); obuf_putc(&outbuf, LF); }
static void u(const char* name, unsigned long value) { obuf_puts(&outbuf, name); obuf_putu(&outbuf, value); obuf_endl(&outbuf); }