X-Git-Url: https://the.earth.li/gitweb/?p=onak.git;a=blobdiff_plain;f=photoid.c;h=d1c07908053860caee150fec6e3b25576cf44554;hp=8da62cee2ff723fcb0d500446828d4b48d566b03;hb=6d60149434eed130c201d4d670ce7b3be5c2866b;hpb=b3e534f945ae56605bc5309e7c5af020c797a69b diff --git a/photoid.c b/photoid.c index 8da62ce..d1c0790 100644 --- a/photoid.c +++ b/photoid.c @@ -1,23 +1,25 @@ /* * photoid.c - Routines for OpenPGP id photos. * - * Jonathan McDowell + * Copyright 2004 Jonathan McDowell * - * Copyright 2004 Project Purple + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; version 2 of the License. * - * $Id: photoid.c,v 1.2 2004/05/27 21:58:18 noodles Exp $ + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ -#include -#include -#include -#include #include -#include "keyid.h" -#include "keyindex.h" #include "keystructs.h" -#include "log.h" +#include "onak.h" #include "photoid.h" /** @@ -32,16 +34,15 @@ * photo id NULL is returned. The returned data pointer refers to the key * data supplied rather than a copy of it. */ -int getphoto(struct openpgp_publickey *key, int index, unsigned char **photo, - size_t *length) +onak_status_t getphoto(struct openpgp_publickey *key, int index, + unsigned char **photo, size_t *length) { struct openpgp_signedpacket_list *curuid = NULL; int i = 0; int j = 0; - assert(key != NULL); - assert(photo != NULL); - assert(length != NULL); + if (key == NULL || photo == NULL || length == NULL) + return ONAK_E_INVALID_PARAM; *photo = NULL; @@ -68,8 +69,6 @@ int getphoto(struct openpgp_publickey *key, int index, unsigned char **photo, *length <<= 8; *length += curuid->packet->data[j++]; } - logthing(LOGTHING_DEBUG, "Got photo, size %d", - *length); j++; *length -= 17; *photo = &(curuid->packet->data[j+16]); @@ -80,5 +79,5 @@ int getphoto(struct openpgp_publickey *key, int index, unsigned char **photo, curuid = curuid->next; } - return (*photo != NULL); + return *photo == NULL ? ONAK_E_NOT_FOUND : ONAK_E_OK; }