scsh-0.6/scsh/network.c

99 lines
2.8 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;
}
void 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(scheme_socket_pair);
S48_EXPORT_FUNCTION(recv_substring);
S48_EXPORT_FUNCTION(send_substring);
S48_EXPORT_FUNCTION(scheme_getsockopt);
S48_EXPORT_FUNCTION(scheme_getsockopt_linger);
S48_EXPORT_FUNCTION(scheme_getsockopt_timeout);
S48_EXPORT_FUNCTION(scheme_setsockopt);
S48_EXPORT_FUNCTION(scheme_setsockopt_linger);
S48_EXPORT_FUNCTION(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);
}