2 * Copyright (c) 2008-2012 Zmanda, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Contact information: Zmanda Inc., 465 S. Mathilda Ave., Suite 300
19 * Sunnyvale, CA 94085, USA, or: http://www.zmanda.com
25 /* TODO: use glib chunk allocator */
37 XMsg *msg = g_new0(XMsg, 1);
40 msg->version = version;
42 /* messages hold a reference to the XferElement, to avoid dangling
44 g_object_ref((GObject *)elt);
53 /* unreference the source */
54 g_object_unref((GObject *)msg->elt);
56 /* and free any allocated attributes */
57 if (msg->repr) g_free(msg->repr);
58 if (msg->message) g_free(msg->message);
60 /* then free the XMsg itself */
68 if (!msg) return "(nil)"; /* better safe than sorry */
70 /* this just shows the "header" fields for now */
74 case XMSG_INFO: typ = "INFO"; break;
75 case XMSG_ERROR: typ = "ERROR"; break;
76 case XMSG_DONE: typ = "DONE"; break;
77 case XMSG_CANCEL: typ = "CANCEL"; break;
78 case XMSG_PART_DONE: typ = "PART_DONE"; break;
79 case XMSG_READY: typ = "READY"; break;
80 default: typ = "**UNKNOWN**"; break;
83 msg->repr = vstrallocf("<XMsg@%p type=XMSG_%s elt=%s version=%d>",
84 msg, typ, xfer_element_repr(msg->elt), msg->version);