aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2016-10-08 19:14:52 +0000
committerWerner Koch <[email protected]>2016-10-08 19:17:48 +0000
commit0ea2ff67900c243fff9f689658dcb23d1c0961cd (patch)
treedbac0b0c700bec5ce5bb31c070047af3f00d4abe /src
parentAdd missing includes. (diff)
downloadgpgme-0ea2ff67900c243fff9f689658dcb23d1c0961cd.tar.gz
gpgme-0ea2ff67900c243fff9f689658dcb23d1c0961cd.zip
core: New helper function gpgme_addrspec_from_uid.
* src/gpgme.h.in: Add gpgme_addrspec_from_uid. * src/gpgme.def, src/libgpgme.vers: Ditto. * src/mbox-util.c (gpgme_addrspec_from_uid): New. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gpgme.def2
-rw-r--r--src/gpgme.h.in6
-rw-r--r--src/libgpgme.vers2
-rw-r--r--src/mbox-util.c18
4 files changed, 27 insertions, 1 deletions
diff --git a/src/gpgme.def b/src/gpgme.def
index 9815a834..c94c9607 100644
--- a/src/gpgme.def
+++ b/src/gpgme.def
@@ -244,5 +244,7 @@ EXPORTS
gpgme_op_interact_start @184
gpgme_op_interact @185
+ gpgme_addrspec_from_uid @186
+
; END
diff --git a/src/gpgme.h.in b/src/gpgme.h.in
index 20654db9..5c914ae7 100644
--- a/src/gpgme.h.in
+++ b/src/gpgme.h.in
@@ -846,7 +846,7 @@ struct _gpgme_user_id
/* The mail address (addr-spec from RFC5322) of the UID string.
* This is general the same as the EMAIL part of this struct but
- * might be slightly different. IF no mail address is available
+ * might be slightly different. If no mail address is available
* NULL is stored. */
char *address;
@@ -2471,6 +2471,10 @@ const char *gpgme_pubkey_algo_name (gpgme_pubkey_algo_t algo);
algorithm ALGO, or NULL if that name is not known. */
const char *gpgme_hash_algo_name (gpgme_hash_algo_t algo);
+/* Return the addr-spec from a user id. Caller must free the result
+ * with gpgme_free. */
+char *gpgme_addrspec_from_uid (const char *uid);
+
/*
diff --git a/src/libgpgme.vers b/src/libgpgme.vers
index aec9090d..d3962db0 100644
--- a/src/libgpgme.vers
+++ b/src/libgpgme.vers
@@ -117,6 +117,8 @@ GPGME_1.1 {
gpgme_op_tofu_policy;
gpgme_op_interact_start;
gpgme_op_interact;
+
+ gpgme_addrspec_from_uid;
};
diff --git a/src/mbox-util.c b/src/mbox-util.c
index 656b5d7b..81e929bd 100644
--- a/src/mbox-util.c
+++ b/src/mbox-util.c
@@ -255,3 +255,21 @@ _gpgme_mailbox_from_userid (const char *userid)
/* return 1; */
/* } */
+
+
+/*
+ * Exported public API
+ */
+
+
+/* Return the mail address ("addr-spec" as per RFC-5322) from a string
+ * which is assumed to be an user id ("address" in RFC-5322). All
+ * plain ASCII characters (those with bit 7 cleared) in the result
+ * are converted to lowercase. Caller must free the result using
+ * gpgme_free. Returns NULL if no valid address was found (in which
+ * case ERRNO is set to EINVAL) or for other errors. */
+char *
+gpgme_addrspec_from_uid (const char *uid)
+{
+ return _gpgme_mailbox_from_userid (uid);
+}