int _hx509_collector_collect_certs(hx509_context context, struct hx509_collector *c, hx509_certs *ret_certs) { hx509_certs certs; int ret, i; *ret_certs = NULL; ret = hx509_certs_init(context, "MEMORY:collector-store", 0, NULL, &certs); if (ret) return ret; ret = hx509_certs_merge(context, certs, c->certs); if (ret) { hx509_certs_free(&certs); return ret; } for (i = 0; i < c->val.len; i++) { ret = match_localkeyid(context, c->val.data[i], certs); if (ret == 0) continue; ret = match_keys(context, c->val.data[i], certs); if (ret == 0) continue; } *ret_certs = certs; return 0; }
/* do a command once for a specified file 'f' */ static int netpgp_cmd(netpgp_t *netpgp, prog_t *p, char *f) { char *key; char *s; switch (p->cmd) { case LIST_KEYS: case LIST_SIGS: return match_keys(netpgp, stdout, f, (p->cmd == LIST_SIGS)); case FIND_KEY: if ((key = f) == NULL) { key = netpgp_getvar(netpgp, "userid"); } return netpgp_find_key(netpgp, key); case EXPORT_KEY: if ((key = f) == NULL) { key = netpgp_getvar(netpgp, "userid"); } if (key) { if ((s = netpgp_export_key(netpgp, key)) != NULL) { printf("%s", s); return 1; } } (void) fprintf(stderr, "key '%s' not found\n", f); return 0; case IMPORT_KEY: return netpgp_import_key(netpgp, f); case GENERATE_KEY: return netpgp_generate_key(netpgp, f, p->numbits); case GET_KEY: key = netpgp_get_key(netpgp, f, netpgp_getvar(netpgp, "format")); if (key) { printf("%s", key); return 1; } (void) fprintf(stderr, "key '%s' not found\n", f); return 0; case TRUSTED_KEYS: return netpgp_match_pubkeys(netpgp, f, stdout); case HELP_CMD: default: print_usage(usage, p->progname); exit(EXIT_SUCCESS); } }
void kpress(XWindow w, ulong mod, KeyCode keycode) { Key *k, *found; for(k=key; k; k=k->lnext) k->tnext = k->lnext; found = match_keys(key, mod, keycode, false); if(!found) /* grabbed but not found */ XBell(display, 0); else if(!found->tnext && !found->next) event("Key %s\n", found->name); else { XGrabKeyboard(display, w, true, GrabModeAsync, GrabModeAsync, CurrentTime); event_flush(FocusChangeMask, true); kpress_seq(w, found); XUngrabKeyboard(display, CurrentTime); } }
static void kpress_seq(XWindow w, Key *done) { ulong mod; KeyCode key; Key *found; next_keystroke(&mod, &key); found = match_keys(done, mod, key, true); if((done->mod == mod) && (done->key == key)) fake_keypress(mod, key); /* double key */ else { if(!found) XBell(display, 0); else if(!found->tnext && !found->next) event("Key %s\n", found->name); else kpress_seq(w, found); } }