/* This is an Scheme48/C interface file, 
** automatically generated by cig.
*/

#include <stdio.h>
#include <stdlib.h> /* For malloc. */
#include "libcig.h"

#include <sys/types.h>

#include <unistd.h>
#include <errno.h>
#include <termios.h>

/* Make sure foreign-function stubs interface to the C funs correctly: */
#include "tty1.h"

#define errno_or_false(x) (((x) == -1) ? ENTER_FIXNUM(errno) : SCHFALSE)
#define errno_on_zero_or_false(x) ((x) ? SCHFALSE : ENTER_FIXNUM(errno))
scheme_value df_scheme_tcgetattr(long nargs, scheme_value *args)
{
    extern int scheme_tcgetattr(int , char *, int *, int *, int *, int *, int *, int *, int *, int *, int *, int *);
    scheme_value ret1;
    int r1;
    int r2;
    int r3;
    int r4;
    int r5;
    int r6;
    int r7;
    int r8;
    int r9;
    int r10;
    int r11;

    cig_check_nargs(3, nargs, "scheme_tcgetattr");
    r1 = scheme_tcgetattr(EXTRACT_FIXNUM(args[2]), cig_string_body(args[1]), &r2, &r3, &r4, &r5, &r6, &r7, &r8, &r9, &r10, &r11);
    ret1 = errno_or_false(r1);
    VECTOR_REF(*args,0) = ENTER_FIXNUM(r2);
    VECTOR_REF(*args,1) = ENTER_FIXNUM(r3);
    VECTOR_REF(*args,2) = ENTER_FIXNUM(r4);
    VECTOR_REF(*args,3) = ENTER_FIXNUM(r5);
    VECTOR_REF(*args,4) = ENTER_FIXNUM(r6);
    VECTOR_REF(*args,5) = ENTER_FIXNUM(r7);
    VECTOR_REF(*args,6) = ENTER_FIXNUM(r8);
    VECTOR_REF(*args,7) = ENTER_FIXNUM(r9);
    VECTOR_REF(*args,8) = ENTER_FIXNUM(r10);
    VECTOR_REF(*args,9) = ENTER_FIXNUM(r11);
    return ret1;
    }

scheme_value df_scheme_tcgetattrB(long nargs, scheme_value *args)
{
    extern int scheme_tcgetattrB(int , char *, scheme_value );
    scheme_value ret1;
    int r1;

    cig_check_nargs(3, nargs, "scheme_tcgetattrB");
    r1 = scheme_tcgetattrB(EXTRACT_FIXNUM(args[2]), cig_string_body(args[1]), args[0]);
    ret1 = errno_or_false(r1);
    return ret1;
    }

scheme_value df_scheme_tcsetattr(long nargs, scheme_value *args)
{
    extern int scheme_tcsetattr(int , int , const char *, int , int , int , int , int , int , int , int , int , int , int , int );
    scheme_value ret1;
    int r1;

    cig_check_nargs(15, nargs, "scheme_tcsetattr");
    r1 = scheme_tcsetattr(EXTRACT_FIXNUM(args[14]), EXTRACT_FIXNUM(args[13]), cig_string_body(args[12]), EXTRACT_FIXNUM(args[11]), EXTRACT_FIXNUM(args[10]), EXTRACT_FIXNUM(args[9]), EXTRACT_FIXNUM(args[8]), EXTRACT_FIXNUM(args[7]), EXTRACT_FIXNUM(args[6]), EXTRACT_FIXNUM(args[5]), EXTRACT_FIXNUM(args[4]), EXTRACT_FIXNUM(args[3]), EXTRACT_FIXNUM(args[2]), EXTRACT_FIXNUM(args[1]), EXTRACT_FIXNUM(args[0]));
    ret1 = errno_or_false(r1);
    return ret1;
    }

scheme_value df_tcsendbreak(long nargs, scheme_value *args)
{
    extern int tcsendbreak(int , int );
    scheme_value ret1;
    int r1;

    cig_check_nargs(2, nargs, "tcsendbreak");
    r1 = tcsendbreak(EXTRACT_FIXNUM(args[1]), EXTRACT_FIXNUM(args[0]));
    ret1 = errno_or_false(r1);
    return ret1;
    }

scheme_value df_tcdrain(long nargs, scheme_value *args)
{
    
    scheme_value ret1;
    int r1;

    cig_check_nargs(1, nargs, "tcdrain");
    r1 = tcdrain(EXTRACT_FIXNUM(args[0]));
    ret1 = errno_or_false(r1);
    return ret1;
    }

scheme_value df_tcflush(long nargs, scheme_value *args)
{
    
    scheme_value ret1;
    int r1;

    cig_check_nargs(2, nargs, "tcflush");
    r1 = tcflush(EXTRACT_FIXNUM(args[1]), EXTRACT_FIXNUM(args[0]));
    ret1 = errno_or_false(r1);
    return ret1;
    }

scheme_value df_tcflow(long nargs, scheme_value *args)
{
    
    scheme_value ret1;
    int r1;

    cig_check_nargs(2, nargs, "tcflow");
    r1 = tcflow(EXTRACT_FIXNUM(args[1]), EXTRACT_FIXNUM(args[0]));
    ret1 = errno_or_false(r1);
    return ret1;
    }

scheme_value df_tcsetpgrp(long nargs, scheme_value *args)
{
    
    scheme_value ret1;
    int r1;

    cig_check_nargs(2, nargs, "tcsetpgrp");
    r1 = tcsetpgrp(EXTRACT_FIXNUM(args[1]), EXTRACT_FIXNUM(args[0]));
    ret1 = errno_or_false(r1);
    return ret1;
    }

scheme_value df_tcgetpgrp(long nargs, scheme_value *args)
{
    
    scheme_value ret1;
    pid_t r1;

    cig_check_nargs(2, nargs, "tcgetpgrp");
    r1 = tcgetpgrp(EXTRACT_FIXNUM(args[1]));
    ret1 = errno_or_false(r1);
    VECTOR_REF(*args,0) = ENTER_FIXNUM(r1);
    return ret1;
    }

scheme_value df_open_ctty(long nargs, scheme_value *args)
{
    extern int open_ctty(const char *, int );
    scheme_value ret1;
    int r1;

    cig_check_nargs(3, nargs, "open_ctty");
    r1 = open_ctty(cig_string_body(args[2]), EXTRACT_FIXNUM(args[1]));
    ret1 = errno_or_false(r1);
    VECTOR_REF(*args,0) = ENTER_FIXNUM(r1);
    return ret1;
    }

scheme_value df_isatty(long nargs, scheme_value *args)
{
    extern int isatty(int );
    scheme_value ret1;
    int r1;

    cig_check_nargs(1, nargs, "isatty");
    r1 = isatty(EXTRACT_FIXNUM(args[0]));
    ret1 = ENTER_BOOLEAN(r1);
    return ret1;
    }

scheme_value df_ttyname(long nargs, scheme_value *args)
{
    extern char *ttyname(int );
    scheme_value ret1;
    char *r1;

    cig_check_nargs(2, nargs, "ttyname");
    r1 = ttyname(EXTRACT_FIXNUM(args[1]));
    ret1 = errno_on_zero_or_false(r1);
    {AlienVal(CAR(VECTOR_REF(*args,0))) = (long) r1; CDR(VECTOR_REF(*args,0)) = strlen_or_false(r1);}
    return ret1;
    }

scheme_value df_scm_ctermid(long nargs, scheme_value *args)
{
    extern char *scm_ctermid(void);
    scheme_value ret1;
    char *r1;

    cig_check_nargs(1, nargs, "scm_ctermid");
    r1 = scm_ctermid();
    ret1 = errno_on_zero_or_false(r1);
    {AlienVal(CAR(VECTOR_REF(*args,0))) = (long) r1; CDR(VECTOR_REF(*args,0)) = strlen_or_false(r1);}
    return ret1;
    }

