home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 3
/
PDCD_3.iso
/
utilities
/
utilsa
/
andylib
/
c
/
tracker
< prev
Wrap
Text File
|
1994-05-11
|
2KB
|
80 lines
/* tracker.c */
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include "tracker.h"
#ifdef MODULE
#include "kernel.h"
#define wimpt_complain(e) (e)
#define wimpt_programname() ("Module")
#define os_swix(n, r) _kernel_swi((n), (r), (r))
#define os_error _kernel_oserror
#define os_regset _kernel_swi_regs
#else
#include "os.h"
#include "wimpt.h"
#endif
enum
{ Tracker_Open = 0xCF000,
Tracker_Close, Tracker_SetPos, Tracker_WriteS, Tracker_CLS, Tracker_Simple
};
static int trackhandle = 0;
static int open(char *title, int width, int height, int flags)
{ os_regset regs;
regs.r[0] = (int) title;
regs.r[1] = width;
regs.r[2] = height;
regs.r[3] = flags;
if (wimpt_complain(os_swix(Tracker_Open, ®s)))
return -1;
return regs.r[0];
}
static void close(int handle)
{ os_regset regs;
regs.r[0] = handle;
os_swix(Tracker_Close, ®s);
}
static void writes(int handle, char *s)
{ os_regset regs;
regs.r[0] = handle;
regs.r[1] = (int) s;
os_swix(Tracker_WriteS, ®s);
}
static void exithandler(void)
{ if (trackhandle)
close(trackhandle);
}
void tracker_printf(char *fmt, ...)
{ char buf[2048];
va_list ap;
if (trackhandle == 0)
{ if (trackhandle = open(wimpt_programname(), 132, 500, 1), trackhandle > 0)
atexit(exithandler);
else
return;
}
else if (trackhandle < 0)
return;
va_start(ap, fmt);
vsprintf(buf, fmt, ap);
va_end(ap);
writes(trackhandle, buf);
}