File: out.h

package info (click to toggle)
sn 0.3.4a-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 784 kB
  • ctags: 826
  • sloc: ansic: 9,023; sh: 339; makefile: 208
file content (34 lines) | stat: -rw-r--r-- 1,002 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
34
/*
 * This file is part of the sn package.
 * Distribution of sn is covered by the GNU GPL. See file COPYING.
 * Copyright  1998-2000 Harold Tay.
 * Copyright  2000- Patrik Rdman.
 */

#ifndef OUT_H
#define OUT_H

#include <stdarg.h>

/*
 * General functions for output.
 * progname, if set, is prepended to each message written with log()
 * or fail().  All calls end in a write, so no buffer flushing problems.
 * writef() works like fprintf(3), writefv() like vfprintf(3); not
 * all conversion specs are supported.  %m is supported, and is the
 * string obtained from strerror(errno).
 * writes() writes a null terminated string.
 */

extern char *progname;

extern void logv (char *fmt, va_list ap);
extern void log (char *fmt, ...);
extern void fail (int ex, char *fmt, ...);
extern int writefv (int fd, char *fmt, va_list ap);
extern int writef (int fd, char *fmt, ...);

#define writes(fd, str) \
   write(fd, str, (sizeof (str) != sizeof (char *)) ? sizeof (str) - 1 : strlen(str))

#endif