/*
*
* RemoteCall.c
*
*/
#include "DataExch.h"
#define RCALL 16
#define RREGISTER 17
typedef int (*funcPtr)();
typedef int *intPtr;
typedef struct {funcPtr func; int level} ProcDesc;
typedef struct {char *base; int startIndex; int count} UnsafeBlock;
void PutPacket(), WatchPacketsIn();
unsigned getTextLength();
static void action←rcall(chars, len, type, data1, data2)
char *chars;
unsigned len, type, data1, data2;
{
unsigned (*proc)();
unsigned result;
proc = (unsigned (*)()) data1;
result = (*proc)(chars, len);
(void) PutPacket(RCALL, data2, result, (char *) 0, 0);
}
int registerProc(key, procD)
char *key;
ProcDesc *procD;
{
int (*proc)();
unsigned len;
if (procD->level!=0) {
PutText(1, "Error in RemoteCall←registerProc : non top level function\n");
return(-1); /*non top level procedure */
};
registration[RCALL].a = action←rcall;
registration[RCALL].t = -1;
len = getTextLength(key);
proc = procD->func;
(void) PutPacket(RREGISTER, (unsigned) proc, 0, key, len);
return(0);
}