diff options
Diffstat (limited to 'src/social/gnunet-social.c')
-rw-r--r-- | src/social/gnunet-social.c | 291 |
1 files changed, 170 insertions, 121 deletions
diff --git a/src/social/gnunet-social.c b/src/social/gnunet-social.c index 1da51243e..4a46fdc99 100644 --- a/src/social/gnunet-social.c +++ b/src/social/gnunet-social.c | |||
@@ -67,10 +67,10 @@ static int op_guest_leave; | |||
67 | static int op_guest_talk; | 67 | static int op_guest_talk; |
68 | 68 | ||
69 | /** --replay */ | 69 | /** --replay */ |
70 | static char *op_replay; | 70 | static int op_replay; |
71 | 71 | ||
72 | /** --replay-latest */ | 72 | /** --replay-latest */ |
73 | static char *op_replay_latest; | 73 | static int op_replay_latest; |
74 | 74 | ||
75 | /** --look-at */ | 75 | /** --look-at */ |
76 | static int op_look_at; | 76 | static int op_look_at; |
@@ -116,13 +116,13 @@ static char *opt_data; | |||
116 | static char *opt_name; | 116 | static char *opt_name; |
117 | 117 | ||
118 | /** --start */ | 118 | /** --start */ |
119 | static uint64_t opt_start; | 119 | static unsigned long long opt_start; |
120 | 120 | ||
121 | /** --until */ | 121 | /** --until */ |
122 | static uint64_t opt_until; | 122 | static unsigned long long opt_until; |
123 | 123 | ||
124 | /** --limit */ | 124 | /** --limit */ |
125 | static int opt_limit; | 125 | static unsigned long long opt_limit; |
126 | 126 | ||
127 | 127 | ||
128 | /* global vars */ | 128 | /* global vars */ |
@@ -563,7 +563,7 @@ slicer_recv_method (void *cls, | |||
563 | "%s (flags: %x)\n", | 563 | "%s (flags: %x)\n", |
564 | message_id, method_name, ntohl (meth->flags)); | 564 | message_id, method_name, ntohl (meth->flags)); |
565 | /* routing header is missing, so we just print double newline */ | 565 | /* routing header is missing, so we just print double newline */ |
566 | printf(".\n\n"); | 566 | printf("\n"); |
567 | /* we output . instead of | to indicate that this is not proper PSYC syntax */ | 567 | /* we output . instead of | to indicate that this is not proper PSYC syntax */ |
568 | /* FIXME: use libpsyc here */ | 568 | /* FIXME: use libpsyc here */ |
569 | } | 569 | } |
@@ -588,10 +588,11 @@ slicer_recv_modifier (void *cls, | |||
588 | "Received modifier for message ID %" PRIu64 ":\n" | 588 | "Received modifier for message ID %" PRIu64 ":\n" |
589 | "%c%s: %.*s (size: %u)\n", | 589 | "%c%s: %.*s (size: %u)\n", |
590 | message_id, oper, name, value_size, (const char *) value, value_size); | 590 | message_id, oper, name, value_size, (const char *) value, value_size); |
591 | #endif | 591 | #else |
592 | /* obviously not binary safe */ | 592 | /* obviously not binary safe */ |
593 | printf("%c%s\t%.*s\n", | 593 | printf("%c%s\t%.*s\n", |
594 | oper, name, value_size, (const char *) value); | 594 | oper, name, value_size, (const char *) value); |
595 | #endif | ||
595 | } | 596 | } |
596 | 597 | ||
597 | 598 | ||
@@ -611,10 +612,11 @@ slicer_recv_data (void *cls, | |||
611 | "Received data for message ID %" PRIu64 ":\n" | 612 | "Received data for message ID %" PRIu64 ":\n" |
612 | "%.*s\n", | 613 | "%.*s\n", |
613 | message_id, data_size, (const char *) data); | 614 | message_id, data_size, (const char *) data); |
614 | #endif | 615 | #else |
615 | /* obviously not binary safe */ | 616 | /* obviously not binary safe */ |
616 | printf("%s\n%.*s\n", | 617 | printf("%s\n%.*s\n", |
617 | method_received, data_size, (const char *) data); | 618 | method_received, data_size, (const char *) data); |
619 | #endif | ||
618 | } | 620 | } |
619 | 621 | ||
620 | 622 | ||
@@ -1016,6 +1018,7 @@ app_connected (void *cls) | |||
1016 | guest_enter (&place_pub_key, &peer); | 1018 | guest_enter (&place_pub_key, &peer); |
1017 | } | 1019 | } |
1018 | } | 1020 | } |
1021 | printf(".\n"); | ||
1019 | } | 1022 | } |
1020 | 1023 | ||
1021 | 1024 | ||
@@ -1161,6 +1164,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1161 | { | 1164 | { |
1162 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1165 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1163 | _("--place missing or invalid.\n")); | 1166 | _("--place missing or invalid.\n")); |
1167 | /* FIXME: why does it segfault here? */ | ||
1164 | exit_fail (); | 1168 | exit_fail (); |
1165 | return; | 1169 | return; |
1166 | } | 1170 | } |
@@ -1195,7 +1199,7 @@ int | |||
1195 | main (int argc, char *const *argv) | 1199 | main (int argc, char *const *argv) |
1196 | { | 1200 | { |
1197 | int res; | 1201 | int res; |
1198 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 1202 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
1199 | /* | 1203 | /* |
1200 | * gnunet program options in addition to the ones below: | 1204 | * gnunet program options in addition to the ones below: |
1201 | * | 1205 | * |
@@ -1208,120 +1212,165 @@ main (int argc, char *const *argv) | |||
1208 | 1212 | ||
1209 | /* operations */ | 1213 | /* operations */ |
1210 | 1214 | ||
1211 | { 'A', "host-assign", NULL, | 1215 | GNUNET_GETOPT_OPTION_SET_ONE ('A', |
1212 | gettext_noop ("assign --name in state to --data"), | 1216 | "host-assign", |
1213 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_assign }, | 1217 | gettext_noop ("assign --name in state to --data"), |
1214 | 1218 | &op_host_assign), | |
1215 | { 'B', "guest-leave", NULL, | 1219 | |
1216 | gettext_noop ("say good-bye and leave somebody else's place"), | 1220 | GNUNET_GETOPT_OPTION_SET_ONE ('B', |
1217 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_leave }, | 1221 | "guest-leave", |
1218 | 1222 | gettext_noop ("say good-bye and leave somebody else's place"), | |
1219 | { 'C', "host-enter", NULL, | 1223 | &op_guest_leave), |
1220 | gettext_noop ("create a place"), | 1224 | |
1221 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_enter }, | 1225 | GNUNET_GETOPT_OPTION_SET_ONE ('C', |
1222 | 1226 | "host-enter", | |
1223 | { 'D', "host-leave", NULL, | 1227 | gettext_noop ("create a place"), |
1224 | gettext_noop ("destroy a place we were hosting"), | 1228 | &op_host_enter), |
1225 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_leave }, | 1229 | |
1226 | 1230 | GNUNET_GETOPT_OPTION_SET_ONE ('C', | |
1227 | { 'E', "guest-enter", NULL, | 1231 | "host-enter", |
1228 | gettext_noop ("enter somebody else's place"), | 1232 | gettext_noop ("create a place"), |
1229 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_enter }, | 1233 | &op_host_enter), |
1230 | 1234 | ||
1231 | { 'F', "look-for", NULL, | 1235 | GNUNET_GETOPT_OPTION_SET_ONE ('D', |
1232 | gettext_noop ("find state matching name prefix"), | 1236 | "host-leave", |
1233 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_look_for }, | 1237 | gettext_noop ("destroy a place we were hosting"), |
1234 | 1238 | &op_host_leave), | |
1235 | { 'H', "replay-latest", NULL, | 1239 | |
1236 | gettext_noop ("replay history of messages up to the given --limit"), | 1240 | GNUNET_GETOPT_OPTION_SET_ONE ('E', |
1237 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_replay_latest }, | 1241 | "guest-enter", |
1238 | 1242 | gettext_noop ("enter somebody else's place"), | |
1239 | { 'N', "host-reconnect", NULL, | 1243 | &op_guest_enter), |
1240 | gettext_noop ("reconnect to a previously created place"), | 1244 | |
1241 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_reconnect }, | 1245 | |
1242 | 1246 | GNUNET_GETOPT_OPTION_SET_ONE ('F', | |
1243 | { 'P', "host-announce", NULL, | 1247 | "look-for", |
1244 | gettext_noop ("publish something to a place we are hosting"), | 1248 | gettext_noop ("find state matching name prefix"), |
1245 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_announce }, | 1249 | &op_look_for), |
1246 | 1250 | ||
1247 | { 'R', "guest-reconnect", NULL, | 1251 | GNUNET_GETOPT_OPTION_SET_ONE ('H', |
1248 | gettext_noop ("reconnect to a previously entered place"), | 1252 | "replay-latest", |
1249 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_reconnect }, | 1253 | gettext_noop ("replay history of messages up to the given --limit"), |
1250 | 1254 | &op_replay_latest), | |
1251 | { 'S', "look-at", NULL, | 1255 | |
1252 | gettext_noop ("search for state matching exact name"), | 1256 | GNUNET_GETOPT_OPTION_SET_ONE ('N', |
1253 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_look_at }, | 1257 | "host-reconnect", |
1254 | 1258 | gettext_noop ("reconnect to a previously created place"), | |
1255 | { 'T', "guest-talk", NULL, | 1259 | &op_host_reconnect), |
1256 | gettext_noop ("submit something to somebody's place"), | 1260 | |
1257 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_talk }, | 1261 | GNUNET_GETOPT_OPTION_SET_ONE ('P', |
1258 | 1262 | "host-announce", | |
1259 | { 'U', "status", NULL, | 1263 | gettext_noop ("publish something to a place we are hosting"), |
1260 | gettext_noop ("list of egos and subscribed places"), | 1264 | &op_host_announce), |
1261 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_status }, | 1265 | |
1262 | 1266 | GNUNET_GETOPT_OPTION_SET_ONE ('R', | |
1263 | { 'X', "replay", NULL, | 1267 | "guest-reconnect", |
1264 | gettext_noop ("extract and replay history between message IDs --start and --until"), | 1268 | gettext_noop ("reconnect to a previously entered place"), |
1265 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_replay }, | 1269 | &op_guest_reconnect), |
1270 | |||
1271 | GNUNET_GETOPT_OPTION_SET_ONE ('S', | ||
1272 | "look-at", | ||
1273 | gettext_noop ("search for state matching exact name"), | ||
1274 | &op_look_at), | ||
1275 | |||
1276 | GNUNET_GETOPT_OPTION_SET_ONE ('T', | ||
1277 | "guest-talk", | ||
1278 | gettext_noop ("submit something to somebody's place"), | ||
1279 | &op_guest_talk), | ||
1280 | |||
1281 | GNUNET_GETOPT_OPTION_SET_ONE ('U', | ||
1282 | "status", | ||
1283 | gettext_noop ("list of egos and subscribed places"), | ||
1284 | &op_status), | ||
1285 | |||
1286 | GNUNET_GETOPT_OPTION_SET_ONE ('X', | ||
1287 | "replay", | ||
1288 | gettext_noop ("extract and replay history between message IDs --start and --until"), | ||
1289 | &op_replay), | ||
1266 | 1290 | ||
1267 | 1291 | ||
1268 | /* options */ | 1292 | /* options */ |
1269 | 1293 | ||
1270 | { 'a', "app", "APPLICATION_ID", | 1294 | GNUNET_GETOPT_OPTION_STRING ('a', |
1271 | gettext_noop ("application ID to use when connecting"), | 1295 | "app", |
1272 | GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_app }, | 1296 | "APPLICATION_ID", |
1273 | 1297 | gettext_noop ("application ID to use when connecting"), | |
1274 | { 'd', "data", "DATA", | 1298 | &opt_app), |
1275 | gettext_noop ("message body or state value"), | 1299 | |
1276 | GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_data }, | 1300 | GNUNET_GETOPT_OPTION_STRING ('d', |
1277 | 1301 | "data", | |
1278 | { 'e', "ego", "NAME|PUBKEY", | 1302 | "DATA", |
1279 | gettext_noop ("name or public key of ego"), | 1303 | gettext_noop ("message body or state value"), |
1280 | GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_ego }, | 1304 | &opt_data), |
1281 | 1305 | ||
1282 | { 'f', "follow", NULL, | 1306 | GNUNET_GETOPT_OPTION_STRING ('e', |
1283 | gettext_noop ("wait for incoming messages"), | 1307 | "ego", |
1284 | GNUNET_NO, &GNUNET_GETOPT_set_one, &opt_follow }, | 1308 | "NAME|PUBKEY", |
1285 | 1309 | gettext_noop ("name or public key of ego"), | |
1286 | { 'g', "gns", "GNS_NAME", | 1310 | &opt_ego), |
1287 | gettext_noop ("GNS name"), | 1311 | |
1288 | GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_gns }, | 1312 | GNUNET_GETOPT_OPTION_SET_ONE ('f', |
1289 | 1313 | "follow", | |
1290 | { 'i', "peer", "PEER_ID", | 1314 | gettext_noop ("wait for incoming messages"), |
1291 | gettext_noop ("peer ID for --guest-enter"), | 1315 | &opt_follow), |
1292 | GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_peer }, | 1316 | |
1293 | 1317 | GNUNET_GETOPT_OPTION_STRING ('g', | |
1294 | { 'k', "name", "VAR_NAME", | 1318 | "gns", |
1295 | gettext_noop ("name (key) to query from state"), | 1319 | "GNS_NAME", |
1296 | GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_name }, | 1320 | gettext_noop ("GNS name"), |
1297 | 1321 | &opt_gns), | |
1298 | { 'm', "method", "METHOD_NAME", | 1322 | |
1299 | gettext_noop ("method name"), | 1323 | GNUNET_GETOPT_OPTION_STRING ('i', |
1300 | GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_method }, | 1324 | "peer", |
1301 | 1325 | "PEER_ID", | |
1302 | { 'n', "limit", NULL, | 1326 | gettext_noop ("peer ID for --guest-enter"), |
1303 | gettext_noop ("number of messages to replay from history"), | 1327 | &opt_peer), |
1304 | GNUNET_YES, &GNUNET_GETOPT_set_ulong, &opt_limit }, | 1328 | |
1305 | 1329 | GNUNET_GETOPT_OPTION_STRING ('k', | |
1306 | { 'p', "place", "PUBKEY", | 1330 | "name", |
1307 | gettext_noop ("key address of place"), | 1331 | "VAR_NAME", |
1308 | GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_place }, | 1332 | gettext_noop ("name (key) to query from state"), |
1309 | 1333 | &opt_name), | |
1310 | { 's', "start", NULL, | 1334 | |
1311 | gettext_noop ("start message ID for history replay"), | 1335 | GNUNET_GETOPT_OPTION_STRING ('m', |
1312 | GNUNET_YES, &GNUNET_GETOPT_set_ulong, &opt_start }, | 1336 | "method", |
1313 | 1337 | "METHOD_NAME", | |
1314 | { 'w', "welcome", NULL, | 1338 | gettext_noop ("method name"), |
1315 | gettext_noop ("respond to entry requests by admitting all guests"), | 1339 | &opt_method), |
1316 | GNUNET_NO, &GNUNET_GETOPT_set_one, &opt_welcome }, | 1340 | |
1317 | 1341 | GNUNET_GETOPT_OPTION_SET_ULONG ('n', | |
1318 | { 'u', "until", NULL, | 1342 | "limit", |
1319 | gettext_noop ("end message ID for history replay"), | 1343 | NULL, |
1320 | GNUNET_YES, &GNUNET_GETOPT_set_ulong, &opt_until }, | 1344 | gettext_noop ("number of messages to replay from history"), |
1321 | 1345 | &opt_limit), | |
1322 | { 'y', "deny", NULL, | 1346 | |
1323 | gettext_noop ("respond to entry requests by refusing all guests"), | 1347 | GNUNET_GETOPT_OPTION_STRING ('p', |
1324 | GNUNET_NO, &GNUNET_GETOPT_set_one, &opt_deny }, | 1348 | "place", |
1349 | "PUBKEY", | ||
1350 | gettext_noop ("key address of place"), | ||
1351 | &opt_place), | ||
1352 | |||
1353 | GNUNET_GETOPT_OPTION_SET_ULONG ('s', | ||
1354 | "start", | ||
1355 | NULL, | ||
1356 | gettext_noop ("start message ID for history replay"), | ||
1357 | &opt_start), | ||
1358 | |||
1359 | GNUNET_GETOPT_OPTION_SET_ONE ('w', | ||
1360 | "welcome", | ||
1361 | gettext_noop ("respond to entry requests by admitting all guests"), | ||
1362 | &opt_welcome), | ||
1363 | |||
1364 | GNUNET_GETOPT_OPTION_SET_ULONG ('u', | ||
1365 | "until", | ||
1366 | NULL, | ||
1367 | gettext_noop ("end message ID for history replay"), | ||
1368 | &opt_until), | ||
1369 | |||
1370 | GNUNET_GETOPT_OPTION_SET_ONE ('y', | ||
1371 | "deny", | ||
1372 | gettext_noop ("respond to entry requests by refusing all guests"), | ||
1373 | &opt_deny), | ||
1325 | 1374 | ||
1326 | GNUNET_GETOPT_OPTION_END | 1375 | GNUNET_GETOPT_OPTION_END |
1327 | }; | 1376 | }; |
@@ -1350,8 +1399,8 @@ main (int argc, char *const *argv) | |||
1350 | "gnunet-social --guest-leave --place <PUBKEY>\n" | 1399 | "gnunet-social --guest-leave --place <PUBKEY>\n" |
1351 | "gnunet-social --guest-talk --place <PUBKEY> --method <METHOD_NAME> --data <MESSAGE_BODY>\n" | 1400 | "gnunet-social --guest-talk --place <PUBKEY> --method <METHOD_NAME> --data <MESSAGE_BODY>\n" |
1352 | "\n" | 1401 | "\n" |
1353 | "gnunet-social --history-replay --place <PUBKEY> --start <MSGID> --until <MSGID> [--method <METHOD_PREFIX>]\n" | 1402 | "gnunet-social --replay --place <PUBKEY> --start <MSGID> --until <MSGID> [--method <METHOD_PREFIX>]\n" |
1354 | "gnunet-social --history-replay-latest --place <PUBKEY> --limit <MSG_LIMIT> [--method <METHOD_PREFIX>]\n" | 1403 | "gnunet-social --replay-latest --place <PUBKEY> --limit <MSG_LIMIT> [--method <METHOD_PREFIX>]\n" |
1355 | "\n" | 1404 | "\n" |
1356 | "gnunet-social --look-at --place <PUBKEY> --name <FULL_NAME>\n" | 1405 | "gnunet-social --look-at --place <PUBKEY> --name <FULL_NAME>\n" |
1357 | "gnunet-social --look-for --place <PUBKEY> --name <NAME_PREFIX>\n"; | 1406 | "gnunet-social --look-for --place <PUBKEY> --name <NAME_PREFIX>\n"; |