#include "girepository.h"
#include "gitypelib-internal.h"
-/* FIXME: Avoid global */
-static gchar *output = NULL;
-gchar **includedirs = NULL;
-static gboolean show_all = FALSE;
-
typedef struct {
FILE *file;
GSList *stack;
+ gboolean show_all;
} Xml;
typedef struct {
xml_printf (file, "\"");
}
- if (show_all)
+ if (file->show_all)
{
if (offset >= 0)
xml_printf (file, "offset=\"%d\"", offset);
write_attributes (file, (GIBaseInfo*) info);
size = g_struct_info_get_size (info);
- if (show_all && size >= 0)
+ if (file->show_all && size >= 0)
xml_printf (file, " size=\"%d\"", size);
foreign = g_struct_info_is_foreign (info);
xml_printf (file, " deprecated=\"1\"");
size = g_union_info_get_size (info);
- if (show_all && size >= 0)
+ if (file->show_all && size >= 0)
xml_printf (file, " size=\"%d\"", size);
write_attributes (file, (GIBaseInfo*) info);
}
static void
-write_repository (const char *namespace,
- gboolean needs_prefix)
+write_repository (const char *filename,
+ const char *namespace,
+ gboolean needs_prefix,
+ gboolean show_all)
{
FILE *ofile;
gint i, j;
repository = g_irepository_get_default ();
- if (output == NULL)
+ if (filename == NULL)
ofile = stdout;
else
{
- gchar *filename;
+ gchar *full_filename;
if (needs_prefix)
- filename = g_strdup_printf ("%s-%s", namespace, output);
+ full_filename = g_strdup_printf ("%s-%s", namespace, filename);
else
- filename = g_strdup (output);
+ full_filename = g_strdup (filename);
ofile = g_fopen (filename, "w");
if (ofile == NULL)
{
g_fprintf (stderr, "failed to open '%s': %s\n",
- filename, g_strerror (errno));
- g_free (filename);
+ full_filename, g_strerror (errno));
+ g_free (full_filename);
return;
}
- g_free (filename);
+ g_free (full_filename);
}
xml = xml_open (ofile);
-
+ xml->show_all = show_all;
xml_printf (xml, "<?xml version=\"1.0\"?>\n");
xml_start_element (xml, "repository");
xml_printf (xml, " version=\"1.0\"\n"
main (int argc, char *argv[])
{
gboolean shlib = FALSE;
+ gchar *output = NULL;
+ gchar **includedirs = NULL;
+ gboolean show_all = FALSE;
gchar **input = NULL;
GOptionContext *context;
GError *error = NULL;
return 1;
}
- write_repository (namespace, needs_prefix);
+ write_repository (output, namespace, needs_prefix, show_all);
if (dlhandle)
{