2 * lookup.c - CGI to lookup keys.
4 * Jonathan McDowell <noodles@earth.li>
6 * Copyright 2002 Project Purple
28 int putnextchar(void *ctx, unsigned char c)
33 void find_keys(char *search, uint64_t keyid, bool ishex,
34 bool fingerprint, bool exact, bool verbose)
36 struct openpgp_publickey *publickey = NULL;
40 if (fetch_key(keyid, &publickey)) {
41 if (publickey != NULL) {
42 key_index(publickey, verbose, fingerprint,
44 free_publickey(publickey);
50 puts("Key not found.");
54 int main(int argc, char *argv[])
59 bool fingerprint = false;
65 struct openpgp_publickey *publickey = NULL;
66 struct openpgp_packet_list *packets = NULL;
67 struct openpgp_packet_list *list_end = NULL;
69 params = getcgivars(argc, argv);
70 for (i = 0; params != NULL && params[i] != NULL; i += 2) {
71 if (!strcmp(params[i], "op")) {
72 if (!strcmp(params[i+1], "get")) {
74 } else if (!strcmp(params[i+1], "index")) {
76 } else if (!strcmp(params[i+1], "vindex")) {
79 } else if (!strcmp(params[i], "search")) {
82 keyid = strtoul(search, &end, 16);
89 } else if (!strcmp(params[i], "fingerprint")) {
90 if (!strcmp(params[i+1], "on")) {
93 } else if (!strcmp(params[i], "exact")) {
94 if (!strcmp(params[i+1], "on")) {
100 // puts("HTTP/1.0 200 OK");
101 // puts("Server: onak 0.0.1");
102 puts("Content-Type: text/html\n");
103 puts("<html>\n<title>Lookup of key</title>");
106 if (op == OP_UNKNOWN) {
107 puts("Error: No operation supplied.");
108 } else if (search == NULL) {
109 puts("Error: No key to search for supplied.");
114 if (fetch_key(keyid, &publickey)) {
116 flatten_publickey(publickey,
119 armor_openpgp_stream(putnextchar,
124 puts("Key not found");
128 find_keys(search, keyid, ishex, fingerprint, exact,
132 find_keys(search, keyid, ishex, fingerprint, exact,
136 puts("Unknown operation!");
141 puts("Produced by onak 0.0.1 by Jonathan McDowell");
142 puts("</body>\n</html>");
143 return (EXIT_SUCCESS);