summaryrefslogtreecommitdiff
path: root/src/parsetlv.h
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2013-08-09 19:19:26 +0200
committerWerner Koch <wk@gnupg.org>2013-08-09 19:19:26 +0200
commit8579091c4f6a36e6bb06fcfbd147a776166fd3ea (patch)
treebf1e746416e7c1378832a65329cdcbffd6070df2 /src/parsetlv.h
parenta4c80126ae4754c8478c69a8a24a6ffd975485fc (diff)
downloadgpgme-8579091c4f6a36e6bb06fcfbd147a776166fd3ea.tar.gz
Add function gpgme_data_identify.
* src/gpgme.h.in (gpgme_data_type_t): New. (gpgme_data_identify): New prototype. * src/data-identify.c: New. * src/parsetlv.c, src/parsetlv.h: New. Take from gpa. * src/libgpgme.vers, src/gpgme.def: Add gpgme_data_identify. * src/gpgme-tool.c (status): Add STATUS_IDENTIFY_RESULT. (gt_identify): New. (cmd_identify): New. (hlp_passwd): Move close to cmd_passwd. -- It is often useful to have a way to identify the data which needs processing. This is such a common task that it makes sense to implement this in gpgme to avoid diverging implementations.
Diffstat (limited to 'src/parsetlv.h')
-rw-r--r--src/parsetlv.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/parsetlv.h b/src/parsetlv.h
new file mode 100644
index 00000000..153073c1
--- /dev/null
+++ b/src/parsetlv.h
@@ -0,0 +1,48 @@
+/* parsetlv.h - TLV functions defintions
+ * Copyright (C) 2012 g10 Code GmbH
+ *
+ * This file is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This file is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef PARSETLV_H
+#define PARSETLV_H
+
+/* ASN.1 constants. */
+#define ASN1_CLASS_UNIVERSAL 0
+#define ASN1_CLASS_APPLICATION 1
+#define ASN1_CLASS_CONTEXT 2
+#define ASN1_CLASS_PRIVATE 3
+#define ASN1_TAG_INTEGER 2
+#define ASN1_TAG_OBJECT_ID 6
+#define ASN1_TAG_SEQUENCE 16
+
+
+/* Object used with parse_tlv. */
+struct tlvinfo_s
+{
+ int cls; /* The class of the tag. */
+ int tag; /* The tag. */
+ int is_cons; /* True if it is a constructed object. */
+ int is_ndef; /* True if the object has an indefinite length. */
+ size_t length; /* The length of the value. */
+ size_t nhdr; /* The number of octets in the header (tag,length). */
+};
+typedef struct tlvinfo_s tlvinfo_t;
+
+/*-- parsetlv.c --*/
+int _gpgme_parse_tlv (char const **buffer, size_t *size, tlvinfo_t *ti);
+#define parse_tlv(a,b,c) _gpgme_parse_tlv ((a), (b), (c))
+
+
+#endif /*PARSETLV_H*/