File: err.c

package info (click to toggle)
zsv 1.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 49,160 kB
  • sloc: ansic: 175,811; cpp: 56,301; sh: 3,623; makefile: 3,048; javascript: 577; cs: 90; awk: 70; python: 41; sql: 15
file content (24 lines) | stat: -rw-r--r-- 567 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
/*
 * Copyright (C) 2021 Liquidaty and the zsv/lib contributors
 * All rights reserved
 *
 * This file is part of zsv/lib, distributed under the license defined at
 * https://opensource.org/licenses/MIT
 */

#include <stdio.h>
#include <stdarg.h>

int zsv_app_printerr(const char *appname, int eno, const char *fmt, ...) {
  if (appname && *appname)
    fprintf(stderr, "(%s) %i: ", appname, eno);
  else
    fprintf(stderr, "%i: ", eno);

  va_list argv;
  va_start(argv, fmt);
  vfprintf(stderr, fmt, argv);
  va_end(argv);
  fprintf(stderr, "\n");
  return eno;
}