184d9c625SLionel Sambuc /*-
284d9c625SLionel Sambuc * Copyright (c) 1996
384d9c625SLionel Sambuc * Keith Bostic. All rights reserved.
484d9c625SLionel Sambuc * Copyright (c) 1996
584d9c625SLionel Sambuc * Sven Verdoolaege. All rights reserved.
684d9c625SLionel Sambuc *
784d9c625SLionel Sambuc * See the LICENSE file for redistribution information.
884d9c625SLionel Sambuc */
984d9c625SLionel Sambuc
10*0a6a1f1dSLionel Sambuc #include <sys/cdefs.h>
11*0a6a1f1dSLionel Sambuc #if 0
1284d9c625SLionel Sambuc #ifndef lint
1384d9c625SLionel Sambuc 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 ";
1484d9c625SLionel Sambuc #endif /* not lint */
15*0a6a1f1dSLionel Sambuc #else
16*0a6a1f1dSLionel Sambuc __RCSID("$NetBSD: perlsfio.c,v 1.3 2014/01/26 21:43:45 christos Exp $");
17*0a6a1f1dSLionel Sambuc #endif
1884d9c625SLionel Sambuc
1984d9c625SLionel Sambuc #include <sys/types.h>
2084d9c625SLionel Sambuc #include <sys/queue.h>
2184d9c625SLionel Sambuc #include <sys/time.h>
2284d9c625SLionel Sambuc
2384d9c625SLionel Sambuc #include <bitstring.h>
2484d9c625SLionel Sambuc #include <ctype.h>
2584d9c625SLionel Sambuc #include <limits.h>
2684d9c625SLionel Sambuc #include <signal.h>
2784d9c625SLionel Sambuc #include <stdio.h>
2884d9c625SLionel Sambuc #include <stdlib.h>
2984d9c625SLionel Sambuc #include <string.h>
3084d9c625SLionel Sambuc #include <termios.h>
3184d9c625SLionel Sambuc #include <unistd.h>
3284d9c625SLionel Sambuc
3384d9c625SLionel Sambuc #include <EXTERN.h>
3484d9c625SLionel Sambuc #include <perl.h>
3584d9c625SLionel Sambuc #include <XSUB.h>
3684d9c625SLionel Sambuc
3784d9c625SLionel Sambuc /* perl redefines them
3884d9c625SLionel Sambuc * avoid warnings
3984d9c625SLionel Sambuc */
4084d9c625SLionel Sambuc #undef USE_DYNAMIC_LOADING
4184d9c625SLionel Sambuc #undef DEBUG
4284d9c625SLionel Sambuc #undef PACKAGE
4384d9c625SLionel Sambuc #undef ARGS
4484d9c625SLionel Sambuc #define ARGS ARGS
4584d9c625SLionel Sambuc
4684d9c625SLionel Sambuc #include "config.h"
4784d9c625SLionel Sambuc
4884d9c625SLionel Sambuc #include "../common/common.h"
4984d9c625SLionel Sambuc #include "perl_api_extern.h"
5084d9c625SLionel Sambuc
5184d9c625SLionel Sambuc /*
5284d9c625SLionel Sambuc * PUBLIC: #ifdef USE_SFIO
5384d9c625SLionel Sambuc */
5484d9c625SLionel Sambuc #ifdef USE_SFIO
5584d9c625SLionel Sambuc
5684d9c625SLionel Sambuc #define NIL(type) ((type)0)
5784d9c625SLionel Sambuc
5884d9c625SLionel Sambuc static int
sfnviwrite(f,buf,n,disc)5984d9c625SLionel Sambuc sfnviwrite(f, buf, n, disc)
6084d9c625SLionel Sambuc Sfio_t* f; /* stream involved */
6184d9c625SLionel Sambuc char* buf; /* buffer to read into */
6284d9c625SLionel Sambuc int n; /* number of bytes to read */
6384d9c625SLionel Sambuc Sfdisc_t* disc; /* discipline */
6484d9c625SLionel Sambuc {
6584d9c625SLionel Sambuc SCR *scrp;
6684d9c625SLionel Sambuc
6784d9c625SLionel Sambuc scrp = (SCR *)SvIV((SV*)SvRV(perl_get_sv("curscr", FALSE)));
6884d9c625SLionel Sambuc msgq(scrp, M_INFO, "%.*s", n, buf);
6984d9c625SLionel Sambuc return n;
7084d9c625SLionel Sambuc }
7184d9c625SLionel Sambuc
7284d9c625SLionel Sambuc /*
7384d9c625SLionel Sambuc * sfdcnewnvi --
7484d9c625SLionel Sambuc * Create nvi discipline
7584d9c625SLionel Sambuc *
7684d9c625SLionel Sambuc * PUBLIC: Sfdisc_t* sfdcnewnvi __P((SCR*));
7784d9c625SLionel Sambuc */
7884d9c625SLionel Sambuc
7984d9c625SLionel Sambuc Sfdisc_t *
sfdcnewnvi(scrp)8084d9c625SLionel Sambuc sfdcnewnvi(scrp)
8184d9c625SLionel Sambuc SCR *scrp;
8284d9c625SLionel Sambuc {
8384d9c625SLionel Sambuc Sfdisc_t* disc;
8484d9c625SLionel Sambuc
8584d9c625SLionel Sambuc MALLOC(scrp, disc, Sfdisc_t*, sizeof(Sfdisc_t));
8684d9c625SLionel Sambuc if (!disc) return disc;
8784d9c625SLionel Sambuc
8884d9c625SLionel Sambuc disc->readf = (Sfread_f)NULL;
8984d9c625SLionel Sambuc disc->writef = sfnviwrite;
9084d9c625SLionel Sambuc disc->seekf = (Sfseek_f)NULL;
9184d9c625SLionel Sambuc disc->exceptf = (Sfexcept_f)NULL;
9284d9c625SLionel Sambuc return disc;
9384d9c625SLionel Sambuc }
9484d9c625SLionel Sambuc
9584d9c625SLionel Sambuc /*
9684d9c625SLionel Sambuc * PUBLIC: #endif
9784d9c625SLionel Sambuc */
9884d9c625SLionel Sambuc #endif /* USE_SFIO */
99