118c2affartem/***************************************************************************
218c2affartem * CVSID: $Id$
318c2affartem *
418c2affartem * utils.c - Some utils for the hald runner
518c2affartem *
618c2affartem * Copyright (C) 2006 Sjoerd Simons, <sjoerd@luon.net>
718c2affartem *
818c2affartem * Licensed under the Academic Free License version 2.1
918c2affartem *
1018c2affartem * This program is free software; you can redistribute it and/or modify
1118c2affartem * it under the terms of the GNU General Public License as published by
1218c2affartem * the Free Software Foundation; either version 2 of the License, or
1318c2affartem * (at your option) any later version.
1418c2affartem *
1518c2affartem * This program is distributed in the hope that it will be useful,
1618c2affartem * but WITHOUT ANY WARRANTY; without even the implied warranty of
1718c2affartem * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1818c2affartem * GNU General Public License for more details.
1918c2affartem *
2018c2affartem * You should have received a copy of the GNU General Public License
2118c2affartem * along with this program; if not, write to the Free Software
2218c2affartem * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
2318c2affartem *
2418c2affartem **************************************************************************/
2518c2affartem#include <stdio.h>
2618c2affartem#include <stdlib.h>
2718c2affartem#define DBUS_API_SUBJECT_TO_CHANGE
2818c2affartem#include <dbus/dbus-glib-lowlevel.h>
2918c2affartem#include <glib.h>
3018c2affartem
3118c2affartem#include "utils.h"
3218c2affartem
3318c2affartemchar **
3418c2affartemget_string_array(DBusMessageIter *iter, char *extra)
3518c2affartem{
3618c2affartem	GArray *array;
3718c2affartem	char **result;
3818c2affartem	array = g_array_new(TRUE, FALSE, sizeof(char *));
3918c2affartem
4018c2affartem	while (dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_STRING) {
4118c2affartem		const char *value;
4218c2affartem		char *t;
4318c2affartem		dbus_message_iter_get_basic(iter, &value);
4418c2affartem		t = g_strdup(value);
4518c2affartem		g_array_append_vals(array, &t, 1);
4618c2affartem		dbus_message_iter_next(iter);
4718c2affartem	}
48