scsh-0.6/scsh/tty.c

206 lines
5.3 KiB
C

/* This is an Scheme48/C interface file,
** automatically generated by a hacked version of cig 3.0.
*/
#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 *, int *, int *, int *, int *);
s48_value ret1;
int r1;
int r2;
int r3;
int r4;
int r5;
int r6;
int r7;
int r8;
int r9;
int r10;
int r11;
r1 = scheme_tcgetattr(s48_extract_fixnum(g1), s48_extract_string(g2), &r2, &r3, &r4, &r5, &r6, &r7, &r8, &r9, &r10, &r11);
ret1 = errno_or_false(r1);
S48_VECTOR_SET(mv_vec,0,s48_enter_fixnum(r2));
S48_VECTOR_SET(mv_vec,1,s48_enter_fixnum(r3));
S48_VECTOR_SET(mv_vec,2,s48_enter_fixnum(r4));
S48_VECTOR_SET(mv_vec,3,s48_enter_fixnum(r5));
S48_VECTOR_SET(mv_vec,4,s48_enter_fixnum(r6));
S48_VECTOR_SET(mv_vec,5,s48_enter_fixnum(r7));
S48_VECTOR_SET(mv_vec,6,s48_enter_fixnum(r8));
S48_VECTOR_SET(mv_vec,7,s48_enter_fixnum(r9));
S48_VECTOR_SET(mv_vec,8,s48_enter_fixnum(r10));
S48_VECTOR_SET(mv_vec,9,s48_enter_fixnum(r11));
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, s48_value g12, s48_value g13, s48_value g14, s48_value g15)
{
extern int scheme_tcsetattr(int , int , const char *, int , int , int , int , int , int , int , int , int , int , int , int );
s48_value ret1;
int r1;
r1 = scheme_tcsetattr(s48_extract_fixnum(g1), s48_extract_fixnum(g2), s48_extract_string(g3), s48_extract_fixnum(g4), s48_extract_fixnum(g5), s48_extract_fixnum(g6), s48_extract_fixnum(g7), s48_extract_fixnum(g8), s48_extract_fixnum(g9), s48_extract_fixnum(g10), s48_extract_fixnum(g11), s48_extract_fixnum(g12), s48_extract_fixnum(g13), s48_extract_fixnum(g14), s48_extract_fixnum(g15));
ret1 = errno_or_false(r1);
return ret1;
}
s48_value df_tcsendbreak(s48_value g1, s48_value g2)
{
extern int tcsendbreak(int , int );
s48_value ret1;
int r1;
r1 = tcsendbreak(s48_extract_fixnum(g1), s48_extract_fixnum(g2));
ret1 = errno_or_false(r1);
return ret1;
}
s48_value df_tcdrain(s48_value g1)
{
s48_value ret1;
int r1;
r1 = tcdrain(s48_extract_fixnum(g1));
ret1 = errno_or_false(r1);
return ret1;
}
s48_value df_tcflush(s48_value g1, s48_value g2)
{
s48_value ret1;
int r1;
r1 = tcflush(s48_extract_fixnum(g1), s48_extract_fixnum(g2));
ret1 = errno_or_false(r1);
return ret1;
}
s48_value df_tcflow(s48_value g1, s48_value g2)
{
s48_value ret1;
int r1;
r1 = tcflow(s48_extract_fixnum(g1), s48_extract_fixnum(g2));
ret1 = errno_or_false(r1);
return ret1;
}
s48_value df_tcsetpgrp(s48_value g1, s48_value g2)
{
s48_value ret1;
int r1;
r1 = tcsetpgrp(s48_extract_fixnum(g1), s48_extract_fixnum(g2));
ret1 = errno_or_false(r1);
return ret1;
}
s48_value df_tcgetpgrp(s48_value g1, s48_value mv_vec)
{
s48_value ret1;
pid_t r1;
r1 = tcgetpgrp(s48_extract_fixnum(g1));
ret1 = errno_or_false(r1);
S48_VECTOR_SET(mv_vec,0,s48_enter_fixnum(r1));
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;
int r1;
r1 = open_ctty(s48_extract_string(g1), s48_extract_fixnum(g2));
ret1 = errno_or_false(r1);
S48_VECTOR_SET(mv_vec,0,s48_enter_fixnum(r1));
return ret1;
}
s48_value df_isatty(s48_value g1)
{
extern int isatty(int );
s48_value ret1;
int r1;
r1 = isatty(s48_extract_fixnum(g1));
ret1 = ENTER_BOOLEAN(r1);
return ret1;
}
s48_value df_ttyname(s48_value g1, s48_value mv_vec)
{
extern char *ttyname(int );
s48_value ret1;
char *r1;
r1 = ttyname(s48_extract_fixnum(g1));
ret1 = errno_on_zero_or_false(r1);
S48_SET_CAR(S48_VECTOR_REF(mv_vec,0),(long) r1); S48_SET_CDR(S48_VECTOR_REF(mv_vec,0),strlen_or_false(r1));
return ret1;
}
s48_value df_scm_ctermid(s48_value mv_vec)
{
extern char *scm_ctermid(void);
s48_value ret1;
char *r1;
r1 = scm_ctermid();
ret1 = errno_on_zero_or_false(r1);
S48_SET_CAR(S48_VECTOR_REF(mv_vec,0),(long) r1); S48_SET_CDR(S48_VECTOR_REF(mv_vec,0),strlen_or_false(r1));
return ret1;
}
s48_value s48_init_tty(void)
{
S48_EXPORT_FUNCTION(df_scheme_tcgetattr);
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);
return S48_UNSPECIFIC;
}