X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=perl%2Famglue%2Fxferwrap.c;fp=perl%2Famglue%2Fxferwrap.c;h=fb50580a38d43483ba8e6ac06b5f30dc2671ddec;hb=538ae376635af705ebcd686f3b4b7b72a6652985;hp=0000000000000000000000000000000000000000;hpb=11425c69eb58b6103beb68adc13912735ba36975;p=debian%2Famanda diff --git a/perl/amglue/xferwrap.c b/perl/amglue/xferwrap.c new file mode 100644 index 0000000..fb50580 --- /dev/null +++ b/perl/amglue/xferwrap.c @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2009 Zmanda, Inc. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation. + * + * This program 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 General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Contact information: Zmanda Inc., 465 S. Mathilda Ave., Suite 300 + * Sunnyvale, CA 94085, USA, or: http://www.zmanda.com + */ + +/* Utility functions for packages that create Amanda::Xfer objects */ + +#include "amglue.h" +#include "amxfer.h" + +SV * +new_sv_for_xfer( + Xfer *xfer) +{ + if (!xfer) return &PL_sv_undef; + + xfer_ref(xfer); + return new_sv_for_c_obj(xfer, "Amanda::Xfer::Xfer"); +} + +SV * +new_sv_for_xfer_element( + XferElement *xe) +{ + const char *perl_class; + + if (!xe) return &PL_sv_undef; + + perl_class = XFER_ELEMENT_GET_CLASS(xe)->perl_class; + if (!perl_class) die("Attempt to wrap an XferElementClass with no perl class!"); + g_object_ref(xe); + return new_sv_for_c_obj(xe, perl_class); +} + +Xfer * +xfer_from_sv( + SV *sv) +{ + return (Xfer *)c_obj_from_sv(sv, "Amanda::Xfer::Xfer"); +} + +XferElement * +xfer_element_from_sv( + SV *sv) +{ + return (XferElement *)c_obj_from_sv(sv, "Amanda::Xfer::Element"); +}