diff options
author | Gabor X Toth <*@tg-x.net> | 2016-05-06 20:30:08 +0000 |
---|---|---|
committer | Gabor X Toth <*@tg-x.net> | 2016-05-06 20:30:08 +0000 |
commit | 9416d745bf3a7abafc895e8bc1083afefaa45755 (patch) | |
tree | a9310aeb5eafbfabb2b624592392ea3bec85e9bf /src/social/gnunet-social.c | |
parent | b402cb83245e4c62b1bb62c2915c67bf7d2465f2 (diff) | |
download | gnunet-9416d745bf3a7abafc895e8bc1083afefaa45755.tar.gz gnunet-9416d745bf3a7abafc895e8bc1083afefaa45755.zip |
social: cli options
Diffstat (limited to 'src/social/gnunet-social.c')
-rw-r--r-- | src/social/gnunet-social.c | 99 |
1 files changed, 65 insertions, 34 deletions
diff --git a/src/social/gnunet-social.c b/src/social/gnunet-social.c index b59aab77c..b9b26496e 100644 --- a/src/social/gnunet-social.c +++ b/src/social/gnunet-social.c | |||
@@ -37,6 +37,9 @@ | |||
37 | 37 | ||
38 | /* operations corresponding to API calls */ | 38 | /* operations corresponding to API calls */ |
39 | 39 | ||
40 | /** --status */ | ||
41 | static int op_status; | ||
42 | |||
40 | /** --host-enter */ | 43 | /** --host-enter */ |
41 | static int op_host_enter; | 44 | static int op_host_enter; |
42 | 45 | ||
@@ -661,7 +664,11 @@ app_connected (void *cls) | |||
661 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 664 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
662 | "App connected: %p\n", cls); | 665 | "App connected: %p\n", cls); |
663 | 666 | ||
664 | if (op_host_enter) { | 667 | if (op_status) |
668 | { | ||
669 | GNUNET_SCHEDULER_add_now (&schedule_end, NULL); | ||
670 | } | ||
671 | else if (op_host_enter) { | ||
665 | host_enter (); | 672 | host_enter (); |
666 | } | 673 | } |
667 | else if (op_guest_enter) { | 674 | else if (op_guest_enter) { |
@@ -725,13 +732,20 @@ app_recv_guest (void *cls, | |||
725 | 732 | ||
726 | static void | 733 | static void |
727 | app_recv_ego (void *cls, | 734 | app_recv_ego (void *cls, |
728 | struct GNUNET_SOCIAL_Ego *ego, | 735 | struct GNUNET_SOCIAL_Ego *e, |
729 | const struct GNUNET_CRYPTO_EcdsaPublicKey *ego_pub_key, | 736 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub_key, |
730 | const char *name) | 737 | const char *name) |
731 | { | 738 | { |
732 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 739 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
733 | "Ego: %s\t%s\n", | 740 | "Ego: %s\t%s\n", |
734 | name, GNUNET_CRYPTO_ecdsa_public_key_to_string (ego_pub_key)); | 741 | name, GNUNET_CRYPTO_ecdsa_public_key_to_string (pub_key)); |
742 | |||
743 | if (0 == memcmp (&ego_pub_key, pub_key, sizeof (*pub_key)) | ||
744 | || 0 == strcmp (opt_ego, name)) | ||
745 | { | ||
746 | ego = e; | ||
747 | } | ||
748 | |||
735 | } | 749 | } |
736 | 750 | ||
737 | 751 | ||
@@ -775,22 +789,24 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
775 | { | 789 | { |
776 | cfg = c; | 790 | cfg = c; |
777 | 791 | ||
778 | if (!opt_follow) | 792 | if (! (op_status || op_host_enter || op_host_leave || op_host_announce |
793 | || op_guest_enter || op_guest_leave || op_guest_talk | ||
794 | || op_history_replay || op_history_replay_latest | ||
795 | || op_look_at || op_look_for)) | ||
779 | { | 796 | { |
780 | timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout, NULL); | 797 | op_status = 1; |
781 | } | 798 | } |
782 | 799 | ||
783 | if (op_host_enter && NULL != opt_place) | 800 | if (!opt_follow) |
784 | { | 801 | { |
785 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 802 | timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout, NULL); |
786 | _("--place must not be specified when using --host-enter\n")); | ||
787 | return; | ||
788 | } | 803 | } |
789 | 804 | ||
790 | if (!opt_place | 805 | if (!op_status && !op_host_enter |
791 | || GNUNET_OK != GNUNET_CRYPTO_eddsa_public_key_from_string (opt_place, | 806 | && (!opt_place |
792 | strlen (opt_place), | 807 | || GNUNET_OK != GNUNET_CRYPTO_eddsa_public_key_from_string (opt_place, |
793 | &place_pub_key)) | 808 | strlen (opt_place), |
809 | &place_pub_key))) | ||
794 | { | 810 | { |
795 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 811 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
796 | _("--place missing or invalid.\n")); | 812 | _("--place missing or invalid.\n")); |
@@ -826,17 +842,31 @@ main (int argc, char *const *argv) | |||
826 | { | 842 | { |
827 | int res; | 843 | int res; |
828 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 844 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { |
845 | /* | ||
846 | * gnunet program options in addition to the ones below: | ||
847 | * | ||
848 | * -c, --config=FILENAME | ||
849 | * -l, --logfile=LOGFILE | ||
850 | * -L, --log=LOGLEVEL | ||
851 | * -h, --help | ||
852 | * -v, --version | ||
853 | */ | ||
854 | |||
829 | /* operations */ | 855 | /* operations */ |
830 | 856 | ||
857 | { 's', "status", NULL, | ||
858 | gettext_noop ("list of egos and subscribed places"), | ||
859 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_status }, | ||
860 | |||
831 | { 'E', "host-enter", NULL, | 861 | { 'E', "host-enter", NULL, |
832 | gettext_noop ("create a place for nyms to join"), | 862 | gettext_noop ("create a place for nyms to join"), |
833 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_enter }, | 863 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_enter }, |
834 | 864 | ||
835 | { 'L', "host-leave", NULL, | 865 | { 'D', "host-leave", NULL, |
836 | gettext_noop ("destroy a place we were hosting"), | 866 | gettext_noop ("destroy a place we were hosting"), |
837 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_leave }, | 867 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_leave }, |
838 | 868 | ||
839 | { 'A', "host-announce", NULL, | 869 | { 'T', "host-announce", NULL, |
840 | gettext_noop ("publish something to a place we are hosting"), | 870 | gettext_noop ("publish something to a place we are hosting"), |
841 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_announce }, | 871 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_announce }, |
842 | 872 | ||
@@ -844,7 +874,7 @@ main (int argc, char *const *argv) | |||
844 | gettext_noop ("join somebody else's place"), | 874 | gettext_noop ("join somebody else's place"), |
845 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_enter }, | 875 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_enter }, |
846 | 876 | ||
847 | { 'l', "guest-leave", NULL, | 877 | { 'd', "guest-leave", NULL, |
848 | gettext_noop ("leave somebody else's place"), | 878 | gettext_noop ("leave somebody else's place"), |
849 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_leave }, | 879 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_leave }, |
850 | 880 | ||
@@ -862,7 +892,7 @@ main (int argc, char *const *argv) | |||
862 | 892 | ||
863 | /* options */ | 893 | /* options */ |
864 | 894 | ||
865 | { 'A', "app", "application ID", | 895 | { 'A', "app", "APPLICATION_ID", |
866 | gettext_noop ("application ID to use when connecting"), | 896 | gettext_noop ("application ID to use when connecting"), |
867 | GNUNET_NO, &GNUNET_GETOPT_set_string, &opt_app }, | 897 | GNUNET_NO, &GNUNET_GETOPT_set_string, &opt_app }, |
868 | 898 | ||
@@ -874,7 +904,7 @@ main (int argc, char *const *argv) | |||
874 | gettext_noop ("peer ID for --guest-enter"), | 904 | gettext_noop ("peer ID for --guest-enter"), |
875 | GNUNET_NO, &GNUNET_GETOPT_set_string, &opt_peer }, | 905 | GNUNET_NO, &GNUNET_GETOPT_set_string, &opt_peer }, |
876 | 906 | ||
877 | { 'g', "ego", "PUBKEY", | 907 | { 'g', "ego", "NAME|PUBKEY", |
878 | gettext_noop ("public key of ego"), | 908 | gettext_noop ("public key of ego"), |
879 | GNUNET_NO, &GNUNET_GETOPT_set_string, &opt_place }, | 909 | GNUNET_NO, &GNUNET_GETOPT_set_string, &opt_place }, |
880 | 910 | ||
@@ -886,11 +916,11 @@ main (int argc, char *const *argv) | |||
886 | gettext_noop ("method name"), | 916 | gettext_noop ("method name"), |
887 | GNUNET_NO, &GNUNET_GETOPT_set_string, &opt_method }, | 917 | GNUNET_NO, &GNUNET_GETOPT_set_string, &opt_method }, |
888 | 918 | ||
889 | { 'd', "data", "DATA", | 919 | { 'b', "body", "DATA", |
890 | gettext_noop ("message body to transmit"), | 920 | gettext_noop ("message body to transmit"), |
891 | GNUNET_NO, &GNUNET_GETOPT_set_string, &opt_data }, | 921 | GNUNET_NO, &GNUNET_GETOPT_set_string, &opt_data }, |
892 | 922 | ||
893 | { 'n', "name", "VAR_NAME", | 923 | { 'k', "name", "VAR_NAME", |
894 | gettext_noop ("state var name to query"), | 924 | gettext_noop ("state var name to query"), |
895 | GNUNET_NO, &GNUNET_GETOPT_set_string, &opt_name }, | 925 | GNUNET_NO, &GNUNET_GETOPT_set_string, &opt_name }, |
896 | 926 | ||
@@ -913,24 +943,25 @@ main (int argc, char *const *argv) | |||
913 | return 2; | 943 | return 2; |
914 | 944 | ||
915 | const char *help = | 945 | const char *help = |
916 | _ ("interact with the social service: enter/leave, send/receive messages, access history and state"); | 946 | _ ("Interact with the social service: enter/leave, send/receive messages, access history and state.\n"); |
917 | const char *usage = | 947 | const char *usage = |
918 | "gnunet-social --host-enter --ego <name or pubkey> [--listen]\n" | 948 | "gnunet-social [--status]\n" |
919 | "gnunet-social --host-leave --place <pubkey>\n" | 949 | "\n" |
920 | "gnunet-social --host-announce --place <pubkey> --method <method_name> --data <message body>\n" | 950 | "gnunet-social --host-enter --ego <NAME or PUBKEY> [--listen]\n" |
951 | "gnunet-social --host-leave --place <PUBKEY>\n" | ||
952 | "gnunet-social --host-announce --place <PUBKEY> --method <METHOD_NAME> --data <MESSAGE BODY>\n" | ||
921 | "\n" | 953 | "\n" |
922 | "gnunet-social --guest-enter --place <pubkey> --ego <name or pubkey> [--listen]\n" | 954 | "gnunet-social --guest-enter --place <PUBKEY> --ego <NAME or PUBKEY> [--listen]\n" |
923 | "gnunet-social --guest-leave --place <pubkey>\n" | 955 | "gnunet-social --guest-leave --place <PUBKEY>\n" |
924 | "gnunet-social --guest-talk --place <pubkey> --method <method_nmae> --data <data>\n" | 956 | "gnunet-social --guest-talk --place <PUBKEY> --method <METHOD_NMAE> --data <DATA>\n" |
925 | "\n" | 957 | "\n" |
926 | "gnunet-social --history-replay --place <pubkey> --start <msgid> --end <msgid> [--method <method_prefix>]\n" | 958 | "gnunet-social --history-replay --place <PUBKEY> --start <MSGID> --end <MSGID> [--method <METHOD_PREFIX>]\n" |
927 | "gnunet-social --history-replay-latest --place <pubkey> --limit <msg_limit> [--method <method_prefix>]\n" | 959 | "gnunet-social --history-replay-latest --place <PUBKEY> --limit <MSG_LIMIT> [--method <METHOD_PREFIX>]\n" |
928 | "\n" | 960 | "\n" |
929 | "gnunet-social --look-at --place <pubkey> --name <full_name>\n" | 961 | "gnunet-social --look-at --place <PUBKEY> --name <FULL_NAME>\n" |
930 | "gnunet-social --look-for --place <pubkey> --name <name_prefix>\n"; | 962 | "gnunet-social --look-for --place <PUBKEY> --name <NAME_PREFIX>\n"; |
931 | 963 | ||
932 | res = GNUNET_PROGRAM_run (argc, argv, usage, | 964 | res = GNUNET_PROGRAM_run (argc, argv, help, usage, options, &run, NULL); |
933 | help, options, &run, NULL); | ||
934 | 965 | ||
935 | GNUNET_free ((void *) argv); | 966 | GNUNET_free ((void *) argv); |
936 | 967 | ||