/* $Id: socdvr.c,v 1.2 1999/01/03 02:07:33 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: socdvr.c,v 1.2 1999/01/03 02:07:33 sybalsky Exp $ Copyright (C) Venue"; /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ /* Manufactured in the United States of America. */ /* */ /* The contents of this file are proprietary information */ /* belonging to Venue, and are provided to you under license. */ /* They may not be further distributed or disclosed to third */ /* parties without the specific permission of Venue. */ /* */ /************************************************************************/ #include "version.h" #include #include #include #include #include #include "lispemul.h" #include "arith.h" #include "adr68k.h" #include "lsptypes.h" #include "lispmap.h" #define min(x,y) (((x) > (y)) ? (y) : (x)) /***********************************************************/ /* L S t r i n g T o C S t r i n g */ /* */ /* Convert a lisp string to a C string up to MaxLen long. */ /***********************************************************/ #define LStringToCString(Lisp, C, MaxLen ,Len) \ { \ OneDArray *arrayp; \ char *base; \ short *sbase; \ int i; \ \ arrayp = (OneDArray *)(Addr68k_from_LADDR((unsigned int)Lisp)); \ Len = min(MaxLen, arrayp->fillpointer); \ \ switch(arrayp->typenumber) \ { \ case THIN_CHAR_TYPENUMBER: \ base = ((char *) \ (Addr68k_from_LADDR((unsigned int)arrayp->base))) \ + ((int)(arrayp->offset)); \ for(i=0;ibase))) \ + ((int)(arrayp->offset)); \ base = (char *)sbase; \ for(i=0;i= 0 ) { packet = (PACKET *) Addr68k_from_LADDR( args[0] ); if( (length = (int)(packet->length)-PACKET_DEFOFFSET) > 0 ) { buffer = &(packet->data[0]); if( (actlen = read( XServer_Fd, buffer, length )) > 0 ) { packet->length = (DLword)(actlen + PACKET_DEFOFFSET); return(ATOM_T); } /* end if(actlen) */ if(actlen < 0) /* error !*/ { if ((errno != EWOULDBLOCK) & (errno != EINTR)) perror("reading X connection"); return(NIL); } } /* end if(length) */ } /* end if( fd ) */ return( NIL ); } /* end Read_Socket */ /************************************************************************/ /* */ /* W r i t e _ S o c k e t */ /* */ /* Write a packet of information to the X server's socket. */ /* */ /************************************************************************/ Write_Socket( args ) LispPTR *args; { PACKET *packet; char *buffer; int length , actlen; #ifdef TRACE printf( "TRACE: Write_Socket()\n" ); #endif if( XServer_Fd >= 0 ) { packet = (PACKET *) Addr68k_from_LADDR( args[0] ); if( (length = (int)(packet->length)-PACKET_DEFOFFSET) > 0 ) { buffer = &(packet->data[0]); if( (actlen = write( XServer_Fd, buffer, length )) > 0 ) { packet->length = (DLword)(actlen + PACKET_DEFOFFSET); return(ATOM_T); } /* end if( actlen ) */ if(actlen < 0) /* error !*/ { if (errno != EINTR) perror("writing X connection"); return(NIL); } } /* end if(length) */ } /* end if( fd ) */ packet->length = 0; return(NIL); } /* end Write_Socket */ /************************************************************************/ /* */ /* K b d _ T r a n s i t i o n */ /* */ /* Stuff a key transition into the C-level buffer from Lisp. */ /* */ /* args[0] - the key number (in lisps terms? Not sure) */ /* args[1] - upflg -- is it an up or down-transition? */ /* */ /************************************************************************/ extern int KBDEventFlg; Kbd_Transition( args ) LispPTR *args; /* args[0] is key-number */ /* args[1] is up-flg */ { DLword key_number; key_number = (DLword)(args[0] & 0xffff); if( args[1] ) kb_trans( key_number, 1 ); else kb_trans( key_number, 0 ); DoRing(); /* If there's something for lisp to do, ask for an interrupt: */ if( (KBDEventFlg += 1) > 0 ) Irq_Stk_End = Irq_Stk_Check = 0; } /* end Kbd_Transition */