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 #include "config.h"
11 
12 #ifndef lint
13 static const char sccsid[] = "@(#)perlsfio.c	8.1 (Berkeley) 9/24/96";
14 #endif /* not lint */
15 
16 #include <sys/types.h>
17 #include <sys/queue.h>
18 #include <sys/time.h>
19 
20 #include <bitstring.h>
21 #include <ctype.h>
22 #include <limits.h>
23 #include <signal.h>
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <string.h>
27 #include <termios.h>
28 #include <unistd.h>
29 
30 #include "../common/common.h"
31 
32 #include <EXTERN.h>
33 #include <perl.h>
34 #include <XSUB.h>
35 
36 #include "perl_extern.h"
37 
38 /*
39  * PUBLIC: #ifdef USE_SFIO
40  */
41 #ifdef USE_SFIO
42 
43 #define NIL(type)       ((type)0)
44 
45 static int
sfnviwrite(f,buf,n,disc)46 sfnviwrite(f, buf, n, disc)
47 Sfio_t* f;      /* stream involved */
48 char*           buf;    /* buffer to read into */
49 int             n;      /* number of bytes to read */
50 Sfdisc_t*       disc;   /* discipline */
51 {
52 	SCR *scrp;
53 
54 	scrp = (SCR *)SvIV((SV*)SvRV(perl_get_sv("curscr", FALSE)));
55 	msgq(scrp, M_INFO, "%.*s", n, buf);
56 	return n;
57 }
58 
59 /*
60  * sfdcnewnvi --
61  *	Create nvi discipline
62  *
63  * PUBLIC: Sfdisc_t* sfdcnewnvi __P((SCR*));
64  */
65 
66 Sfdisc_t *
sfdcnewnvi(scrp)67 sfdcnewnvi(scrp)
68 	SCR *scrp;
69 {
70 	Sfdisc_t*   disc;
71 
72 	MALLOC(scrp, disc, Sfdisc_t*, sizeof(Sfdisc_t));
73 	if (!disc) return disc;
74 
75 	disc->readf = (Sfread_f)NULL;
76 	disc->writef = sfnviwrite;
77 	disc->seekf = (Sfseek_f)NULL;
78 	disc->exceptf = (Sfexcept_f)NULL;
79 	return disc;
80 }
81 
82 /*
83  * PUBLIC: #endif
84  */
85 #endif /* USE_SFIO */
86