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