scsh-0.6/scsh/network.c

251 lines
7.1 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_FALSE;
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_listen(s48_value g1, s48_value g2)
{
s48_value ret1 = S48_FALSE;
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_shutdown(s48_value g1, s48_value g2)
{
extern int shutdown(int , int );
s48_value ret1 = S48_FALSE;
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_FALSE;
S48_DECLARE_GC_PROTECT(2);
int r1;
int r2 = 0;
int r3 = 0;
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_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_FALSE;
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_FALSE;
S48_DECLARE_GC_PROTECT(2);
int r1;
int r2 = 0;
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_FALSE;
S48_DECLARE_GC_PROTECT(2);
int r1;
int r2 = 0;
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_FALSE;
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_FALSE;
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_FALSE;
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_veclen(s48_value g1)
{
extern s48_value veclen(const long * );
s48_value ret1 = S48_FALSE;
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(scheme_bind);
S48_EXPORT_FUNCTION(scheme_connect);
S48_EXPORT_FUNCTION(df_listen);
S48_EXPORT_FUNCTION(scheme_accept);
S48_EXPORT_FUNCTION(scheme_peer_name);
S48_EXPORT_FUNCTION(scheme_socket_name);
S48_EXPORT_FUNCTION(df_shutdown);
S48_EXPORT_FUNCTION(df_scheme_socket_pair);
S48_EXPORT_FUNCTION(recv_substring);
S48_EXPORT_FUNCTION(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(scheme_host_address2host_info);
S48_EXPORT_FUNCTION(scheme_host_name2host_info);
S48_EXPORT_FUNCTION(scheme_net_address2net_info);
S48_EXPORT_FUNCTION(scheme_net_name2net_info);
S48_EXPORT_FUNCTION(scheme_serv_port2serv_info);
S48_EXPORT_FUNCTION(scheme_serv_name2serv_info);
S48_EXPORT_FUNCTION(scheme_proto_num2proto_info);
S48_EXPORT_FUNCTION(scheme_proto_name2proto_info);
S48_EXPORT_FUNCTION(df_veclen);
S48_EXPORT_FUNCTION(df_set_longvec_carriers);
return S48_UNSPECIFIC;
}