ftp.nice.ch/pub/next/unix/audio/cmn.tar.gz#/nps.c

This is nps.c in view mode; [Download] [Up]

/* Lisp to Next DPS window server connections */
/* only relatively low level operations are connected here */
/* The expectation begin that DSPPrintf will provide most of the functionality */
/* see nps.lisp */

#import "/usr/include/dpsclient/dpsNeXT.h"

/* constants (from dpsclient/event.h) */

int MouseUp (void)       {return NX_MOUSEUP;}
int MouseDown (void)     {return NX_MOUSEDOWN;}
int MouseDownMask (void)     {return NX_MOUSEDOWNMASK;}
int MouseUpMask (void)       {return NX_MOUSEUPMASK;}

/* the event structure */
 
static NXEvent event;

int EventWindow (void) {return event.window;}
int EventType (void) {return event.type;}
int EventLocationX (void) {int i; return (i = event.location.x);} /* wants to return a float */
int EventLocationY (void) {int i; return (i = event.location.y);}
int EventFlags (void) {return event.flags;}
int EventDataMouseEventNum (void) {return event.data.mouse.eventNum;}
int EventDataMouseClick (void) {return event.data.mouse.click;}
int EventDataKeyRepeat (void) {return event.data.key.repeat;}
int EventDataKeycharSet (void) {return event.data.key.charSet;}
int EventDataKeycharCode (void) {return event.data.key.charCode;}
int EventDataKeyData (void) {return event.data.key.keyData;}
int EventDataTrackingeventNum (void) {return event.data.tracking.eventNum;}
int EventDataTrackingNum (void) {return event.data.tracking.trackingNum;}
int EventDataTrackingUserData (void) {return event.data.tracking.userData;}
int EventDataCompoundSubtype (void) {return event.data.compound.subtype;}

static DPSContext ctx;

int DisplayPSFile (char *fileName)
{
  NXStream *st;
  char *addr;
  int len, maxlen;
  if (ctx == NULL) {return -1;}
  st = NXMapFile(fileName, NX_READONLY);
  if (st) {
    NXGetMemoryBuffer(st, &addr, &len, &maxlen);
    DPSPrintf(ctx,"/_the_saved_vm_ save def\n");
    DPSWriteData(ctx, addr, len);
    DPSPrintf(ctx,"\ngrestoreall _the_saved_vm_ restore\n");
    NXCloseMemory(st, NX_FREEBUFFER);
    return 1;
  }
  return -2;
}

void myerrorproc (DPSContext ctxt, DPSErrorCode errorCode, long unsigned int arg1, long unsigned int arg2)
{
  printf("%%%%[ %.*s: %.*s; Offending command: %.*s ]%%%%\n",
	 *(short *)(arg1+14),*(char **)(arg1+16)+arg1+4,
	 *(short *)(arg1+22),*(char **)(arg1+24)+arg1+4,
	 *(short *)(arg1+30),*(char **)(arg1+32)+arg1+4);
  fflush(stdout);
}

void myprintproc (DPSContext ctxt, const char *buf, long unsigned int count)
{
  printf(buf);
  fflush(stdout);
}

int CreatePSContext (void)
{
  ctx = DPSCreateContext(0,0,myprintproc,myerrorproc);
  return 1;
}

void KillPSContext (void)
{
  ctx = NULL;
}

int SendPS (char* arg)
{
  if (ctx == NULL) {return -1;}
  DPSPrintf(ctx,arg);
  return 1;
}

int FlushPS (void)
{
  if (ctx == NULL) {return -1;}
  DPSFlushContext(ctx);
  return 1;
}

int GetPSEventNoMatterWhat (void)
{
  if (ctx == NULL) {return -1;}
  DPSGetEvent(ctx,&event,-1,NX_FOREVER,0);
  return event.type;
}

int GetPSEvent (float timeout)
{
  int success;
  double dtimeout;
  if (ctx == NULL) {return -1;}
  dtimeout = timeout;
  success = DPSGetEvent(ctx,&event,-1,dtimeout,0);
  return success;
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.