1
1
/* photoid.c - photo ID handling code
2
* Copyright (C) 2001, 2002 Free Software Foundation, Inc.
2
* Copyright (C) 2001, 2002, 2005 Free Software Foundation, Inc.
4
4
* This file is part of GnuPG.
6
6
* GnuPG is free software; you can redistribute it and/or modify
7
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
8
* the Free Software Foundation; either version 3 of the License, or
9
9
* (at your option) any later version.
11
11
* GnuPG is distributed in the hope that it will be useful,
14
14
* GNU General Public License for more details.
16
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
17
* along with this program; if not, see <http://www.gnu.org/licenses/>.
21
20
#include <config.h>
39
39
#include "options.h"
41
41
#include "photoid.h"
43
44
/* Generate a new photo id packet, or return NULL if canceled */
44
PKT_user_id *generate_photo_id(PKT_public_key *pk)
46
generate_photo_id(PKT_public_key *pk,const char *photo_name)
54
57
header[0]=0x10; /* little side of photo header length */
55
58
header[1]=0; /* big side of photo header length */
62
65
#define EXTRA_UID_NAME_SPACE 71
63
uid=xcalloc (1,sizeof(*uid)+71);
66
uid=xmalloc_clear(sizeof(*uid)+71);
65
printf(_("\nPick an image to use for your photo ID. "
66
"The image must be a JPEG file.\n"
67
"Remember that the image is stored within your public key. "
69
"very large picture, your key will become very large as well!\n"
70
"Keeping the image close to 240x288 is a good size to use.\n"));
68
if(photo_name && *photo_name)
69
filename=make_filename(photo_name,(void *)NULL);
72
tty_printf(_("\nPick an image to use for your photo ID."
73
" The image must be a JPEG file.\n"
74
"Remember that the image is stored within your public key."
76
"very large picture, your key will become very large"
78
"Keeping the image close to 240x288 is a good size"
78
filename=cpr_get("photoid.jpeg.add",
79
_("Enter JPEG filename for photo ID: "));
81
if(strlen(filename)==0)
91
tty_enable_completion(NULL);
93
tempname=cpr_get("photoid.jpeg.add",
94
_("Enter JPEG filename for photo ID: "));
96
tty_disable_completion();
98
filename=make_filename(tempname,(void *)NULL);
102
if(strlen(filename)==0)
84
106
file=iobuf_open(filename);
107
if (file && is_secured_file (iobuf_get_fd (file)))
87
log_error(_("Unable to open photo \"%s\": %s\n"),
115
log_error(_("unable to open JPEG file `%s': %s\n"),
88
116
filename,strerror(errno));
92
len=iobuf_get_filelength(file);
123
len=iobuf_get_filelength(file, &overflow);
124
if(len>6144 || overflow)
95
printf("This JPEG is really large (%d bytes) !\n",len);
126
tty_printf( _("This JPEG is really large (%d bytes) !\n"),len);
96
127
if(!cpr_get_answer_is_yes("photoid.jpeg.size",
97
_("Are you sure you want to use it (y/N)? ")))
128
_("Are you sure you want to use it? (y/N) ")))
99
130
iobuf_close(file);
105
138
iobuf_read(file,photo,len);
106
139
iobuf_close(file);