/* wrappi * Copyright (C) 2011-2012 Red Hat Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include #include #include #include "wrappi.h" #include "internal.h" void wrap_connect (wrap_h *w) { 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, wrap_scheme_enum scheme) { 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) { 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"); } }