File: message.c

package info (click to toggle)
twoftpd 1.14-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,556 kB
  • ctags: 901
  • sloc: ansic: 6,685; makefile: 321; sh: 175
file content (33 lines) | stat: -rw-r--r-- 814 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include "iobuf/iobuf.h"
#include "err.h"

static pid_t pid = 0;

void err_message(const char* type,
		 const char* a, const char* b, const char* c,
		 const char* d, const char* e, const char* f,
		 int showsys)
{
  if (!pid) pid = getpid();
  obuf_puts(&errbuf, program);
  obuf_putc(&errbuf, '[');
  obuf_putu(&errbuf, pid);
  obuf_puts(&errbuf, "]: ");
  obuf_puts(&errbuf, type);
  obuf_puts(&errbuf, ": ");
  if (a) obuf_puts(&errbuf, a);
  if (b) obuf_puts(&errbuf, b);
  if (c) obuf_puts(&errbuf, c);
  if (d) obuf_puts(&errbuf, d);
  if (e) obuf_puts(&errbuf, e);
  if (f) obuf_puts(&errbuf, f);
  if (showsys) {
    obuf_puts(&errbuf, ": ");
    obuf_puts(&errbuf, strerror(errno));
  }
  obuf_putsflush(&errbuf, "\n");
}