1 /* 2 * Copyright 2008 Codethink Ltd. 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public 15 * License along with this library; if not, write to the 16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 20 #ifndef USEFUL_FUNCTIONS_H 21 #define USEFUL_FUNCTIONS_H 22 /* 23 * Functions and macros widely used in the tests. 24 */ 25 26 //macro for creating objects in startup section 27 #define OBJECT_NEW(obj, type, type_str) obj = g_object_new(type,NULL);\ 28 if(obj == NULL)\ 29 {\ 30 INIT_FAILED("Cannot create instance of type" type_str ".\n");\ 31 } 32 //macro for destroying object 33 #define OBJECT_UNREF(obj) if(obj != NULL)\ 34 {\ 35 g_object_unref((gpointer)obj);\ 36 } 37 //for testing signals 38 #define HANDLER_DISCONNECT(obj, h) if((h) != 0)\ 39 {\ 40 g_signal_handler_disconnect(obj, h);\ 41 } 42 43 gboolean my_strcmp(const gchar* str1, const gchar* str2); 44 45 gint my_strlen(const gchar* str); 46 47 gboolean my_strncmp(const gchar* str1, const gchar* str2, gint n); 48 49 #endif /*USEFUL_FUNCTIONS_H*/ 50