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