예제 #1
0
static char *error_str(int e, char *(*error_itoa)(int), char *buf, size_t len)
{
  char *str;

  if(error_itoa == NULL || (str = error_itoa(e)) == NULL)
    {
      buf[0] = '\0';
      return buf;
    }

  snprintf(buf, len, ": %s", str);
  return buf;
}
예제 #2
0
/*
 * print a diagnostic error message to stdout, unless the -n option is in use:
 * then we print ERR and leave it at that.  if a user wants more info than
 * ERR they should run ipmp_ping without the -n flag and see what is causing
 * the error to occur
 */
static void printerror(int ecode, char *(*error_itoa)(int), char *format, ...)
{
  char     message[512];
  char    *error_str = NULL;
  va_list  ap;

  va_start(ap, format);
  vsnprintf(message, sizeof(message), format, ap);
  va_end(ap);
  
  if(error_itoa != NULL)
    {
      error_str = error_itoa(ecode);
    }

  if(error_str != NULL) fprintf(stderr, "%s: %s\n", message, error_str);
  else                  fprintf(stderr, "%s\n", message);

  return;
}