Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.atnf.csiro.au/computing/software/gipsy/sub/ScheduleHerevent.dc3
Дата изменения: Fri Jul 21 10:55:11 2000
Дата индексирования: Sat Jan 17 05:26:55 2009
Кодировка:

Поисковые слова: observatory
Function: ScheduleHerevent

Purpose: Register a function to be called whenever Hermes generates an
event meeting a specified mask.

Category: SYSTEM

File: herevents.c

Author: J.P. Terlouw

Use: #include "herevents.h"
ident id;
id = ScheduleHerevent(proc, mask, arg);

HereventProc proc - pointer to function
int mask - event mask: the bitwise OR of any of
the events defined in taskcom.h
void *arg - 'client' data

Description: ScheduleHerevent registers a function to be called by MainLoop
whenever Hermes generates an event which meets the specified mask.
In this call, 'arg' will be passed to 'proc'.
The return value is a unique identification code corresponding
with the registration, which will also be passed as an
argument to 'proc'.

The prototype of 'proc' is:
void proc(ident id, Event event, void *arg);

The argument 'event' has the generic Hermes event type.
Within 'proc' this should be cast to one or more specific
event types.

Example: The following program illustrates how the function can be used.

#include "stdio.h"
#include "cmain.h"
#include "gipsyc.h"
#include "init.h"
#include "finis.h"
#include "anyout.h"
#include "herevents.h"

static char message[80];
static fint zero=0;

static void handle_key(ident id, Event event, void *arg)
{
KeyEvent keyevent=(KeyEvent)event;
sprintf(message,"%s: %s", (char*)arg, keyevent->key);
anyout_c(&zero,tofchar(message));
}

static void handle_resume(ident id, Event event, void *arg)
{
ResEvent resevent=(ResEvent)event;
anyout_c(&zero,tofchar("Resume after pause"));
}

static void handle_any(ident id, Event event, void *arg)
{
anyout_c(&zero,tofchar("Keychange or resume (only one message)"));
DescheduleHerevent(&id);
}

MAIN_PROGRAM_ENTRY
{
init_c();
(void)ScheduleHerevent(handle_key, KEYCHANGE, "Keyword changed");
(void)ScheduleHerevent(handle_resume,RESEVENT,NULL);
(void)ScheduleHerevent(handle_any,KEYCHANGE|RESEVENT,NULL);
MainLoop();
finis_c();
return 0;
}

Related Docs: DescheduleHerevent.dc3, events.dc3

Updates: Apr 8, 1997: JPT, Document created.