aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-pseudonym.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-03-31 06:40:20 +0000
committerChristian Grothoff <christian@grothoff.org>2010-03-31 06:40:20 +0000
commit5d27676deba6a3f404acf088d3bedc8a0e1d2b1b (patch)
tree9e866163ab820e3e415a3ee50d4021f610fdf24b /src/fs/gnunet-pseudonym.c
parent73b12cfde8218af4f9b246b495e546c17b5d5810 (diff)
downloadgnunet-5d27676deba6a3f404acf088d3bedc8a0e1d2b1b.tar.gz
gnunet-5d27676deba6a3f404acf088d3bedc8a0e1d2b1b.zip
fs hxing
Diffstat (limited to 'src/fs/gnunet-pseudonym.c')
-rw-r--r--src/fs/gnunet-pseudonym.c105
1 files changed, 88 insertions, 17 deletions
diff --git a/src/fs/gnunet-pseudonym.c b/src/fs/gnunet-pseudonym.c
index 2d35e8e8c..b8bd12b35 100644
--- a/src/fs/gnunet-pseudonym.c
+++ b/src/fs/gnunet-pseudonym.c
@@ -66,11 +66,6 @@ static int print_local_only;
66static struct GNUNET_CONTAINER_MetaData *adv_metadata; 66static struct GNUNET_CONTAINER_MetaData *adv_metadata;
67 67
68/** 68/**
69 * -n option.
70 */
71static int no_advertising;
72
73/**
74 * -p option. 69 * -p option.
75 */ 70 */
76static unsigned int priority = 365; 71static unsigned int priority = 365;
@@ -100,6 +95,10 @@ static struct GNUNET_FS_Handle *h;
100 */ 95 */
101static struct GNUNET_FS_Namespace *ns; 96static struct GNUNET_FS_Namespace *ns;
102 97
98/**
99 * Our configuration.
100 */
101static const struct GNUNET_CONFIGURATION_Handle *cfg;
103 102
104static int ret; 103static int ret;
105 104
@@ -126,11 +125,45 @@ ns_printer (void *cls,
126} 125}
127 126
128 127
128static int
129pseudo_printer (void *cls,
130 const GNUNET_HashCode *
131 pseudonym,
132 const struct
133 GNUNET_CONTAINER_MetaData * md,
134 int rating)
135{
136 char *id;
137
138 id = GNUNET_PSEUDONYM_id_to_name (cfg,
139 pseudonym);
140 if (id == NULL)
141 {
142 GNUNET_break (0);
143 return GNUNET_OK;
144 }
145 fprintf (stdout,
146 "%s (%d):\n",
147 id,
148 rating);
149 GNUNET_CONTAINER_meta_data_iterate (md,
150 &EXTRACTOR_meta_data_print,
151 stdout);
152 fprintf (stdout, "\n");
153 GNUNET_free (id);
154 return GNUNET_OK;
155}
156
157
129static void 158static void
130post_advertising (void *cls, 159post_advertising (void *cls,
131 const struct GNUNET_FS_Uri *uri, 160 const struct GNUNET_FS_Uri *uri,
132 const char *emsg) 161 const char *emsg)
133{ 162{
163 GNUNET_HashCode nsid;
164 char *set;
165 int delta;
166
134 if (emsg != NULL) 167 if (emsg != NULL)
135 { 168 {
136 fprintf (stderr, "%s", emsg); 169 fprintf (stderr, "%s", emsg);
@@ -153,7 +186,39 @@ post_advertising (void *cls,
153 } 186 }
154 if (NULL != rating_change) 187 if (NULL != rating_change)
155 { 188 {
156 GNUNET_break (0); // FIXME: not implemented 189 set = rating_change;
190 while ((*set != '\0') && (*set != ':'))
191 set++;
192 if (*set != ':')
193 {
194 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
195 _("Invalid argument `%s'\n"),
196 rating_change);
197 }
198 else
199 {
200 *set = '\0';
201 delta = strtol (&set[1], NULL, /* no error handling yet */
202 10);
203 if (GNUNET_OK ==
204 GNUNET_PSEUDONYM_name_to_id (cfg,
205 rating_change,
206 &nsid))
207 {
208 GNUNET_PSEUDONYM_rank (cfg,
209 &nsid,
210 delta);
211
212 }
213 else
214 {
215 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
216 _("Namespace `%s' unknown.\n"),
217 rating_change);
218 }
219 }
220 GNUNET_free (rating_change);
221 rating_change = NULL;
157 } 222 }
158 if (0 != print_local_only) 223 if (0 != print_local_only)
159 { 224 {
@@ -163,10 +228,10 @@ post_advertising (void *cls,
163 } 228 }
164 else if (0 == no_remote_printing) 229 else if (0 == no_remote_printing)
165 { 230 {
166 GNUNET_break (0); // FIXME: not implemented 231 GNUNET_PSEUDONYM_list_all (cfg,
232 &pseudo_printer,
233 NULL);
167 } 234 }
168 /* FIXME: is this OK here, or do we need
169 for completion of previous requests? */
170 GNUNET_FS_stop (h); 235 GNUNET_FS_stop (h);
171} 236}
172 237
@@ -178,18 +243,20 @@ post_advertising (void *cls,
178 * @param sched the scheduler to use 243 * @param sched the scheduler to use
179 * @param args remaining command-line arguments 244 * @param args remaining command-line arguments
180 * @param cfgfile name of the configuration file used (for saving, can be NULL!) 245 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
181 * @param cfg configuration 246 * @param c configuration
182 */ 247 */
183static void 248static void
184run (void *cls, 249run (void *cls,
185 struct GNUNET_SCHEDULER_Handle *sched, 250 struct GNUNET_SCHEDULER_Handle *sched,
186 char *const *args, 251 char *const *args,
187 const char *cfgfile, 252 const char *cfgfile,
188 const struct GNUNET_CONFIGURATION_Handle *cfg) 253 const struct GNUNET_CONFIGURATION_Handle *c)
189{ 254{
190 struct GNUNET_FS_Uri *ns_uri; 255 struct GNUNET_FS_Uri *ns_uri;
191 struct GNUNET_TIME_Absolute expiration; 256 struct GNUNET_TIME_Absolute expiration;
257 char *emsg;
192 258
259 cfg = c;
193 h = GNUNET_FS_start (sched, 260 h = GNUNET_FS_start (sched,
194 cfg, 261 cfg,
195 "gnunet-pseudonym", 262 "gnunet-pseudonym",
@@ -221,11 +288,18 @@ run (void *cls,
221 } 288 }
222 else 289 else
223 { 290 {
224 if (0 == no_advertising) 291 if (NULL != root_identifier)
225 { 292 {
226 GNUNET_break (0); // FIXME: not implemented 293 emsg = NULL;
227 ns_uri = NULL; // FIXME!! 294 ns_uri = GNUNET_FS_uri_sks_create (ns, root_identifier, &emsg);
295 GNUNET_assert (emsg == NULL);
228 expiration = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_YEARS); 296 expiration = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_YEARS);
297 if (ksk_uri == NULL)
298 {
299 emsg = NULL;
300 ksk_uri = GNUNET_FS_uri_parse ("gnunet://fs/ksk/namespace", &emsg);
301 GNUNET_assert (NULL == emsg);
302 }
229 GNUNET_FS_publish_ksk (h, 303 GNUNET_FS_publish_ksk (h,
230 ksk_uri, 304 ksk_uri,
231 adv_metadata, 305 adv_metadata,
@@ -275,9 +349,6 @@ static struct GNUNET_GETOPT_CommandLineOption options[] = {
275 {'m', "meta", "TYPE:VALUE", 349 {'m', "meta", "TYPE:VALUE",
276 gettext_noop ("set the meta-data for the given TYPE to the given VALUE"), 350 gettext_noop ("set the meta-data for the given TYPE to the given VALUE"),
277 1, &GNUNET_FS_getopt_set_metadata, &adv_metadata}, 351 1, &GNUNET_FS_getopt_set_metadata, &adv_metadata},
278 {'n', "no-advertisement", NULL,
279 gettext_noop ("do not create an advertisement"),
280 0, &GNUNET_GETOPT_set_one, &no_advertising},
281 {'p', "priority", "PRIORITY", 352 {'p', "priority", "PRIORITY",
282 gettext_noop ("use the given PRIORITY for the advertisments"), 353 gettext_noop ("use the given PRIORITY for the advertisments"),
283 1, &GNUNET_GETOPT_set_uint, &priority}, 354 1, &GNUNET_GETOPT_set_uint, &priority},