gpgme_conf_arg_t *arg_p, char *line)
{
gpgme_error_t err;
- char *mark;
+ char *mark = NULL;
if (!line[0])
return 0;
{
gpgme_conf_arg_t arg;
- mark = strchr (line, ',');
+ if (opt->type != GPGME_CONF_STRING)
+ mark = strchr (line, ',');
if (mark)
*mark = '\0';
}
+struct gpgconf_config_dir_s
+{
+ const char *what;
+ char *result;
+};
+
+/* Called for each line in the gpgconf --list-dirs output. Searches
+ for the desired line and returns the result, indicating success by
+ a special error value GPG_ERR_USER_1 (which terminates the
+ operation immediately). */
+static gpgme_error_t
+gpgconf_config_dir_cb (void *hook, char *line)
+{
+ /* This is an input- and output-parameter. */
+ struct gpgconf_config_dir_s *data = (struct gpgconf_config_dir_s *) hook;
+ int len = strlen(data->what);
+
+ if (!strncmp(line, data->what, len) && line[len] == ':')
+ {
+ char *result = strdup(&line[len + 1]);
+ if (!result)
+ return gpg_error_from_syserror ();
+ data->result = result;
+ return gpg_error(GPG_ERR_USER_1);
+ }
+ return 0;
+}
+
+
+/* Like gpgme_get_dirinfo, but uses the home directory of ENGINE and
+ does not cache the result. */
+static gpgme_error_t
+gpgconf_conf_dir (void *engine, const char *what, char **result)
+{
+ gpgme_error_t err;
+ struct gpgconf_config_dir_s data;
+
+ data.what = what;
+ data.result = NULL;
+ err = gpgconf_read (engine, "--list-dirs", NULL,
+ gpgconf_config_dir_cb, &data);
+ if (gpg_err_code (err) == GPG_ERR_USER_1)
+ {
+ /* This signals to us that a result was found. */
+ *result = data.result;
+ return 0;
+ }
+
+ if (!err)
+ err = gpg_error(GPG_ERR_NOT_FOUND);
+ return 0;
+}
+
+
/* Parse a line received from gpgconf --query-swdb. This function may
* modify LINE. The result is stored at RESUL. */
static gpg_error_t
NULL, /* set_colon_line_handler */
NULL, /* set_locale */
NULL, /* set_protocol */
+ NULL, /* set_engine_flags */
NULL, /* decrypt */
NULL, /* delete */
NULL, /* edit */
NULL, /* opassuan_transact */
gpgconf_conf_load,
gpgconf_conf_save,
+ gpgconf_conf_dir,
gpgconf_query_swdb,
gpgconf_set_io_cbs,
NULL, /* io_event */