X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=lib%2Fconnect.c;h=bb28e19d0605d19923a039be5b68326e9863c10c;hb=cf654cde5cfc9337e254934b23274e4a7b3432ba;hp=a57fcfa14f365828e4c8b10ccbb0f85863f4db7f;hpb=53126578ee08c0bd3b3987959fb7d768deb5aedc;p=wrappi.git diff --git a/lib/connect.c b/lib/connect.c index a57fcfa..bb28e19 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -28,18 +28,68 @@ void wrap_connect (wrap_h *w) { - /* Remote not implemented yet. */ - assert (w->scheme == NULL); + switch (w->scheme) { + case WRAP_SCHEME_LOCAL: + /* nothing needed */ + return; + + case WRAP_SCHEME_SSH: + wrap_int_connect_ssh (w); + return; + + default: + set_error ("invalid scheme"); + return; + } } void -wrap_set_scheme (wrap_h *w, const char *scheme) +wrap_set_scheme (wrap_h *w, wrap_scheme_enum scheme) { - /* XXX */ + if (scheme < 0 || scheme >= wrap_scheme_enum_nr(w)) { + set_error ("scheme out of range"); + return; + } + w->scheme = scheme; } void wrap_set_hostname (wrap_h *w, const char *hostname) { - /* XXX */ + if (hostname == NULL || strlen (hostname) == 0) { + set_error ("invalid hostname"); + return; + } + w->hostname = strdup (hostname); + if (!w->hostname) + set_error_errno ("strdup"); +} + +void +wrap_set_wrappid_path (wrap_h *w, const char *wrappid) +{ + if (wrappid == NULL || strlen (wrappid) == 0 || wrappid[0] != '/') { + set_error ("invalid path"); + return; + } + w->wrappid_path = strdup (wrappid); + if (!w->wrappid_path) + set_error_errno ("strdup"); +} + +void +wrap_int_make_request (wrap_h *w, int proc_nr, const void *args, void *ret) +{ + switch (w->scheme) { + case WRAP_SCHEME_LOCAL: + abort (); /* shouldn't be reachable */ + + /* XDR-based methods. */ + case WRAP_SCHEME_SSH: + wrap_int_make_request_xdr (w, proc_nr, args, ret); + break; + + default: + set_error ("invalid scheme"); + } }