aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Shaw <[email protected]>2002-05-04 00:39:15 +0000
committerDavid Shaw <[email protected]>2002-05-04 00:39:15 +0000
commit4991e018bff777461a9d9942b13799629171686e (patch)
treeeb162015db189a44268695e0af381e98784b50b6
parent* keyedit.c (sign_uids): Nonrevocable key signatures cause an automatic (diff)
downloadgnupg-4991e018bff777461a9d9942b13799629171686e.tar.gz
gnupg-4991e018bff777461a9d9942b13799629171686e.zip
* 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.
-rw-r--r--g10/ChangeLog9
-rw-r--r--g10/exec.c22
-rw-r--r--g10/exec.h4
-rw-r--r--g10/keyserver.c4
-rw-r--r--g10/misc.c2
-rw-r--r--g10/photoid.c7
6 files changed, 34 insertions, 14 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index 11b521d79..66d3152b1 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,5 +1,14 @@
2002-05-03 David Shaw <[email protected]>
+ * 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
automatic promotion to v4.
diff --git a/g10/exec.c b/g10/exec.c
index 4c0c664fc..dd2c6472d 100644
--- a/g10/exec.c
+++ b/g10/exec.c
@@ -61,7 +61,10 @@ char *mkdtemp(char *template);
/* Makes a temp directory and filenames */
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 */
if(tmp==NULL)
@@ -112,17 +115,17 @@ static int make_tempdir(struct exec_info *info)
{
info->madedir=1;
- info->tempfile_in=m_alloc(strlen(info->tempdir)
- +strlen(DIRSEP_S)+6+strlen(EXTSEP_S)+3+1);
+ info->tempfile_in=m_alloc(strlen(info->tempdir)+strlen(DIRSEP_S)+6+
+ strlen(EXTSEP_S)+strlen(ext)+1);
sprintf(info->tempfile_in,"%s" DIRSEP_S "datain" EXTSEP_S "%s",
- info->tempdir,info->binary?"bin":"txt");
+ info->tempdir,ext);
if(!info->writeonly)
{
- info->tempfile_out=m_alloc(strlen(info->tempdir)
- +strlen(DIRSEP_S)+7+strlen(EXTSEP_S)+3+1);
+ info->tempfile_out=m_alloc(strlen(info->tempdir)+strlen(DIRSEP_S)+7+
+ strlen(EXTSEP_S)+strlen(ext)+1);
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. */
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;
@@ -257,6 +260,8 @@ int exec_write(struct exec_info **info,const char *program,
*info=m_alloc_clear(sizeof(struct exec_info));
+ if(ext)
+ (*info)->ext=m_strdup(ext);
(*info)->binary=binary;
(*info)->writeonly=writeonly;
@@ -500,6 +505,7 @@ int exec_finish(struct exec_info *info)
}
m_free(info->command);
+ m_free(info->ext);
m_free(info->tempdir);
m_free(info->tempfile_in);
m_free(info->tempfile_out);
diff --git a/g10/exec.h b/g10/exec.h
index 48696d34a..876081778 100644
--- a/g10/exec.h
+++ b/g10/exec.h
@@ -11,11 +11,11 @@ struct exec_info
pid_t child;
FILE *tochild;
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,
- 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_finish(struct exec_info *info);
diff --git a/g10/keyserver.c b/g10/keyserver.c
index dbd2d4733..013ee56fc 100644
--- a/g10/keyserver.c
+++ b/g10/keyserver.c
@@ -297,10 +297,10 @@ keyserver_spawn(int action,STRLIST list,
strcat(command,KEYSERVER_ARGS_NOKEEP);
}
- ret=exec_write(&spawn,NULL,command,0,0);
+ ret=exec_write(&spawn,NULL,command,NULL,0,0);
}
else
- ret=exec_write(&spawn,command,NULL,0,0);
+ ret=exec_write(&spawn,command,NULL,NULL,0,0);
if(ret)
return ret;
diff --git a/g10/misc.c b/g10/misc.c
index 4316d8f01..c9322d9ef 100644
--- a/g10/misc.c
+++ b/g10/misc.c
@@ -516,7 +516,7 @@ pct_expando(const char *string,struct expando_args *args)
break;
case 't': /* e.g. "jpg" */
- str=image_type_to_string(args->imagetype,1);
+ str=image_type_to_string(args->imagetype,0);
/* fall through */
case 'T': /* e.g. "image/jpeg" */
diff --git a/g10/photoid.c b/g10/photoid.c
index 3953e6dbe..7a769b711 100644
--- a/g10/photoid.c
+++ b/g10/photoid.c
@@ -35,7 +35,11 @@
#include "main.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"
+#endif
/* Generate a new photo id packet, or return NULL if canceled */
PKT_user_id *generate_photo_id(PKT_public_key *pk)
@@ -240,7 +244,8 @@ void show_photos(const struct user_attribute *attrs,
if(!command)
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;
fwrite(&attrs[i].data[offset],attrs[i].len-offset,1,spawn->tochild);