summaryrefslogtreecommitdiff
path: root/src/gns/gnunet-gns.c
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2012-03-22 17:52:23 +0000
committerMartin Schanzenbach <mschanzenbach@posteo.de>2012-03-22 17:52:23 +0000
commit3e38c60925c16fdf4bd5fdd1e26f7be3d20be985 (patch)
tree4bfac5a6715d80bb29d8b78c26ca3de8e47dd534 /src/gns/gnunet-gns.c
parent9393482faf10c55fc3a28d160afd23844c44be45 (diff)
downloadgnunet-3e38c60925c16fdf4bd5fdd1e26f7be3d20be985.tar.gz
gnunet-3e38c60925c16fdf4bd5fdd1e26f7be3d20be985.zip
-cli tool fix, bugfix
Diffstat (limited to 'src/gns/gnunet-gns.c')
-rw-r--r--src/gns/gnunet-gns.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/gns/gnunet-gns.c b/src/gns/gnunet-gns.c
index f2600b6a8..b7102eaa9 100644
--- a/src/gns/gnunet-gns.c
+++ b/src/gns/gnunet-gns.c
@@ -89,27 +89,25 @@ process_lookup_result(void* cls, uint32_t rd_count,
89 const struct GNUNET_NAMESTORE_RecordData *rd) 89 const struct GNUNET_NAMESTORE_RecordData *rd)
90{ 90{
91 int i; 91 int i;
92 char* addr;
93 char* name = (char*) cls; 92 char* name = (char*) cls;
93 const char* typename;
94 char* string_val;
94 95
95 if (rd_count == 0) 96 if (rd_count == 0)
96 printf("No results.\n"); 97 printf("No results.\n");
98 else
99 printf("%s:\n", name);
100
101
97 102
98 for (i=0; i<rd_count; i++) 103 for (i=0; i<rd_count; i++)
99 { 104 {
100 if (rd[i].record_type != rtype) 105 typename = GNUNET_NAMESTORE_number_to_typename (rd[i].record_type);
101 continue; 106 string_val = GNUNET_NAMESTORE_value_to_string(rd[i].record_type,
102 if (rd[i].record_type == GNUNET_GNS_RECORD_TYPE_A) 107 rd[i].data,
103 { 108 rd[i].data_size);
104 addr = inet_ntoa(*((struct in_addr*)rd[i].data)); 109 printf("Got %s record: %s\n", typename, string_val);
105 printf("Got A record for %s: %s\n", name, addr); 110
106 }
107 if (rd[i].record_type == GNUNET_GNS_RECORD_MX)
108 {
109 printf("Got MX record for %s: %s\n", name, (char*)rd[i].data);
110 }
111
112 //FIXME others? maybe to string method for records?
113 } 111 }
114 112
115 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); 113 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
@@ -135,7 +133,10 @@ run (void *cls, char *const *args, const char *cfgfile,
135 const struct GNUNET_CONFIGURATION_Handle *cfg) 133 const struct GNUNET_CONFIGURATION_Handle *cfg)
136{ 134{
137 gns = GNUNET_GNS_connect (cfg); 135 gns = GNUNET_GNS_connect (cfg);
138 rtype = GNUNET_GNS_RECORD_TYPE_A; 136 if (lookup_type != NULL)
137 rtype = GNUNET_NAMESTORE_typename_to_number(lookup_type);
138 else
139 rtype = GNUNET_GNS_RECORD_TYPE_A;
139 140
140 if (NULL == gns) 141 if (NULL == gns)
141 { 142 {
@@ -153,6 +154,8 @@ run (void *cls, char *const *args, const char *cfgfile,
153 154
154 if (lookup_name != NULL) 155 if (lookup_name != NULL)
155 { 156 {
157 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
158 "Lookup\n");
156 GNUNET_GNS_lookup(gns, lookup_name, rtype, 159 GNUNET_GNS_lookup(gns, lookup_name, rtype,
157 &process_lookup_result, lookup_name); 160 &process_lookup_result, lookup_name);
158 } 161 }