X-Git-Url: https://the.earth.li/gitweb/?a=blobdiff_plain;f=photoid.c;fp=photoid.c;h=4416e3e35f7c17d1cd33242139da9fe3da4a9ae6;hb=42d43e0ec08e249cecf74ec448cb6405b3c89d84;hp=0000000000000000000000000000000000000000;hpb=1d268f8b7df33d0985b63f7f99b9e3ed597a9982;p=onak.git diff --git a/photoid.c b/photoid.c new file mode 100644 index 0000000..4416e3e --- /dev/null +++ b/photoid.c @@ -0,0 +1,52 @@ +/* + * photoid.c - Routines for OpenPGP id photos. + * + * Jonathan McDowell + * + * Copyright 2004 Project Purple + * + * $Id: photoid.c,v 1.1 2004/05/27 01:25:37 noodles Exp $ + */ + +#include +#include +#include +#include +#include + +#include "keyid.h" +#include "keyindex.h" +#include "keystructs.h" + +/** + * getphoto - returns an OpenPGP packet containing a photo id. + * @key: The key to return the photo id from. + * @index: The index of the photo to return. + * + * This function returns the OpenPGP packet containing a photo id from a + * supplied key. index specifies which photo id should be returned. If + * there's no such photo id NULL is returned. + */ +struct openpgp_packet *getphoto(struct openpgp_publickey *key, int index) +{ + struct openpgp_signedpacket_list *curuid = NULL; + struct openpgp_packet *photo = NULL; + int i = 0; + + assert(key != NULL); + + curuid = key->uids; + i = 0; + while (photo == NULL && curuid != NULL && i <= index) { + if (curuid->packet->tag == 17) { + if (i == index) { + photo = curuid->packet; + } else { + i++; + } + } + curuid = curuid->next; + } + + return photo; +}