Add a debugging function that prints a message and appends the

current strerror.
This commit is contained in:
Hartmut Brandt 2005-03-08 07:47:14 +00:00
parent a0aea18e18
commit 1753d0e6a4
2 changed files with 24 additions and 0 deletions

View File

@ -85,6 +85,24 @@ Debug(const char *fmt, ...)
fflush(stderr);
}
/*-
* Print a debugging message given its format and append the current
* errno description. Terminate with a newline.
*/
/* VARARGS */
void
DebugM(const char *fmt, ...)
{
va_list ap;
int e = errno;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
fprintf(stderr, ": %s\n", strerror(e));
va_end(ap);
fflush(stderr);
}
/*-
* Error --
* Print an error message given its format.

View File

@ -70,11 +70,17 @@ do { \
Debug args ; \
} \
} while (0)
#define DEBUGM(module, args) do { \
if (DEBUG(module)) { \
DebugM args; \
} \
} while (0)
#define ISDOT(c) ((c)[0] == '.' && (((c)[1] == '\0') || ((c)[1] == '/')))
#define ISDOTDOT(c) ((c)[0] == '.' && ISDOT(&((c)[1])))
void Debug(const char *, ...);
void DebugM(const char *, ...);
void Error(const char *, ...);
void Fatal(const char *, ...) __dead2;
void Punt(const char *, ...) __dead2;