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