1
0
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:
llsth
2015-03-16 22:50:29 +01:00
parent 22eab499c3
commit d4f3caf6cc
2 changed files with 18 additions and 27 deletions

View File

@ -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)

View File

@ -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);
}