File: utils.c

package info (click to toggle)
termrec 0.19-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,148 kB
  • sloc: ansic: 8,430; makefile: 181; perl: 16; sh: 15
file content (28 lines) | stat: -rw-r--r-- 483 bytes parent folder | download | duplicates (4)
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
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include "error.h"

void die(const char *txt, ...)
{
    va_list ap;
    char *nl;
    int err=errno;

    va_start(ap, txt);
    vfprintf(stderr, txt, ap);
    va_end(ap);

    nl=strrchr(txt, '\n');
    if (!nl || nl[1])
    {
        if (err)
            fprintf(stderr, ": %s\n", strerror(err));
        else
            fprintf(stderr, ": unknown error\n");
    }

    exit(1);
}