Main Page | Modules | Data Structures | File List | Data Fields | Related Pages

dbus-gutils.c

00001 /* -*- mode: C; c-file-style: "gnu" -*- */ 00002 /* dbus-gutils.c Utils shared between convenience lib and installed lib 00003 * 00004 * Copyright (C) 2003 Red Hat, Inc. 00005 * 00006 * Licensed under the Academic Free License version 2.1 00007 * 00008 * This program is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * This program is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this program; if not, write to the Free Software 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 * 00022 */ 00023 00024 #include <config.h> 00025 #include "dbus-gutils.h" 00026 #include "dbus-gtest.h" 00027 #include <string.h> 00028 00029 #ifndef DOXYGEN_SHOULD_SKIP_THIS 00030 00031 char** 00032 _dbus_gutils_split_path (const char *path) 00033 { 00034 int len; 00035 char **split; 00036 int n_components; 00037 int i, j, comp; 00038 00039 len = strlen (path); 00040 00041 n_components = 0; 00042 i = 0; 00043 while (i < len) 00044 { 00045 if (path[i] == '/') 00046 n_components += 1; 00047 ++i; 00048 } 00049 00050 split = g_new0 (char*, n_components + 1); 00051 00052 comp = 0; 00053 i = 0; 00054 while (i < len) 00055 { 00056 if (path[i] == '/') 00057 ++i; 00058 j = i; 00059 00060 while (j < len && path[j] != '/') 00061 ++j; 00062 00063 /* Now [i, j) is the path component */ 00064 g_assert (i < j); 00065 g_assert (path[i] != '/'); 00066 g_assert (j == len || path[j] == '/'); 00067 00068 split[comp] = g_strndup (&path[i], j - i + 1); 00069 00070 split[comp][j-i] = '\0'; 00071 00072 ++comp; 00073 i = j; 00074 } 00075 g_assert (i == len); 00076 00077 return split; 00078 } 00079 00080 const char * 00081 _dbus_gutils_type_to_string (int type) 00082 { 00083 switch (type) 00084 { 00085 case DBUS_TYPE_INVALID: 00086 return "invalid"; 00087 case DBUS_TYPE_NIL: 00088 return "nil"; 00089 case DBUS_TYPE_BOOLEAN: 00090 return "boolean"; 00091 case DBUS_TYPE_INT32: 00092 return "int32"; 00093 case DBUS_TYPE_UINT32: 00094 return "uint32"; 00095 case DBUS_TYPE_DOUBLE: 00096 return "double"; 00097 case DBUS_TYPE_STRING: 00098 return "string"; 00099 case DBUS_TYPE_CUSTOM: 00100 return "custom"; 00101 case DBUS_TYPE_ARRAY: 00102 return "array"; 00103 case DBUS_TYPE_DICT: 00104 return "dict"; 00105 case DBUS_TYPE_INT64: 00106 return "int64"; 00107 case DBUS_TYPE_UINT64: 00108 return "uint64"; 00109 default: 00110 return "unknown"; 00111 } 00112 } 00113 00114 #ifdef DBUS_BUILD_TESTS 00115 00121 gboolean 00122 _dbus_gutils_test (const char *test_data_dir) 00123 { 00124 00125 return TRUE; 00126 } 00127 00128 #endif /* DBUS_BUILD_TESTS */ 00129 00130 #endif /* DOXYGEN_SHOULD_SKIP_THIS */

Generated on Mon Jun 27 07:48:21 2005 for D-BUS by doxygen 1.3.7