diff options
author | Werner Koch <[email protected]> | 2013-08-09 17:19:26 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2013-08-09 17:19:26 +0000 |
commit | 8579091c4f6a36e6bb06fcfbd147a776166fd3ea (patch) | |
tree | bf1e746416e7c1378832a65329cdcbffd6070df2 /src/parsetlv.h | |
parent | Prefer GnuPG-2 engines over GnuPG-1. (diff) | |
download | gpgme-8579091c4f6a36e6bb06fcfbd147a776166fd3ea.tar.gz gpgme-8579091c4f6a36e6bb06fcfbd147a776166fd3ea.zip |
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.h | 48 |
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*/ |