summaryrefslogtreecommitdiffstats
path: root/src/sbus/sssd_dbus_messages_helpers.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sbus/sssd_dbus_messages_helpers.c')
-rw-r--r--src/sbus/sssd_dbus_messages_helpers.c54
1 files changed, 34 insertions, 20 deletions
diff --git a/src/sbus/sssd_dbus_messages_helpers.c b/src/sbus/sssd_dbus_messages_helpers.c
index bbcee7e3..2fcc88c5 100644
--- a/src/sbus/sssd_dbus_messages_helpers.c
+++ b/src/sbus/sssd_dbus_messages_helpers.c
@@ -1,10 +1,26 @@
/*
- * sssd_dbus_messages_helpers.c
- *
- * Created on: Jul 9, 2011
- * Author: r00tkit
+ SSSD
+
+ Authors:
+ Arun Scaria <arunscaria91@gmail.com>
+
+ Copyright (C) 2011 Arun Scaria <arunscaria91@gmail.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>
*/
+
#include <sys/time.h>
#include <errno.h>
#include "util/util.h"
@@ -38,7 +54,7 @@ int dbus_dhash_to_msg_iter(hash_table_t **table_in,
msg_iter = msg_iter_start;
if( !table_in && !*table_in) {
- fprintf(stderr,"Table is not valid.");
+ DEBUG(0,("Table is not valid."));
return SSS_SBUS_DHASH_NULL;
}
local_table = *table_in;
@@ -47,7 +63,7 @@ int dbus_dhash_to_msg_iter(hash_table_t **table_in,
DBUS_TYPE_ARRAY,
"{ss}",
&sub_iter)) {
- fprintf(stderr, "Out Of Memory!\n");
+ DEBUG(0,("Out Of Memory!\n"));
return SSS_SBUS_ITER_MESSAGE_ERR;
}
@@ -55,7 +71,7 @@ int dbus_dhash_to_msg_iter(hash_table_t **table_in,
while ((entry = iter->next(iter)) != NULL) {
if(entry->key.type != HASH_KEY_STRING && entry->value.type != HASH_VALUE_PTR) {
- fprintf(stderr,"fatal: Unexpected hashtable");
+ DEBUG(0,("fatal: Unexpected hashtable"));
return SSS_SBUS_DHASH_INVALID;
}
@@ -66,23 +82,23 @@ int dbus_dhash_to_msg_iter(hash_table_t **table_in,
DBUS_TYPE_DICT_ENTRY,
NULL,
&dict_iter)) {
- fprintf(stderr, "Out Of Memory!\n");
+ DEBUG(0,( "Out Of Memory!\n"));
return SSS_SBUS_ITER_MESSAGE_ERR;
}
if (!dbus_message_iter_append_basic(&dict_iter, DBUS_TYPE_STRING, &str_key)) {
- fprintf(stderr, "Out Of Memory!\n");
+ DEBUG(0,("Out Of Memory!\n"));
return SSS_SBUS_ITER_MESSAGE_ERR;
}
if (!dbus_message_iter_append_basic(&dict_iter, DBUS_TYPE_STRING, &str_value)) {
- fprintf(stderr, "Out Of Memory!\n");
+ DEBUG(0,( "Out Of Memory!\n"));
return SSS_SBUS_ITER_MESSAGE_ERR;
}
free(str_key);
free(str_value);
if (!dbus_message_iter_close_container(&sub_iter,&dict_iter)) {
- fprintf(stderr, "Out Of Memory!\n");
+ DEBUG(0,( "Out Of Memory!\n"));
return SSS_SBUS_ITER_MESSAGE_ERR;
}
@@ -91,7 +107,7 @@ int dbus_dhash_to_msg_iter(hash_table_t **table_in,
}
free(iter);
if (!dbus_message_iter_close_container(msg_iter,&sub_iter)) {
- fprintf(stderr, "Out Of Memory!\n");
+ DEBUG(0,( "Out Of Memory!\n"));
return SSS_SBUS_ITER_MESSAGE_ERR;
}
@@ -117,12 +133,12 @@ int dbus_msg_iter_to_dhash(DBusMessageIter *iter, hash_table_t **table_out)
callback_delete,
NULL);
if (err_h != HASH_SUCCESS) {
- fprintf(stderr, "couldn't create hash table (%s)\n", hash_error_string(err_h));
+ DEBUG(0,( "couldn't create hash table (%s)\n", hash_error_string(err_h)));
return err_h;
}
if(DBUS_TYPE_ARRAY != dbus_message_iter_get_arg_type(&msg_iter)) {
- fprintf(stderr,"message Iter is invalid\n");
+ DEBUG(0,("message Iter is invalid\n"));
return SSS_SBUS_ITER_INVALID_ERR;
}
@@ -133,14 +149,14 @@ int dbus_msg_iter_to_dhash(DBusMessageIter *iter, hash_table_t **table_out)
while(1){
if(DBUS_TYPE_DICT_ENTRY != dbus_message_iter_get_arg_type(&sub_iter)) {
- fprintf(stderr,"dict content failed");
+ DEBUG(0,("dict content failed"));
}
else {
dbus_message_iter_recurse(&sub_iter, &dict_iter);
}
if(DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&dict_iter)) {
- printf("string array content failed");
+ DEBUG(0,("string array content failed"));
return SSS_SBUS_ITER_MESSAGE_ERR;
}
else {
@@ -148,18 +164,16 @@ int dbus_msg_iter_to_dhash(DBusMessageIter *iter, hash_table_t **table_out)
value.type = HASH_VALUE_PTR;
dbus_message_iter_get_basic(&dict_iter, &tmp);
key.str = tmp;
- fprintf(stdout,"%s : ",key.str);
dbus_message_iter_next (&dict_iter);
if(DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&dict_iter)) {
- printf("string array content failed");
+ DEBUG(0,("string array content failed"));
return SSS_SBUS_ITER_MESSAGE_ERR;
}
dbus_message_iter_get_basic(&dict_iter, &tmp);
value.ptr = tmp;
- fprintf(stdout,"%s\n",(char *)value.ptr);
if ((err_h = hash_enter(local_table, &key, &value)) != HASH_SUCCESS) {
- fprintf(stderr, "couldn't add to table \"%s\" (%s)\n", key.str, hash_error_string(err_h));
+ DEBUG(0,( "couldn't add to table \"%s\" (%s)\n", key.str, hash_error_string(err_h)));
return err_h;
}
if(!dbus_message_iter_next (&sub_iter)) {