X-Git-Url: https://git.sommitrealweird.co.uk/onak.git/blobdiff_plain/8b4052ad6015aa9f54c9c824f28655f230d09d8d..f0a63a7442a69bd08130efcb03d5e4b18110b859:/photoid.c?ds=sidebyside diff --git a/photoid.c b/photoid.c index dd28753..2501f4a 100644 --- a/photoid.c +++ b/photoid.c @@ -1,9 +1,20 @@ /* * 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. + * + * 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, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include @@ -14,7 +25,7 @@ #include "keyid.h" #include "keyindex.h" #include "keystructs.h" -#include "log.h" +#include "onak.h" #include "photoid.h" /** @@ -29,16 +40,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; - log_assert(key != NULL); - log_assert(photo != NULL); - log_assert(length != NULL); + if (key == NULL || photo == NULL || length == NULL) + return ONAK_E_INVALID_PARAM; *photo = NULL; @@ -65,8 +75,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]); @@ -77,5 +85,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; }