00001 /* 00002 * This code is extracted and adapted from GLib's gerror.c, 00003 * and can be considered a derived work. 00004 * 00005 * Adaptation at HIIT 2010. Relevant portions 00006 * Copyright 2010 Helsinki Institute for Information Technology (HIIT) 00007 * and Tero Hasu <tero.hasu@hut.fi>. 00008 */ 00009 00010 /* 00011 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald 00012 * Portions copyright (c) 2006 Nokia Corporation. All rights reserved. 00013 * 00014 * This library is free software; you can redistribute it and/or 00015 * modify it under the terms of the GNU Lesser General Public 00016 * License as published by the Free Software Foundation; either 00017 * version 2 of the License, or (at your option) any later version. 00018 * 00019 * This library is distributed in the hope that it will be useful, 00020 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00022 * Lesser General Public License for more details. 00023 * 00024 * You should have received a copy of the GNU Lesser General Public 00025 * License along with this library; if not, write to the 00026 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00027 * Boston, MA 02111-1307, USA. 00028 */ 00029 00030 /* 00031 * Modified by the GLib Team and others 1997-2000. See the AUTHORS 00032 * file for a list of people on the GLib Team. See the ChangeLog 00033 * files for a list of changes. These files are distributed with 00034 * GLib at ftp://ftp.gtk.org/pub/gtk/. 00035 */ 00036 00037 #include "common/gxerror.h" 00038 00039 #include "common/gxlowmem.h" 00040 00041 #include <glib.h> 00042 00043 GError* 00044 gx_error_new_valist (GQuark domain, 00045 gint code, 00046 const gchar *format, 00047 va_list args) 00048 { 00049 GError *error = NULL; 00050 SET_TRAP_OOM_FAIL(); 00051 00052 error = g_new (GError, 1); 00053 00054 error->domain = domain; 00055 error->code = code; 00056 error->message = g_strdup_vprintf (format, args); 00057 00058 UNSET_TRAP_OOM(); 00059 return error; 00060 00061 #if HAVE_TRAP_OOM 00062 fail: 00063 if (error) { 00064 g_free(error); 00065 } 00066 return NULL; 00067 #endif 00068 } 00069 00070 GError* 00071 gx_error_new (GQuark domain, 00072 gint code, 00073 const gchar *format, 00074 ...) 00075 { 00076 GError* error; 00077 va_list args; 00078 00079 g_return_val_if_fail (format != NULL, NULL); 00080 g_return_val_if_fail (domain != 0, NULL); 00081 00082 va_start (args, format); 00083 error = gx_error_new_valist (domain, code, format, args); 00084 va_end (args); 00085 00086 return error; 00087 } 00088 00089 GError* 00090 gx_error_new_literal (GQuark domain, 00091 gint code, 00092 const gchar *message) 00093 { 00094 GError* err; 00095 SET_TRAP_OOM_VALUE(NULL); 00096 err = g_error_new_literal(domain, code, message); 00097 UNSET_TRAP_OOM(); 00098 return err; 00099 }
ContextLogger2—ContextLogger2 Logger Daemon Internals—Generated on Mon May 2 13:49:54 2011 by Doxygen 1.6.1