scsh-0.6/scsh/tty.c

262 lines
6.5 KiB
C

/* This is an Scheme48/C interface file,
** automatically generated by a hacked version of cig 3.0.
step 4
*/
#include <stdio.h>
#include <stdlib.h> /* For malloc. */
#include "libcig.h"
#include <sys/types.h>
#include <unistd.h>
#include <termios.h>
/* Make sure foreign-function stubs interface to the C funs correctly: */
#include "tty1.h"
extern int errno;
#define errno_or_false(x) (((x) == -1) ? s48_enter_fixnum(errno) : S48_FALSE)
#define errno_on_zero_or_false(x) ((x) ? S48_FALSE : s48_enter_fixnum(errno))
s48_value df_scheme_tcgetattr(s48_value g1, s48_value g2, s48_value mv_vec)
{
extern int scheme_tcgetattr(int , char *, int *, int *, int *, int *, int *, int *);
s48_value ret1 = S48_FALSE;
S48_DECLARE_GC_PROTECT(2);
int r1;
int r2 = 0;
int r3 = 0;
int r4 = 0;
int r5 = 0;
int r6 = 0;
int r7 = 0;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = scheme_tcgetattr(s48_extract_fixnum(g1), s48_extract_string(g2), &r2, &r3, &r4, &r5, &r6, &r7);
ret1 = errno_or_false(r1);
S48_VECTOR_SET(mv_vec,0,s48_enter_integer(r2));
S48_VECTOR_SET(mv_vec,1,s48_enter_integer(r3));
S48_VECTOR_SET(mv_vec,2,s48_enter_integer(r4));
S48_VECTOR_SET(mv_vec,3,s48_enter_integer(r5));
S48_VECTOR_SET(mv_vec,4,s48_enter_fixnum(r6));
S48_VECTOR_SET(mv_vec,5,s48_enter_fixnum(r7));
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_scheme_tcgetattrB(s48_value g1, s48_value g2, s48_value g3)
{
extern int scheme_tcgetattrB(int , char *, s48_value );
s48_value ret1 = S48_FALSE;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = scheme_tcgetattrB(s48_extract_fixnum(g1), s48_extract_string(g2), g3);
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_scheme_tcsetattr(s48_value g1, s48_value g2, s48_value g3, s48_value g4, s48_value g5, s48_value g6, s48_value g7, s48_value g8, s48_value g9, s48_value g10, s48_value g11)
{
extern int scheme_tcsetattr(int , int , const char *, int , int , int , int , int , int , int , int );
s48_value ret1 = S48_FALSE;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = scheme_tcsetattr(s48_extract_fixnum(g1), s48_extract_fixnum(g2), s48_extract_string(g3), s48_extract_integer(g4), s48_extract_integer(g5), s48_extract_integer(g6), s48_extract_integer(g7), s48_extract_fixnum(g8), s48_extract_fixnum(g9), s48_extract_fixnum(g10), s48_extract_fixnum(g11));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_tcsendbreak(s48_value g1, s48_value g2)
{
extern int tcsendbreak(int , int );
s48_value ret1 = S48_FALSE;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = tcsendbreak(s48_extract_integer(g1), s48_extract_integer(g2));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_tcdrain(s48_value g1)
{
s48_value ret1 = S48_FALSE;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = tcdrain(s48_extract_integer(g1));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_tcflush(s48_value g1, s48_value g2)
{
s48_value ret1 = S48_FALSE;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = tcflush(s48_extract_integer(g1), s48_extract_integer(g2));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_tcflow(s48_value g1, s48_value g2)
{
s48_value ret1 = S48_FALSE;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = tcflow(s48_extract_integer(g1), s48_extract_integer(g2));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_tcsetpgrp(s48_value g1, s48_value g2)
{
s48_value ret1 = S48_FALSE;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = tcsetpgrp(s48_extract_fixnum(g1), s48_extract_fixnum(g2));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_tcgetpgrp(s48_value g1, s48_value mv_vec)
{
s48_value ret1 = S48_FALSE;
S48_DECLARE_GC_PROTECT(2);
pid_t r1;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = tcgetpgrp(s48_extract_fixnum(g1));
ret1 = errno_or_false(r1);
S48_VECTOR_SET(mv_vec,0,s48_enter_fixnum(r1));
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_open_ctty(s48_value g1, s48_value g2, s48_value mv_vec)
{
extern int open_ctty(const char *, int );
s48_value ret1 = S48_FALSE;
S48_DECLARE_GC_PROTECT(2);
int r1;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = open_ctty(s48_extract_string(g1), s48_extract_fixnum(g2));
ret1 = errno_or_false(r1);
S48_VECTOR_SET(mv_vec,0,s48_enter_integer(r1));
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_isatty(s48_value g1)
{
extern int isatty(int );
s48_value ret1 = S48_FALSE;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = isatty(s48_extract_integer(g1));
ret1 = ENTER_BOOLEAN(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_ttyname(s48_value g1, s48_value mv_vec)
{
extern char *ttyname(int );
s48_value ret1 = S48_FALSE;
S48_DECLARE_GC_PROTECT(2);
char *r1;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = ttyname(s48_extract_integer(g1));
ret1 = errno_on_zero_or_false(r1);
SetAlienVal(S48_CAR(S48_VECTOR_REF(mv_vec,0)),(long) r1); S48_SET_CDR(S48_VECTOR_REF(mv_vec,0),strlen_or_false(r1));//str-and-len
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_scm_ctermid(s48_value mv_vec)
{
extern char *scm_ctermid(void);
s48_value ret1 = S48_FALSE;
S48_DECLARE_GC_PROTECT(2);
char *r1;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = scm_ctermid();
ret1 = errno_on_zero_or_false(r1);
SetAlienVal(S48_CAR(S48_VECTOR_REF(mv_vec,0)),(long) r1); S48_SET_CDR(S48_VECTOR_REF(mv_vec,0),strlen_or_false(r1));//str-and-len
S48_GC_UNPROTECT();
return ret1;
}
void s48_init_tty(void)
{
S48_EXPORT_FUNCTION(df_scheme_tcgetattr);
S48_EXPORT_FUNCTION(df_scheme_tcgetattrB);
S48_EXPORT_FUNCTION(df_scheme_tcsetattr);
S48_EXPORT_FUNCTION(df_tcsendbreak);
S48_EXPORT_FUNCTION(df_tcdrain);
S48_EXPORT_FUNCTION(df_tcflush);
S48_EXPORT_FUNCTION(df_tcflow);
S48_EXPORT_FUNCTION(df_tcsetpgrp);
S48_EXPORT_FUNCTION(df_tcgetpgrp);
S48_EXPORT_FUNCTION(df_open_ctty);
S48_EXPORT_FUNCTION(df_isatty);
S48_EXPORT_FUNCTION(df_ttyname);
S48_EXPORT_FUNCTION(df_scm_ctermid);
}