]> the.earth.li Git - onak.git/blobdiff - photoid.c
0.6.2 release
[onak.git] / photoid.c
index febc3f5441847be211fb02e40c405201c8789447..d1c07908053860caee150fec6e3b25576cf44554 100644 (file)
--- a/photoid.c
+++ b/photoid.c
  * 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.
+ * this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#include <inttypes.h>
-#include <stdbool.h>
-#include <stdio.h>
 #include <stdlib.h>
 
-#include "keyid.h"
-#include "keyindex.h"
 #include "keystructs.h"
-#include "log.h"
+#include "onak.h"
 #include "photoid.h"
 
 /**
  *     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;
        
@@ -76,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]);
@@ -88,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;
 }