diff options
Diffstat (limited to 'g10/exec.c')
-rw-r--r-- | g10/exec.c | 22 |
1 files changed, 14 insertions, 8 deletions
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); |