home *** CD-ROM | disk | FTP | other *** search
- /* toollib.c
- * Library for OscliD tools
- * (c) Chris Rutter 1996
- */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "os:os.h"
- #include "os:wimp.h"
- #include "os:taskmanage.h"
-
- extern void tool_main (int argc, char *argv[]);
- wimp_t taskhandle (char *);
-
- wimp_block block[1];
-
- int main (int argc, char *argv[])
- {
- xwimp_initialise (wimp_VERSION_RO3, TOOLNAME, 0, 0, 0);
- tool_main (argc, argv);
- }
-
- void wait (int cs)
- {
- wimp_poll_idle (0, block, os_read_monotonic_time() + cs, 0);
- }
-
- int running (char *name)
- {
- if (taskhandle (name)) return TRUE;
- else return FALSE;
- }
-
- void kill (char *name)
- {
- wimp_message message;
- message.size=256;
- message.your_ref=0;
- message.action=0;
- if (running (name)) wimp_send_message (wimp_USER_MESSAGE, &message, taskhandle (name));
- }
-
- void reset (void)
- {
- taskmanager_shutdown (0);
- }
-
- wimp_t taskhandle (char *name)
- {
- int context = 0;
- char *end = 0;
- wimp_t handle = 0;
- taskmanager_task task;
- while (context >= 0)
- {
- context = taskmanager_enumerate_tasks (context, &task, sizeof task, &end);
- if (!strcmp (task.name, name)) handle = task.task;
- }
- return handle;
- }
-
- void tool_main (int argc, char *argv[])
-