X-Git-Url: http://git.dolda2000.com/gitweb/?a=blobdiff_plain;f=lib%2Fguile%2Fdolcon-guile.c;h=3ad21ff356ff16cb8e5684b6f6ee6c2f7f07093e;hb=4070426d5489d98be7e2e2d7042562f80673c4b2;hp=9e0575366eea8200634c35c041588b270a887324;hpb=d3372da97568d5e1f35fa19787c8ec8af93a0435;p=doldaconnect.git diff --git a/lib/guile/dolcon-guile.c b/lib/guile/dolcon-guile.c index 9e05753..3ad21ff 100644 --- a/lib/guile/dolcon-guile.c +++ b/lib/guile/dolcon-guile.c @@ -24,21 +24,20 @@ struct scmcb static int fd = -1; static scm_bits_t resptype; -static SCM scm_dc_connect(SCM host, SCM port) +static SCM scm_dc_connect(SCM host) { - int cport; + char *chost; - SCM_ASSERT(SCM_STRINGP(host), host, SCM_ARG1, "dc-connect"); - if(port == SCM_UNDEFINED) + if(fd >= 0) + dc_disconnect(); + if((host == SCM_UNDEFINED) || (host == SCM_BOOL_F)) { - cport = -1; + chost = NULL; } else { - SCM_ASSERT(SCM_INUMP(port), port, SCM_ARG2, "dc-connect"); - cport = SCM_INUM(port); + SCM_ASSERT(SCM_STRINGP(host), host, SCM_ARG1, "dc-connect"); + chost = SCM_STRING_CHARS(host); } - if(fd >= 0) - dc_disconnect(); - if((fd = dc_connect(SCM_STRING_CHARS(host), cport)) < 0) + if((fd = dc_connect(chost)) < 0) scm_syserror("dc-connect"); return(SCM_MAKINUM(fd)); } @@ -322,7 +321,7 @@ static int resp_print(SCM respsmob, SCM port, scm_print_state *pstate) void init_guiledc(void) { - scm_c_define_gsubr("dc-connect", 1, 1, 0, scm_dc_connect); + scm_c_define_gsubr("dc-connect", 0, 1, 0, scm_dc_connect); scm_c_define_gsubr("dc-disconnect", 0, 0, 0, scm_dc_disconnect); scm_c_define_gsubr("dc-connected", 0, 0, 0, scm_dc_connected); scm_c_define_gsubr("dc-select", 0, 1, 0, scm_dc_select);