Home | History | Annotate | Line # | Download | only in perl_api
perlsfio.c revision 1.1.1.1
      1 /*-
      2  * Copyright (c) 1996
      3  *	Keith Bostic.  All rights reserved.
      4  * Copyright (c) 1996
      5  *	Sven Verdoolaege. All rights reserved.
      6  *
      7  * See the LICENSE file for redistribution information.
      8  */
      9 
     10 #ifndef lint
     11 static const char sccsid[] = "Id: perlsfio.c,v 8.3 2000/04/30 17:00:15 skimo Exp  (Berkeley) Date: 2000/04/30 17:00:15 ";
     12 #endif /* not lint */
     13 
     14 #include <sys/types.h>
     15 #include <sys/queue.h>
     16 #include <sys/time.h>
     17 
     18 #include <bitstring.h>
     19 #include <ctype.h>
     20 #include <limits.h>
     21 #include <signal.h>
     22 #include <stdio.h>
     23 #include <stdlib.h>
     24 #include <string.h>
     25 #include <termios.h>
     26 #include <unistd.h>
     27 
     28 #include <EXTERN.h>
     29 #include <perl.h>
     30 #include <XSUB.h>
     31 
     32 /* perl redefines them
     33  * avoid warnings
     34  */
     35 #undef USE_DYNAMIC_LOADING
     36 #undef DEBUG
     37 #undef PACKAGE
     38 #undef ARGS
     39 #define ARGS ARGS
     40 
     41 #include "config.h"
     42 
     43 #include "../common/common.h"
     44 #include "extern.h"
     45 
     46 /*
     47  * PUBLIC: #ifdef USE_SFIO
     48  */
     49 #ifdef USE_SFIO
     50 
     51 #define NIL(type)       ((type)0)
     52 
     53 static int
     54 sfnviwrite(f, buf, n, disc)
     55 Sfio_t* f;      /* stream involved */
     56 char*           buf;    /* buffer to read into */
     57 int             n;      /* number of bytes to read */
     58 Sfdisc_t*       disc;   /* discipline */
     59 {
     60 	SCR *scrp;
     61 
     62 	scrp = (SCR *)SvIV((SV*)SvRV(perl_get_sv("curscr", FALSE)));
     63 	msgq(scrp, M_INFO, "%.*s", n, buf);
     64 	return n;
     65 }
     66 
     67 /*
     68  * sfdcnewnvi --
     69  *	Create nvi discipline
     70  *
     71  * PUBLIC: Sfdisc_t* sfdcnewnvi __P((SCR*));
     72  */
     73 
     74 Sfdisc_t *
     75 sfdcnewnvi(scrp)
     76 	SCR *scrp;
     77 {
     78 	Sfdisc_t*   disc;
     79 
     80 	MALLOC(scrp, disc, Sfdisc_t*, sizeof(Sfdisc_t));
     81 	if (!disc) return disc;
     82 
     83 	disc->readf = (Sfread_f)NULL;
     84 	disc->writef = sfnviwrite;
     85 	disc->seekf = (Sfseek_f)NULL;
     86 	disc->exceptf = (Sfexcept_f)NULL;
     87 	return disc;
     88 }
     89 
     90 /*
     91  * PUBLIC: #endif
     92  */
     93 #endif /* USE_SFIO */
     94