Blame portability/error.c

Packit b802ec
 /*
Packit b802ec
   Linux error(3) function go around for systems that has err(3) and
Packit b802ec
   warn(3), but no error(3).  MacOS is good example of such.
Packit b802ec
Packit b802ec
   The GNU C Library is free software; you can redistribute it and/or
Packit b802ec
   modify it under the terms of the GNU Lesser General Public
Packit b802ec
   License as published by the Free Software Foundation version 2.
Packit b802ec
Packit b802ec
   The GNU C Library is distributed in the hope that it will be useful,
Packit b802ec
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit b802ec
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit b802ec
   Lesser General Public License for more details.
Packit b802ec
Packit b802ec
   You should have received a copy of the GNU Lesser General Public
Packit b802ec
   License along with the GNU C Library; if not, write to the Free
Packit b802ec
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
Packit b802ec
   02111-1307 USA.
Packit b802ec
*/
Packit b802ec
Packit b802ec
#include <stdarg.h>
Packit b802ec
#include <err.h>
Packit b802ec
Packit b802ec
void error(int status, int errnum, const char *format, ...) {
Packit b802ec
  va_list arg;
Packit b802ec
Packit b802ec
  va_start(arg, format);
Packit b802ec
  if (errnum == 0) {
Packit b802ec
    if (status == 0)
Packit b802ec
      vwarnx(format, arg);
Packit b802ec
    else
Packit b802ec
      verrx(status, format, arg);
Packit b802ec
  } else {
Packit b802ec
    if (status == 0)
Packit b802ec
      vwarn(format, arg);
Packit b802ec
    else
Packit b802ec
      verr(status, format, arg);
Packit b802ec
  }
Packit b802ec
  va_end(arg);
Packit b802ec
}