mirror of
https://frontier.innolan.net/rainlance/amiga-ntimed.git
synced 2025-11-20 08:09:33 +00:00
Removed va_copy & cleaned up
This commit is contained in:
4
atimed.h
4
atimed.h
@ -81,10 +81,6 @@ typedef uint32_t register_t;
|
||||
#define AF_INET6 10
|
||||
#endif
|
||||
|
||||
#ifndef va_copy
|
||||
#define va_copy(dst, src) memcpy(&(dst), &(src), sizeof(va_list))
|
||||
#endif
|
||||
|
||||
#ifndef _ALIGNBYTES
|
||||
#define _ALIGNBYTES (sizeof(register_t) - 1)
|
||||
#define ALIGN(p) (((uintptr_t)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
|
||||
|
||||
41
ocx_stdio.c
41
ocx_stdio.c
@ -63,7 +63,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include "ntimed.h"
|
||||
|
||||
@ -83,23 +82,6 @@ getdst(enum ocx_chan chan)
|
||||
NEEDLESS_RETURN(NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
putv(struct ocx *ocx, enum ocx_chan chan, const char *fmt, va_list ap)
|
||||
{
|
||||
FILE *dst = getdst(chan);
|
||||
va_list ap2;
|
||||
|
||||
va_copy(ap2, ap);
|
||||
AZ(ocx);
|
||||
if (dst != NULL) {
|
||||
(void)vfprintf(dst, fmt, ap);
|
||||
fflush(dst);
|
||||
}
|
||||
// if (chan == OCX_DIAG)
|
||||
// vsyslog(LOG_ERR, fmt, ap2);
|
||||
va_end(ap2);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
* XXX: take strftime format string to chop tracefiles in time.
|
||||
*/
|
||||
@ -124,13 +106,12 @@ ArgTracefile(const char *fn)
|
||||
tracefile = fopen(fn, "w");
|
||||
if (tracefile == NULL)
|
||||
Fail(NULL, 1, "Could not open '%s' for writing", fn);
|
||||
setbuf(tracefile, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
EnableDebug()
|
||||
{
|
||||
debugfile = stdout;
|
||||
debugfile = stdout;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
@ -141,11 +122,18 @@ EnableDebug()
|
||||
void
|
||||
Put(struct ocx *ocx, enum ocx_chan chan, const char *fmt, ...)
|
||||
{
|
||||
FILE *dst;
|
||||
va_list ap;
|
||||
|
||||
AZ(ocx);
|
||||
va_start(ap, fmt);
|
||||
putv(ocx, chan, fmt, ap);
|
||||
|
||||
dst = getdst(chan);
|
||||
if (dst != NULL) {
|
||||
(void)vfprintf(dst, fmt, ap);
|
||||
fflush(dst);
|
||||
}
|
||||
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
@ -159,7 +147,6 @@ PutHex(struct ocx *ocx, enum ocx_chan chan, const void *ptr, ssize_t len)
|
||||
assert(len >= 0);
|
||||
|
||||
while(len--) {
|
||||
// Put(ocx, chan, "%s%02x", s, *p++);
|
||||
Put(ocx, chan, "%s%x", s, *p++);
|
||||
s = " ";
|
||||
}
|
||||
@ -168,16 +155,24 @@ PutHex(struct ocx *ocx, enum ocx_chan chan, const void *ptr, ssize_t len)
|
||||
void
|
||||
Fail(struct ocx *ocx, int err, const char *fmt, ...)
|
||||
{
|
||||
FILE *dst;
|
||||
va_list ap;
|
||||
|
||||
if (err)
|
||||
err = errno;
|
||||
Put(ocx, OCX_DIAG, "Failure: ");
|
||||
|
||||
va_start(ap, fmt);
|
||||
putv(ocx, OCX_DIAG, fmt, ap);
|
||||
dst = getdst(OCX_DIAG);
|
||||
if (dst != NULL) {
|
||||
(void)vfprintf(dst, fmt, ap);
|
||||
fflush(dst);
|
||||
}
|
||||
va_end(ap);
|
||||
|
||||
Put(ocx, OCX_DIAG, "\n");
|
||||
if (err)
|
||||
Put(ocx, OCX_DIAG, "errno = %d (%s)\n", err, strerror(err));
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user