/* GObject - GLib Type, Object, Parameter and Signal Library
- * Copyright (C) 1998, 1999, 2000 Tim Janik and Red Hat, Inc.
+ * Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
-#include "../config.h"
-#include <glib-object.h>
+#include "config.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include <glib-object.h>
+#include <glib/gprintf.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <sys/stat.h>
-#include <fcntl.h>
static gchar *indent_inc = NULL;
static guint spacing = 1;
if (type != root)
for (i = 0; i < spacing; i++)
- fprintf (f_out, "%s%s\n", indent, O_VLINE);
+ g_fprintf (f_out, "%s%s\n", indent, O_VLINE);
- fprintf (f_out, "%s%s%s%s",
+ g_fprintf (f_out, "%s%s%s%s",
indent,
sibling ? O_BRANCH : (type != root ? O_LLEAF : O_SPACE),
O_ESPACE,
static gint
help (gchar *arg)
{
- fprintf (stderr, "usage: query <qualifier> [-r <type>] [-{i|b} \"\"] [-s #] [-{h|x|y}]\n");
- fprintf (stderr, " -r specifiy root type\n");
- fprintf (stderr, " -n don't descend type tree\n");
- fprintf (stderr, " -h guess what ;)\n");
- fprintf (stderr, " -b specifiy indent string\n");
- fprintf (stderr, " -i specifiy incremental indent string\n");
- fprintf (stderr, " -s specifiy line spacing\n");
- fprintf (stderr, "qualifiers:\n");
- fprintf (stderr, " froots iterate over fundamental roots\n");
- fprintf (stderr, " tree print BSE type tree\n");
+ g_fprintf (stderr, "usage: gobject-query <qualifier> [-r <type>] [-{i|b} \"\"] [-s #] [-{h|x|y}]\n");
+ g_fprintf (stderr, " -r specifiy root type\n");
+ g_fprintf (stderr, " -n don't descend type tree\n");
+ g_fprintf (stderr, " -h guess what ;)\n");
+ g_fprintf (stderr, " -b specify indent string\n");
+ g_fprintf (stderr, " -i specify incremental indent string\n");
+ g_fprintf (stderr, " -s specify line spacing\n");
+ g_fprintf (stderr, "qualifiers:\n");
+ g_fprintf (stderr, " froots iterate over fundamental roots\n");
+ g_fprintf (stderr, " tree print type tree\n");
return arg != NULL;
}
main (gint argc,
gchar *argv[])
{
+ GLogLevelFlags fatal_mask;
gboolean gen_froots = 0;
gboolean gen_tree = 0;
- guint i;
+ gint i;
gchar *iindent = "";
-
+
f_out = stdout;
- g_type_init ();
+ fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
+ fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
+ g_log_set_always_fatal (fatal_mask);
root = G_TYPE_OBJECT;
-
+
for (i = 1; i < argc; i++)
{
if (strcmp ("-s", argv[i]) == 0)
else
return help (argv[i]);
}
+
if (!gen_froots && !gen_tree)
return help (argv[i-1]);
indent_inc = g_new (gchar, strlen (O_SPACE) + 1);
*indent_inc = 0;
strcpy (indent_inc, O_SPACE);
- strcpy (indent_inc, O_SPACE);
- strcpy (indent_inc, O_SPACE);
}
if (gen_tree)
if (gen_froots)
{
root = ~0;
- for (i = 0; i < 256; i++)
+ for (i = 0; i <= G_TYPE_FUNDAMENTAL_MAX; i += G_TYPE_MAKE_FUNDAMENTAL (1))
{
- gchar *name = g_type_name (i);
+ const gchar *name = g_type_name (i);
if (name)
show_nodes (i, 0, iindent);