104 |
|
|
105 |
int running; |
int running; |
106 |
|
|
107 |
|
char *path; |
108 |
|
|
109 |
/* stuff needed for interactive (command) mode */ |
/* stuff needed for interactive (command) mode */ |
110 |
struct { |
struct { |
111 |
int used; |
int used; |
191 |
|
|
192 |
|
|
193 |
gpgme_error_t |
gpgme_error_t |
194 |
_gpgme_gpg_new ( _gpg_object_t *r_gpg ) |
_gpgme_gpg_new (_gpg_object_t *r_gpg) |
195 |
{ |
{ |
196 |
_gpg_object_t gpg; |
_gpg_object_t gpg; |
197 |
char * p; |
char * p; |
274 |
} |
} |
275 |
|
|
276 |
static void |
static void |
277 |
_pipe_close( int * fd ) |
_pipe_close (int * fd) |
278 |
{ |
{ |
279 |
if( fd[0] != -1 ) |
if (fd[0] != -1) |
280 |
_gpgme_io_close( fd[0] ); |
_gpgme_io_close (fd[0]); |
281 |
if( fd[1] != -1 ) |
if (fd[1] != -1) |
282 |
_gpgme_io_close( fd[1] ); |
_gpgme_io_close (fd[1]); |
283 |
} |
} |
284 |
|
|
285 |
|
|
286 |
void |
void |
287 |
_gpgme_gpg_release( _gpg_object_t *r_gpg ) |
_gpgme_gpg_release (_gpg_object_t *r_gpg) |
288 |
{ |
{ |
289 |
struct arg_and_data_s * a; |
struct arg_and_data_s * a; |
290 |
_gpg_object_t gpg = *r_gpg; |
_gpg_object_t gpg = *r_gpg; |
291 |
|
|
292 |
if( !gpg ) |
if( !gpg ) |
293 |
return; |
return; |
294 |
safe_free( gpg->status.buffer ); |
safe_free (gpg->status.buffer); |
295 |
safe_free( gpg->logging.buffer ); |
safe_free (gpg->logging.buffer); |
296 |
safe_free( gpg->colon.buffer ); |
safe_free (gpg->colon.buffer); |
297 |
safe_free( gpg->cmd.keyword ); |
safe_free (gpg->cmd.keyword); |
298 |
if (gpg->argv) |
if (gpg->argv) |
299 |
free_argv(gpg->argv); |
free_argv(gpg->argv); |
300 |
|
|
301 |
|
safe_free (gpg->path); |
302 |
|
|
303 |
if (gpg->pid != -1) |
if (gpg->pid != -1) |
304 |
_gpgme_remove_proc_from_wait_queue ( gpg->pid ); |
_gpgme_remove_proc_from_wait_queue ( gpg->pid ); |
305 |
_pipe_close( gpg->status.fd ); |
_pipe_close( gpg->status.fd ); |
515 |
} |
} |
516 |
|
|
517 |
|
|
518 |
|
void |
519 |
|
_gpgme_gpg_set_path (_gpg_object_t gpg, const char *homedir) |
520 |
|
{ |
521 |
|
const char * s = "gpg.exe"; |
522 |
|
safe_free (gpg->path); |
523 |
|
if (!homedir) |
524 |
|
return; |
525 |
|
gpg->path = malloc (strlen (homedir) + 1 + strlen (s)); |
526 |
|
sprintf (gpg->path, "%s\\%s", homedir, s); |
527 |
|
} |
528 |
|
|
529 |
|
|
530 |
gpgme_error_t |
gpgme_error_t |
531 |
_gpgme_gpg_set_list_options (_gpg_object_t gpg, int opts) |
_gpgme_gpg_set_list_options (_gpg_object_t gpg, int opts) |
532 |
{ |
{ |
607 |
char **argv; |
char **argv; |
608 |
int need_special = 0; |
int need_special = 0; |
609 |
int use_agent = !!getenv ("GPG_AGENT_INFO"); |
int use_agent = !!getenv ("GPG_AGENT_INFO"); |
610 |
char *optfile = _gpgme_get_gpg_optfile (); |
const char *optfile = _gpgme_get_gpg_optfile (0); |
611 |
|
|
612 |
if ( gpg->argv ) { |
if (gpg->argv) { |
613 |
free_argv ( gpg->argv ); |
free_argv (gpg->argv); |
614 |
gpg->argv = NULL; |
gpg->argv = NULL; |
615 |
} |
} |
616 |
if (gpg->fd_data_map) { |
if (gpg->fd_data_map) { |
703 |
return mk_error(Out_Of_Core); |
return mk_error(Out_Of_Core); |
704 |
} |
} |
705 |
argc++; |
argc++; |
|
safe_free(optfile); |
|
706 |
} |
} |
707 |
if (!gpg->cmd.used) { |
if (!gpg->cmd.used) { |
708 |
argv[argc] = strdup ( "--batch" ); |
argv[argc] = strdup ( "--batch" ); |
839 |
int i, n; |
int i, n; |
840 |
int pid; |
int pid; |
841 |
struct spawn_fd_item_s *fd_child_list, *fd_parent_list; |
struct spawn_fd_item_s *fd_child_list, *fd_parent_list; |
842 |
|
const char *gpg_path = _gpgme_get_gpg_path (0); |
843 |
|
|
844 |
if ( !gpg ) |
if ( !gpg ) |
845 |
return mk_error (Invalid_Value); |
return mk_error (Invalid_Value); |
922 |
fd_parent_list[n].dup_to = -1; |
fd_parent_list[n].dup_to = -1; |
923 |
|
|
924 |
|
|
925 |
pid = _gpgme_io_spawn (_gpgme_get_gpg_path (), |
if (gpg->path) |
926 |
gpg->argv, fd_child_list, fd_parent_list); |
gpg_path = gpg->path; |
927 |
|
pid = _gpgme_io_spawn (gpg_path, gpg->argv, fd_child_list, fd_parent_list); |
928 |
safe_free (fd_child_list); |
safe_free (fd_child_list); |
929 |
if( pid == -1 ) |
if (pid == -1) |
930 |
return mk_error (Exec_Error); |
return mk_error (Exec_Error); |
931 |
|
|
932 |
gpg->pid = pid; |
gpg->pid = pid; |
974 |
} |
} |
975 |
} |
} |
976 |
|
|
977 |
if( gpg->cmd.used ) |
if (gpg->cmd.used) |
978 |
_gpgme_freeze_fd( gpg->cmd.fd ); |
_gpgme_freeze_fd (gpg->cmd.fd); |
979 |
|
|
980 |
/* fixme: check what data we can release here */ |
/* fixme: check what data we can release here */ |
981 |
|
|