4 void help(FILE *out, const char *argv0) {
5 fprintf(out, "Usage: %s <command> [arguments]\n\n", argv0);
6 fprintf(out, "Available commands are:\n");
7 fprintf(out, " init Initialise fides, generate a public/private keypair.\n");
8 fprintf(out, " version Show version and copyright information.\n");
9 fprintf(out, " help Show this help message.\n");
10 fprintf(out, " trust <keyid>\n");
11 fprintf(out, " Trust allow/deny packets signed by the specified key.\n");
12 fprintf(out, " distrust <keyid>\n");
13 fprintf(out, " Distrust allow/deny packets signed by the specified key.\n");
14 fprintf(out, " allow <keyid> <stuff ...>\n");
15 fprintf(out, " Allow the entity identified by keyid some stuff.\n");
16 fprintf(out, " deny <keyid> <stuff ...> \n");
17 fprintf(out, " Deny the entity identified by keyid some stuff.\n");
18 fprintf(out, " import [filename]\n");
19 fprintf(out, " Import trust packets from file, or stdin if unspecified.\n");
20 fprintf(out, " export [filename]\n");
21 fprintf(out, " Export trust packets to file, or stdout if unspecified.\n");
22 fprintf(out, " test <stuff ...>\n");
23 fprintf(out, " Tell whether stuff is allowed or not, and why.\n");
24 fprintf(out, " fsck Verify the signature on all information collected.\n");
28 fprintf(stdout, "fides version 0.1\n");
29 fprintf(stdout, "Copyright (c) 2008 Guus Sliepen <guus@tinc-vpn.org>\n\n");
30 fprintf(stdout, "This program is free software; you can redistribute it and/or modify\n"
31 "it under the terms of the GNU General Public License as published by\n"
32 "the Free Software Foundation; either version 2 of the License, or\n"
33 "(at your option) any later version.\n");
39 // Generate a public/private keypair if it does not already exist
43 int trust(int argc, char *argv[]) {
48 int distrust(int argc, char *argv[]) {
49 // Distrust another key
53 int allow(int argc, char *argv[]) {
54 // Generate a certficate allowing something
58 int deny(int argc, char *argv[]) {
59 // Generate a certificate denying something
63 int import(int argc, char *argv[]) {
64 // Import certificates
68 int export(int argc, char *argv[]) {
69 // Export certificates
73 int test(int argc, char *argv[]) {
74 // Test something against all certificates
79 // Verify the integrity of all certificates
83 main(int argc, char *argv[]) {
85 help(stderr, argv[0]);
89 if(!strcmp(argv[1], "help")) {
90 help(stdout, argv[0]);
94 if(!strcmp(argv[1], "version"))
97 if(!strcmp(argv[1], "init"))
100 if(!strcmp(argv[1], "trust"))
101 return trust(argc - 2, argv + 2);
103 if(!strcmp(argv[1], "distrust"))
104 return distrust(argc - 2, argv + 2);
106 if(!strcmp(argv[1], "allow"))
107 return allow(argc - 2, argv + 2);
109 if(!strcmp(argv[1], "deny"))
110 return deny(argc - 2, argv + 2);
112 if(!strcmp(argv[1], "import"))
113 return import(argc - 2, argv + 2);
115 if(!strcmp(argv[1], "export"))
116 return export(argc - 2, argv + 2);
118 if(!strcmp(argv[1], "test"))
119 return test(argc - 2, argv + 2);
121 if(!strcmp(argv[1], "fsck"))
124 fprintf(stderr, "Unknown command '%s'\n", argv[1]);