scsh-0.6/scsh/network.c

542 lines
16 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 <sys/socket.h>
/* Make sure foreign-function stubs interface to the C funs correctly: */
#include "network1.h"
extern int errno;
extern int h_errno;
#define errno_on_zero_or_false(x) ((x) ? S48_FALSE : s48_enter_fixnum(errno))
#define errno_or_false(x) (((x) == -1) ? s48_enter_fixnum(errno) : S48_FALSE)
#define False_on_zero(x) ((x) ? s48_enter_fixnum(x) : S48_FALSE)
s48_value df_socket(s48_value g1, s48_value g2, s48_value g3, s48_value mv_vec)
{
extern int socket(int , int , int );
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
int r1;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = socket(s48_extract_fixnum(g1), s48_extract_fixnum(g2), s48_extract_fixnum(g3));
ret1 = errno_or_false(r1);
S48_VECTOR_SET(mv_vec,0,s48_enter_fixnum(r1));
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_scheme_bind(s48_value g1, s48_value g2, s48_value g3)
{
extern int scheme_bind(int , int , s48_value );
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = scheme_bind(s48_extract_fixnum(g1), s48_extract_fixnum(g2), g3);
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_scheme_connect(s48_value g1, s48_value g2, s48_value g3)
{
extern int scheme_connect(int , int , s48_value );
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = scheme_connect(s48_extract_fixnum(g1), s48_extract_fixnum(g2), g3);
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_listen(s48_value g1, s48_value g2)
{
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = listen(s48_extract_fixnum(g1), s48_extract_fixnum(g2));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_scheme_accept(s48_value g1, s48_value g2, s48_value g3, s48_value mv_vec)
{
extern int scheme_accept(int , int , s48_value );
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
int r1;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = scheme_accept(s48_extract_fixnum(g1), s48_extract_fixnum(g2), g3);
ret1 = errno_or_false(r1);
S48_VECTOR_SET(mv_vec,0,s48_enter_fixnum(r1));
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_scheme_peer_name(s48_value g1, s48_value g2, s48_value g3)
{
extern int scheme_peer_name(int , int , s48_value );
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = scheme_peer_name(s48_extract_fixnum(g1), s48_extract_fixnum(g2), g3);
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_scheme_socket_name(s48_value g1, s48_value g2, s48_value g3)
{
extern int scheme_socket_name(int , int , s48_value );
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = scheme_socket_name(s48_extract_fixnum(g1), s48_extract_fixnum(g2), g3);
ret1 = False_on_zero(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_shutdown(s48_value g1, s48_value g2)
{
extern int shutdown(int , int );
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = shutdown(s48_extract_fixnum(g1), s48_extract_fixnum(g2));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_scheme_socket_pair(s48_value g1, s48_value mv_vec)
{
extern int scheme_socket_pair(int , int *, int *);
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
int r1;
int r2;
int r3;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = scheme_socket_pair(s48_extract_fixnum(g1), &r2, &r3);
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_GC_UNPROTECT();
return ret1;
}
s48_value df_recv_substring(s48_value g1, s48_value g2, s48_value g3, s48_value g4, s48_value g5, s48_value g6, s48_value mv_vec)
{
extern ssize_t recv_substring(int , int , s48_value , size_t , size_t , s48_value );
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
ssize_t r1;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = recv_substring(s48_extract_fixnum(g1), s48_extract_fixnum(g2), g3, s48_extract_fixnum(g4), s48_extract_fixnum(g5), g6);
ret1 = errno_or_false(r1);
S48_VECTOR_SET(mv_vec,0,s48_enter_fixnum(r1));
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_send_substring(s48_value g1, s48_value g2, s48_value g3, s48_value g4, s48_value g5, s48_value g6, s48_value g7, s48_value mv_vec)
{
extern ssize_t send_substring(int , int , s48_value , size_t , size_t , int , s48_value );
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
ssize_t r1;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = send_substring(s48_extract_fixnum(g1), s48_extract_fixnum(g2), g3, s48_extract_fixnum(g4), s48_extract_fixnum(g5), s48_extract_fixnum(g6), g7);
ret1 = errno_or_false(r1);
S48_VECTOR_SET(mv_vec,0,s48_enter_fixnum(r1));
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_scheme_getsockopt(s48_value g1, s48_value g2, s48_value g3, s48_value mv_vec)
{
extern int scheme_getsockopt(int , int , int );
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
int r1;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = scheme_getsockopt(s48_extract_fixnum(g1), s48_extract_fixnum(g2), s48_extract_fixnum(g3));
ret1 = errno_or_false(r1);
S48_VECTOR_SET(mv_vec,0,s48_enter_fixnum(r1));
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_scheme_getsockopt_linger(s48_value g1, s48_value g2, s48_value g3, s48_value mv_vec)
{
extern int scheme_getsockopt_linger(int , int , int , int *);
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
int r1;
int r2;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = scheme_getsockopt_linger(s48_extract_fixnum(g1), s48_extract_fixnum(g2), s48_extract_fixnum(g3), &r2);
ret1 = errno_or_false(r1);
S48_VECTOR_SET(mv_vec,0,s48_enter_fixnum(r1));
S48_VECTOR_SET(mv_vec,1,s48_enter_fixnum(r2));
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_scheme_getsockopt_timeout(s48_value g1, s48_value g2, s48_value g3, s48_value mv_vec)
{
extern int scheme_getsockopt_timeout(int , int , int , int *);
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
int r1;
int r2;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = scheme_getsockopt_timeout(s48_extract_fixnum(g1), s48_extract_fixnum(g2), s48_extract_fixnum(g3), &r2);
ret1 = errno_or_false(r1);
S48_VECTOR_SET(mv_vec,0,s48_enter_fixnum(r1));
S48_VECTOR_SET(mv_vec,1,s48_enter_fixnum(r2));
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_scheme_setsockopt(s48_value g1, s48_value g2, s48_value g3, s48_value g4)
{
extern int scheme_setsockopt(int , int , int , int );
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = scheme_setsockopt(s48_extract_fixnum(g1), s48_extract_fixnum(g2), s48_extract_fixnum(g3), s48_extract_fixnum(g4));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_scheme_setsockopt_linger(s48_value g1, s48_value g2, s48_value g3, s48_value g4, s48_value g5)
{
extern int scheme_setsockopt_linger(int , int , int , int , int );
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = scheme_setsockopt_linger(s48_extract_fixnum(g1), s48_extract_fixnum(g2), s48_extract_fixnum(g3), s48_extract_fixnum(g4), s48_extract_fixnum(g5));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_scheme_setsockopt_timeout(s48_value g1, s48_value g2, s48_value g3, s48_value g4, s48_value g5)
{
extern int scheme_setsockopt_timeout(int , int , int , int , int );
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = scheme_setsockopt_timeout(s48_extract_fixnum(g1), s48_extract_fixnum(g2), s48_extract_fixnum(g3), s48_extract_fixnum(g4), s48_extract_fixnum(g5));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_scheme_host_address2host_info(s48_value g1, s48_value mv_vec)
{
extern int scheme_host_address2host_info(s48_value , char **, char** *, char** *);
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
int r1;
char *r2;
char** r3;
char** r4;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = scheme_host_address2host_info(g1, &r2, &r3, &r4);
ret1 = False_on_zero(r1);
SetAlienVal(S48_CAR(S48_VECTOR_REF(mv_vec,0)),(long) r2); S48_SET_CDR(S48_VECTOR_REF(mv_vec,0),strlen_or_false(r2));//str-and-len
SetAlienVal(S48_VECTOR_REF(mv_vec,1),(long) r3);//simple-assign
SetAlienVal(S48_VECTOR_REF(mv_vec,2),(long) r4);//simple-assign
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_scheme_host_name2host_info(s48_value g1, s48_value mv_vec)
{
extern int scheme_host_name2host_info(const char *, char **, char** *, char** *);
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
int r1;
char *r2;
char** r3;
char** r4;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = scheme_host_name2host_info(s48_extract_string(g1), &r2, &r3, &r4);
ret1 = False_on_zero(r1);
SetAlienVal(S48_CAR(S48_VECTOR_REF(mv_vec,0)),(long) r2); S48_SET_CDR(S48_VECTOR_REF(mv_vec,0),strlen_or_false(r2));//str-and-len
SetAlienVal(S48_VECTOR_REF(mv_vec,1),(long) r3);//simple-assign
SetAlienVal(S48_VECTOR_REF(mv_vec,2),(long) r4);//simple-assign
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_scheme_net_address2net_info(s48_value g1, s48_value g2, s48_value mv_vec)
{
extern int scheme_net_address2net_info(s48_value , s48_value , char **, char** *);
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
int r1;
char *r2;
char** r3;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = scheme_net_address2net_info(g1, g2, &r2, &r3);
ret1 = False_on_zero(r1);
SetAlienVal(S48_CAR(S48_VECTOR_REF(mv_vec,0)),(long) r2); S48_SET_CDR(S48_VECTOR_REF(mv_vec,0),strlen_or_false(r2));//str-and-len
SetAlienVal(S48_VECTOR_REF(mv_vec,1),(long) r3);//simple-assign
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_scheme_net_name2net_info(s48_value g1, s48_value g2, s48_value mv_vec)
{
extern int scheme_net_name2net_info(const char *, s48_value , char **, char** *);
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
int r1;
char *r2;
char** r3;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = scheme_net_name2net_info(s48_extract_string(g1), g2, &r2, &r3);
ret1 = False_on_zero(r1);
SetAlienVal(S48_CAR(S48_VECTOR_REF(mv_vec,0)),(long) r2); S48_SET_CDR(S48_VECTOR_REF(mv_vec,0),strlen_or_false(r2));//str-and-len
SetAlienVal(S48_VECTOR_REF(mv_vec,1),(long) r3);//simple-assign
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_scheme_serv_port2serv_info(s48_value g1, s48_value g2, s48_value mv_vec)
{
extern int scheme_serv_port2serv_info(int , const char *, char **, char** *, int *, char **);
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
int r1;
char *r2;
char** r3;
int r4;
char *r5;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = scheme_serv_port2serv_info(s48_extract_fixnum(g1), s48_extract_string(g2), &r2, &r3, &r4, &r5);
ret1 = False_on_zero(r1);
SetAlienVal(S48_CAR(S48_VECTOR_REF(mv_vec,0)),(long) r2); S48_SET_CDR(S48_VECTOR_REF(mv_vec,0),strlen_or_false(r2));//str-and-len
SetAlienVal(S48_VECTOR_REF(mv_vec,1),(long) r3);//simple-assign
S48_VECTOR_SET(mv_vec,2,s48_enter_fixnum(r4));
SetAlienVal(S48_CAR(S48_VECTOR_REF(mv_vec,3)),(long) r5); S48_SET_CDR(S48_VECTOR_REF(mv_vec,3),strlen_or_false(r5));//str-and-len
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_scheme_serv_name2serv_info(s48_value g1, s48_value g2, s48_value mv_vec)
{
extern int scheme_serv_name2serv_info(const char *, const char *, char **, char** *, int *, char **);
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
int r1;
char *r2;
char** r3;
int r4;
char *r5;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = scheme_serv_name2serv_info(s48_extract_string(g1), s48_extract_string(g2), &r2, &r3, &r4, &r5);
ret1 = False_on_zero(r1);
SetAlienVal(S48_CAR(S48_VECTOR_REF(mv_vec,0)),(long) r2); S48_SET_CDR(S48_VECTOR_REF(mv_vec,0),strlen_or_false(r2));//str-and-len
SetAlienVal(S48_VECTOR_REF(mv_vec,1),(long) r3);//simple-assign
S48_VECTOR_SET(mv_vec,2,s48_enter_fixnum(r4));
SetAlienVal(S48_CAR(S48_VECTOR_REF(mv_vec,3)),(long) r5); S48_SET_CDR(S48_VECTOR_REF(mv_vec,3),strlen_or_false(r5));//str-and-len
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_scheme_proto_num2proto_info(s48_value g1, s48_value mv_vec)
{
extern int scheme_proto_num2proto_info(int , char **, char** *, int *);
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
int r1;
char *r2;
char** r3;
int r4;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = scheme_proto_num2proto_info(s48_extract_fixnum(g1), &r2, &r3, &r4);
ret1 = False_on_zero(r1);
SetAlienVal(S48_CAR(S48_VECTOR_REF(mv_vec,0)),(long) r2); S48_SET_CDR(S48_VECTOR_REF(mv_vec,0),strlen_or_false(r2));//str-and-len
SetAlienVal(S48_VECTOR_REF(mv_vec,1),(long) r3);//simple-assign
S48_VECTOR_SET(mv_vec,2,s48_enter_fixnum(r4));
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_scheme_proto_name2proto_info(s48_value g1, s48_value mv_vec)
{
extern int scheme_proto_name2proto_info(const char *, char **, char** *, int *);
s48_value ret1;
S48_DECLARE_GC_PROTECT(2);
int r1;
char *r2;
char** r3;
int r4;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = scheme_proto_name2proto_info(s48_extract_string(g1), &r2, &r3, &r4);
ret1 = False_on_zero(r1);
SetAlienVal(S48_CAR(S48_VECTOR_REF(mv_vec,0)),(long) r2); S48_SET_CDR(S48_VECTOR_REF(mv_vec,0),strlen_or_false(r2));//str-and-len
SetAlienVal(S48_VECTOR_REF(mv_vec,1),(long) r3);//simple-assign
S48_VECTOR_SET(mv_vec,2,s48_enter_fixnum(r4));
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_veclen(s48_value g1)
{
extern s48_value veclen(const long * );
s48_value ret1;
S48_DECLARE_GC_PROTECT(1);
s48_value r1;
S48_GC_PROTECT_1(ret1);
r1 = veclen((const long * )AlienVal(g1));
ret1 = r1;
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_set_longvec_carriers(s48_value g1, s48_value g2)
{
extern void set_longvec_carriers(s48_value , long const * const * );
set_longvec_carriers(g1, (long const * const * )AlienVal(g2));
return S48_FALSE;
}
s48_value s48_init_network(void)
{
S48_EXPORT_FUNCTION(df_socket);
S48_EXPORT_FUNCTION(df_scheme_bind);
S48_EXPORT_FUNCTION(df_scheme_connect);
S48_EXPORT_FUNCTION(df_listen);
S48_EXPORT_FUNCTION(df_scheme_accept);
S48_EXPORT_FUNCTION(df_scheme_peer_name);
S48_EXPORT_FUNCTION(df_scheme_socket_name);
S48_EXPORT_FUNCTION(df_shutdown);
S48_EXPORT_FUNCTION(df_scheme_socket_pair);
S48_EXPORT_FUNCTION(df_recv_substring);
S48_EXPORT_FUNCTION(df_send_substring);
S48_EXPORT_FUNCTION(df_scheme_getsockopt);
S48_EXPORT_FUNCTION(df_scheme_getsockopt_linger);
S48_EXPORT_FUNCTION(df_scheme_getsockopt_timeout);
S48_EXPORT_FUNCTION(df_scheme_setsockopt);
S48_EXPORT_FUNCTION(df_scheme_setsockopt_linger);
S48_EXPORT_FUNCTION(df_scheme_setsockopt_timeout);
S48_EXPORT_FUNCTION(df_scheme_host_address2host_info);
S48_EXPORT_FUNCTION(df_scheme_host_name2host_info);
S48_EXPORT_FUNCTION(df_scheme_net_address2net_info);
S48_EXPORT_FUNCTION(df_scheme_net_name2net_info);
S48_EXPORT_FUNCTION(df_scheme_serv_port2serv_info);
S48_EXPORT_FUNCTION(df_scheme_serv_name2serv_info);
S48_EXPORT_FUNCTION(df_scheme_proto_num2proto_info);
S48_EXPORT_FUNCTION(df_scheme_proto_name2proto_info);
S48_EXPORT_FUNCTION(df_veclen);
S48_EXPORT_FUNCTION(df_set_longvec_carriers);
return S48_UNSPECIFIC;
}