1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-01-03 20:34:14 +01:00

- Added a global var WErrorCode similar to errno or RErrorCode.

- New function wsyserrorwithcode(), like wsyserror() for prints the message
  for the specified error code, instead of errno. This is for cases where
  you can't call wsyserror() immediately after the error, but save errno
  code for a later use.
This commit is contained in:
dan
1999-12-12 04:17:18 +00:00
parent adaa3e0aeb
commit 9e47eba187
3 changed files with 46 additions and 0 deletions

View File

@@ -29,6 +29,10 @@
extern char *_WINGS_progname;
int WErrorCode = 0;
#define MAXLINE 1024
@@ -142,3 +146,33 @@ wsyserror(const char *msg, ...)
va_end(args);
}
/*********************************************************************
* Prints a system error message with variable arguments, being given
* the error code.
*
* error - the error code foe which to print the message
* msg - message to print with optional formatting
* ... - arguments to use on formatting
*********************************************************************/
void
wsyserrorwithcode(int error, const char *msg, ...)
{
va_list args;
char buf[MAXLINE];
va_start(args, msg);
vsprintf(buf, msg, args);
fflush(stdout);
fputs(_WINGS_progname, stderr);
fputs(" error: ", stderr);
strcat(buf, ": ");
strcat(buf, wstrerror(error));
strcat(buf,"\n");
fputs(buf, stderr);
fflush(stderr);
fflush(stdout);
va_end(args);
}