1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-11-04 20:38:50 +01:00

* photoid.c: Provide default image viewer for Win32.

* misc.c (pct_expando): %t means extension, not name ("jpg", not "jpeg").

* keyserver.c (keyserver_spawn), photoid.c (show_photos), exec.h, exec.c:
Allow the caller to determine the temp file extension when starting an
exec_write and change all callers.
This commit is contained in:
David Shaw 2002-05-04 00:39:15 +00:00
parent 201ad25df9
commit 4991e018bf
6 changed files with 34 additions and 14 deletions

View File

@ -1,5 +1,14 @@
2002-05-03 David Shaw <dshaw@jabberwocky.com> 2002-05-03 David Shaw <dshaw@jabberwocky.com>
* photoid.c: Provide default image viewer for Win32.
* misc.c (pct_expando): %t means extension, not name ("jpg", not
"jpeg").
* keyserver.c (keyserver_spawn), photoid.c (show_photos), exec.h,
exec.c: Allow the caller to determine the temp file extension when
starting an exec_write and change all callers.
* keyedit.c (sign_uids): Nonrevocable key signatures cause an * keyedit.c (sign_uids): Nonrevocable key signatures cause an
automatic promotion to v4. automatic promotion to v4.

View File

@ -61,7 +61,10 @@ char *mkdtemp(char *template);
/* Makes a temp directory and filenames */ /* Makes a temp directory and filenames */
static int make_tempdir(struct exec_info *info) static int make_tempdir(struct exec_info *info)
{ {
char *tmp=opt.temp_dir; char *tmp=opt.temp_dir,*ext=info->ext;
if(!ext)
ext=info->binary?"bin":"txt";
/* Make up the temp dir and files in case we need them */ /* Make up the temp dir and files in case we need them */
if(tmp==NULL) if(tmp==NULL)
@ -112,17 +115,17 @@ static int make_tempdir(struct exec_info *info)
{ {
info->madedir=1; info->madedir=1;
info->tempfile_in=m_alloc(strlen(info->tempdir) info->tempfile_in=m_alloc(strlen(info->tempdir)+strlen(DIRSEP_S)+6+
+strlen(DIRSEP_S)+6+strlen(EXTSEP_S)+3+1); strlen(EXTSEP_S)+strlen(ext)+1);
sprintf(info->tempfile_in,"%s" DIRSEP_S "datain" EXTSEP_S "%s", sprintf(info->tempfile_in,"%s" DIRSEP_S "datain" EXTSEP_S "%s",
info->tempdir,info->binary?"bin":"txt"); info->tempdir,ext);
if(!info->writeonly) if(!info->writeonly)
{ {
info->tempfile_out=m_alloc(strlen(info->tempdir) info->tempfile_out=m_alloc(strlen(info->tempdir)+strlen(DIRSEP_S)+7+
+strlen(DIRSEP_S)+7+strlen(EXTSEP_S)+3+1); strlen(EXTSEP_S)+strlen(ext)+1);
sprintf(info->tempfile_out,"%s" DIRSEP_S "dataout" EXTSEP_S "%s", sprintf(info->tempfile_out,"%s" DIRSEP_S "dataout" EXTSEP_S "%s",
info->tempdir,info->binary?"bin":"txt"); info->tempdir,ext);
} }
} }
@ -233,7 +236,7 @@ static int expand_args(struct exec_info *info,const char *args_in)
shell -c. If there are tempfiles, then it's a system. */ shell -c. If there are tempfiles, then it's a system. */
int exec_write(struct exec_info **info,const char *program, int exec_write(struct exec_info **info,const char *program,
const char *args_in,int writeonly,int binary) const char *args_in,const char *ext,int writeonly,int binary)
{ {
int ret=G10ERR_GENERAL; int ret=G10ERR_GENERAL;
@ -257,6 +260,8 @@ int exec_write(struct exec_info **info,const char *program,
*info=m_alloc_clear(sizeof(struct exec_info)); *info=m_alloc_clear(sizeof(struct exec_info));
if(ext)
(*info)->ext=m_strdup(ext);
(*info)->binary=binary; (*info)->binary=binary;
(*info)->writeonly=writeonly; (*info)->writeonly=writeonly;
@ -500,6 +505,7 @@ int exec_finish(struct exec_info *info)
} }
m_free(info->command); m_free(info->command);
m_free(info->ext);
m_free(info->tempdir); m_free(info->tempdir);
m_free(info->tempfile_in); m_free(info->tempfile_in);
m_free(info->tempfile_out); m_free(info->tempfile_out);

View File

@ -11,11 +11,11 @@ struct exec_info
pid_t child; pid_t child;
FILE *tochild; FILE *tochild;
IOBUF fromchild; IOBUF fromchild;
char *command,*tempdir,*tempfile_in,*tempfile_out; char *command,*ext,*tempdir,*tempfile_in,*tempfile_out;
}; };
int exec_write(struct exec_info **info,const char *program, int exec_write(struct exec_info **info,const char *program,
const char *args_in,int writeonly,int binary); const char *args_in,const char *ext,int writeonly,int binary);
int exec_read(struct exec_info *info); int exec_read(struct exec_info *info);
int exec_finish(struct exec_info *info); int exec_finish(struct exec_info *info);

View File

@ -297,10 +297,10 @@ keyserver_spawn(int action,STRLIST list,
strcat(command,KEYSERVER_ARGS_NOKEEP); strcat(command,KEYSERVER_ARGS_NOKEEP);
} }
ret=exec_write(&spawn,NULL,command,0,0); ret=exec_write(&spawn,NULL,command,NULL,0,0);
} }
else else
ret=exec_write(&spawn,command,NULL,0,0); ret=exec_write(&spawn,command,NULL,NULL,0,0);
if(ret) if(ret)
return ret; return ret;

View File

@ -516,7 +516,7 @@ pct_expando(const char *string,struct expando_args *args)
break; break;
case 't': /* e.g. "jpg" */ case 't': /* e.g. "jpg" */
str=image_type_to_string(args->imagetype,1); str=image_type_to_string(args->imagetype,0);
/* fall through */ /* fall through */
case 'T': /* e.g. "image/jpeg" */ case 'T': /* e.g. "image/jpeg" */

View File

@ -35,7 +35,11 @@
#include "main.h" #include "main.h"
#include "photoid.h" #include "photoid.h"
#ifdef HAVE_DOSISH_SYSTEM
#define DEFAULT_PHOTO_COMMAND "start /w %i"
#else
#define DEFAULT_PHOTO_COMMAND "xloadimage -fork -quiet -title 'KeyID 0x%k' stdin" #define DEFAULT_PHOTO_COMMAND "xloadimage -fork -quiet -title 'KeyID 0x%k' stdin"
#endif
/* Generate a new photo id packet, or return NULL if canceled */ /* Generate a new photo id packet, or return NULL if canceled */
PKT_user_id *generate_photo_id(PKT_public_key *pk) PKT_user_id *generate_photo_id(PKT_public_key *pk)
@ -240,7 +244,8 @@ void show_photos(const struct user_attribute *attrs,
if(!command) if(!command)
goto fail; goto fail;
if(exec_write(&spawn,NULL,command,1,1)!=0) if(exec_write(&spawn,NULL,command,
image_type_to_string(args.imagetype,0),1,1)!=0)
goto fail; goto fail;
fwrite(&attrs[i].data[offset],attrs[i].len-offset,1,spawn->tochild); fwrite(&attrs[i].data[offset],attrs[i].len-offset,1,spawn->tochild);