summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/ASN1.c3004
-rw-r--r--lib/ASN1.y894
-rw-r--r--lib/Makefile.am59
-rw-r--r--lib/coding.c1347
-rw-r--r--lib/decoding.c2376
-rw-r--r--lib/element.c1111
-rw-r--r--lib/element.h40
-rw-r--r--lib/errors.c99
-rw-r--r--lib/gllib/Makefile.am419
-rw-r--r--lib/gllib/hash-pjw-bare.c42
-rw-r--r--lib/gllib/hash-pjw-bare.h24
-rw-r--r--lib/gllib/intprops.h458
-rw-r--r--lib/gllib/limits.in.h63
-rw-r--r--lib/gllib/minmax.h60
-rw-r--r--lib/gllib/stddef.in.h110
-rw-r--r--lib/gllib/stdint.in.h707
-rw-r--r--lib/gllib/string.in.h1046
-rw-r--r--lib/gllib/strverscmp.c117
-rw-r--r--lib/gllib/sys_types.in.h53
-rw-r--r--lib/gllib/verify.h279
-rw-r--r--lib/glm4/00gnulib.m446
-rw-r--r--lib/glm4/absolute-header.m4102
-rw-r--r--lib/glm4/extensions.m4173
-rw-r--r--lib/glm4/extern-inline.m4102
-rw-r--r--lib/glm4/gnulib-cache.m456
-rw-r--r--lib/glm4/gnulib-common.m4462
-rw-r--r--lib/glm4/gnulib-comp.m4272
-rw-r--r--lib/glm4/gnulib-tool.m457
-rw-r--r--lib/glm4/include_next.m4223
-rw-r--r--lib/glm4/ld-version-script.m448
-rw-r--r--lib/glm4/limits-h.m431
-rw-r--r--lib/glm4/longlong.m4113
-rw-r--r--lib/glm4/minmax.m444
-rw-r--r--lib/glm4/multiarch.m462
-rw-r--r--lib/glm4/off_t.m418
-rw-r--r--lib/glm4/ssize_t.m423
-rw-r--r--lib/glm4/stddef_h.m451
-rw-r--r--lib/glm4/stdint.m4541
-rw-r--r--lib/glm4/string_h.m4120
-rw-r--r--lib/glm4/strverscmp.m422
-rw-r--r--lib/glm4/sys_types_h.m449
-rw-r--r--lib/glm4/visibility.m477
-rw-r--r--lib/glm4/warn-on-use.m447
-rw-r--r--lib/glm4/wchar_t.m424
-rw-r--r--lib/glm4/wint_t.m462
-rw-r--r--lib/gstr.c74
-rw-r--r--lib/gstr.h42
-rw-r--r--lib/int.h222
-rw-r--r--lib/libtasn1.h405
-rw-r--r--lib/libtasn1.map63
-rw-r--r--lib/libtasn1.pc.in30
-rw-r--r--lib/parser_aux.c1097
-rw-r--r--lib/parser_aux.h158
-rw-r--r--lib/structure.c1197
-rw-r--r--lib/structure.h40
-rw-r--r--lib/version.c51
56 files changed, 0 insertions, 18512 deletions
diff --git a/lib/ASN1.c b/lib/ASN1.c
deleted file mode 100644
index 586dcca..0000000
--- a/lib/ASN1.c
+++ /dev/null
@@ -1,3004 +0,0 @@
-/* A Bison parser, made by GNU Bison 3.0.4. */
-
-/* Bison implementation for Yacc-like parsers in C
-
- Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-/* As a special exception, you may create a larger work that contains
- part or all of the Bison parser skeleton and distribute that work
- under terms of your choice, so long as that work isn't itself a
- parser generator using the skeleton or a modified version thereof
- as a parser skeleton. Alternatively, if you modify or redistribute
- the parser skeleton itself, you may (at your option) remove this
- special exception, which will cause the skeleton and the resulting
- Bison output files to be licensed under the GNU General Public
- License without this special exception.
-
- This special exception was added by the Free Software Foundation in
- version 2.2 of Bison. */
-
-/* C LALR(1) parser skeleton written by Richard Stallman, by
- simplifying the original so-called "semantic" parser. */
-
-/* All symbols defined below should begin with yy or YY, to avoid
- infringing on user name space. This should be done even for local
- variables, as they might otherwise be expanded by user macros.
- There are some unavoidable exceptions within include files to
- define necessary library symbols; they are noted "INFRINGES ON
- USER NAME SPACE" below. */
-
-/* Identify Bison output. */
-#define YYBISON 1
-
-/* Bison version. */
-#define YYBISON_VERSION "3.0.4"
-
-/* Skeleton name. */
-#define YYSKELETON_NAME "yacc.c"
-
-/* Pure parsers. */
-#define YYPURE 0
-
-/* Push parsers. */
-#define YYPUSH 0
-
-/* Pull parsers. */
-#define YYPULL 1
-
-
-/* Substitute the variable and function names. */
-#define yyparse _asn1_yyparse
-#define yylex _asn1_yylex
-#define yyerror _asn1_yyerror
-#define yydebug _asn1_yydebug
-#define yynerrs _asn1_yynerrs
-
-#define yylval _asn1_yylval
-#define yychar _asn1_yychar
-
-/* Copy the first part of user declarations. */
-#line 1 "ASN1.y" /* yacc.c:339 */
-
-/*
- * Copyright (C) 2001-2014 Free Software Foundation, Inc.
- *
- * This file is part of LIBTASN1.
- *
- * The LIBTASN1 library 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 library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- */
-
-/*****************************************************/
-/* File: x509_ASN.y */
-/* Description: input file for 'bison' program. */
-/* The output file is a parser (in C language) for */
-/* ASN.1 syntax */
-/*****************************************************/
-
-#include <int.h>
-#include <parser_aux.h>
-#include <structure.h>
-#include <libtasn1.h>
-
-static FILE *file_asn1; /* Pointer to file to parse */
-static int result_parse = 0; /* result of the parser
- algorithm */
-static asn1_node p_tree; /* pointer to the root of the
- structure created by the
- parser*/
-static unsigned int line_number; /* line number describing the
- parser position inside the
- file */
-static char last_error[ASN1_MAX_ERROR_DESCRIPTION_SIZE] = "";
-static char last_error_token[ASN1_MAX_ERROR_DESCRIPTION_SIZE+1] = ""; /* used when expected errors occur */
-static char last_token[ASN1_MAX_NAME_SIZE+1] = ""; /* last token find in the file
- to parse before the 'parse
- error' */
-extern char _asn1_identifierMissing[];
-static const char *file_name; /* file to parse */
-
-static void _asn1_yyerror (const char *);
-static int _asn1_yylex(void);
-
-
-#line 130 "ASN1.c" /* yacc.c:339 */
-
-# ifndef YY_NULLPTR
-# if defined __cplusplus && 201103L <= __cplusplus
-# define YY_NULLPTR nullptr
-# else
-# define YY_NULLPTR 0
-# endif
-# endif
-
-/* Enabling verbose error messages. */
-#ifdef YYERROR_VERBOSE
-# undef YYERROR_VERBOSE
-# define YYERROR_VERBOSE 1
-#else
-# define YYERROR_VERBOSE 1
-#endif
-
-
-/* Debug traces. */
-#ifndef YYDEBUG
-# define YYDEBUG 0
-#endif
-#if YYDEBUG
-extern int _asn1_yydebug;
-#endif
-
-/* Token type. */
-#ifndef YYTOKENTYPE
-# define YYTOKENTYPE
- enum yytokentype
- {
- ASSIG = 258,
- NUM = 259,
- IDENTIFIER = 260,
- OPTIONAL = 261,
- INTEGER = 262,
- SIZE = 263,
- OCTET = 264,
- STRING = 265,
- SEQUENCE = 266,
- BIT = 267,
- UNIVERSAL = 268,
- PRIVATE = 269,
- APPLICATION = 270,
- DEFAULT = 271,
- CHOICE = 272,
- OF = 273,
- OBJECT = 274,
- STR_IDENTIFIER = 275,
- BOOLEAN = 276,
- ASN1_TRUE = 277,
- ASN1_FALSE = 278,
- TOKEN_NULL = 279,
- ANY = 280,
- DEFINED = 281,
- BY = 282,
- SET = 283,
- EXPLICIT = 284,
- IMPLICIT = 285,
- DEFINITIONS = 286,
- TAGS = 287,
- BEGIN = 288,
- END = 289,
- UTCTime = 290,
- GeneralizedTime = 291,
- GeneralString = 292,
- NumericString = 293,
- IA5String = 294,
- TeletexString = 295,
- PrintableString = 296,
- UniversalString = 297,
- BMPString = 298,
- UTF8String = 299,
- VisibleString = 300,
- FROM = 301,
- IMPORTS = 302,
- ENUMERATED = 303
- };
-#endif
-/* Tokens. */
-#define ASSIG 258
-#define NUM 259
-#define IDENTIFIER 260
-#define OPTIONAL 261
-#define INTEGER 262
-#define SIZE 263
-#define OCTET 264
-#define STRING 265
-#define SEQUENCE 266
-#define BIT 267
-#define UNIVERSAL 268
-#define PRIVATE 269
-#define APPLICATION 270
-#define DEFAULT 271
-#define CHOICE 272
-#define OF 273
-#define OBJECT 274
-#define STR_IDENTIFIER 275
-#define BOOLEAN 276
-#define ASN1_TRUE 277
-#define ASN1_FALSE 278
-#define TOKEN_NULL 279
-#define ANY 280
-#define DEFINED 281
-#define BY 282
-#define SET 283
-#define EXPLICIT 284
-#define IMPLICIT 285
-#define DEFINITIONS 286
-#define TAGS 287
-#define BEGIN 288
-#define END 289
-#define UTCTime 290
-#define GeneralizedTime 291
-#define GeneralString 292
-#define NumericString 293
-#define IA5String 294
-#define TeletexString 295
-#define PrintableString 296
-#define UniversalString 297
-#define BMPString 298
-#define UTF8String 299
-#define VisibleString 300
-#define FROM 301
-#define IMPORTS 302
-#define ENUMERATED 303
-
-/* Value type. */
-#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-
-union YYSTYPE
-{
-#line 62 "ASN1.y" /* yacc.c:355 */
-
- unsigned int constant;
- char str[ASN1_MAX_NAME_SIZE+1];
- asn1_node node;
-
-#line 269 "ASN1.c" /* yacc.c:355 */
-};
-
-typedef union YYSTYPE YYSTYPE;
-# define YYSTYPE_IS_TRIVIAL 1
-# define YYSTYPE_IS_DECLARED 1
-#endif
-
-
-extern YYSTYPE _asn1_yylval;
-
-int _asn1_yyparse (void);
-
-
-
-/* Copy the second part of user declarations. */
-
-#line 286 "ASN1.c" /* yacc.c:358 */
-
-#ifdef short
-# undef short
-#endif
-
-#ifdef YYTYPE_UINT8
-typedef YYTYPE_UINT8 yytype_uint8;
-#else
-typedef unsigned char yytype_uint8;
-#endif
-
-#ifdef YYTYPE_INT8
-typedef YYTYPE_INT8 yytype_int8;
-#else
-typedef signed char yytype_int8;
-#endif
-
-#ifdef YYTYPE_UINT16
-typedef YYTYPE_UINT16 yytype_uint16;
-#else
-typedef unsigned short int yytype_uint16;
-#endif
-
-#ifdef YYTYPE_INT16
-typedef YYTYPE_INT16 yytype_int16;
-#else
-typedef short int yytype_int16;
-#endif
-
-#ifndef YYSIZE_T
-# ifdef __SIZE_TYPE__
-# define YYSIZE_T __SIZE_TYPE__
-# elif defined size_t
-# define YYSIZE_T size_t
-# elif ! defined YYSIZE_T
-# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
-# define YYSIZE_T size_t
-# else
-# define YYSIZE_T unsigned int
-# endif
-#endif
-
-#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
-
-#ifndef YY_
-# if defined YYENABLE_NLS && YYENABLE_NLS
-# if ENABLE_NLS
-# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
-# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
-# endif
-# endif
-# ifndef YY_
-# define YY_(Msgid) Msgid
-# endif
-#endif
-
-#ifndef YY_ATTRIBUTE
-# if (defined __GNUC__ \
- && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
- || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
-# define YY_ATTRIBUTE(Spec) __attribute__(Spec)
-# else
-# define YY_ATTRIBUTE(Spec) /* empty */
-# endif
-#endif
-
-#ifndef YY_ATTRIBUTE_PURE
-# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
-#endif
-
-#ifndef YY_ATTRIBUTE_UNUSED
-# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
-#endif
-
-#if !defined _Noreturn \
- && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
-# if defined _MSC_VER && 1200 <= _MSC_VER
-# define _Noreturn __declspec (noreturn)
-# else
-# define _Noreturn YY_ATTRIBUTE ((__noreturn__))
-# endif
-#endif
-
-/* Suppress unused-variable warnings by "using" E. */
-#if ! defined lint || defined __GNUC__
-# define YYUSE(E) ((void) (E))
-#else
-# define YYUSE(E) /* empty */
-#endif
-
-#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
-/* Suppress an incorrect diagnostic about yylval being uninitialized. */
-# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
- _Pragma ("GCC diagnostic push") \
- _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
- _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
-# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
- _Pragma ("GCC diagnostic pop")
-#else
-# define YY_INITIAL_VALUE(Value) Value
-#endif
-#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
-# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
-# define YY_IGNORE_MAYBE_UNINITIALIZED_END
-#endif
-#ifndef YY_INITIAL_VALUE
-# define YY_INITIAL_VALUE(Value) /* Nothing. */
-#endif
-
-
-#if ! defined yyoverflow || YYERROR_VERBOSE
-
-/* The parser invokes alloca or malloc; define the necessary symbols. */
-
-# ifdef YYSTACK_USE_ALLOCA
-# if YYSTACK_USE_ALLOCA
-# ifdef __GNUC__
-# define YYSTACK_ALLOC __builtin_alloca
-# elif defined __BUILTIN_VA_ARG_INCR
-# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
-# elif defined _AIX
-# define YYSTACK_ALLOC __alloca
-# elif defined _MSC_VER
-# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
-# define alloca _alloca
-# else
-# define YYSTACK_ALLOC alloca
-# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
-# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
- /* Use EXIT_SUCCESS as a witness for stdlib.h. */
-# ifndef EXIT_SUCCESS
-# define EXIT_SUCCESS 0
-# endif
-# endif
-# endif
-# endif
-# endif
-
-# ifdef YYSTACK_ALLOC
- /* Pacify GCC's 'empty if-body' warning. */
-# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
-# ifndef YYSTACK_ALLOC_MAXIMUM
- /* The OS might guarantee only one guard page at the bottom of the stack,
- and a page size can be as small as 4096 bytes. So we cannot safely
- invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
- to allow for a few compiler-allocated temporary stack slots. */
-# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
-# endif
-# else
-# define YYSTACK_ALLOC YYMALLOC
-# define YYSTACK_FREE YYFREE
-# ifndef YYSTACK_ALLOC_MAXIMUM
-# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
-# endif
-# if (defined __cplusplus && ! defined EXIT_SUCCESS \
- && ! ((defined YYMALLOC || defined malloc) \
- && (defined YYFREE || defined free)))
-# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
-# ifndef EXIT_SUCCESS
-# define EXIT_SUCCESS 0
-# endif
-# endif
-# ifndef YYMALLOC
-# define YYMALLOC malloc
-# if ! defined malloc && ! defined EXIT_SUCCESS
-void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
-# endif
-# endif
-# ifndef YYFREE
-# define YYFREE free
-# if ! defined free && ! defined EXIT_SUCCESS
-void free (void *); /* INFRINGES ON USER NAME SPACE */
-# endif
-# endif
-# endif
-#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
-
-
-#if (! defined yyoverflow \
- && (! defined __cplusplus \
- || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
-
-/* A type that is properly aligned for any stack member. */
-union yyalloc
-{
- yytype_int16 yyss_alloc;
- YYSTYPE yyvs_alloc;
-};
-
-/* The size of the maximum gap between one aligned stack and the next. */
-# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
-
-/* The size of an array large to enough to hold all stacks, each with
- N elements. */
-# define YYSTACK_BYTES(N) \
- ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
- + YYSTACK_GAP_MAXIMUM)
-
-# define YYCOPY_NEEDED 1
-
-/* Relocate STACK from its old location to the new one. The
- local variables YYSIZE and YYSTACKSIZE give the old and new number of
- elements in the stack, and YYPTR gives the new location of the
- stack. Advance YYPTR to a properly aligned location for the next
- stack. */
-# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
- do \
- { \
- YYSIZE_T yynewbytes; \
- YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
- Stack = &yyptr->Stack_alloc; \
- yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
- yyptr += yynewbytes / sizeof (*yyptr); \
- } \
- while (0)
-
-#endif
-
-#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
-/* Copy COUNT objects from SRC to DST. The source and destination do
- not overlap. */
-# ifndef YYCOPY
-# if defined __GNUC__ && 1 < __GNUC__
-# define YYCOPY(Dst, Src, Count) \
- __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
-# else
-# define YYCOPY(Dst, Src, Count) \
- do \
- { \
- YYSIZE_T yyi; \
- for (yyi = 0; yyi < (Count); yyi++) \
- (Dst)[yyi] = (Src)[yyi]; \
- } \
- while (0)
-# endif
-# endif
-#endif /* !YYCOPY_NEEDED */
-
-/* YYFINAL -- State number of the termination state. */
-#define YYFINAL 5
-/* YYLAST -- Last index in YYTABLE. */
-#define YYLAST 223
-
-/* YYNTOKENS -- Number of terminals. */
-#define YYNTOKENS 60
-/* YYNNTS -- Number of nonterminals. */
-#define YYNNTS 52
-/* YYNRULES -- Number of rules. */
-#define YYNRULES 128
-/* YYNSTATES -- Number of states. */
-#define YYNSTATES 223
-
-/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
- by yylex, with out-of-bounds checking. */
-#define YYUNDEFTOK 2
-#define YYMAXUTOK 303
-
-#define YYTRANSLATE(YYX) \
- ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
-
-/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
- as returned by yylex, without out-of-bounds checking. */
-static const yytype_uint8 yytranslate[] =
-{
- 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 51, 52, 2, 49, 53, 50, 59, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 54, 2, 55, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 57, 56, 58, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
- 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
- 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
- 45, 46, 47, 48
-};
-
-#if YYDEBUG
- /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
-static const yytype_uint16 yyrline[] =
-{
- 0, 135, 135, 148, 149, 152, 155, 156, 159, 160,
- 163, 164, 165, 168, 169, 172, 174, 179, 180, 184,
- 186, 191, 192, 196, 197, 198, 201, 203, 207, 208,
- 209, 212, 214, 215, 219, 220, 224, 225, 227, 228,
- 235, 238, 239, 242, 244, 250, 251, 254, 255, 259,
- 260, 264, 265, 269, 270, 274, 275, 279, 280, 284,
- 285, 289, 290, 294, 295, 299, 300, 304, 309, 310,
- 314, 315, 316, 321, 327, 330, 332, 335, 336, 337,
- 338, 339, 340, 341, 342, 343, 344, 345, 346, 347,
- 348, 349, 350, 351, 352, 353, 354, 355, 358, 359,
- 364, 365, 368, 371, 374, 375, 379, 381, 383, 388,
- 390, 392, 397, 401, 402, 407, 409, 412, 416, 421,
- 427, 428, 431, 432, 436, 439, 441, 465, 466
-};
-#endif
-
-#if YYDEBUG || YYERROR_VERBOSE || 1
-/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
- First, the terminals, then, starting at YYNTOKENS, nonterminals. */
-static const char *const yytname[] =
-{
- "$end", "error", "$undefined", "\"::=\"", "NUM", "IDENTIFIER",
- "OPTIONAL", "INTEGER", "SIZE", "OCTET", "STRING", "SEQUENCE", "BIT",
- "UNIVERSAL", "PRIVATE", "APPLICATION", "DEFAULT", "CHOICE", "OF",
- "OBJECT", "STR_IDENTIFIER", "BOOLEAN", "ASN1_TRUE", "ASN1_FALSE",
- "TOKEN_NULL", "ANY", "DEFINED", "BY", "SET", "EXPLICIT", "IMPLICIT",
- "DEFINITIONS", "TAGS", "BEGIN", "END", "UTCTime", "GeneralizedTime",
- "GeneralString", "NumericString", "IA5String", "TeletexString",
- "PrintableString", "UniversalString", "BMPString", "UTF8String",
- "VisibleString", "FROM", "IMPORTS", "ENUMERATED", "'+'", "'-'", "'('",
- "')'", "','", "'['", "']'", "'|'", "'{'", "'}'", "'.'", "$accept",
- "definitions", "pos_num", "neg_num", "pos_neg_num", "num_identifier",
- "int_identifier", "pos_neg_identifier", "constant", "constant_list",
- "obj_constant", "obj_constant_list", "class", "tag_type", "tag",
- "default", "pos_neg_list", "integer_def", "boolean_def", "Time",
- "size_def2", "size_def", "generalstring_def", "numericstring_def",
- "ia5string_def", "teletexstring_def", "printablestring_def",
- "universalstring_def", "bmpstring_def", "utf8string_def",
- "visiblestring_def", "octet_string_def", "bit_element",
- "bit_element_list", "bit_string_def", "enumerated_def", "object_def",
- "type_assig_right", "type_assig_right_tag",
- "type_assig_right_tag_default", "type_assig", "type_assig_list",
- "sequence_def", "set_def", "choise_def", "any_def", "type_def",
- "constant_def", "type_constant", "type_constant_list", "definitions_id",
- "explicit_implicit", YY_NULLPTR
-};
-#endif
-
-# ifdef YYPRINT
-/* YYTOKNUM[NUM] -- (External) token number corresponding to the
- (internal) symbol number NUM (which must be that of a token). */
-static const yytype_uint16 yytoknum[] =
-{
- 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
- 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
- 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
- 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
- 295, 296, 297, 298, 299, 300, 301, 302, 303, 43,
- 45, 40, 41, 44, 91, 93, 124, 123, 125, 46
-};
-# endif
-
-#define YYPACT_NINF -129
-
-#define yypact_value_is_default(Yystate) \
- (!!((Yystate) == (-129)))
-
-#define YYTABLE_NINF -12
-
-#define yytable_value_is_error(Yytable_value) \
- 0
-
- /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
- STATE-NUM. */
-static const yytype_int16 yypact[] =
-{
- 36, -7, 74, 22, 3, -129, 26, -129, 34, -129,
- -129, -129, 5, -129, -129, 55, 89, -129, -129, 97,
- 57, 101, -129, 122, 141, 132, -129, -129, -129, 32,
- 77, 77, 152, 165, 150, -129, -129, 6, 119, 167,
- 18, 168, 124, 159, -129, -129, 156, 21, -129, -129,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 126,
- 30, 38, 121, 133, -129, -129, -129, -129, -129, -129,
- -129, -129, -129, -129, -129, -129, -129, -129, -129, -129,
- -129, -129, -129, -129, -129, -129, 128, 58, 183, 136,
- 180, -129, -129, 20, 6, 121, 184, 172, -3, 184,
- -129, 164, 121, 184, 174, -129, -129, -129, -129, -129,
- -129, -129, -129, -129, 188, 139, -129, -129, -129, 191,
- -129, -129, -129, 42, 149, -129, 192, 193, -129, -129,
- -129, 142, 169, 146, 151, 58, -129, 53, -129, -129,
- 77, -129, 71, 121, 188, -129, 83, 195, -129, 90,
- 121, 153, -129, 94, -129, 148, 147, -129, 197, -129,
- 154, 43, 7, -129, -129, 149, -129, -21, -129, 58,
- 155, 20, -129, 24, -129, 184, -129, -129, 114, -129,
- -129, -129, -129, 201, 188, -129, -129, 157, 158, -129,
- 58, -129, 23, -129, 160, 162, -129, -129, -129, 54,
- -129, -129, -129, 163, -129, 47, -129, -129, 169, -129,
- -129, -129, -129, -129, -129, -129, -129, 204, 166, 170,
- -129, -129, -129
-};
-
- /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
- Performed when YYTABLE does not specify something else to do. Zero
- means the default is an error. */
-static const yytype_uint8 yydefact[] =
-{
- 0, 126, 0, 0, 0, 1, 0, 8, 9, 125,
- 19, 21, 0, 127, 128, 0, 0, 124, 22, 0,
- 0, 0, 20, 0, 0, 0, 120, 121, 122, 0,
- 0, 0, 0, 0, 0, 2, 123, 75, 36, 0,
- 0, 0, 0, 0, 40, 97, 113, 0, 41, 42,
- 47, 49, 51, 53, 55, 57, 59, 61, 63, 0,
- 0, 28, 0, 77, 79, 80, 83, 84, 85, 86,
- 87, 88, 89, 90, 91, 81, 82, 78, 93, 98,
- 116, 92, 96, 94, 95, 115, 0, 0, 0, 0,
- 0, 45, 76, 0, 65, 0, 0, 0, 70, 0,
- 74, 0, 0, 0, 0, 48, 50, 52, 54, 56,
- 58, 60, 62, 64, 0, 0, 23, 24, 25, 0,
- 29, 30, 99, 0, 0, 3, 0, 0, 6, 7,
- 119, 0, 0, 0, 0, 0, 17, 0, 66, 107,
- 0, 104, 0, 0, 0, 71, 0, 0, 110, 0,
- 0, 0, 68, 0, 26, 0, 3, 12, 0, 34,
- 0, 0, 0, 4, 5, 0, 9, 0, 46, 0,
- 0, 0, 37, 100, 103, 0, 106, 108, 0, 112,
- 114, 109, 111, 0, 0, 73, 27, 5, 0, 38,
- 0, 118, 0, 43, 0, 0, 15, 18, 102, 0,
- 101, 105, 72, 0, 69, 0, 35, 117, 0, 16,
- 14, 32, 33, 13, 31, 67, 10, 0, 0, 0,
- 11, 39, 44
-};
-
- /* YYPGOTO[NTERM-NUM]. */
-static const yytype_int16 yypgoto[] =
-{
- -129, -129, -129, -129, -120, -128, 4, -129, 39, -129,
- -12, -92, -129, -129, -129, -129, -129, -129, -129, -129,
- 130, -34, -129, -129, -129, -129, -129, -129, -129, -129,
- -129, -129, 27, 68, -129, -129, -129, -60, -30, -129,
- 46, 72, -129, -129, -129, -129, -129, -129, 194, -129,
- -129, -129
-};
-
- /* YYDEFGOTO[NTERM-NUM]. */
-static const yytype_int16 yydefgoto[] =
-{
- -1, 2, 128, 129, 130, 10, 160, 214, 136, 137,
- 11, 12, 119, 61, 62, 200, 161, 63, 64, 65,
- 91, 92, 66, 67, 68, 69, 70, 71, 72, 73,
- 74, 75, 152, 153, 76, 77, 78, 79, 80, 174,
- 141, 142, 81, 82, 83, 84, 26, 27, 28, 29,
- 3, 15
-};
-
- /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
- positive, shift that token. If negative, reduce the rule whose
- number is the opposite. If YYTABLE_NINF, syntax error. */
-static const yytype_int16 yytable[] =
-{
- 18, 85, 122, 159, 167, 89, 97, 7, 8, 7,
- 8, 7, 8, 104, 89, 170, 105, 106, 107, 108,
- 109, 110, 111, 112, 113, 134, 89, 7, 8, 89,
- 198, 193, 162, 24, 115, 139, 95, 25, 194, 102,
- 199, 1, 148, 116, 117, 118, 156, 157, 90, 195,
- 4, 216, 157, 6, 144, 13, 14, 90, 125, 210,
- 138, 9, 125, 17, 145, 191, 35, 120, 121, 90,
- 206, 135, 90, 192, 5, 96, 211, 212, 103, 213,
- 219, 207, 37, 177, 38, 16, 39, 19, 40, 41,
- 182, 126, 158, 20, 42, 189, 43, 217, 44, 190,
- 21, 45, 46, 126, 127, 47, 171, 126, 127, 22,
- 173, 172, 48, 49, 50, 51, 52, 53, 54, 55,
- 56, 57, 58, 24, 175, 59, 37, 25, 38, 176,
- 39, 60, 40, 41, 23, 31, 175, 32, 42, 33,
- 43, 179, 44, 175, 30, 45, 46, 184, 181, 47,
- 18, 34, 185, 7, 8, 86, 48, 49, 50, 51,
- 52, 53, 54, 55, 56, 57, 58, 184, 87, 59,
- 88, 146, 202, 7, 166, 149, 93, 94, 98, 100,
- 18, 99, 101, 114, 123, 124, 131, 132, 89, 140,
- 143, 147, 150, 151, 154, 155, 163, 164, 168, 165,
- 180, 187, 169, 186, 183, 203, -10, 196, 220, 218,
- 197, 204, 178, 188, 209, 215, -11, 205, 221, 208,
- 133, 201, 222, 36
-};
-
-static const yytype_uint8 yycheck[] =
-{
- 12, 31, 62, 123, 132, 8, 40, 4, 5, 4,
- 5, 4, 5, 47, 8, 135, 50, 51, 52, 53,
- 54, 55, 56, 57, 58, 5, 8, 4, 5, 8,
- 6, 52, 124, 1, 4, 95, 18, 5, 59, 18,
- 16, 5, 102, 13, 14, 15, 4, 5, 51, 169,
- 57, 4, 5, 31, 57, 29, 30, 51, 4, 5,
- 94, 58, 4, 58, 98, 58, 34, 29, 30, 51,
- 190, 51, 51, 165, 0, 57, 22, 23, 57, 199,
- 208, 58, 5, 143, 7, 51, 9, 32, 11, 12,
- 150, 49, 50, 4, 17, 52, 19, 50, 21, 56,
- 3, 24, 25, 49, 50, 28, 53, 49, 50, 52,
- 140, 58, 35, 36, 37, 38, 39, 40, 41, 42,
- 43, 44, 45, 1, 53, 48, 5, 5, 7, 58,
- 9, 54, 11, 12, 33, 3, 53, 5, 17, 7,
- 19, 58, 21, 53, 3, 24, 25, 53, 58, 28,
- 162, 19, 58, 4, 5, 3, 35, 36, 37, 38,
- 39, 40, 41, 42, 43, 44, 45, 53, 3, 48,
- 20, 99, 58, 4, 5, 103, 57, 10, 10, 20,
- 192, 57, 26, 57, 51, 57, 3, 51, 8, 5,
- 18, 27, 18, 5, 55, 4, 4, 4, 52, 57,
- 5, 4, 51, 55, 51, 4, 59, 52, 4, 205,
- 171, 184, 144, 59, 52, 52, 59, 59, 52, 59,
- 90, 175, 52, 29
-};
-
- /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
- symbol of state STATE-NUM. */
-static const yytype_uint8 yystos[] =
-{
- 0, 5, 61, 110, 57, 0, 31, 4, 5, 58,
- 65, 70, 71, 29, 30, 111, 51, 58, 70, 32,
- 4, 3, 52, 33, 1, 5, 106, 107, 108, 109,
- 3, 3, 5, 7, 19, 34, 108, 5, 7, 9,
- 11, 12, 17, 19, 21, 24, 25, 28, 35, 36,
- 37, 38, 39, 40, 41, 42, 43, 44, 45, 48,
- 54, 73, 74, 77, 78, 79, 82, 83, 84, 85,
- 86, 87, 88, 89, 90, 91, 94, 95, 96, 97,
- 98, 102, 103, 104, 105, 98, 3, 3, 20, 8,
- 51, 80, 81, 57, 10, 18, 57, 81, 10, 57,
- 20, 26, 18, 57, 81, 81, 81, 81, 81, 81,
- 81, 81, 81, 81, 57, 4, 13, 14, 15, 72,
- 29, 30, 97, 51, 57, 4, 49, 50, 62, 63,
- 64, 3, 51, 80, 5, 51, 68, 69, 81, 97,
- 5, 100, 101, 18, 57, 81, 101, 27, 97, 101,
- 18, 5, 92, 93, 55, 4, 4, 5, 50, 64,
- 66, 76, 71, 4, 4, 57, 5, 65, 52, 51,
- 64, 53, 58, 98, 99, 53, 58, 97, 93, 58,
- 5, 58, 97, 51, 53, 58, 55, 4, 59, 52,
- 56, 58, 71, 52, 59, 64, 52, 68, 6, 16,
- 75, 100, 58, 4, 92, 59, 64, 58, 59, 52,
- 5, 22, 23, 64, 67, 52, 4, 50, 66, 65,
- 4, 52, 52
-};
-
- /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
-static const yytype_uint8 yyr1[] =
-{
- 0, 60, 61, 62, 62, 63, 64, 64, 65, 65,
- 66, 66, 66, 67, 67, 68, 68, 69, 69, 70,
- 70, 71, 71, 72, 72, 72, 73, 73, 74, 74,
- 74, 75, 75, 75, 76, 76, 77, 77, 77, 77,
- 78, 79, 79, 80, 80, 81, 81, 82, 82, 83,
- 83, 84, 84, 85, 85, 86, 86, 87, 87, 88,
- 88, 89, 89, 90, 90, 91, 91, 92, 93, 93,
- 94, 94, 94, 95, 96, 97, 97, 97, 97, 97,
- 97, 97, 97, 97, 97, 97, 97, 97, 97, 97,
- 97, 97, 97, 97, 97, 97, 97, 97, 98, 98,
- 99, 99, 99, 100, 101, 101, 102, 102, 102, 103,
- 103, 103, 104, 105, 105, 106, 106, 107, 107, 107,
- 108, 108, 109, 109, 110, 110, 110, 111, 111
-};
-
- /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
-static const yytype_uint8 yyr2[] =
-{
- 0, 2, 8, 1, 2, 2, 1, 1, 1, 1,
- 1, 2, 1, 1, 1, 3, 4, 1, 3, 1,
- 4, 1, 2, 1, 1, 1, 3, 4, 1, 2,
- 2, 2, 2, 2, 1, 3, 1, 4, 4, 7,
- 1, 1, 1, 4, 7, 1, 3, 1, 2, 1,
- 2, 1, 2, 1, 2, 1, 2, 1, 2, 1,
- 2, 1, 2, 1, 2, 2, 3, 4, 1, 3,
- 2, 3, 5, 4, 2, 1, 2, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
- 1, 2, 2, 2, 1, 3, 4, 3, 4, 4,
- 3, 4, 4, 1, 4, 3, 3, 7, 6, 4,
- 1, 1, 1, 2, 4, 3, 1, 1, 1
-};
-
-
-#define yyerrok (yyerrstatus = 0)
-#define yyclearin (yychar = YYEMPTY)
-#define YYEMPTY (-2)
-#define YYEOF 0
-
-#define YYACCEPT goto yyacceptlab
-#define YYABORT goto yyabortlab
-#define YYERROR goto yyerrorlab
-
-
-#define YYRECOVERING() (!!yyerrstatus)
-
-#define YYBACKUP(Token, Value) \
-do \
- if (yychar == YYEMPTY) \
- { \
- yychar = (Token); \
- yylval = (Value); \
- YYPOPSTACK (yylen); \
- yystate = *yyssp; \
- goto yybackup; \
- } \
- else \
- { \
- yyerror (YY_("syntax error: cannot back up")); \
- YYERROR; \
- } \
-while (0)
-
-/* Error token number */
-#define YYTERROR 1
-#define YYERRCODE 256
-
-
-
-/* Enable debugging if requested. */
-#if YYDEBUG
-
-# ifndef YYFPRINTF
-# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
-# define YYFPRINTF fprintf
-# endif
-
-# define YYDPRINTF(Args) \
-do { \
- if (yydebug) \
- YYFPRINTF Args; \
-} while (0)
-
-/* This macro is provided for backward compatibility. */
-#ifndef YY_LOCATION_PRINT
-# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
-#endif
-
-
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
-do { \
- if (yydebug) \
- { \
- YYFPRINTF (stderr, "%s ", Title); \
- yy_symbol_print (stderr, \
- Type, Value); \
- YYFPRINTF (stderr, "\n"); \
- } \
-} while (0)
-
-
-/*----------------------------------------.
-| Print this symbol's value on YYOUTPUT. |
-`----------------------------------------*/
-
-static void
-yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
-{
- FILE *yyo = yyoutput;
- YYUSE (yyo);
- if (!yyvaluep)
- return;
-# ifdef YYPRINT
- if (yytype < YYNTOKENS)
- YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
-# endif
- YYUSE (yytype);
-}
-
-
-/*--------------------------------.
-| Print this symbol on YYOUTPUT. |
-`--------------------------------*/
-
-static void
-yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
-{
- YYFPRINTF (yyoutput, "%s %s (",
- yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
-
- yy_symbol_value_print (yyoutput, yytype, yyvaluep);
- YYFPRINTF (yyoutput, ")");
-}
-
-/*------------------------------------------------------------------.
-| yy_stack_print -- Print the state stack from its BOTTOM up to its |
-| TOP (included). |
-`------------------------------------------------------------------*/
-
-static void
-yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
-{
- YYFPRINTF (stderr, "Stack now");
- for (; yybottom <= yytop; yybottom++)
- {
- int yybot = *yybottom;
- YYFPRINTF (stderr, " %d", yybot);
- }
- YYFPRINTF (stderr, "\n");
-}
-
-# define YY_STACK_PRINT(Bottom, Top) \
-do { \
- if (yydebug) \
- yy_stack_print ((Bottom), (Top)); \
-} while (0)
-
-
-/*------------------------------------------------.
-| Report that the YYRULE is going to be reduced. |
-`------------------------------------------------*/
-
-static void
-yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule)
-{
- unsigned long int yylno = yyrline[yyrule];
- int yynrhs = yyr2[yyrule];
- int yyi;
- YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
- yyrule - 1, yylno);
- /* The symbols being reduced. */
- for (yyi = 0; yyi < yynrhs; yyi++)
- {
- YYFPRINTF (stderr, " $%d = ", yyi + 1);
- yy_symbol_print (stderr,
- yystos[yyssp[yyi + 1 - yynrhs]],
- &(yyvsp[(yyi + 1) - (yynrhs)])
- );
- YYFPRINTF (stderr, "\n");
- }
-}
-
-# define YY_REDUCE_PRINT(Rule) \
-do { \
- if (yydebug) \
- yy_reduce_print (yyssp, yyvsp, Rule); \
-} while (0)
-
-/* Nonzero means print parse trace. It is left uninitialized so that
- multiple parsers can coexist. */
-int yydebug;
-#else /* !YYDEBUG */
-# define YYDPRINTF(Args)
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
-# define YY_STACK_PRINT(Bottom, Top)
-# define YY_REDUCE_PRINT(Rule)
-#endif /* !YYDEBUG */
-
-
-/* YYINITDEPTH -- initial size of the parser's stacks. */
-#ifndef YYINITDEPTH
-# define YYINITDEPTH 200
-#endif
-
-/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
- if the built-in stack extension method is used).
-
- Do not make this value too large; the results are undefined if
- YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
- evaluated with infinite-precision integer arithmetic. */
-
-#ifndef YYMAXDEPTH
-# define YYMAXDEPTH 10000
-#endif
-
-
-#if YYERROR_VERBOSE
-
-# ifndef yystrlen
-# if defined __GLIBC__ && defined _STRING_H
-# define yystrlen strlen
-# else
-/* Return the length of YYSTR. */
-static YYSIZE_T
-yystrlen (const char *yystr)
-{
- YYSIZE_T yylen;
- for (yylen = 0; yystr[yylen]; yylen++)
- continue;
- return yylen;
-}
-# endif
-# endif
-
-# ifndef yystpcpy
-# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
-# define yystpcpy stpcpy
-# else
-/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
- YYDEST. */
-static char *
-yystpcpy (char *yydest, const char *yysrc)
-{
- char *yyd = yydest;
- const char *yys = yysrc;
-
- while ((*yyd++ = *yys++) != '\0')
- continue;
-
- return yyd - 1;
-}
-# endif
-# endif
-
-# ifndef yytnamerr
-/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
- quotes and backslashes, so that it's suitable for yyerror. The
- heuristic is that double-quoting is unnecessary unless the string
- contains an apostrophe, a comma, or backslash (other than
- backslash-backslash). YYSTR is taken from yytname. If YYRES is
- null, do not copy; instead, return the length of what the result
- would have been. */
-static YYSIZE_T
-yytnamerr (char *yyres, const char *yystr)
-{
- if (*yystr == '"')
- {
- YYSIZE_T yyn = 0;
- char const *yyp = yystr;
-
- for (;;)
- switch (*++yyp)
- {
- case '\'':
- case ',':
- goto do_not_strip_quotes;
-
- case '\\':
- if (*++yyp != '\\')
- goto do_not_strip_quotes;
- /* Fall through. */
- default:
- if (yyres)
- yyres[yyn] = *yyp;
- yyn++;
- break;
-
- case '"':
- if (yyres)
- yyres[yyn] = '\0';
- return yyn;
- }
- do_not_strip_quotes: ;
- }
-
- if (! yyres)
- return yystrlen (yystr);
-
- return yystpcpy (yyres, yystr) - yyres;
-}
-# endif
-
-/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
- about the unexpected token YYTOKEN for the state stack whose top is
- YYSSP.
-
- Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
- not large enough to hold the message. In that case, also set
- *YYMSG_ALLOC to the required number of bytes. Return 2 if the
- required number of bytes is too large to store. */
-static int
-yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
- yytype_int16 *yyssp, int yytoken)
-{
- YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
- YYSIZE_T yysize = yysize0;
- enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
- /* Internationalized format string. */
- const char *yyformat = YY_NULLPTR;
- /* Arguments of yyformat. */
- char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
- /* Number of reported tokens (one for the "unexpected", one per
- "expected"). */
- int yycount = 0;
-
- /* There are many possibilities here to consider:
- - If this state is a consistent state with a default action, then
- the only way this function was invoked is if the default action
- is an error action. In that case, don't check for expected
- tokens because there are none.
- - The only way there can be no lookahead present (in yychar) is if
- this state is a consistent state with a default action. Thus,
- detecting the absence of a lookahead is sufficient to determine
- that there is no unexpected or expected token to report. In that
- case, just report a simple "syntax error".
- - Don't assume there isn't a lookahead just because this state is a
- consistent state with a default action. There might have been a
- previous inconsistent state, consistent state with a non-default
- action, or user semantic action that manipulated yychar.
- - Of course, the expected token list depends on states to have
- correct lookahead information, and it depends on the parser not
- to perform extra reductions after fetching a lookahead from the
- scanner and before detecting a syntax error. Thus, state merging
- (from LALR or IELR) and default reductions corrupt the expected
- token list. However, the list is correct for canonical LR with
- one exception: it will still contain any token that will not be
- accepted due to an error action in a later state.
- */
- if (yytoken != YYEMPTY)
- {
- int yyn = yypact[*yyssp];
- yyarg[yycount++] = yytname[yytoken];
- if (!yypact_value_is_default (yyn))
- {
- /* Start YYX at -YYN if negative to avoid negative indexes in
- YYCHECK. In other words, skip the first -YYN actions for
- this state because they are default actions. */
- int yyxbegin = yyn < 0 ? -yyn : 0;
- /* Stay within bounds of both yycheck and yytname. */
- int yychecklim = YYLAST - yyn + 1;
- int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
- int yyx;
-
- for (yyx = yyxbegin; yyx < yyxend; ++yyx)
- if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
- && !yytable_value_is_error (yytable[yyx + yyn]))
- {
- if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
- {
- yycount = 1;
- yysize = yysize0;
- break;
- }
- yyarg[yycount++] = yytname[yyx];
- {
- YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
- if (! (yysize <= yysize1
- && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
- return 2;
- yysize = yysize1;
- }
- }
- }
- }
-
- switch (yycount)
- {
-# define YYCASE_(N, S) \
- case N: \
- yyformat = S; \
- break
- YYCASE_(0, YY_("syntax error"));
- YYCASE_(1, YY_("syntax error, unexpected %s"));
- YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
- YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
- YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
- YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
-# undef YYCASE_
- }
-
- {
- YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
- if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
- return 2;
- yysize = yysize1;
- }
-
- if (*yymsg_alloc < yysize)
- {
- *yymsg_alloc = 2 * yysize;
- if (! (yysize <= *yymsg_alloc
- && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
- *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
- return 1;
- }
-
- /* Avoid sprintf, as that infringes on the user's name space.
- Don't have undefined behavior even if the translation
- produced a string with the wrong number of "%s"s. */
- {
- char *yyp = *yymsg;
- int yyi = 0;
- while ((*yyp = *yyformat) != '\0')
- if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
- {
- yyp += yytnamerr (yyp, yyarg[yyi++]);
- yyformat += 2;
- }
- else
- {
- yyp++;
- yyformat++;
- }
- }
- return 0;
-}
-#endif /* YYERROR_VERBOSE */
-
-/*-----------------------------------------------.
-| Release the memory associated to this symbol. |
-`-----------------------------------------------*/
-
-static void
-yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
-{
- YYUSE (yyvaluep);
- if (!yymsg)
- yymsg = "Deleting";
- YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
-
- YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
- YYUSE (yytype);
- YY_IGNORE_MAYBE_UNINITIALIZED_END
-}
-
-
-
-
-/* The lookahead symbol. */
-int yychar;
-
-/* The semantic value of the lookahead symbol. */
-YYSTYPE yylval;
-/* Number of syntax errors so far. */
-int yynerrs;
-
-
-/*----------.
-| yyparse. |
-`----------*/
-
-int
-yyparse (void)
-{
- int yystate;
- /* Number of tokens to shift before error messages enabled. */
- int yyerrstatus;
-
- /* The stacks and their tools:
- 'yyss': related to states.
- 'yyvs': related to semantic values.
-
- Refer to the stacks through separate pointers, to allow yyoverflow
- to reallocate them elsewhere. */
-
- /* The state stack. */
- yytype_int16 yyssa[YYINITDEPTH];
- yytype_int16 *yyss;
- yytype_int16 *yyssp;
-
- /* The semantic value stack. */
- YYSTYPE yyvsa[YYINITDEPTH];
- YYSTYPE *yyvs;
- YYSTYPE *yyvsp;
-
- YYSIZE_T yystacksize;
-
- int yyn;
- int yyresult;
- /* Lookahead token as an internal (translated) token number. */
- int yytoken = 0;
- /* The variables used to return semantic value and location from the
- action routines. */
- YYSTYPE yyval;
-
-#if YYERROR_VERBOSE
- /* Buffer for error messages, and its allocated size. */
- char yymsgbuf[128];
- char *yymsg = yymsgbuf;
- YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
-#endif
-
-#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
-
- /* The number of symbols on the RHS of the reduced rule.
- Keep to zero when no symbol should be popped. */
- int yylen = 0;
-
- yyssp = yyss = yyssa;
- yyvsp = yyvs = yyvsa;
- yystacksize = YYINITDEPTH;
-
- YYDPRINTF ((stderr, "Starting parse\n"));
-
- yystate = 0;
- yyerrstatus = 0;
- yynerrs = 0;
- yychar = YYEMPTY; /* Cause a token to be read. */
- goto yysetstate;
-
-/*------------------------------------------------------------.
-| yynewstate -- Push a new state, which is found in yystate. |
-`------------------------------------------------------------*/
- yynewstate:
- /* In all cases, when you get here, the value and location stacks
- have just been pushed. So pushing a state here evens the stacks. */
- yyssp++;
-
- yysetstate:
- *yyssp = yystate;
-
- if (yyss + yystacksize - 1 <= yyssp)
- {
- /* Get the current used size of the three stacks, in elements. */
- YYSIZE_T yysize = yyssp - yyss + 1;
-
-#ifdef yyoverflow
- {
- /* Give user a chance to reallocate the stack. Use copies of
- these so that the &'s don't force the real ones into
- memory. */
- YYSTYPE *yyvs1 = yyvs;
- yytype_int16 *yyss1 = yyss;
-
- /* Each stack pointer address is followed by the size of the
- data in use in that stack, in bytes. This used to be a
- conditional around just the two extra args, but that might
- be undefined if yyoverflow is a macro. */
- yyoverflow (YY_("memory exhausted"),
- &yyss1, yysize * sizeof (*yyssp),
- &yyvs1, yysize * sizeof (*yyvsp),
- &yystacksize);
-
- yyss = yyss1;
- yyvs = yyvs1;
- }
-#else /* no yyoverflow */
-# ifndef YYSTACK_RELOCATE
- goto yyexhaustedlab;
-# else
- /* Extend the stack our own way. */
- if (YYMAXDEPTH <= yystacksize)
- goto yyexhaustedlab;
- yystacksize *= 2;
- if (YYMAXDEPTH < yystacksize)
- yystacksize = YYMAXDEPTH;
-
- {
- yytype_int16 *yyss1 = yyss;
- union yyalloc *yyptr =
- (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
- if (! yyptr)
- goto yyexhaustedlab;
- YYSTACK_RELOCATE (yyss_alloc, yyss);
- YYSTACK_RELOCATE (yyvs_alloc, yyvs);
-# undef YYSTACK_RELOCATE
- if (yyss1 != yyssa)
- YYSTACK_FREE (yyss1);
- }
-# endif
-#endif /* no yyoverflow */
-
- yyssp = yyss + yysize - 1;
- yyvsp = yyvs + yysize - 1;
-
- YYDPRINTF ((stderr, "Stack size increased to %lu\n",
- (unsigned long int) yystacksize));
-
- if (yyss + yystacksize - 1 <= yyssp)
- YYABORT;
- }
-
- YYDPRINTF ((stderr, "Entering state %d\n", yystate));
-
- if (yystate == YYFINAL)
- YYACCEPT;
-
- goto yybackup;
-
-/*-----------.
-| yybackup. |
-`-----------*/
-yybackup:
-
- /* Do appropriate processing given the current state. Read a
- lookahead token if we need one and don't already have one. */
-
- /* First try to decide what to do without reference to lookahead token. */
- yyn = yypact[yystate];
- if (yypact_value_is_default (yyn))
- goto yydefault;
-
- /* Not known => get a lookahead token if don't already have one. */
-
- /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
- if (yychar == YYEMPTY)
- {
- YYDPRINTF ((stderr, "Reading a token: "));
- yychar = yylex ();
- }
-
- if (yychar <= YYEOF)
- {
- yychar = yytoken = YYEOF;
- YYDPRINTF ((stderr, "Now at end of input.\n"));
- }
- else
- {
- yytoken = YYTRANSLATE (yychar);
- YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
- }
-
- /* If the proper action on seeing token YYTOKEN is to reduce or to
- detect an error, take that action. */
- yyn += yytoken;
- if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
- goto yydefault;
- yyn = yytable[yyn];
- if (yyn <= 0)
- {
- if (yytable_value_is_error (yyn))
- goto yyerrlab;
- yyn = -yyn;
- goto yyreduce;
- }
-
- /* Count tokens shifted since error; after three, turn off error
- status. */
- if (yyerrstatus)
- yyerrstatus--;
-
- /* Shift the lookahead token. */
- YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
-
- /* Discard the shifted token. */
- yychar = YYEMPTY;
-
- yystate = yyn;
- YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
- *++yyvsp = yylval;
- YY_IGNORE_MAYBE_UNINITIALIZED_END
-
- goto yynewstate;
-
-
-/*-----------------------------------------------------------.
-| yydefault -- do the default action for the current state. |
-`-----------------------------------------------------------*/
-yydefault:
- yyn = yydefact[yystate];
- if (yyn == 0)
- goto yyerrlab;
- goto yyreduce;
-
-
-/*-----------------------------.
-| yyreduce -- Do a reduction. |
-`-----------------------------*/
-yyreduce:
- /* yyn is the number of a rule to reduce with. */
- yylen = yyr2[yyn];
-
- /* If YYLEN is nonzero, implement the default value of the action:
- '$$ = $1'.
-
- Otherwise, the following line sets YYVAL to garbage.
- This behavior is undocumented and Bison
- users should not rely upon it. Assigning to YYVAL
- unconditionally makes the parser a bit smaller, and it avoids a
- GCC warning that YYVAL may be used uninitialized. */
- yyval = yyvsp[1-yylen];
-
-
- YY_REDUCE_PRINT (yyn);
- switch (yyn)
- {
- case 2:
-#line 138 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_DEFINITIONS|(yyvsp[-5].constant));
- _asn1_set_name((yyval.node),_asn1_get_name((yyvsp[-7].node)));
- _asn1_set_name((yyvsp[-7].node),"");
- _asn1_set_right((yyvsp[-7].node),(yyvsp[-1].node));
- _asn1_set_down((yyval.node),(yyvsp[-7].node));
-
- p_tree=(yyval.node);
- }
-#line 1546 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 3:
-#line 148 "ASN1.y" /* yacc.c:1646 */
- {snprintf((yyval.str),sizeof((yyval.str)),"%s",(yyvsp[0].str));}
-#line 1552 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 4:
-#line 149 "ASN1.y" /* yacc.c:1646 */
- {snprintf((yyval.str),sizeof((yyval.str)),"%s",(yyvsp[0].str));}
-#line 1558 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 5:
-#line 152 "ASN1.y" /* yacc.c:1646 */
- {snprintf((yyval.str),sizeof((yyval.str)),"-%s",(yyvsp[0].str));}
-#line 1564 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 6:
-#line 155 "ASN1.y" /* yacc.c:1646 */
- {snprintf((yyval.str),sizeof((yyval.str)),"%s",(yyvsp[0].str));}
-#line 1570 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 7:
-#line 156 "ASN1.y" /* yacc.c:1646 */
- {snprintf((yyval.str),sizeof((yyval.str)),"%s",(yyvsp[0].str));}
-#line 1576 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 8:
-#line 159 "ASN1.y" /* yacc.c:1646 */
- {snprintf((yyval.str),sizeof((yyval.str)),"%s",(yyvsp[0].str));}
-#line 1582 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 9:
-#line 160 "ASN1.y" /* yacc.c:1646 */
- {snprintf((yyval.str),sizeof((yyval.str)),"%s",(yyvsp[0].str));}
-#line 1588 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 10:
-#line 163 "ASN1.y" /* yacc.c:1646 */
- {snprintf((yyval.str),sizeof((yyval.str)),"%s",(yyvsp[0].str));}
-#line 1594 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 11:
-#line 164 "ASN1.y" /* yacc.c:1646 */
- {snprintf((yyval.str),sizeof((yyval.str)),"-%s",(yyvsp[0].str));}
-#line 1600 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 12:
-#line 165 "ASN1.y" /* yacc.c:1646 */
- {snprintf((yyval.str),sizeof((yyval.str)),"%s",(yyvsp[0].str));}
-#line 1606 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 13:
-#line 168 "ASN1.y" /* yacc.c:1646 */
- {snprintf((yyval.str),sizeof((yyval.str)),"%s",(yyvsp[0].str));}
-#line 1612 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 14:
-#line 169 "ASN1.y" /* yacc.c:1646 */
- {snprintf((yyval.str),sizeof((yyval.str)),"%s",(yyvsp[0].str));}
-#line 1618 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 15:
-#line 172 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_CONSTANT);
- _asn1_set_value((yyval.node),(yyvsp[-1].str),strlen((yyvsp[-1].str))+1);}
-#line 1625 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 16:
-#line 174 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_CONSTANT);
- _asn1_set_name((yyval.node),(yyvsp[-3].str));
- _asn1_set_value((yyval.node),(yyvsp[-1].str),strlen((yyvsp[-1].str))+1);}
-#line 1633 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 17:
-#line 179 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[0].node);}
-#line 1639 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 18:
-#line 180 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[-2].node);
- _asn1_set_right(_asn1_get_last_right((yyvsp[-2].node)),(yyvsp[0].node));}
-#line 1646 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 19:
-#line 184 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_CONSTANT);
- _asn1_set_value((yyval.node),(yyvsp[0].str),strlen((yyvsp[0].str))+1);}
-#line 1653 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 20:
-#line 186 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_CONSTANT);
- _asn1_set_name((yyval.node),(yyvsp[-3].str));
- _asn1_set_value((yyval.node),(yyvsp[-1].str),strlen((yyvsp[-1].str))+1);}
-#line 1661 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 21:
-#line 191 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[0].node);}
-#line 1667 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 22:
-#line 192 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[-1].node);
- _asn1_set_right(_asn1_get_last_right((yyvsp[-1].node)),(yyvsp[0].node));}
-#line 1674 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 23:
-#line 196 "ASN1.y" /* yacc.c:1646 */
- {(yyval.constant)=CONST_UNIVERSAL;}
-#line 1680 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 24:
-#line 197 "ASN1.y" /* yacc.c:1646 */
- {(yyval.constant)=CONST_PRIVATE;}
-#line 1686 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 25:
-#line 198 "ASN1.y" /* yacc.c:1646 */
- {(yyval.constant)=CONST_APPLICATION;}
-#line 1692 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 26:
-#line 201 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_TAG);
- _asn1_set_value((yyval.node),(yyvsp[-1].str),strlen((yyvsp[-1].str))+1);}
-#line 1699 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 27:
-#line 203 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_TAG | (yyvsp[-2].constant));
- _asn1_set_value((yyval.node),(yyvsp[-1].str),strlen((yyvsp[-1].str))+1);}
-#line 1706 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 28:
-#line 207 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[0].node);}
-#line 1712 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 29:
-#line 208 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_mod_type((yyvsp[-1].node),CONST_EXPLICIT);}
-#line 1718 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 30:
-#line 209 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_mod_type((yyvsp[-1].node),CONST_IMPLICIT);}
-#line 1724 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 31:
-#line 212 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_DEFAULT);
- _asn1_set_value((yyval.node),(yyvsp[0].str),strlen((yyvsp[0].str))+1);}
-#line 1731 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 32:
-#line 214 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_DEFAULT|CONST_TRUE);}
-#line 1737 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 33:
-#line 215 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_DEFAULT|CONST_FALSE);}
-#line 1743 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 36:
-#line 224 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_INTEGER);}
-#line 1749 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 37:
-#line 225 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_INTEGER|CONST_LIST);
- _asn1_set_down((yyval.node),(yyvsp[-1].node));}
-#line 1756 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 38:
-#line 227 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_INTEGER);}
-#line 1762 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 39:
-#line 229 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_INTEGER|CONST_MIN_MAX);
- _asn1_set_down((yyval.node),_asn1_add_static_node(ASN1_ETYPE_SIZE));
- _asn1_set_value(_asn1_get_down((yyval.node)),(yyvsp[-1].str),strlen((yyvsp[-1].str))+1);
- _asn1_set_name(_asn1_get_down((yyval.node)),(yyvsp[-4].str));}
-#line 1771 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 40:
-#line 235 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_BOOLEAN);}
-#line 1777 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 41:
-#line 238 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_UTC_TIME);}
-#line 1783 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 42:
-#line 239 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_GENERALIZED_TIME);}
-#line 1789 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 43:
-#line 242 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_SIZE|CONST_1_PARAM);
- _asn1_set_value((yyval.node),(yyvsp[-1].str),strlen((yyvsp[-1].str))+1);}
-#line 1796 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 44:
-#line 245 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_SIZE|CONST_MIN_MAX);
- _asn1_set_value((yyval.node),(yyvsp[-4].str),strlen((yyvsp[-4].str))+1);
- _asn1_set_name((yyval.node),(yyvsp[-1].str));}
-#line 1804 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 45:
-#line 250 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[0].node);}
-#line 1810 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 46:
-#line 251 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[-1].node);}
-#line 1816 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 47:
-#line 254 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_GENERALSTRING);}
-#line 1822 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 48:
-#line 255 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_GENERALSTRING|CONST_SIZE);
- _asn1_set_down((yyval.node),(yyvsp[0].node));}
-#line 1829 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 49:
-#line 259 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_NUMERIC_STRING|CONST_UNIVERSAL);}
-#line 1835 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 50:
-#line 260 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_NUMERIC_STRING|CONST_SIZE);
- _asn1_set_down((yyval.node),(yyvsp[0].node));}
-#line 1842 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 51:
-#line 264 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_IA5_STRING);}
-#line 1848 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 52:
-#line 265 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_IA5_STRING|CONST_SIZE);
- _asn1_set_down((yyval.node),(yyvsp[0].node));}
-#line 1855 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 53:
-#line 269 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_TELETEX_STRING);}
-#line 1861 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 54:
-#line 270 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_TELETEX_STRING|CONST_SIZE);
- _asn1_set_down((yyval.node),(yyvsp[0].node));}
-#line 1868 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 55:
-#line 274 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_PRINTABLE_STRING);}
-#line 1874 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 56:
-#line 275 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_PRINTABLE_STRING|CONST_SIZE);
- _asn1_set_down((yyval.node),(yyvsp[0].node));}
-#line 1881 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 57:
-#line 279 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_UNIVERSAL_STRING);}
-#line 1887 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 58:
-#line 280 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_UNIVERSAL_STRING|CONST_SIZE);
- _asn1_set_down((yyval.node),(yyvsp[0].node));}
-#line 1894 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 59:
-#line 284 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_BMP_STRING);}
-#line 1900 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 60:
-#line 285 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_BMP_STRING|CONST_SIZE);
- _asn1_set_down((yyval.node),(yyvsp[0].node));}
-#line 1907 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 61:
-#line 289 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_UTF8_STRING);}
-#line 1913 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 62:
-#line 290 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_UTF8_STRING|CONST_SIZE);
- _asn1_set_down((yyval.node),(yyvsp[0].node));}
-#line 1920 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 63:
-#line 294 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_VISIBLE_STRING);}
-#line 1926 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 64:
-#line 295 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_VISIBLE_STRING|CONST_SIZE);
- _asn1_set_down((yyval.node),(yyvsp[0].node));}
-#line 1933 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 65:
-#line 299 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_OCTET_STRING);}
-#line 1939 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 66:
-#line 300 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_OCTET_STRING|CONST_SIZE);
- _asn1_set_down((yyval.node),(yyvsp[0].node));}
-#line 1946 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 67:
-#line 304 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_CONSTANT);
- _asn1_set_name((yyval.node),(yyvsp[-3].str));
- _asn1_set_value((yyval.node),(yyvsp[-1].str),strlen((yyvsp[-1].str))+1);}
-#line 1954 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 68:
-#line 309 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[0].node);}
-#line 1960 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 69:
-#line 310 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[-2].node);
- _asn1_set_right(_asn1_get_last_right((yyvsp[-2].node)),(yyvsp[0].node));}
-#line 1967 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 70:
-#line 314 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_BIT_STRING);}
-#line 1973 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 71:
-#line 315 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_BIT_STRING|CONST_SIZE);}
-#line 1979 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 72:
-#line 317 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_BIT_STRING|CONST_LIST);
- _asn1_set_down((yyval.node),(yyvsp[-1].node));}
-#line 1986 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 73:
-#line 322 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_ENUMERATED|CONST_LIST);
- _asn1_set_down((yyval.node),(yyvsp[-1].node));}
-#line 1993 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 74:
-#line 327 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_OBJECT_ID);}
-#line 1999 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 75:
-#line 330 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_IDENTIFIER);
- _asn1_set_value((yyval.node),(yyvsp[0].str),strlen((yyvsp[0].str))+1);}
-#line 2006 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 76:
-#line 332 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_IDENTIFIER|CONST_SIZE);
- _asn1_set_value((yyval.node),(yyvsp[-1].str),strlen((yyvsp[-1].str))+1);
- _asn1_set_down((yyval.node),(yyvsp[0].node));}
-#line 2014 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 77:
-#line 335 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[0].node);}
-#line 2020 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 78:
-#line 336 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[0].node);}
-#line 2026 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 79:
-#line 337 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[0].node);}
-#line 2032 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 81:
-#line 339 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[0].node);}
-#line 2038 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 82:
-#line 340 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[0].node);}
-#line 2044 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 83:
-#line 341 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[0].node);}
-#line 2050 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 84:
-#line 342 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[0].node);}
-#line 2056 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 85:
-#line 343 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[0].node);}
-#line 2062 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 86:
-#line 344 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[0].node);}
-#line 2068 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 87:
-#line 345 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[0].node);}
-#line 2074 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 88:
-#line 346 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[0].node);}
-#line 2080 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 89:
-#line 347 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[0].node);}
-#line 2086 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 90:
-#line 348 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[0].node);}
-#line 2092 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 91:
-#line 349 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[0].node);}
-#line 2098 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 92:
-#line 350 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[0].node);}
-#line 2104 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 93:
-#line 351 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[0].node);}
-#line 2110 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 94:
-#line 352 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[0].node);}
-#line 2116 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 95:
-#line 353 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[0].node);}
-#line 2122 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 96:
-#line 354 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[0].node);}
-#line 2128 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 97:
-#line 355 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_NULL);}
-#line 2134 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 98:
-#line 358 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[0].node);}
-#line 2140 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 99:
-#line 359 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_mod_type((yyvsp[0].node),CONST_TAG);
- _asn1_set_right((yyvsp[-1].node),_asn1_get_down((yyval.node)));
- _asn1_set_down((yyval.node),(yyvsp[-1].node));}
-#line 2148 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 100:
-#line 364 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[0].node);}
-#line 2154 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 101:
-#line 365 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_mod_type((yyvsp[-1].node),CONST_DEFAULT);
- _asn1_set_right((yyvsp[0].node),_asn1_get_down((yyval.node)));
- _asn1_set_down((yyval.node),(yyvsp[0].node));}
-#line 2162 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 102:
-#line 368 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_mod_type((yyvsp[-1].node),CONST_OPTION);}
-#line 2168 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 103:
-#line 371 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_set_name((yyvsp[0].node),(yyvsp[-1].str));}
-#line 2174 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 104:
-#line 374 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[0].node);}
-#line 2180 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 105:
-#line 375 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[-2].node);
- _asn1_set_right(_asn1_get_last_right((yyvsp[-2].node)),(yyvsp[0].node));}
-#line 2187 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 106:
-#line 379 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_SEQUENCE);
- _asn1_set_down((yyval.node),(yyvsp[-1].node));}
-#line 2194 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 107:
-#line 381 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_SEQUENCE_OF);
- _asn1_set_down((yyval.node),(yyvsp[0].node));}
-#line 2201 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 108:
-#line 383 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_SEQUENCE_OF|CONST_SIZE);
- _asn1_set_right((yyvsp[-2].node),(yyvsp[0].node));
- _asn1_set_down((yyval.node),(yyvsp[-2].node));}
-#line 2209 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 109:
-#line 388 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_SET);
- _asn1_set_down((yyval.node),(yyvsp[-1].node));}
-#line 2216 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 110:
-#line 390 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_SET_OF);
- _asn1_set_down((yyval.node),(yyvsp[0].node));}
-#line 2223 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 111:
-#line 392 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_SET_OF|CONST_SIZE);
- _asn1_set_right((yyvsp[-2].node),(yyvsp[0].node));
- _asn1_set_down((yyval.node),(yyvsp[-2].node));}
-#line 2231 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 112:
-#line 397 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_CHOICE);
- _asn1_set_down((yyval.node),(yyvsp[-1].node));}
-#line 2238 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 113:
-#line 401 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_ANY);}
-#line 2244 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 114:
-#line 402 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_ANY|CONST_DEFINED_BY);
- _asn1_set_down((yyval.node),_asn1_add_static_node(ASN1_ETYPE_CONSTANT));
- _asn1_set_name(_asn1_get_down((yyval.node)),(yyvsp[0].str));}
-#line 2252 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 115:
-#line 407 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_set_name((yyvsp[0].node),(yyvsp[-2].str));}
-#line 2258 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 116:
-#line 409 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_set_name((yyvsp[0].node), last_error_token);}
-#line 2264 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 117:
-#line 413 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_OBJECT_ID|CONST_ASSIGN);
- _asn1_set_name((yyval.node),(yyvsp[-6].str));
- _asn1_set_down((yyval.node),(yyvsp[-1].node));}
-#line 2272 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 118:
-#line 417 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_OBJECT_ID|CONST_ASSIGN|CONST_1_PARAM);
- _asn1_set_name((yyval.node),(yyvsp[-5].str));
- _asn1_set_value((yyval.node),(yyvsp[-4].str),strlen((yyvsp[-4].str))+1);
- _asn1_set_down((yyval.node),(yyvsp[-1].node));}
-#line 2281 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 119:
-#line 422 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_INTEGER|CONST_ASSIGN);
- _asn1_set_name((yyval.node),(yyvsp[-3].str));
- _asn1_set_value((yyval.node),(yyvsp[0].str),strlen((yyvsp[0].str))+1);}
-#line 2289 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 120:
-#line 427 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[0].node);}
-#line 2295 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 121:
-#line 428 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[0].node);}
-#line 2301 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 122:
-#line 431 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[0].node);}
-#line 2307 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 123:
-#line 432 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=(yyvsp[-1].node);
- _asn1_set_right(_asn1_get_last_right((yyvsp[-1].node)),(yyvsp[0].node));}
-#line 2314 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 124:
-#line 436 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_OBJECT_ID);
- _asn1_set_down((yyval.node),(yyvsp[-1].node));
- _asn1_set_name((yyval.node),(yyvsp[-3].str));}
-#line 2322 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 125:
-#line 439 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_OBJECT_ID);
- _asn1_set_name((yyval.node),(yyvsp[-2].str));}
-#line 2329 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 126:
-#line 441 "ASN1.y" /* yacc.c:1646 */
- {(yyval.node)=_asn1_add_static_node(ASN1_ETYPE_OBJECT_ID);
- _asn1_set_name((yyval.node),(yyvsp[0].str));}
-#line 2336 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 127:
-#line 465 "ASN1.y" /* yacc.c:1646 */
- {(yyval.constant)=CONST_EXPLICIT;}
-#line 2342 "ASN1.c" /* yacc.c:1646 */
- break;
-
- case 128:
-#line 466 "ASN1.y" /* yacc.c:1646 */
- {(yyval.constant)=CONST_IMPLICIT;}
-#line 2348 "ASN1.c" /* yacc.c:1646 */
- break;
-
-
-#line 2352 "ASN1.c" /* yacc.c:1646 */
- default: break;
- }
- /* User semantic actions sometimes alter yychar, and that requires
- that yytoken be updated with the new translation. We take the
- approach of translating immediately before every use of yytoken.
- One alternative is translating here after every semantic action,
- but that translation would be missed if the semantic action invokes
- YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
- if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
- incorrect destructor might then be invoked immediately. In the
- case of YYERROR or YYBACKUP, subsequent parser actions might lead
- to an incorrect destructor call or verbose syntax error message
- before the lookahead is translated. */
- YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
-
- YYPOPSTACK (yylen);
- yylen = 0;
- YY_STACK_PRINT (yyss, yyssp);
-
- *++yyvsp = yyval;
-
- /* Now 'shift' the result of the reduction. Determine what state
- that goes to, based on the state we popped back to and the rule
- number reduced by. */
-
- yyn = yyr1[yyn];
-
- yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
- if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
- yystate = yytable[yystate];
- else
- yystate = yydefgoto[yyn - YYNTOKENS];
-
- goto yynewstate;
-
-
-/*--------------------------------------.
-| yyerrlab -- here on detecting error. |
-`--------------------------------------*/
-yyerrlab:
- /* Make sure we have latest lookahead translation. See comments at
- user semantic actions for why this is necessary. */
- yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
-
- /* If not already recovering from an error, report this error. */
- if (!yyerrstatus)
- {
- ++yynerrs;
-#if ! YYERROR_VERBOSE
- yyerror (YY_("syntax error"));
-#else
-# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
- yyssp, yytoken)
- {
- char const *yymsgp = YY_("syntax error");
- int yysyntax_error_status;
- yysyntax_error_status = YYSYNTAX_ERROR;
- if (yysyntax_error_status == 0)
- yymsgp = yymsg;
- else if (yysyntax_error_status == 1)
- {
- if (yymsg != yymsgbuf)
- YYSTACK_FREE (yymsg);
- yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
- if (!yymsg)
- {
- yymsg = yymsgbuf;
- yymsg_alloc = sizeof yymsgbuf;
- yysyntax_error_status = 2;
- }
- else
- {
- yysyntax_error_status = YYSYNTAX_ERROR;
- yymsgp = yymsg;
- }
- }
- yyerror (yymsgp);
- if (yysyntax_error_status == 2)
- goto yyexhaustedlab;
- }
-# undef YYSYNTAX_ERROR
-#endif
- }
-
-
-
- if (yyerrstatus == 3)
- {
- /* If just tried and failed to reuse lookahead token after an
- error, discard it. */
-
- if (yychar <= YYEOF)
- {
- /* Return failure if at end of input. */
- if (yychar == YYEOF)
- YYABORT;
- }
- else
- {
- yydestruct ("Error: discarding",
- yytoken, &yylval);
- yychar = YYEMPTY;
- }
- }
-
- /* Else will try to reuse lookahead token after shifting the error
- token. */
- goto yyerrlab1;
-
-
-/*---------------------------------------------------.
-| yyerrorlab -- error raised explicitly by YYERROR. |
-`---------------------------------------------------*/
-yyerrorlab:
-
- /* Pacify compilers like GCC when the user code never invokes
- YYERROR and the label yyerrorlab therefore never appears in user
- code. */
- if (/*CONSTCOND*/ 0)
- goto yyerrorlab;
-
- /* Do not reclaim the symbols of the rule whose action triggered
- this YYERROR. */
- YYPOPSTACK (yylen);
- yylen = 0;
- YY_STACK_PRINT (yyss, yyssp);
- yystate = *yyssp;
- goto yyerrlab1;
-
-
-/*-------------------------------------------------------------.
-| yyerrlab1 -- common code for both syntax error and YYERROR. |
-`-------------------------------------------------------------*/
-yyerrlab1:
- yyerrstatus = 3; /* Each real token shifted decrements this. */
-
- for (;;)
- {
- yyn = yypact[yystate];
- if (!yypact_value_is_default (yyn))
- {
- yyn += YYTERROR;
- if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
- {
- yyn = yytable[yyn];
- if (0 < yyn)
- break;
- }
- }
-
- /* Pop the current state because it cannot handle the error token. */
- if (yyssp == yyss)
- YYABORT;
-
-
- yydestruct ("Error: popping",
- yystos[yystate], yyvsp);
- YYPOPSTACK (1);
- yystate = *yyssp;
- YY_STACK_PRINT (yyss, yyssp);
- }
-
- YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
- *++yyvsp = yylval;
- YY_IGNORE_MAYBE_UNINITIALIZED_END
-
-
- /* Shift the error token. */
- YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
-
- yystate = yyn;
- goto yynewstate;
-
-
-/*-------------------------------------.
-| yyacceptlab -- YYACCEPT comes here. |
-`-------------------------------------*/
-yyacceptlab:
- yyresult = 0;
- goto yyreturn;
-
-/*-----------------------------------.
-| yyabortlab -- YYABORT comes here. |
-`-----------------------------------*/
-yyabortlab:
- yyresult = 1;
- goto yyreturn;
-
-#if !defined yyoverflow || YYERROR_VERBOSE
-/*-------------------------------------------------.
-| yyexhaustedlab -- memory exhaustion comes here. |
-`-------------------------------------------------*/
-yyexhaustedlab:
- yyerror (YY_("memory exhausted"));
- yyresult = 2;
- /* Fall through. */
-#endif
-
-yyreturn:
- if (yychar != YYEMPTY)
- {
- /* Make sure we have latest lookahead translation. See comments at
- user semantic actions for why this is necessary. */
- yytoken = YYTRANSLATE (yychar);
- yydestruct ("Cleanup: discarding lookahead",
- yytoken, &yylval);
- }
- /* Do not reclaim the symbols of the rule whose action triggered
- this YYABORT or YYACCEPT. */
- YYPOPSTACK (yylen);
- YY_STACK_PRINT (yyss, yyssp);
- while (yyssp != yyss)
- {
- yydestruct ("Cleanup: popping",
- yystos[*yyssp], yyvsp);
- YYPOPSTACK (1);
- }
-#ifndef yyoverflow
- if (yyss != yyssa)
- YYSTACK_FREE (yyss);
-#endif
-#if YYERROR_VERBOSE
- if (yymsg != yymsgbuf)
- YYSTACK_FREE (yymsg);
-#endif
- return yyresult;
-}
-#line 470 "ASN1.y" /* yacc.c:1906 */
-
-
-
-
-static const char *key_word[] = {
- "::=","OPTIONAL","INTEGER","SIZE","OCTET","STRING",
- "SEQUENCE","BIT","UNIVERSAL","PRIVATE","OPTIONAL",
- "DEFAULT","CHOICE","OF","OBJECT","IDENTIFIER",
- "BOOLEAN","TRUE","FALSE","APPLICATION","ANY","DEFINED",
- "SET","BY","EXPLICIT","IMPLICIT","DEFINITIONS","TAGS",
- "BEGIN","END","UTCTime","GeneralizedTime",
- "GeneralString","FROM","IMPORTS","NULL","ENUMERATED",
- "NumericString", "IA5String", "TeletexString", "PrintableString",
- "UniversalString", "BMPString", "UTF8String", "VisibleString"};
-
-static const int key_word_token[] = {
- ASSIG, OPTIONAL, INTEGER, SIZE, OCTET, STRING, SEQUENCE, BIT, UNIVERSAL,
- PRIVATE, OPTIONAL, DEFAULT, CHOICE, OF, OBJECT, STR_IDENTIFIER,
- BOOLEAN, ASN1_TRUE, ASN1_FALSE, APPLICATION, ANY, DEFINED, SET, BY,
- EXPLICIT, IMPLICIT, DEFINITIONS, TAGS, BEGIN, END, UTCTime,
- GeneralizedTime, GeneralString, FROM, IMPORTS, TOKEN_NULL,
- ENUMERATED, NumericString, IA5String, TeletexString, PrintableString,
- UniversalString, BMPString, UTF8String, VisibleString
-};
-
-/*************************************************************/
-/* Function: _asn1_yylex */
-/* Description: looks for tokens in file_asn1 pointer file. */
-/* Return: int */
-/* Token identifier or ASCII code or 0(zero: End Of File) */
-/*************************************************************/
-static int
-_asn1_yylex ()
-{
- int c, counter = 0, k, lastc;
- char string[ASN1_MAX_NAME_SIZE + 1]; /* will contain the next token */
- size_t i;
-
- while (1)
- {
- while ((c = fgetc (file_asn1)) == ' ' || c == '\t' || c == '\n')
- if (c == '\n')
- line_number++;
-
- if (c == EOF)
- {
- snprintf (last_token, sizeof(last_token), "End Of File");
- return 0;
- }
-
- if (c == '(' || c == ')' || c == '[' || c == ']' ||
- c == '{' || c == '}' || c == ',' || c == '.' ||
- c == '+' || c == '|')
- {
- last_token[0] = c;
- last_token[1] = 0;
- return c;
- }
- if (c == '-')
- { /* Maybe the first '-' of a comment */
- if ((c = fgetc (file_asn1)) != '-')
- {
- ungetc (c, file_asn1);
- last_token[0] = '-';
- last_token[1] = 0;
- return '-';
- }
- else
- { /* Comments */
- lastc = 0;
- counter = 0;
- /* A comment finishes at the next double hypen or the end of line */
- while ((c = fgetc (file_asn1)) != EOF && c != '\n' &&
- (lastc != '-' || (lastc == '-' && c != '-')))
- lastc = c;
- if (c == EOF)
- {
- snprintf (last_token, sizeof(last_token), "End Of File");
- return 0;
- }
- else
- {
- if (c == '\n')
- line_number++;
- continue; /* next char, please! (repeat the search) */
- }
- }
- }
- string[counter++] = c;
- /* Till the end of the token */
- while (!
- ((c = fgetc (file_asn1)) == EOF || c == ' ' || c == '\t'
- || c == '\n' || c == '(' || c == ')' || c == '[' || c == ']'
- || c == '{' || c == '}' || c == ',' || c == '.'))
- {
- if (counter >= ASN1_MAX_NAME_SIZE)
- {
- result_parse = ASN1_NAME_TOO_LONG;
- return 0;
- }
- string[counter++] = c;
- }
- ungetc (c, file_asn1);
- string[counter] = 0;
- snprintf (last_token, sizeof(last_token), "%s", string);
-
- /* Is STRING a number? */
- for (k = 0; k < counter; k++)
- if (!isdigit ((int)string[k]))
- break;
- if (k >= counter)
- {
- snprintf (yylval.str, sizeof(yylval.str), "%s", string);
- return NUM; /* return the number */
- }
-
- /* Is STRING a keyword? */
- for (i = 0; i < (sizeof (key_word) / sizeof (char *)); i++)
- if (!strcmp (string, key_word[i]))
- return key_word_token[i];
-
- /* STRING is an IDENTIFIER */
- snprintf (yylval.str, sizeof(yylval.str), "%s", string);
- return IDENTIFIER;
- }
-}
-
-/*************************************************************/
-/* Function: _asn1_create_errorDescription */
-/* Description: creates a string with the description of the*/
-/* error. */
-/* Parameters: */
-/* error : error to describe. */
-/* error_desc: string that will contain the */
-/* description. */
-/*************************************************************/
-static void
-_asn1_create_errorDescription (int error, char *error_desc)
-{
- if (error_desc == NULL)
- return;
-
-
- switch (error)
- {
- case ASN1_FILE_NOT_FOUND:
- snprintf(error_desc, ASN1_MAX_ERROR_DESCRIPTION_SIZE, "%s file was not found", file_name);
- break;
- case ASN1_SYNTAX_ERROR:
- snprintf(error_desc, ASN1_MAX_ERROR_DESCRIPTION_SIZE, "%s", last_error);
- break;
- case ASN1_NAME_TOO_LONG:
- snprintf (error_desc, ASN1_MAX_ERROR_DESCRIPTION_SIZE,
- "%s:%u: name too long (more than %u characters)", file_name,
- line_number, (unsigned)ASN1_MAX_NAME_SIZE);
- break;
- case ASN1_IDENTIFIER_NOT_FOUND:
- snprintf (error_desc, ASN1_MAX_ERROR_DESCRIPTION_SIZE,
- "%s:: identifier '%s' not found", file_name,
- _asn1_identifierMissing);
- break;
- default:
- error_desc[0] = 0;
- break;
- }
-
-}
-
-/**
- * asn1_parser2tree:
- * @file: specify the path and the name of file that contains
- * ASN.1 declarations.
- * @definitions: return the pointer to the structure created from
- * "file" ASN.1 declarations.
- * @error_desc: return the error description or an empty
- * string if success.
- *
- * Function used to start the parse algorithm. Creates the structures
- * needed to manage the definitions included in @file file.
- *
- * Returns: %ASN1_SUCCESS if the file has a correct syntax and every
- * identifier is known, %ASN1_ELEMENT_NOT_EMPTY if @definitions not
- * %NULL, %ASN1_FILE_NOT_FOUND if an error occurred while
- * opening @file, %ASN1_SYNTAX_ERROR if the syntax is not
- * correct, %ASN1_IDENTIFIER_NOT_FOUND if in the file there is an
- * identifier that is not defined, %ASN1_NAME_TOO_LONG if in the
- * file there is an identifier whith more than %ASN1_MAX_NAME_SIZE
- * characters.
- **/
-int
-asn1_parser2tree (const char *file, asn1_node * definitions,
- char *error_desc)
-{
-
- p_tree = NULL;
-
- if (*definitions != NULL)
- return ASN1_ELEMENT_NOT_EMPTY;
-
- *definitions = NULL;
-
- file_name = file;
-
- /* open the file to parse */
- file_asn1 = fopen (file, "r");
-
- if (file_asn1 == NULL)
- {
- result_parse = ASN1_FILE_NOT_FOUND;
- }
- else
- {
- result_parse = ASN1_SUCCESS;
-
- line_number = 1;
- yyparse ();
-
- fclose (file_asn1);
-
- if (result_parse == ASN1_SUCCESS)
- { /* syntax OK */
- /* set IMPLICIT or EXPLICIT property */
- _asn1_set_default_tag (p_tree);
- /* set CONST_SET and CONST_NOT_USED */
- _asn1_type_set_config (p_tree);
- /* check the identifier definitions */
- result_parse = _asn1_check_identifier (p_tree);
- if (result_parse == ASN1_SUCCESS)
- { /* all identifier defined */
- /* Delete the list and keep the ASN1 structure */
- _asn1_delete_list ();
- /* Convert into DER coding the value assign to INTEGER constants */
- _asn1_change_integer_value (p_tree);
- /* Expand the IDs of OBJECT IDENTIFIER constants */
- _asn1_expand_object_id (p_tree);
-
- *definitions = p_tree;
- }
- else /* some identifiers not defined */
- /* Delete the list and the ASN1 structure */
- _asn1_delete_list_and_nodes ();
- }
- else /* syntax error */
- /* Delete the list and the ASN1 structure */
- _asn1_delete_list_and_nodes ();
- }
-
- _asn1_create_errorDescription (result_parse, error_desc);
-
- return result_parse;
-}
-
-/**
- * asn1_parser2array:
- * @inputFileName: specify the path and the name of file that
- * contains ASN.1 declarations.
- * @outputFileName: specify the path and the name of file that will
- * contain the C vector definition.
- * @vectorName: specify the name of the C vector.
- * @error_desc: return the error description or an empty
- * string if success.
- *
- * Function that generates a C structure from an ASN1 file. Creates a
- * file containing a C vector to use to manage the definitions
- * included in @inputFileName file. If @inputFileName is
- * "/aa/bb/xx.yy" and @outputFileName is %NULL, the file created is
- * "/aa/bb/xx_asn1_tab.c". If @vectorName is %NULL the vector name
- * will be "xx_asn1_tab".
- *
- * Returns: %ASN1_SUCCESS if the file has a correct syntax and every
- * identifier is known, %ASN1_FILE_NOT_FOUND if an error occurred
- * while opening @inputFileName, %ASN1_SYNTAX_ERROR if the syntax is
- * not correct, %ASN1_IDENTIFIER_NOT_FOUND if in the file there is
- * an identifier that is not defined, %ASN1_NAME_TOO_LONG if in the
- * file there is an identifier whith more than %ASN1_MAX_NAME_SIZE
- * characters.
- **/
-int
-asn1_parser2array (const char *inputFileName, const char *outputFileName,
- const char *vectorName, char *error_desc)
-{
- char *file_out_name = NULL;
- char *vector_name = NULL;
- const char *char_p, *slash_p, *dot_p;
-
- p_tree = NULL;
-
- file_name = inputFileName;
-
- /* open the file to parse */
- file_asn1 = fopen (inputFileName, "r");
-
- if (file_asn1 == NULL)
- result_parse = ASN1_FILE_NOT_FOUND;
- else
- {
- result_parse = ASN1_SUCCESS;
-
- line_number = 1;
- yyparse ();
-
- fclose (file_asn1);
-
- if (result_parse == ASN1_SUCCESS)
- { /* syntax OK */
- /* set IMPLICIT or EXPLICIT property */
- _asn1_set_default_tag (p_tree);
- /* set CONST_SET and CONST_NOT_USED */
- _asn1_type_set_config (p_tree);
- /* check the identifier definitions */
- result_parse = _asn1_check_identifier (p_tree);
-
- if (result_parse == ASN1_SUCCESS)
- { /* all identifier defined */
-
- /* searching the last '/' and '.' in inputFileName */
- char_p = inputFileName;
- slash_p = inputFileName;
- while ((char_p = strchr (char_p, '/')))
- {
- char_p++;
- slash_p = char_p;
- }
-
- char_p = slash_p;
- dot_p = inputFileName + strlen (inputFileName);
-
- while ((char_p = strchr (char_p, '.')))
- {
- dot_p = char_p;
- char_p++;
- }
-
- if (outputFileName == NULL)
- {
- /* file_out_name = inputFileName + _asn1_tab.c */
- file_out_name = malloc (dot_p - inputFileName + 1 +
- strlen ("_asn1_tab.c"));
- memcpy (file_out_name, inputFileName,
- dot_p - inputFileName);
- file_out_name[dot_p - inputFileName] = 0;
- strcat (file_out_name, "_asn1_tab.c");
- }
- else
- {
- /* file_out_name = inputFileName */
- file_out_name =
- (char *) malloc (strlen (outputFileName) + 1);
- strcpy (file_out_name, outputFileName);
- }
-
- if (vectorName == NULL)
- {
- /* vector_name = file name + _asn1_tab */
- vector_name = malloc (dot_p - slash_p + 1 +
- strlen ("_asn1_tab"));
- memcpy (vector_name, slash_p, dot_p - slash_p);
- vector_name[dot_p - slash_p] = 0;
- strcat (vector_name, "_asn1_tab");
- }
- else
- {
- /* vector_name = vectorName */
- vector_name = (char *) malloc (strlen (vectorName) + 1);
- strcpy (vector_name, vectorName);
- }
-
- /* Save structure in a file */
- _asn1_create_static_structure (p_tree,
- file_out_name, vector_name);
-
- free (file_out_name);
- free (vector_name);
- } /* result == OK */
- } /* result == OK */
-
- /* Delete the list and the ASN1 structure */
- _asn1_delete_list_and_nodes ();
- } /* inputFile exist */
-
- _asn1_create_errorDescription (result_parse, error_desc);
-
- return result_parse;
-}
-
-/*************************************************************/
-/* Function: _asn1_yyerror */
-/* Description: function called when there are syntax errors*/
-/* Parameters: */
-/* char *s : error description */
-/* Return: int */
-/* */
-/*************************************************************/
-static void
-_asn1_yyerror (const char *s)
-{
- /* Sends the error description to the std_out */
-
- if (strcmp (last_token, "VisibleString") == 0 ||
- strcmp (last_token, "PrintableString") == 0 ||
- strcmp (last_token, "UniversalString") == 0 ||
- strcmp (last_token, "IA5String") == 0 ||
- strcmp (last_token, "UTF8String") == 0 ||
- strcmp (last_token, "NumericString") == 0 ||
- strcmp (last_token, "TeletexString") == 0 ||
- strcmp (last_token, "BMPString") == 0)
- {
- snprintf (last_error_token, sizeof(last_error_token),
- "%s", last_token);
- fprintf(stderr, "%s:%u: Warning: %s is a built-in ASN.1 type.\n",
- file_name, line_number, last_token);
- return;
- }
- last_error_token[0] = 0;
-
- if (result_parse != ASN1_NAME_TOO_LONG)
- {
- snprintf (last_error, sizeof(last_error),
- "%s:%u: Error: %s near '%s'", file_name,
- line_number, s, last_token);
- result_parse = ASN1_SYNTAX_ERROR;
- }
-
- return;
-}
diff --git a/lib/ASN1.y b/lib/ASN1.y
deleted file mode 100644
index 534a9f1..0000000
--- a/lib/ASN1.y
+++ /dev/null
@@ -1,894 +0,0 @@
-%{
-/*
- * Copyright (C) 2001-2014 Free Software Foundation, Inc.
- *
- * This file is part of LIBTASN1.
- *
- * The LIBTASN1 library 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 library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- */
-
-/*****************************************************/
-/* File: x509_ASN.y */
-/* Description: input file for 'bison' program. */
-/* The output file is a parser (in C language) for */
-/* ASN.1 syntax */
-/*****************************************************/
-
-#include <int.h>
-#include <parser_aux.h>
-#include <structure.h>
-#include <libtasn1.h>
-
-static FILE *file_asn1; /* Pointer to file to parse */
-static int result_parse = 0; /* result of the parser
- algorithm */
-static asn1_node p_tree; /* pointer to the root of the
- structure created by the
- parser*/
-static unsigned int line_number; /* line number describing the
- parser position inside the
- file */
-static char last_error[ASN1_MAX_ERROR_DESCRIPTION_SIZE] = "";
-static char last_error_token[ASN1_MAX_ERROR_DESCRIPTION_SIZE+1] = ""; /* used when expected errors occur */
-static char last_token[ASN1_MAX_NAME_SIZE+1] = ""; /* last token find in the file
- to parse before the 'parse
- error' */
-extern char _asn1_identifierMissing[];
-static const char *file_name; /* file to parse */
-
-static void _asn1_yyerror (const char *);
-static int _asn1_yylex(void);
-
-%}
-
-/* Prefix symbols and functions with _asn1_ */
-/* %define parse.lac full */
-%error-verbose
-%name-prefix "_asn1_yy"
-
-%union {
- unsigned int constant;
- char str[ASN1_MAX_NAME_SIZE+1];
- asn1_node node;
-}
-
-
-%token ASSIG "::="
-%token <str> NUM
-%token <str> IDENTIFIER
-%token OPTIONAL
-%token INTEGER
-%token SIZE
-%token OCTET
-%token STRING
-%token SEQUENCE
-%token BIT
-%token UNIVERSAL
-%token PRIVATE
-%token APPLICATION
-%token DEFAULT
-%token CHOICE
-%token OF
-%token OBJECT
-%token STR_IDENTIFIER
-%token BOOLEAN
-%token ASN1_TRUE
-%token ASN1_FALSE
-%token TOKEN_NULL
-%token ANY
-%token DEFINED
-%token BY
-%token SET
-%token EXPLICIT
-%token IMPLICIT
-%token DEFINITIONS
-%token TAGS
-%token BEGIN
-%token END
-%token UTCTime
-%token GeneralizedTime
-%token GeneralString
-%token NumericString
-%token IA5String
-%token TeletexString
-%token PrintableString
-%token UniversalString
-%token BMPString
-%token UTF8String
-%token VisibleString
-
-%token FROM
-%token IMPORTS
-%token ENUMERATED
-
-%type <node> octet_string_def constant constant_list type_assig_right
-%type <node> integer_def type_assig type_assig_list sequence_def type_def
-%type <node> bit_string_def default size_def choise_def object_def
-%type <node> boolean_def any_def size_def2 obj_constant obj_constant_list
-%type <node> constant_def type_constant type_constant_list definitions
-%type <node> definitions_id Time bit_element bit_element_list set_def
-%type <node> tag_type tag type_assig_right_tag generalstring_def
-%type <node> numericstring_def ia5string_def printablestring_def universalstring_def
-%type <node> bmpstring_def utf8string_def visiblestring_def teletexstring_def
-%type <node> type_assig_right_tag_default enumerated_def
-%type <str> pos_num neg_num pos_neg_num pos_neg_identifier pos_neg_list
-%type <str> num_identifier
-%type <str> int_identifier
-%type <constant> class explicit_implicit
-
-%%
-
-
-definitions: definitions_id
- DEFINITIONS explicit_implicit TAGS "::=" BEGIN /* imports_def */
- type_constant_list END
- {$$=_asn1_add_static_node(ASN1_ETYPE_DEFINITIONS|$3);
- _asn1_set_name($$,_asn1_get_name($1));
- _asn1_set_name($1,"");
- _asn1_set_right($1,$7);
- _asn1_set_down($$,$1);
-
- p_tree=$$;
- }
-;
-
-pos_num : NUM {snprintf($$,sizeof($$),"%s",$1);}
- | '+' NUM {snprintf($$,sizeof($$),"%s",$2);}
-;
-
-neg_num : '-' NUM {snprintf($$,sizeof($$),"-%s",$2);}
-;
-
-pos_neg_num : pos_num {snprintf($$,sizeof($$),"%s",$1);}
- | neg_num {snprintf($$,sizeof($$),"%s",$1);}
-;
-
-num_identifier : NUM {snprintf($$,sizeof($$),"%s",$1);}
- | IDENTIFIER {snprintf($$,sizeof($$),"%s",$1);}
-;
-
-int_identifier : NUM {snprintf($$,sizeof($$),"%s",$1);}
- | '-' NUM {snprintf($$,sizeof($$),"-%s",$2);}
- | IDENTIFIER {snprintf($$,sizeof($$),"%s",$1);}
-;
-
-pos_neg_identifier : pos_neg_num {snprintf($$,sizeof($$),"%s",$1);}
- | IDENTIFIER {snprintf($$,sizeof($$),"%s",$1);}
-;
-
-constant: '(' pos_neg_num ')' {$$=_asn1_add_static_node(ASN1_ETYPE_CONSTANT);
- _asn1_set_value($$,$2,strlen($2)+1);}
- | IDENTIFIER'('pos_neg_num')' {$$=_asn1_add_static_node(ASN1_ETYPE_CONSTANT);
- _asn1_set_name($$,$1);
- _asn1_set_value($$,$3,strlen($3)+1);}
-;
-
-constant_list: constant {$$=$1;}
- | constant_list ',' constant {$$=$1;
- _asn1_set_right(_asn1_get_last_right($1),$3);}
-;
-
-obj_constant: num_identifier {$$=_asn1_add_static_node(ASN1_ETYPE_CONSTANT);
- _asn1_set_value($$,$1,strlen($1)+1);}
- | IDENTIFIER'('NUM')' {$$=_asn1_add_static_node(ASN1_ETYPE_CONSTANT);
- _asn1_set_name($$,$1);
- _asn1_set_value($$,$3,strlen($3)+1);}
-;
-
-obj_constant_list: obj_constant {$$=$1;}
- | obj_constant_list obj_constant {$$=$1;
- _asn1_set_right(_asn1_get_last_right($1),$2);}
-;
-
-class : UNIVERSAL {$$=CONST_UNIVERSAL;}
- | PRIVATE {$$=CONST_PRIVATE;}
- | APPLICATION {$$=CONST_APPLICATION;}
-;
-
-tag_type : '[' NUM ']' {$$=_asn1_add_static_node(ASN1_ETYPE_TAG);
- _asn1_set_value($$,$2,strlen($2)+1);}
- | '[' class NUM ']' {$$=_asn1_add_static_node(ASN1_ETYPE_TAG | $2);
- _asn1_set_value($$,$3,strlen($3)+1);}
-;
-
-tag : tag_type {$$=$1;}
- | tag_type EXPLICIT {$$=_asn1_mod_type($1,CONST_EXPLICIT);}
- | tag_type IMPLICIT {$$=_asn1_mod_type($1,CONST_IMPLICIT);}
-;
-
-default : DEFAULT pos_neg_identifier {$$=_asn1_add_static_node(ASN1_ETYPE_DEFAULT);
- _asn1_set_value($$,$2,strlen($2)+1);}
- | DEFAULT ASN1_TRUE {$$=_asn1_add_static_node(ASN1_ETYPE_DEFAULT|CONST_TRUE);}
- | DEFAULT ASN1_FALSE {$$=_asn1_add_static_node(ASN1_ETYPE_DEFAULT|CONST_FALSE);}
-;
-
-
-pos_neg_list: pos_neg_num
- | pos_neg_list '|' pos_neg_num
-;
-
-
-integer_def: INTEGER {$$=_asn1_add_static_node(ASN1_ETYPE_INTEGER);}
- | INTEGER'{'constant_list'}' {$$=_asn1_add_static_node(ASN1_ETYPE_INTEGER|CONST_LIST);
- _asn1_set_down($$,$3);}
- | integer_def'(' pos_neg_list ')' {$$=_asn1_add_static_node(ASN1_ETYPE_INTEGER);}
- | integer_def'('int_identifier'.''.'int_identifier')'
- {$$=_asn1_add_static_node(ASN1_ETYPE_INTEGER|CONST_MIN_MAX);
- _asn1_set_down($$,_asn1_add_static_node(ASN1_ETYPE_SIZE));
- _asn1_set_value(_asn1_get_down($$),$6,strlen($6)+1);
- _asn1_set_name(_asn1_get_down($$),$3);}
-;
-
-boolean_def: BOOLEAN {$$=_asn1_add_static_node(ASN1_ETYPE_BOOLEAN);}
-;
-
-Time: UTCTime {$$=_asn1_add_static_node(ASN1_ETYPE_UTC_TIME);}
- | GeneralizedTime {$$=_asn1_add_static_node(ASN1_ETYPE_GENERALIZED_TIME);}
-;
-
-size_def2: SIZE'('num_identifier')' {$$=_asn1_add_static_node(ASN1_ETYPE_SIZE|CONST_1_PARAM);
- _asn1_set_value($$,$3,strlen($3)+1);}
- | SIZE'('num_identifier'.''.'num_identifier')'
- {$$=_asn1_add_static_node(ASN1_ETYPE_SIZE|CONST_MIN_MAX);
- _asn1_set_value($$,$3,strlen($3)+1);
- _asn1_set_name($$,$6);}
-;
-
-size_def: size_def2 {$$=$1;}
- | '(' size_def2 ')' {$$=$2;}
-;
-
-generalstring_def: GeneralString {$$=_asn1_add_static_node(ASN1_ETYPE_GENERALSTRING);}
- | GeneralString size_def {$$=_asn1_add_static_node(ASN1_ETYPE_GENERALSTRING|CONST_SIZE);
- _asn1_set_down($$,$2);}
-;
-
-numericstring_def: NumericString {$$=_asn1_add_static_node(ASN1_ETYPE_NUMERIC_STRING|CONST_UNIVERSAL);}
- | NumericString size_def {$$=_asn1_add_static_node(ASN1_ETYPE_NUMERIC_STRING|CONST_SIZE);
- _asn1_set_down($$,$2);}
-;
-
-ia5string_def: IA5String {$$=_asn1_add_static_node(ASN1_ETYPE_IA5_STRING);}
- | IA5String size_def {$$=_asn1_add_static_node(ASN1_ETYPE_IA5_STRING|CONST_SIZE);
- _asn1_set_down($$,$2);}
-;
-
-teletexstring_def: TeletexString {$$=_asn1_add_static_node(ASN1_ETYPE_TELETEX_STRING);}
- | TeletexString size_def {$$=_asn1_add_static_node(ASN1_ETYPE_TELETEX_STRING|CONST_SIZE);
- _asn1_set_down($$,$2);}
-;
-
-printablestring_def: PrintableString {$$=_asn1_add_static_node(ASN1_ETYPE_PRINTABLE_STRING);}
- | PrintableString size_def {$$=_asn1_add_static_node(ASN1_ETYPE_PRINTABLE_STRING|CONST_SIZE);
- _asn1_set_down($$,$2);}
-;
-
-universalstring_def: UniversalString {$$=_asn1_add_static_node(ASN1_ETYPE_UNIVERSAL_STRING);}
- | UniversalString size_def {$$=_asn1_add_static_node(ASN1_ETYPE_UNIVERSAL_STRING|CONST_SIZE);
- _asn1_set_down($$,$2);}
-;
-
-bmpstring_def: BMPString {$$=_asn1_add_static_node(ASN1_ETYPE_BMP_STRING);}
- | BMPString size_def {$$=_asn1_add_static_node(ASN1_ETYPE_BMP_STRING|CONST_SIZE);
- _asn1_set_down($$,$2);}
-;
-
-utf8string_def: UTF8String {$$=_asn1_add_static_node(ASN1_ETYPE_UTF8_STRING);}
- | UTF8String size_def {$$=_asn1_add_static_node(ASN1_ETYPE_UTF8_STRING|CONST_SIZE);
- _asn1_set_down($$,$2);}
-;
-
-visiblestring_def: VisibleString {$$=_asn1_add_static_node(ASN1_ETYPE_VISIBLE_STRING);}
- | VisibleString size_def {$$=_asn1_add_static_node(ASN1_ETYPE_VISIBLE_STRING|CONST_SIZE);
- _asn1_set_down($$,$2);}
-;
-
-octet_string_def : OCTET STRING {$$=_asn1_add_static_node(ASN1_ETYPE_OCTET_STRING);}
- | OCTET STRING size_def {$$=_asn1_add_static_node(ASN1_ETYPE_OCTET_STRING|CONST_SIZE);
- _asn1_set_down($$,$3);}
-;
-
-bit_element : IDENTIFIER'('NUM')' {$$=_asn1_add_static_node(ASN1_ETYPE_CONSTANT);
- _asn1_set_name($$,$1);
- _asn1_set_value($$,$3,strlen($3)+1);}
-;
-
-bit_element_list : bit_element {$$=$1;}
- | bit_element_list ',' bit_element {$$=$1;
- _asn1_set_right(_asn1_get_last_right($1),$3);}
-;
-
-bit_string_def : BIT STRING {$$=_asn1_add_static_node(ASN1_ETYPE_BIT_STRING);}
- | BIT STRING size_def {$$=_asn1_add_static_node(ASN1_ETYPE_BIT_STRING|CONST_SIZE);}
- | BIT STRING'{'bit_element_list'}'
- {$$=_asn1_add_static_node(ASN1_ETYPE_BIT_STRING|CONST_LIST);
- _asn1_set_down($$,$4);}
-;
-
-enumerated_def : ENUMERATED'{'bit_element_list'}'
- {$$=_asn1_add_static_node(ASN1_ETYPE_ENUMERATED|CONST_LIST);
- _asn1_set_down($$,$3);}
-;
-
-
-object_def : OBJECT STR_IDENTIFIER {$$=_asn1_add_static_node(ASN1_ETYPE_OBJECT_ID);}
-;
-
-type_assig_right: IDENTIFIER {$$=_asn1_add_static_node(ASN1_ETYPE_IDENTIFIER);
- _asn1_set_value($$,$1,strlen($1)+1);}
- | IDENTIFIER size_def {$$=_asn1_add_static_node(ASN1_ETYPE_IDENTIFIER|CONST_SIZE);
- _asn1_set_value($$,$1,strlen($1)+1);
- _asn1_set_down($$,$2);}
- | integer_def {$$=$1;}
- | enumerated_def {$$=$1;}
- | boolean_def {$$=$1;}
- | Time
- | octet_string_def {$$=$1;}
- | bit_string_def {$$=$1;}
- | generalstring_def {$$=$1;}
- | numericstring_def {$$=$1;}
- | ia5string_def {$$=$1;}
- | teletexstring_def {$$=$1;}
- | printablestring_def {$$=$1;}
- | universalstring_def {$$=$1;}
- | bmpstring_def {$$=$1;}
- | utf8string_def {$$=$1;}
- | visiblestring_def {$$=$1;}
- | sequence_def {$$=$1;}
- | object_def {$$=$1;}
- | choise_def {$$=$1;}
- | any_def {$$=$1;}
- | set_def {$$=$1;}
- | TOKEN_NULL {$$=_asn1_add_static_node(ASN1_ETYPE_NULL);}
-;
-
-type_assig_right_tag : type_assig_right {$$=$1;}
- | tag type_assig_right {$$=_asn1_mod_type($2,CONST_TAG);
- _asn1_set_right($1,_asn1_get_down($$));
- _asn1_set_down($$,$1);}
-;
-
-type_assig_right_tag_default : type_assig_right_tag {$$=$1;}
- | type_assig_right_tag default {$$=_asn1_mod_type($1,CONST_DEFAULT);
- _asn1_set_right($2,_asn1_get_down($$));
- _asn1_set_down($$,$2);}
- | type_assig_right_tag OPTIONAL {$$=_asn1_mod_type($1,CONST_OPTION);}
-;
-
-type_assig : IDENTIFIER type_assig_right_tag_default {$$=_asn1_set_name($2,$1);}
-;
-
-type_assig_list : type_assig {$$=$1;}
- | type_assig_list','type_assig {$$=$1;
- _asn1_set_right(_asn1_get_last_right($1),$3);}
-;
-
-sequence_def : SEQUENCE'{'type_assig_list'}' {$$=_asn1_add_static_node(ASN1_ETYPE_SEQUENCE);
- _asn1_set_down($$,$3);}
- | SEQUENCE OF type_assig_right {$$=_asn1_add_static_node(ASN1_ETYPE_SEQUENCE_OF);
- _asn1_set_down($$,$3);}
- | SEQUENCE size_def OF type_assig_right {$$=_asn1_add_static_node(ASN1_ETYPE_SEQUENCE_OF|CONST_SIZE);
- _asn1_set_right($2,$4);
- _asn1_set_down($$,$2);}
-;
-
-set_def : SET'{'type_assig_list'}' {$$=_asn1_add_static_node(ASN1_ETYPE_SET);
- _asn1_set_down($$,$3);}
- | SET OF type_assig_right {$$=_asn1_add_static_node(ASN1_ETYPE_SET_OF);
- _asn1_set_down($$,$3);}
- | SET size_def OF type_assig_right {$$=_asn1_add_static_node(ASN1_ETYPE_SET_OF|CONST_SIZE);
- _asn1_set_right($2,$4);
- _asn1_set_down($$,$2);}
-;
-
-choise_def : CHOICE'{'type_assig_list'}' {$$=_asn1_add_static_node(ASN1_ETYPE_CHOICE);
- _asn1_set_down($$,$3);}
-;
-
-any_def : ANY {$$=_asn1_add_static_node(ASN1_ETYPE_ANY);}
- | ANY DEFINED BY IDENTIFIER {$$=_asn1_add_static_node(ASN1_ETYPE_ANY|CONST_DEFINED_BY);
- _asn1_set_down($$,_asn1_add_static_node(ASN1_ETYPE_CONSTANT));
- _asn1_set_name(_asn1_get_down($$),$4);}
-;
-
-type_def : IDENTIFIER "::=" type_assig_right_tag {$$=_asn1_set_name($3,$1);}
- /* below should match: BMPString ::= [UNIVERSAL 30] IMPLICIT OCTET STRING etc*/
- | error "::=" type_assig_right_tag {$$=_asn1_set_name($3, last_error_token);}
-;
-
-constant_def : IDENTIFIER OBJECT STR_IDENTIFIER "::=" '{'obj_constant_list'}'
- {$$=_asn1_add_static_node(ASN1_ETYPE_OBJECT_ID|CONST_ASSIGN);
- _asn1_set_name($$,$1);
- _asn1_set_down($$,$6);}
- | IDENTIFIER IDENTIFIER "::=" '{' obj_constant_list '}'
- {$$=_asn1_add_static_node(ASN1_ETYPE_OBJECT_ID|CONST_ASSIGN|CONST_1_PARAM);
- _asn1_set_name($$,$1);
- _asn1_set_value($$,$2,strlen($2)+1);
- _asn1_set_down($$,$5);}
- | IDENTIFIER INTEGER "::=" pos_neg_num
- {$$=_asn1_add_static_node(ASN1_ETYPE_INTEGER|CONST_ASSIGN);
- _asn1_set_name($$,$1);
- _asn1_set_value($$,$4,strlen($4)+1);}
-;
-
-type_constant: type_def {$$=$1;}
- | constant_def {$$=$1;}
-;
-
-type_constant_list : type_constant {$$=$1;}
- | type_constant_list type_constant {$$=$1;
- _asn1_set_right(_asn1_get_last_right($1),$2);}
-;
-
-definitions_id : IDENTIFIER '{' obj_constant_list '}' {$$=_asn1_add_static_node(ASN1_ETYPE_OBJECT_ID);
- _asn1_set_down($$,$3);
- _asn1_set_name($$,$1);}
- | IDENTIFIER '{' '}' {$$=_asn1_add_static_node(ASN1_ETYPE_OBJECT_ID);
- _asn1_set_name($$,$1);}
- | IDENTIFIER {$$=_asn1_add_static_node(ASN1_ETYPE_OBJECT_ID);
- _asn1_set_name($$,$1);}
-;
-
-/*
-identifier_list : IDENTIFIER {$$=_asn1_add_static_node(ASN1_ETYPE_IDENTIFIER);
- _asn1_set_name($$,$1);}
- | identifier_list IDENTIFIER
- {$$=$1;
- _asn1_set_right(_asn1_get_last_right($$),_asn1_add_static_node(ASN1_ETYPE_IDENTIFIER));
- _asn1_set_name(_asn1_get_last_right($$),$2);}
-;
-
-
-imports_def : empty {$$=NULL;}
- | IMPORTS identifier_list FROM IDENTIFIER obj_constant_list
- {$$=_asn1_add_static_node(ASN1_ETYPE_IMPORTS);
- _asn1_set_down($$,_asn1_add_static_node(ASN1_ETYPE_OBJECT_ID));
- _asn1_set_name(_asn1_get_down($$),$4);
- _asn1_set_down(_asn1_get_down($$),$5);
- _asn1_set_right($$,$2);}
-;
-*/
-
-explicit_implicit : EXPLICIT {$$=CONST_EXPLICIT;}
- | IMPLICIT {$$=CONST_IMPLICIT;}
-;
-
-
-%%
-
-
-
-static const char *key_word[] = {
- "::=","OPTIONAL","INTEGER","SIZE","OCTET","STRING",
- "SEQUENCE","BIT","UNIVERSAL","PRIVATE","OPTIONAL",
- "DEFAULT","CHOICE","OF","OBJECT","IDENTIFIER",
- "BOOLEAN","TRUE","FALSE","APPLICATION","ANY","DEFINED",
- "SET","BY","EXPLICIT","IMPLICIT","DEFINITIONS","TAGS",
- "BEGIN","END","UTCTime","GeneralizedTime",
- "GeneralString","FROM","IMPORTS","NULL","ENUMERATED",
- "NumericString", "IA5String", "TeletexString", "PrintableString",
- "UniversalString", "BMPString", "UTF8String", "VisibleString"};
-
-static const int key_word_token[] = {
- ASSIG, OPTIONAL, INTEGER, SIZE, OCTET, STRING, SEQUENCE, BIT, UNIVERSAL,
- PRIVATE, OPTIONAL, DEFAULT, CHOICE, OF, OBJECT, STR_IDENTIFIER,
- BOOLEAN, ASN1_TRUE, ASN1_FALSE, APPLICATION, ANY, DEFINED, SET, BY,
- EXPLICIT, IMPLICIT, DEFINITIONS, TAGS, BEGIN, END, UTCTime,
- GeneralizedTime, GeneralString, FROM, IMPORTS, TOKEN_NULL,
- ENUMERATED, NumericString, IA5String, TeletexString, PrintableString,
- UniversalString, BMPString, UTF8String, VisibleString
-};
-
-/*************************************************************/
-/* Function: _asn1_yylex */
-/* Description: looks for tokens in file_asn1 pointer file. */
-/* Return: int */
-/* Token identifier or ASCII code or 0(zero: End Of File) */
-/*************************************************************/
-static int
-_asn1_yylex ()
-{
- int c, counter = 0, k, lastc;
- char string[ASN1_MAX_NAME_SIZE + 1]; /* will contain the next token */
- size_t i;
-
- while (1)
- {
- while ((c = fgetc (file_asn1)) == ' ' || c == '\t' || c == '\n')
- if (c == '\n')
- line_number++;
-
- if (c == EOF)
- {
- snprintf (last_token, sizeof(last_token), "End Of File");
- return 0;
- }
-
- if (c == '(' || c == ')' || c == '[' || c == ']' ||
- c == '{' || c == '}' || c == ',' || c == '.' ||
- c == '+' || c == '|')
- {
- last_token[0] = c;
- last_token[1] = 0;
- return c;
- }
- if (c == '-')
- { /* Maybe the first '-' of a comment */
- if ((c = fgetc (file_asn1)) != '-')
- {
- ungetc (c, file_asn1);
- last_token[0] = '-';
- last_token[1] = 0;
- return '-';
- }
- else
- { /* Comments */
- lastc = 0;
- counter = 0;
- /* A comment finishes at the next double hypen or the end of line */
- while ((c = fgetc (file_asn1)) != EOF && c != '\n' &&
- (lastc != '-' || (lastc == '-' && c != '-')))
- lastc = c;
- if (c == EOF)
- {
- snprintf (last_token, sizeof(last_token), "End Of File");
- return 0;
- }
- else
- {
- if (c == '\n')
- line_number++;
- continue; /* next char, please! (repeat the search) */
- }
- }
- }
- string[counter++] = c;
- /* Till the end of the token */
- while (!
- ((c = fgetc (file_asn1)) == EOF || c == ' ' || c == '\t'
- || c == '\n' || c == '(' || c == ')' || c == '[' || c == ']'
- || c == '{' || c == '}' || c == ',' || c == '.'))
- {
- if (counter >= ASN1_MAX_NAME_SIZE)
- {
- result_parse = ASN1_NAME_TOO_LONG;
- return 0;
- }
- string[counter++] = c;
- }
- ungetc (c, file_asn1);
- string[counter] = 0;
- snprintf (last_token, sizeof(last_token), "%s", string);
-
- /* Is STRING a number? */
- for (k = 0; k < counter; k++)
- if (!isdigit ((int)string[k]))
- break;
- if (k >= counter)
- {
- snprintf (yylval.str, sizeof(yylval.str), "%s", string);
- return NUM; /* return the number */
- }
-
- /* Is STRING a keyword? */
- for (i = 0; i < (sizeof (key_word) / sizeof (char *)); i++)
- if (!strcmp (string, key_word[i]))
- return key_word_token[i];
-
- /* STRING is an IDENTIFIER */
- snprintf (yylval.str, sizeof(yylval.str), "%s", string);
- return IDENTIFIER;
- }
-}
-
-/*************************************************************/
-/* Function: _asn1_create_errorDescription */
-/* Description: creates a string with the description of the*/
-/* error. */
-/* Parameters: */
-/* error : error to describe. */
-/* error_desc: string that will contain the */
-/* description. */
-/*************************************************************/
-static void
-_asn1_create_errorDescription (int error, char *error_desc)
-{
- if (error_desc == NULL)
- return;
-
-
- switch (error)
- {
- case ASN1_FILE_NOT_FOUND:
- snprintf(error_desc, ASN1_MAX_ERROR_DESCRIPTION_SIZE, "%s file was not found", file_name);
- break;
- case ASN1_SYNTAX_ERROR:
- snprintf(error_desc, ASN1_MAX_ERROR_DESCRIPTION_SIZE, "%s", last_error);
- break;
- case ASN1_NAME_TOO_LONG:
- snprintf (error_desc, ASN1_MAX_ERROR_DESCRIPTION_SIZE,
- "%s:%u: name too long (more than %u characters)", file_name,
- line_number, (unsigned)ASN1_MAX_NAME_SIZE);
- break;
- case ASN1_IDENTIFIER_NOT_FOUND:
- snprintf (error_desc, ASN1_MAX_ERROR_DESCRIPTION_SIZE,
- "%s:: identifier '%s' not found", file_name,
- _asn1_identifierMissing);
- break;
- default:
- error_desc[0] = 0;
- break;
- }
-
-}
-
-/**
- * asn1_parser2tree:
- * @file: specify the path and the name of file that contains
- * ASN.1 declarations.
- * @definitions: return the pointer to the structure created from
- * "file" ASN.1 declarations.
- * @error_desc: return the error description or an empty
- * string if success.
- *
- * Function used to start the parse algorithm. Creates the structures
- * needed to manage the definitions included in @file file.
- *
- * Returns: %ASN1_SUCCESS if the file has a correct syntax and every
- * identifier is known, %ASN1_ELEMENT_NOT_EMPTY if @definitions not
- * %NULL, %ASN1_FILE_NOT_FOUND if an error occurred while
- * opening @file, %ASN1_SYNTAX_ERROR if the syntax is not
- * correct, %ASN1_IDENTIFIER_NOT_FOUND if in the file there is an
- * identifier that is not defined, %ASN1_NAME_TOO_LONG if in the
- * file there is an identifier whith more than %ASN1_MAX_NAME_SIZE
- * characters.
- **/
-int
-asn1_parser2tree (const char *file, asn1_node * definitions,
- char *error_desc)
-{
-
- p_tree = NULL;
-
- if (*definitions != NULL)
- return ASN1_ELEMENT_NOT_EMPTY;
-
- *definitions = NULL;
-
- file_name = file;
-
- /* open the file to parse */
- file_asn1 = fopen (file, "r");
-
- if (file_asn1 == NULL)
- {
- result_parse = ASN1_FILE_NOT_FOUND;
- }
- else
- {
- result_parse = ASN1_SUCCESS;
-
- line_number = 1;
- yyparse ();
-
- fclose (file_asn1);
-
- if (result_parse == ASN1_SUCCESS)
- { /* syntax OK */
- /* set IMPLICIT or EXPLICIT property */
- _asn1_set_default_tag (p_tree);
- /* set CONST_SET and CONST_NOT_USED */
- _asn1_type_set_config (p_tree);
- /* check the identifier definitions */
- result_parse = _asn1_check_identifier (p_tree);
- if (result_parse == ASN1_SUCCESS)
- { /* all identifier defined */
- /* Delete the list and keep the ASN1 structure */
- _asn1_delete_list ();
- /* Convert into DER coding the value assign to INTEGER constants */
- _asn1_change_integer_value (p_tree);
- /* Expand the IDs of OBJECT IDENTIFIER constants */
- _asn1_expand_object_id (p_tree);
-
- *definitions = p_tree;
- }
- else /* some identifiers not defined */
- /* Delete the list and the ASN1 structure */
- _asn1_delete_list_and_nodes ();
- }
- else /* syntax error */
- /* Delete the list and the ASN1 structure */
- _asn1_delete_list_and_nodes ();
- }
-
- _asn1_create_errorDescription (result_parse, error_desc);
-
- return result_parse;
-}
-
-/**
- * asn1_parser2array:
- * @inputFileName: specify the path and the name of file that
- * contains ASN.1 declarations.
- * @outputFileName: specify the path and the name of file that will
- * contain the C vector definition.
- * @vectorName: specify the name of the C vector.
- * @error_desc: return the error description or an empty
- * string if success.
- *
- * Function that generates a C structure from an ASN1 file. Creates a
- * file containing a C vector to use to manage the definitions
- * included in @inputFileName file. If @inputFileName is
- * "/aa/bb/xx.yy" and @outputFileName is %NULL, the file created is
- * "/aa/bb/xx_asn1_tab.c". If @vectorName is %NULL the vector name
- * will be "xx_asn1_tab".
- *
- * Returns: %ASN1_SUCCESS if the file has a correct syntax and every
- * identifier is known, %ASN1_FILE_NOT_FOUND if an error occurred
- * while opening @inputFileName, %ASN1_SYNTAX_ERROR if the syntax is
- * not correct, %ASN1_IDENTIFIER_NOT_FOUND if in the file there is
- * an identifier that is not defined, %ASN1_NAME_TOO_LONG if in the
- * file there is an identifier whith more than %ASN1_MAX_NAME_SIZE
- * characters.
- **/
-int
-asn1_parser2array (const char *inputFileName, const char *outputFileName,
- const char *vectorName, char *error_desc)
-{
- char *file_out_name = NULL;
- char *vector_name = NULL;
- const char *char_p, *slash_p, *dot_p;
-
- p_tree = NULL;
-
- file_name = inputFileName;
-
- /* open the file to parse */
- file_asn1 = fopen (inputFileName, "r");
-
- if (file_asn1 == NULL)
- result_parse = ASN1_FILE_NOT_FOUND;
- else
- {
- result_parse = ASN1_SUCCESS;
-
- line_number = 1;
- yyparse ();
-
- fclose (file_asn1);
-
- if (result_parse == ASN1_SUCCESS)
- { /* syntax OK */
- /* set IMPLICIT or EXPLICIT property */
- _asn1_set_default_tag (p_tree);
- /* set CONST_SET and CONST_NOT_USED */
- _asn1_type_set_config (p_tree);
- /* check the identifier definitions */
- result_parse = _asn1_check_identifier (p_tree);
-
- if (result_parse == ASN1_SUCCESS)
- { /* all identifier defined */
-
- /* searching the last '/' and '.' in inputFileName */
- char_p = inputFileName;
- slash_p = inputFileName;
- while ((char_p = strchr (char_p, '/')))
- {
- char_p++;
- slash_p = char_p;
- }
-
- char_p = slash_p;
- dot_p = inputFileName + strlen (inputFileName);
-
- while ((char_p = strchr (char_p, '.')))
- {
- dot_p = char_p;
- char_p++;
- }
-
- if (outputFileName == NULL)
- {
- /* file_out_name = inputFileName + _asn1_tab.c */
- file_out_name = malloc (dot_p - inputFileName + 1 +
- strlen ("_asn1_tab.c"));
- memcpy (file_out_name, inputFileName,
- dot_p - inputFileName);
- file_out_name[dot_p - inputFileName] = 0;
- strcat (file_out_name, "_asn1_tab.c");
- }
- else
- {
- /* file_out_name = inputFileName */
- file_out_name =
- (char *) malloc (strlen (outputFileName) + 1);
- strcpy (file_out_name, outputFileName);
- }
-
- if (vectorName == NULL)
- {
- /* vector_name = file name + _asn1_tab */
- vector_name = malloc (dot_p - slash_p + 1 +
- strlen ("_asn1_tab"));
- memcpy (vector_name, slash_p, dot_p - slash_p);
- vector_name[dot_p - slash_p] = 0;
- strcat (vector_name, "_asn1_tab");
- }
- else
- {
- /* vector_name = vectorName */
- vector_name = (char *) malloc (strlen (vectorName) + 1);
- strcpy (vector_name, vectorName);
- }
-
- /* Save structure in a file */
- _asn1_create_static_structure (p_tree,
- file_out_name, vector_name);
-
- free (file_out_name);
- free (vector_name);
- } /* result == OK */
- } /* result == OK */
-
- /* Delete the list and the ASN1 structure */
- _asn1_delete_list_and_nodes ();
- } /* inputFile exist */
-
- _asn1_create_errorDescription (result_parse, error_desc);
-
- return result_parse;
-}
-
-/*************************************************************/
-/* Function: _asn1_yyerror */
-/* Description: function called when there are syntax errors*/
-/* Parameters: */
-/* char *s : error description */
-/* Return: int */
-/* */
-/*************************************************************/
-static void
-_asn1_yyerror (const char *s)
-{
- /* Sends the error description to the std_out */
-
- if (strcmp (last_token, "VisibleString") == 0 ||
- strcmp (last_token, "PrintableString") == 0 ||
- strcmp (last_token, "UniversalString") == 0 ||
- strcmp (last_token, "IA5String") == 0 ||
- strcmp (last_token, "UTF8String") == 0 ||
- strcmp (last_token, "NumericString") == 0 ||
- strcmp (last_token, "TeletexString") == 0 ||
- strcmp (last_token, "BMPString") == 0)
- {
- snprintf (last_error_token, sizeof(last_error_token),
- "%s", last_token);
- fprintf(stderr, "%s:%u: Warning: %s is a built-in ASN.1 type.\n",
- file_name, line_number, last_token);
- return;
- }
- last_error_token[0] = 0;
-
- if (result_parse != ASN1_NAME_TOO_LONG)
- {
- snprintf (last_error, sizeof(last_error),
- "%s:%u: Error: %s near '%s'", file_name,
- line_number, s, last_token);
- result_parse = ASN1_SYNTAX_ERROR;
- }
-
- return;
-}
diff --git a/lib/Makefile.am b/lib/Makefile.am
deleted file mode 100644
index 8b6a0f0..0000000
--- a/lib/Makefile.am
+++ /dev/null
@@ -1,59 +0,0 @@
-## Process this file with automake to produce Makefile.in
-# Copyright (C) 2002-2014 Free Software Foundation, Inc.
-#
-# This file is part of LIBTASN1.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program 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 General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-SUBDIRS = gllib
-
-AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS) $(CFLAG_VISIBILITY)
-AM_CPPFLAGS = -I$(srcdir)/gllib -DASN1_BUILDING
-
-include_HEADERS = libtasn1.h
-
-pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = libtasn1.pc
-
-lib_LTLIBRARIES = libtasn1.la
-
-libtasn1_la_SOURCES = \
- ASN1.y \
- coding.c \
- decoding.c \
- element.c \
- element.h \
- errors.c \
- gstr.c \
- gstr.h \
- int.h \
- libtasn1.h \
- libtasn1.map \
- parser_aux.c \
- parser_aux.h \
- structure.c \
- structure.h \
- version.c
-
-libtasn1_la_LIBADD = gllib/libgnu.la
-
-libtasn1_la_LDFLAGS = \
- -no-undefined \
- -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
-
-if HAVE_LD_VERSION_SCRIPT
-libtasn1_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libtasn1.map
-else
-libtasn1_la_LDFLAGS += -export-symbols-regex '^(asn1|libtasn1_).*'
-endif
diff --git a/lib/coding.c b/lib/coding.c
deleted file mode 100644
index 7141df7..0000000
--- a/lib/coding.c
+++ /dev/null
@@ -1,1347 +0,0 @@
-/*
- * Copyright (C) 2002-2014 Free Software Foundation, Inc.
- *
- * This file is part of LIBTASN1.
- *
- * The LIBTASN1 library 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 library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- */
-
-
-/*****************************************************/
-/* File: coding.c */
-/* Description: Functions to create a DER coding of */
-/* an ASN1 type. */
-/*****************************************************/
-
-#include <int.h>
-#include "parser_aux.h"
-#include <gstr.h>
-#include "element.h"
-#include "minmax.h"
-#include <structure.h>
-
-#define MAX_TAG_LEN 16
-
-/******************************************************/
-/* Function : _asn1_error_description_value_not_found */
-/* Description: creates the ErrorDescription string */
-/* for the ASN1_VALUE_NOT_FOUND error. */
-/* Parameters: */
-/* node: node of the tree where the value is NULL. */
-/* ErrorDescription: string returned. */
-/* Return: */
-/******************************************************/
-static void
-_asn1_error_description_value_not_found (asn1_node node,
- char *ErrorDescription)
-{
-
- if (ErrorDescription == NULL)
- return;
-
- Estrcpy (ErrorDescription, ":: value of element '");
- _asn1_hierarchical_name (node, ErrorDescription + strlen (ErrorDescription),
- ASN1_MAX_ERROR_DESCRIPTION_SIZE - 40);
- Estrcat (ErrorDescription, "' not found");
-
-}
-
-/**
- * asn1_length_der:
- * @len: value to convert.
- * @der: buffer to hold the returned encoding (may be %NULL).
- * @der_len: number of meaningful bytes of ANS (der[0]..der[der_len-1]).
- *
- * Creates the DER encoding of the provided length value.
- * The @der buffer must have enough room for the output. The maximum
- * length this function will encode is %ASN1_MAX_LENGTH_SIZE.
- *
- * To know the size of the DER encoding use a %NULL value for @der.
- **/
-void
-asn1_length_der (unsigned long int len, unsigned char *der, int *der_len)
-{
- int k;
- unsigned char temp[ASN1_MAX_LENGTH_SIZE];
-#if SIZEOF_UNSIGNED_LONG_INT > 8
- len &= 0xFFFFFFFFFFFFFFFF;
-#endif
-
- if (len < 128)
- {
- /* short form */
- if (der != NULL)
- der[0] = (unsigned char) len;
- *der_len = 1;
- }
- else
- {
- /* Long form */
- k = 0;
- while (len)
- {
- temp[k++] = len & 0xFF;
- len = len >> 8;
- }
- *der_len = k + 1;
- if (der != NULL)
- {
- der[0] = ((unsigned char) k & 0x7F) + 128;
- while (k--)
- der[*der_len - 1 - k] = temp[k];
- }
- }
-}
-
-/******************************************************/
-/* Function : _asn1_tag_der */
-/* Description: creates the DER coding for the CLASS */
-/* and TAG parameters. */
-/* It is limited by the ASN1_MAX_TAG_SIZE variable */
-/* Parameters: */
-/* class: value to convert. */
-/* tag_value: value to convert. */
-/* ans: string returned. */
-/* ans_len: number of meaningful bytes of ANS */
-/* (ans[0]..ans[ans_len-1]). */
-/* Return: */
-/******************************************************/
-static void
-_asn1_tag_der (unsigned char class, unsigned int tag_value,
- unsigned char *ans, int *ans_len)
-{
- int k;
- unsigned char temp[ASN1_MAX_TAG_SIZE];
-
- if (tag_value < 31)
- {
- /* short form */
- ans[0] = (class & 0xE0) + ((unsigned char) (tag_value & 0x1F));
- *ans_len = 1;
- }
- else
- {
- /* Long form */
- ans[0] = (class & 0xE0) + 31;
- k = 0;
- while (tag_value != 0)
- {
- temp[k++] = tag_value & 0x7F;
- tag_value >>= 7;
-
- if (k > ASN1_MAX_TAG_SIZE - 1)
- break; /* will not encode larger tags */
- }
- *ans_len = k + 1;
- while (k--)
- ans[*ans_len - 1 - k] = temp[k] + 128;
- ans[*ans_len - 1] -= 128;
- }
-}
-
-/**
- * asn1_octet_der:
- * @str: the input data.
- * @str_len: STR length (str[0]..str[*str_len-1]).
- * @der: encoded string returned.
- * @der_len: number of meaningful bytes of DER (der[0]..der[der_len-1]).
- *
- * Creates a length-value DER encoding for the input data.
- * The DER encoding of the input data will be placed in the @der variable.
- *
- * Note that the OCTET STRING tag is not included in the output.
- *
- * This function does not return any value because it is expected
- * that @der_len will contain enough bytes to store the string
- * plus the DER encoding. The DER encoding size can be obtained using
- * asn1_length_der().
- **/
-void
-asn1_octet_der (const unsigned char *str, int str_len,
- unsigned char *der, int *der_len)
-{
- int len_len;
-
- if (der == NULL || str_len < 0)
- return;
-
- asn1_length_der (str_len, der, &len_len);
- memcpy (der + len_len, str, str_len);
- *der_len = str_len + len_len;
-}
-
-
-/**
- * asn1_encode_simple_der:
- * @etype: The type of the string to be encoded (ASN1_ETYPE_)
- * @str: the string data.
- * @str_len: the string length
- * @tl: the encoded tag and length
- * @tl_len: the bytes of the @tl field
- *
- * Creates the DER encoding for various simple ASN.1 types like strings etc.
- * It stores the tag and length in @tl, which should have space for at least
- * %ASN1_MAX_TL_SIZE bytes. Initially @tl_len should contain the size of @tl.
- *
- * The complete DER encoding should consist of the value in @tl appended
- * with the provided @str.
- *
- * Returns: %ASN1_SUCCESS if successful or an error value.
- **/
-int
-asn1_encode_simple_der (unsigned int etype, const unsigned char *str,
- unsigned int str_len, unsigned char *tl,
- unsigned int *tl_len)
-{
- int tag_len, len_len;
- unsigned tlen;
- unsigned char der_tag[ASN1_MAX_TAG_SIZE];
- unsigned char der_length[ASN1_MAX_LENGTH_SIZE];
- unsigned char *p;
-
- if (str == NULL)
- return ASN1_VALUE_NOT_VALID;
-
- if (ETYPE_OK (etype) == 0)
- return ASN1_VALUE_NOT_VALID;
-
- /* doesn't handle constructed classes */
- if (ETYPE_CLASS (etype) != ASN1_CLASS_UNIVERSAL)
- return ASN1_VALUE_NOT_VALID;
-
- _asn1_tag_der (ETYPE_CLASS (etype), ETYPE_TAG (etype), der_tag, &tag_len);
-
- asn1_length_der (str_len, der_length, &len_len);
-
- if (tag_len <= 0 || len_len <= 0)
- return ASN1_VALUE_NOT_VALID;
-
- tlen = tag_len + len_len;
-
- if (*tl_len < tlen)
- return ASN1_MEM_ERROR;
-
- p = tl;
- memcpy (p, der_tag, tag_len);
- p += tag_len;
- memcpy (p, der_length, len_len);
-
- *tl_len = tlen;
-
- return ASN1_SUCCESS;
-}
-
-/******************************************************/
-/* Function : _asn1_time_der */
-/* Description: creates the DER coding for a TIME */
-/* type (length included). */
-/* Parameters: */
-/* str: TIME null-terminated string. */
-/* der: string returned. */
-/* der_len: number of meaningful bytes of DER */
-/* (der[0]..der[ans_len-1]). Initially it */
-/* if must store the lenght of DER. */
-/* Return: */
-/* ASN1_MEM_ERROR when DER isn't big enough */
-/* ASN1_SUCCESS otherwise */
-/******************************************************/
-static int
-_asn1_time_der (unsigned char *str, int str_len, unsigned char *der,
- int *der_len)
-{
- int len_len;
- int max_len;
-
- max_len = *der_len;
-
- asn1_length_der (str_len, (max_len > 0) ? der : NULL, &len_len);
-
- if ((len_len + str_len) <= max_len)
- memcpy (der + len_len, str, str_len);
- *der_len = len_len + str_len;
-
- if ((*der_len) > max_len)
- return ASN1_MEM_ERROR;
-
- return ASN1_SUCCESS;
-}
-
-
-/*
-void
-_asn1_get_utctime_der(unsigned char *der,int *der_len,unsigned char *str)
-{
- int len_len,str_len;
- char temp[20];
-
- if(str==NULL) return;
- str_len=asn1_get_length_der(der,*der_len,&len_len);
- if (str_len<0) return;
- memcpy(temp,der+len_len,str_len);
- *der_len=str_len+len_len;
- switch(str_len){
- case 11:
- temp[10]=0;
- strcat(temp,"00+0000");
- break;
- case 13:
- temp[12]=0;
- strcat(temp,"+0000");
- break;
- case 15:
- temp[15]=0;
- memmove(temp+12,temp+10,6);
- temp[10]=temp[11]='0';
- break;
- case 17:
- temp[17]=0;
- break;
- default:
- return;
- }
- strcpy(str,temp);
-}
-*/
-
-/******************************************************/
-/* Function : _asn1_objectid_der */
-/* Description: creates the DER coding for an */
-/* OBJECT IDENTIFIER type (length included). */
-/* Parameters: */
-/* str: OBJECT IDENTIFIER null-terminated string. */
-/* der: string returned. */
-/* der_len: number of meaningful bytes of DER */
-/* (der[0]..der[ans_len-1]). Initially it */
-/* must store the length of DER. */
-/* Return: */
-/* ASN1_MEM_ERROR when DER isn't big enough */
-/* ASN1_SUCCESS if succesful */
-/* or an error value. */
-/******************************************************/
-static int
-_asn1_objectid_der (unsigned char *str, unsigned char *der, int *der_len)
-{
- int len_len, counter, k, first, max_len;
- char *temp, *n_end, *n_start;
- unsigned char bit7;
- uint64_t val, val1 = 0;
- int str_len = _asn1_strlen (str);
-
- max_len = *der_len;
-
- temp = malloc (str_len + 2);
- if (temp == NULL)
- return ASN1_MEM_ALLOC_ERROR;
-
- memcpy (temp, str, str_len);
- temp[str_len] = '.';
- temp[str_len + 1] = 0;
-
- counter = 0;
- n_start = temp;
- while ((n_end = strchr (n_start, '.')))
- {
- *n_end = 0;
- val = _asn1_strtou64 (n_start, NULL, 10);
- counter++;
-
- if (counter == 1)
- val1 = val;
- else if (counter == 2)
- {
- if (max_len > 0)
- der[0] = 40 * val1 + val;
- *der_len = 1;
- }
- else
- {
- first = 0;
- for (k = sizeof(val); k >= 0; k--)
- {
- bit7 = (val >> (k * 7)) & 0x7F;
- if (bit7 || first || !k)
- {
- if (k)
- bit7 |= 0x80;
- if (max_len > (*der_len))
- der[*der_len] = bit7;
- (*der_len)++;
- first = 1;
- }
- }
-
- }
- n_start = n_end + 1;
- }
-
- asn1_length_der (*der_len, NULL, &len_len);
- if (max_len >= (*der_len + len_len))
- {
- memmove (der + len_len, der, *der_len);
- asn1_length_der (*der_len, der, &len_len);
- }
- *der_len += len_len;
-
- free (temp);
-
- if (max_len < (*der_len))
- return ASN1_MEM_ERROR;
-
- return ASN1_SUCCESS;
-}
-
-
-static const unsigned char bit_mask[] =
- { 0xFF, 0xFE, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0x80 };
-
-/**
- * asn1_bit_der:
- * @str: BIT string.
- * @bit_len: number of meaningful bits in STR.
- * @der: string returned.
- * @der_len: number of meaningful bytes of DER
- * (der[0]..der[ans_len-1]).
- *
- * Creates a length-value DER encoding for the input data
- * as it would have been for a BIT STRING.
- * The DER encoded data will be copied in @der.
- *
- * Note that the BIT STRING tag is not included in the output.
- *
- * This function does not return any value because it is expected
- * that @der_len will contain enough bytes to store the string
- * plus the DER encoding. The DER encoding size can be obtained using
- * asn1_length_der().
- **/
-void
-asn1_bit_der (const unsigned char *str, int bit_len,
- unsigned char *der, int *der_len)
-{
- int len_len, len_byte, len_pad;
-
- if (der == NULL)
- return;
-
- len_byte = bit_len >> 3;
- len_pad = 8 - (bit_len & 7);
- if (len_pad == 8)
- len_pad = 0;
- else
- len_byte++;
- asn1_length_der (len_byte + 1, der, &len_len);
- der[len_len] = len_pad;
-
- if (str)
- memcpy (der + len_len + 1, str, len_byte);
- der[len_len + len_byte] &= bit_mask[len_pad];
- *der_len = len_byte + len_len + 1;
-}
-
-
-/******************************************************/
-/* Function : _asn1_complete_explicit_tag */
-/* Description: add the length coding to the EXPLICIT */
-/* tags. */
-/* Parameters: */
-/* node: pointer to the tree element. */
-/* der: string with the DER coding of the whole tree*/
-/* counter: number of meaningful bytes of DER */
-/* (der[0]..der[*counter-1]). */
-/* max_len: size of der vector */
-/* Return: */
-/* ASN1_MEM_ERROR if der vector isn't big enough, */
-/* otherwise ASN1_SUCCESS. */
-/******************************************************/
-static int
-_asn1_complete_explicit_tag (asn1_node node, unsigned char *der,
- int *counter, int *max_len)
-{
- asn1_node p;
- int is_tag_implicit, len2, len3;
- unsigned char temp[SIZEOF_UNSIGNED_INT];
-
- is_tag_implicit = 0;
-
- if (node->type & CONST_TAG)
- {
- p = node->down;
- if (p == NULL)
- return ASN1_DER_ERROR;
- /* When there are nested tags we must complete them reverse to
- the order they were created. This is because completing a tag
- modifies all data within it, including the incomplete tags
- which store buffer positions -- simon@josefsson.org 2002-09-06
- */
- while (p->right)
- p = p->right;
- while (p && p != node->down->left)
- {
- if (type_field (p->type) == ASN1_ETYPE_TAG)
- {
- if (p->type & CONST_EXPLICIT)
- {
- len2 = strtol (p->name, NULL, 10);
- _asn1_set_name (p, NULL);
-
- asn1_length_der (*counter - len2, temp, &len3);
- if (len3 <= (*max_len))
- {
- memmove (der + len2 + len3, der + len2,
- *counter - len2);
- memcpy (der + len2, temp, len3);
- }
- *max_len -= len3;
- *counter += len3;
- is_tag_implicit = 0;
- }
- else
- { /* CONST_IMPLICIT */
- if (!is_tag_implicit)
- {
- is_tag_implicit = 1;
- }
- }
- }
- p = p->left;
- }
- }
-
- if (*max_len < 0)
- return ASN1_MEM_ERROR;
-
- return ASN1_SUCCESS;
-}
-
-const tag_and_class_st _asn1_tags[] = {
- [ASN1_ETYPE_GENERALSTRING] =
- {ASN1_TAG_GENERALSTRING, ASN1_CLASS_UNIVERSAL, "type:GENERALSTRING"},
- [ASN1_ETYPE_NUMERIC_STRING] =
- {ASN1_TAG_NUMERIC_STRING, ASN1_CLASS_UNIVERSAL, "type:NUMERIC_STR"},
- [ASN1_ETYPE_IA5_STRING] =
- {ASN1_TAG_IA5_STRING, ASN1_CLASS_UNIVERSAL, "type:IA5_STR"},
- [ASN1_ETYPE_TELETEX_STRING] =
- {ASN1_TAG_TELETEX_STRING, ASN1_CLASS_UNIVERSAL, "type:TELETEX_STR"},
- [ASN1_ETYPE_PRINTABLE_STRING] =
- {ASN1_TAG_PRINTABLE_STRING, ASN1_CLASS_UNIVERSAL, "type:PRINTABLE_STR"},
- [ASN1_ETYPE_UNIVERSAL_STRING] =
- {ASN1_TAG_UNIVERSAL_STRING, ASN1_CLASS_UNIVERSAL, "type:UNIVERSAL_STR"},
- [ASN1_ETYPE_BMP_STRING] =
- {ASN1_TAG_BMP_STRING, ASN1_CLASS_UNIVERSAL, "type:BMP_STR"},
- [ASN1_ETYPE_UTF8_STRING] =
- {ASN1_TAG_UTF8_STRING, ASN1_CLASS_UNIVERSAL, "type:UTF8_STR"},
- [ASN1_ETYPE_VISIBLE_STRING] =
- {ASN1_TAG_VISIBLE_STRING, ASN1_CLASS_UNIVERSAL, "type:VISIBLE_STR"},
- [ASN1_ETYPE_OCTET_STRING] =
- {ASN1_TAG_OCTET_STRING, ASN1_CLASS_UNIVERSAL, "type:OCT_STR"},
- [ASN1_ETYPE_BIT_STRING] =
- {ASN1_TAG_BIT_STRING, ASN1_CLASS_UNIVERSAL, "type:BIT_STR"},
- [ASN1_ETYPE_OBJECT_ID] =
- {ASN1_TAG_OBJECT_ID, ASN1_CLASS_UNIVERSAL, "type:OBJ_ID"},
- [ASN1_ETYPE_NULL] = {ASN1_TAG_NULL, ASN1_CLASS_UNIVERSAL, "type:NULL"},
- [ASN1_ETYPE_BOOLEAN] =
- {ASN1_TAG_BOOLEAN, ASN1_CLASS_UNIVERSAL, "type:BOOLEAN"},
- [ASN1_ETYPE_INTEGER] =
- {ASN1_TAG_INTEGER, ASN1_CLASS_UNIVERSAL, "type:INTEGER"},
- [ASN1_ETYPE_ENUMERATED] =
- {ASN1_TAG_ENUMERATED, ASN1_CLASS_UNIVERSAL, "type:ENUMERATED"},
- [ASN1_ETYPE_SEQUENCE] =
- {ASN1_TAG_SEQUENCE, ASN1_CLASS_UNIVERSAL | ASN1_CLASS_STRUCTURED,
- "type:SEQUENCE"},
- [ASN1_ETYPE_SEQUENCE_OF] =
- {ASN1_TAG_SEQUENCE, ASN1_CLASS_UNIVERSAL | ASN1_CLASS_STRUCTURED,
- "type:SEQ_OF"},
- [ASN1_ETYPE_SET] =
- {ASN1_TAG_SET, ASN1_CLASS_UNIVERSAL | ASN1_CLASS_STRUCTURED, "type:SET"},
- [ASN1_ETYPE_SET_OF] =
- {ASN1_TAG_SET, ASN1_CLASS_UNIVERSAL | ASN1_CLASS_STRUCTURED,
- "type:SET_OF"},
- [ASN1_ETYPE_GENERALIZED_TIME] =
- {ASN1_TAG_GENERALIZEDTime, ASN1_CLASS_UNIVERSAL, "type:GENERALIZED_TIME"},
- [ASN1_ETYPE_UTC_TIME] =
- {ASN1_TAG_UTCTime, ASN1_CLASS_UNIVERSAL, "type:UTC_TIME"},
-};
-
-unsigned int _asn1_tags_size = sizeof (_asn1_tags) / sizeof (_asn1_tags[0]);
-
-/******************************************************/
-/* Function : _asn1_insert_tag_der */
-/* Description: creates the DER coding of tags of one */
-/* NODE. */
-/* Parameters: */
-/* node: pointer to the tree element. */
-/* der: string returned */
-/* counter: number of meaningful bytes of DER */
-/* (counter[0]..der[*counter-1]). */
-/* max_len: size of der vector */
-/* Return: */
-/* ASN1_GENERIC_ERROR if the type is unknown, */
-/* ASN1_MEM_ERROR if der vector isn't big enough, */
-/* otherwise ASN1_SUCCESS. */
-/******************************************************/
-static int
-_asn1_insert_tag_der (asn1_node node, unsigned char *der, int *counter,
- int *max_len)
-{
- asn1_node p;
- int tag_len, is_tag_implicit;
- unsigned char class, class_implicit = 0, temp[MAX(SIZEOF_UNSIGNED_INT * 3 + 1, LTOSTR_MAX_SIZE)];
- unsigned long tag_implicit = 0;
- unsigned char tag_der[MAX_TAG_LEN];
-
- is_tag_implicit = 0;
-
- if (node->type & CONST_TAG)
- {
- p = node->down;
- while (p)
- {
- if (type_field (p->type) == ASN1_ETYPE_TAG)
- {
- if (p->type & CONST_APPLICATION)
- class = ASN1_CLASS_APPLICATION;
- else if (p->type & CONST_UNIVERSAL)
- class = ASN1_CLASS_UNIVERSAL;
- else if (p->type & CONST_PRIVATE)
- class = ASN1_CLASS_PRIVATE;
- else
- class = ASN1_CLASS_CONTEXT_SPECIFIC;
-
- if (p->type & CONST_EXPLICIT)
- {
- if (is_tag_implicit)
- _asn1_tag_der (class_implicit, tag_implicit, tag_der,
- &tag_len);
- else
- _asn1_tag_der (class | ASN1_CLASS_STRUCTURED,
- _asn1_strtoul (p->value, NULL, 10),
- tag_der, &tag_len);
-
- *max_len -= tag_len;
- if (der && *max_len >= 0)
- memcpy (der + *counter, tag_der, tag_len);
- *counter += tag_len;
-
- _asn1_ltostr (*counter, (char *) temp);
- _asn1_set_name (p, (const char *) temp);
-
- is_tag_implicit = 0;
- }
- else
- { /* CONST_IMPLICIT */
- if (!is_tag_implicit)
- {
- if ((type_field (node->type) == ASN1_ETYPE_SEQUENCE) ||
- (type_field (node->type) == ASN1_ETYPE_SEQUENCE_OF)
- || (type_field (node->type) == ASN1_ETYPE_SET)
- || (type_field (node->type) == ASN1_ETYPE_SET_OF))
- class |= ASN1_CLASS_STRUCTURED;
- class_implicit = class;
- tag_implicit = _asn1_strtoul (p->value, NULL, 10);
- is_tag_implicit = 1;
- }
- }
- }
- p = p->right;
- }
- }
-
- if (is_tag_implicit)
- {
- _asn1_tag_der (class_implicit, tag_implicit, tag_der, &tag_len);
- }
- else
- {
- unsigned type = type_field (node->type);
- switch (type)
- {
- CASE_HANDLED_ETYPES:
- _asn1_tag_der (_asn1_tags[type].class, _asn1_tags[type].tag,
- tag_der, &tag_len);
- break;
- case ASN1_ETYPE_TAG:
- case ASN1_ETYPE_CHOICE:
- case ASN1_ETYPE_ANY:
- tag_len = 0;
- break;
- default:
- return ASN1_GENERIC_ERROR;
- }
- }
-
- *max_len -= tag_len;
- if (der && *max_len >= 0)
- memcpy (der + *counter, tag_der, tag_len);
- *counter += tag_len;
-
- if (*max_len < 0)
- return ASN1_MEM_ERROR;
-
- return ASN1_SUCCESS;
-}
-
-/******************************************************/
-/* Function : _asn1_ordering_set */
-/* Description: puts the elements of a SET type in */
-/* the correct order according to DER rules. */
-/* Parameters: */
-/* der: string with the DER coding. */
-/* node: pointer to the SET element. */
-/* Return: */
-/* ASN1_SUCCESS if successful */
-/* or an error value. */
-/******************************************************/
-static int
-_asn1_ordering_set (unsigned char *der, int der_len, asn1_node node)
-{
- struct vet
- {
- int end;
- unsigned long value;
- struct vet *next, *prev;
- };
-
- int counter, len, len2;
- struct vet *first, *last, *p_vet, *p2_vet;
- asn1_node p;
- unsigned char class, *temp;
- unsigned long tag, t;
- int err;
-
- counter = 0;
-
- if (type_field (node->type) != ASN1_ETYPE_SET)
- return ASN1_VALUE_NOT_VALID;
-
- p = node->down;
- while (p && ((type_field (p->type) == ASN1_ETYPE_TAG) ||
- (type_field (p->type) == ASN1_ETYPE_SIZE)))
- p = p->right;
-
- if ((p == NULL) || (p->right == NULL))
- return ASN1_SUCCESS;
-
- first = last = NULL;
- while (p)
- {
- p_vet = malloc (sizeof (struct vet));
- if (p_vet == NULL)
- {
- err = ASN1_MEM_ALLOC_ERROR;
- goto error;
- }
-
- p_vet->next = NULL;
- p_vet->prev = last;
- if (first == NULL)
- first = p_vet;
- else
- last->next = p_vet;
- last = p_vet;
-
- /* tag value calculation */
- err = asn1_get_tag_der (der + counter, der_len - counter, &class, &len2,
- &tag);
- if (err != ASN1_SUCCESS)
- goto error;
-
- t = ((unsigned int)class) << 24;
- p_vet->value = t | tag;
- counter += len2;
-
- /* extraction and length */
- len2 = asn1_get_length_der (der + counter, der_len - counter, &len);
- if (len2 < 0)
- {
- err = ASN1_DER_ERROR;
- goto error;
- }
- counter += len + len2;
-
- p_vet->end = counter;
- p = p->right;
- }
-
- p_vet = first;
-
- while (p_vet)
- {
- p2_vet = p_vet->next;
- counter = 0;
- while (p2_vet)
- {
- if (p_vet->value > p2_vet->value)
- {
- /* change position */
- temp = malloc (p_vet->end - counter);
- if (temp == NULL)
- {
- err = ASN1_MEM_ALLOC_ERROR;
- goto error;
- }
-
- memcpy (temp, der + counter, p_vet->end - counter);
- memcpy (der + counter, der + p_vet->end,
- p2_vet->end - p_vet->end);
- memcpy (der + counter + p2_vet->end - p_vet->end, temp,
- p_vet->end - counter);
- free (temp);
-
- tag = p_vet->value;
- p_vet->value = p2_vet->value;
- p2_vet->value = tag;
-
- p_vet->end = counter + (p2_vet->end - p_vet->end);
- }
- counter = p_vet->end;
-
- p2_vet = p2_vet->next;
- p_vet = p_vet->next;
- }
-
- if (p_vet != first)
- p_vet->prev->next = NULL;
- else
- first = NULL;
- free (p_vet);
- p_vet = first;
- }
- return ASN1_SUCCESS;
-
-error:
- while (first != NULL)
- {
- p_vet = first;
- first = first->next;
- free(p_vet);
- }
- return err;
-}
-
-/******************************************************/
-/* Function : _asn1_ordering_set_of */
-/* Description: puts the elements of a SET OF type in */
-/* the correct order according to DER rules. */
-/* Parameters: */
-/* der: string with the DER coding. */
-/* node: pointer to the SET OF element. */
-/* Return: */
-/* ASN1_SUCCESS if successful */
-/* or an error value. */
-/******************************************************/
-static int
-_asn1_ordering_set_of (unsigned char *der, int der_len, asn1_node node)
-{
- struct vet
- {
- int end;
- struct vet *next, *prev;
- };
-
- int counter, len, len2, change;
- struct vet *first, *last, *p_vet, *p2_vet;
- asn1_node p;
- unsigned char *temp, class;
- unsigned long k, length;
- int err;
-
- counter = 0;
-
- if (type_field (node->type) != ASN1_ETYPE_SET_OF)
- return ASN1_VALUE_NOT_VALID;
-
- p = node->down;
- while (p && ((type_field (p->type) == ASN1_ETYPE_TAG) ||
- (type_field (p->type) == ASN1_ETYPE_SIZE)))
- p = p->right;
- if (p == NULL)
- return ASN1_VALUE_NOT_VALID;
- p = p->right;
-
- if ((p == NULL) || (p->right == NULL))
- return ASN1_SUCCESS;
-
- first = last = NULL;
- while (p)
- {
- p_vet = malloc (sizeof (struct vet));
- if (p_vet == NULL)
- {
- err = ASN1_MEM_ALLOC_ERROR;
- goto error;
- }
-
- p_vet->next = NULL;
- p_vet->prev = last;
- if (first == NULL)
- first = p_vet;
- else
- last->next = p_vet;
- last = p_vet;
-
- /* extraction of tag and length */
- if (der_len - counter > 0)
- {
-
- err = asn1_get_tag_der (der + counter, der_len - counter, &class,
- &len, NULL);
- if (err != ASN1_SUCCESS)
- goto error;
- counter += len;
-
- len2 = asn1_get_length_der (der + counter, der_len - counter, &len);
- if (len2 < 0)
- {
- err = ASN1_DER_ERROR;
- goto error;
- }
- counter += len + len2;
- }
- else
- {
- err = ASN1_DER_ERROR;
- goto error;
- }
-
- p_vet->end = counter;
- p = p->right;
- }
-
- p_vet = first;
-
- while (p_vet)
- {
- p2_vet = p_vet->next;
- counter = 0;
- while (p2_vet)
- {
- length = MIN(p_vet->end - counter, p2_vet->end - p_vet->end);
- change = -1;
- for (k = 0; k < length; k++)
- if (der[counter + k] > der[p_vet->end + k])
- {
- change = 1;
- break;
- }
- else if (der[counter + k] < der[p_vet->end + k])
- {
- change = 0;
- break;
- }
-
- if ((change == -1)
- && ((p_vet->end - counter) > (p2_vet->end - p_vet->end)))
- change = 1;
-
- if (change == 1)
- {
- /* change position */
- temp = malloc (p_vet->end - counter);
- if (temp == NULL)
- {
- err = ASN1_MEM_ALLOC_ERROR;
- goto error;
- }
-
- memcpy (temp, der + counter, (p_vet->end) - counter);
- memcpy (der + counter, der + (p_vet->end),
- (p2_vet->end) - (p_vet->end));
- memcpy (der + counter + (p2_vet->end) - (p_vet->end), temp,
- (p_vet->end) - counter);
- free (temp);
-
- p_vet->end = counter + (p2_vet->end - p_vet->end);
- }
- counter = p_vet->end;
-
- p2_vet = p2_vet->next;
- p_vet = p_vet->next;
- }
-
- if (p_vet != first)
- p_vet->prev->next = NULL;
- else
- first = NULL;
- free (p_vet);
- p_vet = first;
- }
- return ASN1_SUCCESS;
-
-error:
- while (first != NULL)
- {
- p_vet = first;
- first = first->next;
- free(p_vet);
- }
- return err;
-}
-
-/**
- * asn1_der_coding:
- * @element: pointer to an ASN1 element
- * @name: the name of the structure you want to encode (it must be
- * inside *POINTER).
- * @ider: vector that will contain the DER encoding. DER must be a
- * pointer to memory cells already allocated.
- * @len: number of bytes of *@ider: @ider[0]..@ider[len-1], Initialy
- * holds the sizeof of der vector.
- * @ErrorDescription: return the error description or an empty
- * string if success.
- *
- * Creates the DER encoding for the NAME structure (inside *POINTER
- * structure).
- *
- * Returns: %ASN1_SUCCESS if DER encoding OK, %ASN1_ELEMENT_NOT_FOUND
- * if @name is not a valid element, %ASN1_VALUE_NOT_FOUND if there
- * is an element without a value, %ASN1_MEM_ERROR if the @ider
- * vector isn't big enough and in this case @len will contain the
- * length needed.
- **/
-int
-asn1_der_coding (asn1_node element, const char *name, void *ider, int *len,
- char *ErrorDescription)
-{
- asn1_node node, p, p2;
- unsigned char temp[MAX(LTOSTR_MAX_SIZE, SIZEOF_UNSIGNED_LONG_INT * 3 + 1)];
- int counter, counter_old, len2, len3, move, max_len, max_len_old;
- int err;
- unsigned char *der = ider;
-
- if (ErrorDescription)
- ErrorDescription[0] = 0;
-
- node = asn1_find_node (element, name);
- if (node == NULL)
- return ASN1_ELEMENT_NOT_FOUND;
-
- /* Node is now a locally allocated variable.
- * That is because in some point we modify the
- * structure, and I don't know why! --nmav
- */
- node = _asn1_copy_structure3 (node);
- if (node == NULL)
- return ASN1_ELEMENT_NOT_FOUND;
-
- max_len = *len;
-
- counter = 0;
- move = DOWN;
- p = node;
-
- while (1)
- {
-
- counter_old = counter;
- max_len_old = max_len;
- if (move != UP)
- {
- p->start = counter;
- err = _asn1_insert_tag_der (p, der, &counter, &max_len);
- if (err != ASN1_SUCCESS && err != ASN1_MEM_ERROR)
- goto error;
- }
- switch (type_field (p->type))
- {
- case ASN1_ETYPE_NULL:
- max_len--;
- if (max_len >= 0)
- der[counter] = 0;
- counter++;
- move = RIGHT;
- break;
- case ASN1_ETYPE_BOOLEAN:
- if ((p->type & CONST_DEFAULT) && (p->value == NULL))
- {
- counter = counter_old;
- max_len = max_len_old;
- }
- else
- {
- if (p->value == NULL)
- {
- _asn1_error_description_value_not_found (p,
- ErrorDescription);
- err = ASN1_VALUE_NOT_FOUND;
- goto error;
- }
- max_len -= 2;
- if (max_len >= 0)
- {
- der[counter++] = 1;
- if (p->value[0] == 'F')
- der[counter++] = 0;
- else
- der[counter++] = 0xFF;
- }
- else
- counter += 2;
- }
- move = RIGHT;
- break;
- case ASN1_ETYPE_INTEGER:
- case ASN1_ETYPE_ENUMERATED:
- if ((p->type & CONST_DEFAULT) && (p->value == NULL))
- {
- counter = counter_old;
- max_len = max_len_old;
- }
- else
- {
- if (p->value == NULL)
- {
- _asn1_error_description_value_not_found (p,
- ErrorDescription);
- err = ASN1_VALUE_NOT_FOUND;
- goto error;
- }
- len2 = asn1_get_length_der (p->value, p->value_len, &len3);
- if (len2 < 0)
- {
- err = ASN1_DER_ERROR;
- goto error;
- }
- max_len -= len2 + len3;
- if (max_len >= 0)
- memcpy (der + counter, p->value, len3 + len2);
- counter += len3 + len2;
- }
- move = RIGHT;
- break;
- case ASN1_ETYPE_OBJECT_ID:
- if ((p->type & CONST_DEFAULT) && (p->value == NULL))
- {
- counter = counter_old;
- max_len = max_len_old;
- }
- else
- {
- if (p->value == NULL)
- {
- _asn1_error_description_value_not_found (p,
- ErrorDescription);
- err = ASN1_VALUE_NOT_FOUND;
- goto error;
- }
- len2 = max_len;
- err = _asn1_objectid_der (p->value, der + counter, &len2);
- if (err != ASN1_SUCCESS && err != ASN1_MEM_ERROR)
- goto error;
-
- max_len -= len2;
- counter += len2;
- }
- move = RIGHT;
- break;
- case ASN1_ETYPE_GENERALIZED_TIME:
- case ASN1_ETYPE_UTC_TIME:
- if (p->value == NULL)
- {
- _asn1_error_description_value_not_found (p, ErrorDescription);
- err = ASN1_VALUE_NOT_FOUND;
- goto error;
- }
- len2 = max_len;
- err = _asn1_time_der (p->value, p->value_len, der + counter, &len2);
- if (err != ASN1_SUCCESS && err != ASN1_MEM_ERROR)
- goto error;
-
- max_len -= len2;
- counter += len2;
- move = RIGHT;
- break;
- case ASN1_ETYPE_OCTET_STRING:
- case ASN1_ETYPE_GENERALSTRING:
- case ASN1_ETYPE_NUMERIC_STRING:
- case ASN1_ETYPE_IA5_STRING:
- case ASN1_ETYPE_TELETEX_STRING:
- case ASN1_ETYPE_PRINTABLE_STRING:
- case ASN1_ETYPE_UNIVERSAL_STRING:
- case ASN1_ETYPE_BMP_STRING:
- case ASN1_ETYPE_UTF8_STRING:
- case ASN1_ETYPE_VISIBLE_STRING:
- case ASN1_ETYPE_BIT_STRING:
- if (p->value == NULL)
- {
- _asn1_error_description_value_not_found (p, ErrorDescription);
- err = ASN1_VALUE_NOT_FOUND;
- goto error;
- }
- len2 = asn1_get_length_der (p->value, p->value_len, &len3);
- if (len2 < 0)
- {
- err = ASN1_DER_ERROR;
- goto error;
- }
- max_len -= len2 + len3;
- if (max_len >= 0)
- memcpy (der + counter, p->value, len3 + len2);
- counter += len3 + len2;
- move = RIGHT;
- break;
- case ASN1_ETYPE_SEQUENCE:
- case ASN1_ETYPE_SET:
- if (move != UP)
- {
- p->tmp_ival = counter;
- if (p->down == NULL)
- {
- move = UP;
- continue;
- }
- else
- {
- p2 = p->down;
- while (p2 && (type_field (p2->type) == ASN1_ETYPE_TAG))
- p2 = p2->right;
- if (p2)
- {
- p = p2;
- move = RIGHT;
- continue;
- }
- move = UP;
- continue;
- }
- }
- else
- { /* move==UP */
- len2 = p->tmp_ival;
- p->tmp_ival = 0;
- if ((type_field (p->type) == ASN1_ETYPE_SET) && (max_len >= 0))
- {
- err = _asn1_ordering_set (der + len2, counter - len2, p);
- if (err != ASN1_SUCCESS)
- goto error;
- }
- asn1_length_der (counter - len2, temp, &len3);
- max_len -= len3;
- if (max_len >= 0)
- {
- memmove (der + len2 + len3, der + len2, counter - len2);
- memcpy (der + len2, temp, len3);
- }
- counter += len3;
- move = RIGHT;
- }
- break;
- case ASN1_ETYPE_SEQUENCE_OF:
- case ASN1_ETYPE_SET_OF:
- if (move != UP)
- {
- p->tmp_ival = counter;
- p = p->down;
- while ((type_field (p->type) == ASN1_ETYPE_TAG)
- || (type_field (p->type) == ASN1_ETYPE_SIZE))
- p = p->right;
- if (p->right)
- {
- p = p->right;
- move = RIGHT;
- continue;
- }
- else
- p = _asn1_find_up (p);
- move = UP;
- }
- if (move == UP)
- {
- len2 = p->tmp_ival;
- p->tmp_ival = 0;
- if ((type_field (p->type) == ASN1_ETYPE_SET_OF)
- && (counter - len2 > 0) && (max_len >= 0))
- {
- err = _asn1_ordering_set_of (der + len2, counter - len2, p);
- if (err != ASN1_SUCCESS)
- goto error;
- }
- asn1_length_der (counter - len2, temp, &len3);
- max_len -= len3;
- if (max_len >= 0)
- {
- memmove (der + len2 + len3, der + len2, counter - len2);
- memcpy (der + len2, temp, len3);
- }
- counter += len3;
- move = RIGHT;
- }
- break;
- case ASN1_ETYPE_ANY:
- if (p->value == NULL)
- {
- _asn1_error_description_value_not_found (p, ErrorDescription);
- err = ASN1_VALUE_NOT_FOUND;
- goto error;
- }
- len2 = asn1_get_length_der (p->value, p->value_len, &len3);
- if (len2 < 0)
- {
- err = ASN1_DER_ERROR;
- goto error;
- }
- max_len -= len2;
- if (max_len >= 0)
- memcpy (der + counter, p->value + len3, len2);
- counter += len2;
- move = RIGHT;
- break;
- default:
- move = (move == UP) ? RIGHT : DOWN;
- break;
- }
-
- if ((move != DOWN) && (counter != counter_old))
- {
- p->end = counter - 1;
- err = _asn1_complete_explicit_tag (p, der, &counter, &max_len);
- if (err != ASN1_SUCCESS && err != ASN1_MEM_ERROR)
- goto error;
- }
-
- if (p == node && move != DOWN)
- break;
-
- if (move == DOWN)
- {
- if (p->down)
- p = p->down;
- else
- move = RIGHT;
- }
- if (move == RIGHT)
- {
- if (p->right)
- p = p->right;
- else
- move = UP;
- }
- if (move == UP)
- p = _asn1_find_up (p);
- }
-
- *len = counter;
-
- if (max_len < 0)
- {
- err = ASN1_MEM_ERROR;
- goto error;
- }
-
- err = ASN1_SUCCESS;
-
-error:
- asn1_delete_structure (&node);
- return err;
-}
diff --git a/lib/decoding.c b/lib/decoding.c
deleted file mode 100644
index 05dc236..0000000
--- a/lib/decoding.c
+++ /dev/null
@@ -1,2376 +0,0 @@
-/*
- * Copyright (C) 2002-2016 Free Software Foundation, Inc.
- *
- * This file is part of LIBTASN1.
- *
- * The LIBTASN1 library 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 library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- */
-
-
-/*****************************************************/
-/* File: decoding.c */
-/* Description: Functions to manage DER decoding */
-/*****************************************************/
-
-#include <int.h>
-#include <parser_aux.h>
-#include <gstr.h>
-#include <structure.h>
-#include <element.h>
-#include <limits.h>
-#include <intprops.h>
-
-#ifdef DEBUG
-# define warn() fprintf(stderr, "%s: %d\n", __func__, __LINE__)
-#else
-# define warn()
-#endif
-
-#define IS_ERR(len, flags) (len < -1 || ((flags & ASN1_DECODE_FLAG_STRICT_DER) && len < 0))
-
-#define HAVE_TWO(x) (x>=2?1:0)
-
-/* Decoding flags (dflags) used in several decoding functions.
- * DECODE_FLAG_HAVE_TAG: The provided buffer includes a tag
- * DECODE_FLAG_INDEFINITE: The provided buffer is of indefinite encoding (useful
- * when no tags are present).
- * DECODE_FLAG_LEVEL1: Internal flag to indicate a level of recursion for BER strings.
- * DECODE_FLAG_LEVEL2: Internal flag to indicate two levels of recursion for BER strings.
- * DECODE_FLAG_LEVEL3: Internal flag to indicate three levels of recursion for BER strings.
- * This is the maximum levels of recursion possible to prevent stack
- * exhaustion.
- */
-
-#define DECODE_FLAG_HAVE_TAG 1
-#define DECODE_FLAG_INDEFINITE (1<<1)
-#define DECODE_FLAG_LEVEL1 (1<<2)
-#define DECODE_FLAG_LEVEL2 (1<<3)
-#define DECODE_FLAG_LEVEL3 (1<<4)
-
-#define DECR_LEN(l, s) do { \
- l -= s; \
- if (l < 0) { \
- warn(); \
- result = ASN1_DER_ERROR; \
- goto cleanup; \
- } \
- } while (0)
-
-static int
-_asn1_get_indefinite_length_string (const unsigned char *der, int der_len, int *len);
-
-static int
-_asn1_decode_simple_ber (unsigned int etype, const unsigned char *der,
- unsigned int _der_len, unsigned char **str,
- unsigned int *str_len, unsigned int *ber_len,
- unsigned dflags);
-
-static int
-_asn1_decode_simple_der (unsigned int etype, const unsigned char *der,
- unsigned int _der_len, const unsigned char **str,
- unsigned int *str_len, unsigned dflags);
-
-static void
-_asn1_error_description_tag_error (asn1_node node, char *ErrorDescription)
-{
-
- Estrcpy (ErrorDescription, ":: tag error near element '");
- _asn1_hierarchical_name (node, ErrorDescription + strlen (ErrorDescription),
- ASN1_MAX_ERROR_DESCRIPTION_SIZE - 40);
- Estrcat (ErrorDescription, "'");
-
-}
-
-/**
- * asn1_get_length_der:
- * @der: DER data to decode.
- * @der_len: Length of DER data to decode.
- * @len: Output variable containing the length of the DER length field.
- *
- * Extract a length field from DER data.
- *
- * Returns: Return the decoded length value, or -1 on indefinite
- * length, or -2 when the value was too big to fit in a int, or -4
- * when the decoded length value plus @len would exceed @der_len.
- **/
-long
-asn1_get_length_der (const unsigned char *der, int der_len, int *len)
-{
- unsigned int ans;
- int k, punt, sum;
-
- *len = 0;
- if (der_len <= 0)
- return 0;
-
- if (!(der[0] & 128))
- {
- /* short form */
- *len = 1;
- ans = der[0];
- }
- else
- {
- /* Long form */
- k = der[0] & 0x7F;
- punt = 1;
- if (k)
- { /* definite length method */
- ans = 0;
- while (punt <= k && punt < der_len)
- {
- if (INT_MULTIPLY_OVERFLOW (ans, 256))
- return -2;
- ans *= 256;
-
- if (INT_ADD_OVERFLOW (ans, ((unsigned) der[punt])))
- return -2;
- ans += der[punt];
- punt++;
- }
- }
- else
- { /* indefinite length method */
- *len = punt;
- return -1;
- }
-
- *len = punt;
- }
-
- sum = ans;
- if (ans >= INT_MAX || INT_ADD_OVERFLOW (sum, (*len)))
- return -2;
- sum += *len;
-
- if (sum > der_len)
- return -4;
-
- return ans;
-}
-
-/**
- * asn1_get_tag_der:
- * @der: DER data to decode.
- * @der_len: Length of DER data to decode.
- * @cls: Output variable containing decoded class.
- * @len: Output variable containing the length of the DER TAG data.
- * @tag: Output variable containing the decoded tag (may be %NULL).
- *
- * Decode the class and TAG from DER code.
- *
- * Returns: Returns %ASN1_SUCCESS on success, or an error.
- **/
-int
-asn1_get_tag_der (const unsigned char *der, int der_len,
- unsigned char *cls, int *len, unsigned long *tag)
-{
- unsigned int ris;
- int punt;
-
- if (der == NULL || der_len < 2 || len == NULL)
- return ASN1_DER_ERROR;
-
- *cls = der[0] & 0xE0;
- if ((der[0] & 0x1F) != 0x1F)
- {
- /* short form */
- *len = 1;
- ris = der[0] & 0x1F;
- }
- else
- {
- /* Long form */
- punt = 1;
- ris = 0;
- while (punt < der_len && der[punt] & 128)
- {
-
- if (INT_MULTIPLY_OVERFLOW (ris, 128))
- return ASN1_DER_ERROR;
- ris *= 128;
-
- if (INT_ADD_OVERFLOW (ris, ((unsigned) (der[punt] & 0x7F))))
- return ASN1_DER_ERROR;
- ris += (der[punt] & 0x7F);
- punt++;
- }
-
- if (punt >= der_len)
- return ASN1_DER_ERROR;
-
- if (INT_MULTIPLY_OVERFLOW (ris, 128))
- return ASN1_DER_ERROR;
- ris *= 128;
-
- if (INT_ADD_OVERFLOW (ris, ((unsigned) (der[punt] & 0x7F))))
- return ASN1_DER_ERROR;
- ris += (der[punt] & 0x7F);
- punt++;
-
- *len = punt;
- }
-
- if (tag)
- *tag = ris;
- return ASN1_SUCCESS;
-}
-
-/**
- * asn1_get_length_ber:
- * @ber: BER data to decode.
- * @ber_len: Length of BER data to decode.
- * @len: Output variable containing the length of the BER length field.
- *
- * Extract a length field from BER data. The difference to
- * asn1_get_length_der() is that this function will return a length
- * even if the value has indefinite encoding.
- *
- * Returns: Return the decoded length value, or negative value when
- * the value was too big.
- *
- * Since: 2.0
- **/
-long
-asn1_get_length_ber (const unsigned char *ber, int ber_len, int *len)
-{
- int ret;
- long err;
-
- ret = asn1_get_length_der (ber, ber_len, len);
- if (ret == -1 && ber_len > 1)
- { /* indefinite length method */
- err = _asn1_get_indefinite_length_string (ber + 1, ber_len-1, &ret);
- if (err != ASN1_SUCCESS)
- return -3;
- }
-
- return ret;
-}
-
-/**
- * asn1_get_octet_der:
- * @der: DER data to decode containing the OCTET SEQUENCE.
- * @der_len: The length of the @der data to decode.
- * @ret_len: Output variable containing the encoded length of the DER data.
- * @str: Pre-allocated output buffer to put decoded OCTET SEQUENCE in.
- * @str_size: Length of pre-allocated output buffer.
- * @str_len: Output variable containing the length of the contents of the OCTET SEQUENCE.
- *
- * Extract an OCTET SEQUENCE from DER data. Note that this function
- * expects the DER data past the tag field, i.e., the length and
- * content octets.
- *
- * Returns: Returns %ASN1_SUCCESS on success, or an error.
- **/
-int
-asn1_get_octet_der (const unsigned char *der, int der_len,
- int *ret_len, unsigned char *str, int str_size,
- int *str_len)
-{
- int len_len = 0;
-
- if (der_len <= 0)
- return ASN1_GENERIC_ERROR;
-
- *str_len = asn1_get_length_der (der, der_len, &len_len);
-
- if (*str_len < 0)
- return ASN1_DER_ERROR;
-
- *ret_len = *str_len + len_len;
- if (str_size >= *str_len)
- {
- if (*str_len > 0 && str != NULL)
- memcpy (str, der + len_len, *str_len);
- }
- else
- {
- return ASN1_MEM_ERROR;
- }
-
- return ASN1_SUCCESS;
-}
-
-
-/*-
- * _asn1_get_time_der:
- * @type: %ASN1_ETYPE_GENERALIZED_TIME or %ASN1_ETYPE_UTC_TIME
- * @der: DER data to decode containing the time
- * @der_len: Length of DER data to decode.
- * @ret_len: Output variable containing the length of the DER data.
- * @str: Pre-allocated output buffer to put the textual time in.
- * @str_size: Length of pre-allocated output buffer.
- * @flags: Zero or %ASN1_DECODE_FLAG_STRICT_DER
- *
- * Performs basic checks in the DER encoded time object and returns its textual form.
- * The textual form will be in the YYYYMMDD000000Z format for GeneralizedTime
- * and YYMMDD000000Z for UTCTime.
- *
- * Returns: %ASN1_SUCCESS on success, or an error.
- -*/
-static int
-_asn1_get_time_der (unsigned type, const unsigned char *der, int der_len, int *ret_len,
- char *str, int str_size, unsigned flags)
-{
- int len_len, str_len;
- unsigned i;
- unsigned sign_count = 0;
- unsigned dot_count = 0;
- const unsigned char *p;
-
- if (der_len <= 0 || str == NULL)
- return ASN1_DER_ERROR;
-
- str_len = asn1_get_length_der (der, der_len, &len_len);
- if (str_len <= 0 || str_size < str_len)
- return ASN1_DER_ERROR;
-
- /* perform some sanity checks on the data */
- if (str_len < 8)
- {
- warn();
- return ASN1_TIME_ENCODING_ERROR;
- }
-
- if ((flags & ASN1_DECODE_FLAG_STRICT_DER) && !(flags & ASN1_DECODE_FLAG_ALLOW_INCORRECT_TIME))
- {
- p = &der[len_len];
- for (i=0;i<(unsigned)(str_len-1);i++)
- {
- if (isdigit(p[i]) == 0)
- {
- if (type == ASN1_ETYPE_GENERALIZED_TIME)
- {
- /* tolerate lax encodings */
- if (p[i] == '.' && dot_count == 0)
- {
- dot_count++;
- continue;
- }
-
- /* This is not really valid DER, but there are
- * structures using that */
- if (!(flags & ASN1_DECODE_FLAG_STRICT_DER) &&
- (p[i] == '+' || p[i] == '-') && sign_count == 0)
- {
- sign_count++;
- continue;
- }
- }
-
- warn();
- return ASN1_TIME_ENCODING_ERROR;
- }
- }
-
- if (sign_count == 0 && p[str_len-1] != 'Z')
- {
- warn();
- return ASN1_TIME_ENCODING_ERROR;
- }
- }
- memcpy (str, der + len_len, str_len);
- str[str_len] = 0;
- *ret_len = str_len + len_len;
-
- return ASN1_SUCCESS;
-}
-
-/**
- * asn1_get_objectid_der:
- * @der: DER data to decode containing the OBJECT IDENTIFIER
- * @der_len: Length of DER data to decode.
- * @ret_len: Output variable containing the length of the DER data.
- * @str: Pre-allocated output buffer to put the textual object id in.
- * @str_size: Length of pre-allocated output buffer.
- *
- * Converts a DER encoded object identifier to its textual form. This
- * function expects the DER object identifier without the tag.
- *
- * Returns: %ASN1_SUCCESS on success, or an error.
- **/
-int
-asn1_get_object_id_der (const unsigned char *der, int der_len, int *ret_len,
- char *str, int str_size)
-{
- int len_len, len, k;
- int leading;
- char temp[LTOSTR_MAX_SIZE];
- uint64_t val, val1;
-
- *ret_len = 0;
- if (str && str_size > 0)
- str[0] = 0; /* no oid */
-
- if (str == NULL || der_len <= 0)
- return ASN1_GENERIC_ERROR;
-
- len = asn1_get_length_der (der, der_len, &len_len);
-
- if (len <= 0 || len + len_len > der_len)
- return ASN1_DER_ERROR;
-
- val1 = der[len_len] / 40;
- val = der[len_len] - val1 * 40;
-
- _asn1_str_cpy (str, str_size, _asn1_ltostr (val1, temp));
- _asn1_str_cat (str, str_size, ".");
- _asn1_str_cat (str, str_size, _asn1_ltostr (val, temp));
-
- val = 0;
- leading = 1;
- for (k = 1; k < len; k++)
- {
- /* X.690 mandates that the leading byte must never be 0x80
- */
- if (leading != 0 && der[len_len + k] == 0x80)
- return ASN1_DER_ERROR;
- leading = 0;
-
- /* check for wrap around */
- if (INT_LEFT_SHIFT_OVERFLOW (val, 7))
- return ASN1_DER_ERROR;
-
- val = val << 7;
- val |= der[len_len + k] & 0x7F;
-
- if (!(der[len_len + k] & 0x80))
- {
- _asn1_str_cat (str, str_size, ".");
- _asn1_str_cat (str, str_size, _asn1_ltostr (val, temp));
- val = 0;
- leading = 1;
- }
- }
-
- if (INT_ADD_OVERFLOW (len, len_len))
- return ASN1_DER_ERROR;
-
- *ret_len = len + len_len;
-
- return ASN1_SUCCESS;
-}
-
-/**
- * asn1_get_bit_der:
- * @der: DER data to decode containing the BIT SEQUENCE.
- * @der_len: Length of DER data to decode.
- * @ret_len: Output variable containing the length of the DER data.
- * @str: Pre-allocated output buffer to put decoded BIT SEQUENCE in.
- * @str_size: Length of pre-allocated output buffer.
- * @bit_len: Output variable containing the size of the BIT SEQUENCE.
- *
- * Extract a BIT SEQUENCE from DER data.
- *
- * Returns: %ASN1_SUCCESS on success, or an error.
- **/
-int
-asn1_get_bit_der (const unsigned char *der, int der_len,
- int *ret_len, unsigned char *str, int str_size,
- int *bit_len)
-{
- int len_len = 0, len_byte;
-
- if (der_len <= 0)
- return ASN1_GENERIC_ERROR;
-
- len_byte = asn1_get_length_der (der, der_len, &len_len) - 1;
- if (len_byte < 0)
- return ASN1_DER_ERROR;
-
- *ret_len = len_byte + len_len + 1;
- *bit_len = len_byte * 8 - der[len_len];
-
- if (*bit_len < 0)
- return ASN1_DER_ERROR;
-
- if (str_size >= len_byte)
- {
- if (len_byte > 0 && str)
- memcpy (str, der + len_len + 1, len_byte);
- }
- else
- {
- return ASN1_MEM_ERROR;
- }
-
- return ASN1_SUCCESS;
-}
-
-/* tag_len: the total tag length (explicit+inner)
- * inner_tag_len: the inner_tag length
- */
-static int
-_asn1_extract_tag_der (asn1_node node, const unsigned char *der, int der_len,
- int *tag_len, int *inner_tag_len, unsigned flags)
-{
- asn1_node p;
- int counter, len2, len3, is_tag_implicit;
- int result;
- unsigned long tag, tag_implicit = 0;
- unsigned char class, class2, class_implicit = 0;
-
- if (der_len <= 0)
- return ASN1_GENERIC_ERROR;
-
- counter = is_tag_implicit = 0;
-
- if (node->type & CONST_TAG)
- {
- p = node->down;
- while (p)
- {
- if (type_field (p->type) == ASN1_ETYPE_TAG)
- {
- if (p->type & CONST_APPLICATION)
- class2 = ASN1_CLASS_APPLICATION;
- else if (p->type & CONST_UNIVERSAL)
- class2 = ASN1_CLASS_UNIVERSAL;
- else if (p->type & CONST_PRIVATE)
- class2 = ASN1_CLASS_PRIVATE;
- else
- class2 = ASN1_CLASS_CONTEXT_SPECIFIC;
-
- if (p->type & CONST_EXPLICIT)
- {
- if (asn1_get_tag_der
- (der + counter, der_len, &class, &len2,
- &tag) != ASN1_SUCCESS)
- return ASN1_DER_ERROR;
-
- DECR_LEN(der_len, len2);
- counter += len2;
-
- if (flags & ASN1_DECODE_FLAG_STRICT_DER)
- len3 =
- asn1_get_length_der (der + counter, der_len,
- &len2);
- else
- len3 =
- asn1_get_length_ber (der + counter, der_len,
- &len2);
- if (len3 < 0)
- return ASN1_DER_ERROR;
-
- DECR_LEN(der_len, len2);
- counter += len2;
-
- if (!is_tag_implicit)
- {
- if ((class != (class2 | ASN1_CLASS_STRUCTURED)) ||
- (tag != strtoul ((char *) p->value, NULL, 10)))
- return ASN1_TAG_ERROR;
- }
- else
- { /* ASN1_TAG_IMPLICIT */
- if ((class != class_implicit) || (tag != tag_implicit))
- return ASN1_TAG_ERROR;
- }
- is_tag_implicit = 0;
- }
- else
- { /* ASN1_TAG_IMPLICIT */
- if (!is_tag_implicit)
- {
- if ((type_field (node->type) == ASN1_ETYPE_SEQUENCE) ||
- (type_field (node->type) == ASN1_ETYPE_SEQUENCE_OF)
- || (type_field (node->type) == ASN1_ETYPE_SET)
- || (type_field (node->type) == ASN1_ETYPE_SET_OF))
- class2 |= ASN1_CLASS_STRUCTURED;
- class_implicit = class2;
- tag_implicit = strtoul ((char *) p->value, NULL, 10);
- is_tag_implicit = 1;
- }
- }
- }
- p = p->right;
- }
- }
-
- if (is_tag_implicit)
- {
- if (asn1_get_tag_der
- (der + counter, der_len, &class, &len2,
- &tag) != ASN1_SUCCESS)
- return ASN1_DER_ERROR;
-
- DECR_LEN(der_len, len2);
-
- if ((class != class_implicit) || (tag != tag_implicit))
- {
- if (type_field (node->type) == ASN1_ETYPE_OCTET_STRING)
- {
- class_implicit |= ASN1_CLASS_STRUCTURED;
- if ((class != class_implicit) || (tag != tag_implicit))
- return ASN1_TAG_ERROR;
- }
- else
- return ASN1_TAG_ERROR;
- }
- }
- else
- {
- unsigned type = type_field (node->type);
- if (type == ASN1_ETYPE_TAG)
- {
- *tag_len = 0;
- if (inner_tag_len)
- *inner_tag_len = 0;
- return ASN1_SUCCESS;
- }
-
- if (asn1_get_tag_der
- (der + counter, der_len, &class, &len2,
- &tag) != ASN1_SUCCESS)
- return ASN1_DER_ERROR;
-
- DECR_LEN(der_len, len2);
-
- switch (type)
- {
- case ASN1_ETYPE_NULL:
- case ASN1_ETYPE_BOOLEAN:
- case ASN1_ETYPE_INTEGER:
- case ASN1_ETYPE_ENUMERATED:
- case ASN1_ETYPE_OBJECT_ID:
- case ASN1_ETYPE_GENERALSTRING:
- case ASN1_ETYPE_NUMERIC_STRING:
- case ASN1_ETYPE_IA5_STRING:
- case ASN1_ETYPE_TELETEX_STRING:
- case ASN1_ETYPE_PRINTABLE_STRING:
- case ASN1_ETYPE_UNIVERSAL_STRING:
- case ASN1_ETYPE_BMP_STRING:
- case ASN1_ETYPE_UTF8_STRING:
- case ASN1_ETYPE_VISIBLE_STRING:
- case ASN1_ETYPE_BIT_STRING:
- case ASN1_ETYPE_SEQUENCE:
- case ASN1_ETYPE_SEQUENCE_OF:
- case ASN1_ETYPE_SET:
- case ASN1_ETYPE_SET_OF:
- case ASN1_ETYPE_GENERALIZED_TIME:
- case ASN1_ETYPE_UTC_TIME:
- if ((class != _asn1_tags[type].class)
- || (tag != _asn1_tags[type].tag))
- return ASN1_DER_ERROR;
- break;
-
- case ASN1_ETYPE_OCTET_STRING:
- /* OCTET STRING is handled differently to allow
- * BER encodings (structured class). */
- if (((class != ASN1_CLASS_UNIVERSAL)
- && (class != (ASN1_CLASS_UNIVERSAL | ASN1_CLASS_STRUCTURED)))
- || (tag != ASN1_TAG_OCTET_STRING))
- return ASN1_DER_ERROR;
- break;
- case ASN1_ETYPE_ANY:
- counter -= len2;
- break;
- case ASN1_ETYPE_CHOICE:
- counter -= len2;
- break;
- default:
- return ASN1_DER_ERROR;
- break;
- }
- }
-
- counter += len2;
- *tag_len = counter;
- if (inner_tag_len)
- *inner_tag_len = len2;
- return ASN1_SUCCESS;
-
-cleanup:
- return result;
-}
-
-static int
-extract_tag_der_recursive(asn1_node node, const unsigned char *der, int der_len,
- int *ret_len, int *inner_len, unsigned flags)
-{
-asn1_node p;
-int ris = ASN1_DER_ERROR;
-
- if (type_field (node->type) == ASN1_ETYPE_CHOICE)
- {
- p = node->down;
- while (p)
- {
- ris = _asn1_extract_tag_der (p, der, der_len, ret_len, inner_len, flags);
- if (ris == ASN1_SUCCESS)
- break;
- p = p->right;
- }
-
- *ret_len = 0;
- return ris;
- }
- else
- return _asn1_extract_tag_der (node, der, der_len, ret_len, inner_len, flags);
-}
-
-static int
-_asn1_delete_not_used (asn1_node node)
-{
- asn1_node p, p2;
-
- if (node == NULL)
- return ASN1_ELEMENT_NOT_FOUND;
-
- p = node;
- while (p)
- {
- if (p->type & CONST_NOT_USED)
- {
- p2 = NULL;
- if (p != node)
- {
- p2 = _asn1_find_left (p);
- if (!p2)
- p2 = _asn1_find_up (p);
- }
- asn1_delete_structure (&p);
- p = p2;
- }
-
- if (!p)
- break; /* reach node */
-
- if (p->down)
- {
- p = p->down;
- }
- else
- {
- if (p == node)
- p = NULL;
- else if (p->right)
- p = p->right;
- else
- {
- while (1)
- {
- p = _asn1_find_up (p);
- if (p == node)
- {
- p = NULL;
- break;
- }
- if (p->right)
- {
- p = p->right;
- break;
- }
- }
- }
- }
- }
- return ASN1_SUCCESS;
-}
-
-static int
-_asn1_get_indefinite_length_string (const unsigned char *der,
- int der_len, int *len)
-{
- int len2, len3, counter, indefinite;
- int result;
- unsigned long tag;
- unsigned char class;
-
- counter = indefinite = 0;
-
- while (1)
- {
- if (HAVE_TWO(der_len) && (der[counter] == 0) && (der[counter + 1] == 0))
- {
- counter += 2;
- DECR_LEN(der_len, 2);
-
- indefinite--;
- if (indefinite <= 0)
- break;
- else
- continue;
- }
-
- if (asn1_get_tag_der
- (der + counter, der_len, &class, &len2,
- &tag) != ASN1_SUCCESS)
- return ASN1_DER_ERROR;
-
- DECR_LEN(der_len, len2);
- counter += len2;
-
- len2 = asn1_get_length_der (der + counter, der_len, &len3);
- if (len2 < -1)
- return ASN1_DER_ERROR;
-
- if (len2 == -1)
- {
- indefinite++;
- counter += 1;
- DECR_LEN(der_len, 1);
- }
- else
- {
- counter += len2 + len3;
- DECR_LEN(der_len, len2+len3);
- }
- }
-
- *len = counter;
- return ASN1_SUCCESS;
-
-cleanup:
- return result;
-}
-
-static void delete_unneeded_choice_fields(asn1_node p)
-{
- asn1_node p2;
-
- while (p->right)
- {
- p2 = p->right;
- asn1_delete_structure (&p2);
- }
-}
-
-
-/**
- * asn1_der_decoding2
- * @element: pointer to an ASN1 structure.
- * @ider: vector that contains the DER encoding.
- * @max_ider_len: pointer to an integer giving the information about the
- * maximal number of bytes occupied by *@ider. The real size of the DER
- * encoding is returned through this pointer.
- * @flags: flags controlling the behaviour of the function.
- * @errorDescription: null-terminated string contains details when an
- * error occurred.
- *
- * Fill the structure *@element with values of a DER encoding string. The
- * structure must just be created with function asn1_create_element().
- *
- * If %ASN1_DECODE_FLAG_ALLOW_PADDING flag is set then the function will ignore
- * padding after the decoded DER data. Upon a successful return the value of
- * *@max_ider_len will be set to the number of bytes decoded.
- *
- * If %ASN1_DECODE_FLAG_STRICT_DER flag is set then the function will
- * not decode any BER-encoded elements.
- *
- * Returns: %ASN1_SUCCESS if DER encoding OK, %ASN1_ELEMENT_NOT_FOUND
- * if @ELEMENT is %NULL, and %ASN1_TAG_ERROR or
- * %ASN1_DER_ERROR if the der encoding doesn't match the structure
- * name (*@ELEMENT deleted).
- **/
-int
-asn1_der_decoding2 (asn1_node *element, const void *ider, int *max_ider_len,
- unsigned int flags, char *errorDescription)
-{
- asn1_node node, p, p2, p3;
- char temp[128];
- int counter, len2, len3, len4, move, ris, tlen;
- struct node_tail_cache_st tcache = {NULL, NULL};
- unsigned char class;
- unsigned long tag;
- int tag_len;
- int indefinite, result, total_len = *max_ider_len, ider_len = *max_ider_len;
- int inner_tag_len;
- unsigned char *ptmp;
- const unsigned char *ptag;
- const unsigned char *der = ider;
-
- node = *element;
-
- if (errorDescription != NULL)
- errorDescription[0] = 0;
-
- if (node == NULL)
- return ASN1_ELEMENT_NOT_FOUND;
-
- if (node->type & CONST_OPTION)
- {
- result = ASN1_GENERIC_ERROR;
- warn();
- goto cleanup;
- }
-
- counter = 0;
- move = DOWN;
- p = node;
- while (1)
- {
- tag_len = 0;
- inner_tag_len = 0;
- ris = ASN1_SUCCESS;
- if (move != UP)
- {
- if (p->type & CONST_SET)
- {
- p2 = _asn1_find_up (p);
- len2 = p2->tmp_ival;
- if (len2 == -1)
- {
- if (HAVE_TWO(ider_len) && !der[counter] && !der[counter + 1])
- {
- p = p2;
- move = UP;
- counter += 2;
- DECR_LEN(ider_len, 2);
- continue;
- }
- }
- else if (counter == len2)
- {
- p = p2;
- move = UP;
- continue;
- }
- else if (counter > len2)
- {
- result = ASN1_DER_ERROR;
- warn();
- goto cleanup;
- }
- p2 = p2->down;
- while (p2)
- {
- if ((p2->type & CONST_SET) && (p2->type & CONST_NOT_USED))
- {
- ris =
- extract_tag_der_recursive (p2, der + counter,
- ider_len, &len2, NULL, flags);
- if (ris == ASN1_SUCCESS)
- {
- p2->type &= ~CONST_NOT_USED;
- p = p2;
- break;
- }
- }
- p2 = p2->right;
- }
- if (p2 == NULL)
- {
- result = ASN1_DER_ERROR;
- warn();
- goto cleanup;
- }
- }
-
- /* the position in the DER structure this starts */
- p->start = counter;
- p->end = total_len - 1;
-
- if ((p->type & CONST_OPTION) || (p->type & CONST_DEFAULT))
- {
- p2 = _asn1_find_up (p);
- len2 = p2->tmp_ival;
- if (counter == len2)
- {
- if (p->right)
- {
- p2 = p->right;
- move = RIGHT;
- }
- else
- move = UP;
-
- if (p->type & CONST_OPTION)
- asn1_delete_structure (&p);
-
- p = p2;
- continue;
- }
- }
-
- if (type_field (p->type) == ASN1_ETYPE_CHOICE)
- {
- while (p->down)
- {
- ris =
- extract_tag_der_recursive (p->down, der + counter,
- ider_len, &len2, NULL, flags);
-
- if (ris == ASN1_SUCCESS)
- {
- delete_unneeded_choice_fields(p->down);
- break;
- }
- else if (ris == ASN1_ERROR_TYPE_ANY)
- {
- result = ASN1_ERROR_TYPE_ANY;
- warn();
- goto cleanup;
- }
- else
- {
- p2 = p->down;
- asn1_delete_structure (&p2);
- }
- }
-
- if (p->down == NULL)
- {
- if (!(p->type & CONST_OPTION))
- {
- result = ASN1_DER_ERROR;
- warn();
- goto cleanup;
- }
- }
- else if (type_field (p->type) != ASN1_ETYPE_CHOICE)
- p = p->down;
-
- p->start = counter;
- }
-
- if ((p->type & CONST_OPTION) || (p->type & CONST_DEFAULT))
- {
- p2 = _asn1_find_up (p);
- len2 = p2->tmp_ival;
-
- if ((len2 != -1) && (counter > len2))
- ris = ASN1_TAG_ERROR;
- }
-
- if (ris == ASN1_SUCCESS)
- ris =
- extract_tag_der_recursive (p, der + counter, ider_len,
- &tag_len, &inner_tag_len, flags);
-
- if (ris != ASN1_SUCCESS)
- {
- if (p->type & CONST_OPTION)
- {
- p->type |= CONST_NOT_USED;
- move = RIGHT;
- }
- else if (p->type & CONST_DEFAULT)
- {
- _asn1_set_value (p, NULL, 0);
- move = RIGHT;
- }
- else
- {
- if (errorDescription != NULL)
- _asn1_error_description_tag_error (p, errorDescription);
-
- result = ASN1_TAG_ERROR;
- warn();
- goto cleanup;
- }
- }
- else
- {
- DECR_LEN(ider_len, tag_len);
- counter += tag_len;
- }
- }
-
- if (ris == ASN1_SUCCESS)
- {
- switch (type_field (p->type))
- {
- case ASN1_ETYPE_NULL:
- DECR_LEN(ider_len, 1);
- if (der[counter])
- {
- result = ASN1_DER_ERROR;
- warn();
- goto cleanup;
- }
- counter++;
- move = RIGHT;
- break;
- case ASN1_ETYPE_BOOLEAN:
- DECR_LEN(ider_len, 2);
-
- if (der[counter++] != 1)
- {
- result = ASN1_DER_ERROR;
- warn();
- goto cleanup;
- }
- if (der[counter++] == 0)
- _asn1_set_value (p, "F", 1);
- else
- _asn1_set_value (p, "T", 1);
- move = RIGHT;
- break;
- case ASN1_ETYPE_INTEGER:
- case ASN1_ETYPE_ENUMERATED:
- len2 =
- asn1_get_length_der (der + counter, ider_len, &len3);
- if (len2 < 0)
- {
- result = ASN1_DER_ERROR;
- warn();
- goto cleanup;
- }
-
- DECR_LEN(ider_len, len3+len2);
-
- _asn1_set_value (p, der + counter, len3 + len2);
- counter += len3 + len2;
- move = RIGHT;
- break;
- case ASN1_ETYPE_OBJECT_ID:
- result =
- asn1_get_object_id_der (der + counter, ider_len, &len2,
- temp, sizeof (temp));
- if (result != ASN1_SUCCESS)
- {
- warn();
- goto cleanup;
- }
-
- DECR_LEN(ider_len, len2);
-
- tlen = strlen (temp);
- if (tlen > 0)
- _asn1_set_value (p, temp, tlen + 1);
-
- counter += len2;
- move = RIGHT;
- break;
- case ASN1_ETYPE_GENERALIZED_TIME:
- case ASN1_ETYPE_UTC_TIME:
- result =
- _asn1_get_time_der (type_field (p->type), der + counter, ider_len, &len2, temp,
- sizeof (temp) - 1, flags);
- if (result != ASN1_SUCCESS)
- {
- warn();
- goto cleanup;
- }
-
- DECR_LEN(ider_len, len2);
-
- tlen = strlen (temp);
- if (tlen > 0)
- _asn1_set_value (p, temp, tlen);
-
- counter += len2;
- move = RIGHT;
- break;
- case ASN1_ETYPE_OCTET_STRING:
- if (counter < inner_tag_len)
- {
- result = ASN1_DER_ERROR;
- warn();
- goto cleanup;
- }
-
- ptag = der + counter - inner_tag_len;
- if (flags & ASN1_DECODE_FLAG_STRICT_DER || !(ptag[0] & ASN1_CLASS_STRUCTURED))
- {
- len2 =
- asn1_get_length_der (der + counter, ider_len, &len3);
- if (len2 < 0)
- {
- result = ASN1_DER_ERROR;
- warn();
- goto cleanup;
- }
-
- DECR_LEN(ider_len, len3+len2);
-
- _asn1_set_value (p, der + counter, len3 + len2);
- counter += len3 + len2;
- }
- else
- {
- unsigned dflags = 0, vlen, ber_len;
-
- if (ptag[0] & ASN1_CLASS_STRUCTURED)
- dflags |= DECODE_FLAG_INDEFINITE;
-
- result = _asn1_decode_simple_ber(type_field (p->type), der+counter, ider_len, &ptmp, &vlen, &ber_len, dflags);
- if (result != ASN1_SUCCESS)
- {
- warn();
- goto cleanup;
- }
-
- DECR_LEN(ider_len, ber_len);
-
- _asn1_set_value_lv (p, ptmp, vlen);
-
- counter += ber_len;
- free(ptmp);
- }
- move = RIGHT;
- break;
- case ASN1_ETYPE_GENERALSTRING:
- case ASN1_ETYPE_NUMERIC_STRING:
- case ASN1_ETYPE_IA5_STRING:
- case ASN1_ETYPE_TELETEX_STRING:
- case ASN1_ETYPE_PRINTABLE_STRING:
- case ASN1_ETYPE_UNIVERSAL_STRING:
- case ASN1_ETYPE_BMP_STRING:
- case ASN1_ETYPE_UTF8_STRING:
- case ASN1_ETYPE_VISIBLE_STRING:
- case ASN1_ETYPE_BIT_STRING:
- len2 =
- asn1_get_length_der (der + counter, ider_len, &len3);
- if (len2 < 0)
- {
- result = ASN1_DER_ERROR;
- warn();
- goto cleanup;
- }
-
- DECR_LEN(ider_len, len3+len2);
-
- _asn1_set_value (p, der + counter, len3 + len2);
- counter += len3 + len2;
- move = RIGHT;
- break;
- case ASN1_ETYPE_SEQUENCE:
- case ASN1_ETYPE_SET:
- if (move == UP)
- {
- len2 = p->tmp_ival;
- p->tmp_ival = 0;
- if (len2 == -1)
- { /* indefinite length method */
- DECR_LEN(ider_len, 2);
- if ((der[counter]) || der[counter + 1])
- {
- result = ASN1_DER_ERROR;
- warn();
- goto cleanup;
- }
- counter += 2;
- }
- else
- { /* definite length method */
- if (len2 != counter)
- {
- result = ASN1_DER_ERROR;
- warn();
- goto cleanup;
- }
- }
- move = RIGHT;
- }
- else
- { /* move==DOWN || move==RIGHT */
- len3 =
- asn1_get_length_der (der + counter, ider_len, &len2);
- if (IS_ERR(len3, flags))
- {
- result = ASN1_DER_ERROR;
- warn();
- goto cleanup;
- }
-
- DECR_LEN(ider_len, len2);
- counter += len2;
-
- if (len3 > 0)
- {
- p->tmp_ival = counter + len3;
- move = DOWN;
- }
- else if (len3 == 0)
- {
- p2 = p->down;
- while (p2)
- {
- if (type_field (p2->type) != ASN1_ETYPE_TAG)
- {
- p3 = p2->right;
- asn1_delete_structure (&p2);
- p2 = p3;
- }
- else
- p2 = p2->right;
- }
- move = RIGHT;
- }
- else
- { /* indefinite length method */
- p->tmp_ival = -1;
- move = DOWN;
- }
- }
- break;
- case ASN1_ETYPE_SEQUENCE_OF:
- case ASN1_ETYPE_SET_OF:
- if (move == UP)
- {
- len2 = p->tmp_ival;
- if (len2 == -1)
- { /* indefinite length method */
- if (!HAVE_TWO(ider_len) || ((der[counter]) || der[counter + 1]))
- {
- result = _asn1_append_sequence_set (p, &tcache);
- if (result != 0)
- {
- warn();
- goto cleanup;
- }
- p = tcache.tail;
- move = RIGHT;
- continue;
- }
-
- p->tmp_ival = 0;
- tcache.tail = NULL; /* finished decoding this structure */
- tcache.head = NULL;
- DECR_LEN(ider_len, 2);
- counter += 2;
- }
- else
- { /* definite length method */
- if (len2 > counter)
- {
- result = _asn1_append_sequence_set (p, &tcache);
- if (result != 0)
- {
- warn();
- goto cleanup;
- }
- p = tcache.tail;
- move = RIGHT;
- continue;
- }
-
- p->tmp_ival = 0;
- tcache.tail = NULL; /* finished decoding this structure */
- tcache.head = NULL;
-
- if (len2 != counter)
- {
- result = ASN1_DER_ERROR;
- warn();
- goto cleanup;
- }
- }
- }
- else
- { /* move==DOWN || move==RIGHT */
- len3 =
- asn1_get_length_der (der + counter, ider_len, &len2);
- if (IS_ERR(len3, flags))
- {
- result = ASN1_DER_ERROR;
- warn();
- goto cleanup;
- }
-
- DECR_LEN(ider_len, len2);
- counter += len2;
- if (len3)
- {
- if (len3 > 0)
- { /* definite length method */
- p->tmp_ival = counter + len3;
- }
- else
- { /* indefinite length method */
- p->tmp_ival = -1;
- }
-
- p2 = p->down;
- if (p2 == NULL)
- {
- result = ASN1_DER_ERROR;
- warn();
- goto cleanup;
- }
-
- while ((type_field (p2->type) == ASN1_ETYPE_TAG)
- || (type_field (p2->type) == ASN1_ETYPE_SIZE))
- p2 = p2->right;
- if (p2->right == NULL)
- {
- result = _asn1_append_sequence_set (p, &tcache);
- if (result != 0)
- {
- warn();
- goto cleanup;
- }
- }
- p = p2;
- }
- }
- move = RIGHT;
- break;
- case ASN1_ETYPE_ANY:
- /* Check indefinite lenth method in an EXPLICIT TAG */
-
- if (!(flags & ASN1_DECODE_FLAG_STRICT_DER) && (p->type & CONST_TAG) &&
- tag_len == 2 && (der[counter - 1] == 0x80))
- indefinite = 1;
- else
- indefinite = 0;
-
- if (asn1_get_tag_der
- (der + counter, ider_len, &class, &len2,
- &tag) != ASN1_SUCCESS)
- {
- result = ASN1_DER_ERROR;
- warn();
- goto cleanup;
- }
-
- DECR_LEN(ider_len, len2);
-
- len4 =
- asn1_get_length_der (der + counter + len2,
- ider_len, &len3);
- if (IS_ERR(len4, flags))
- {
- result = ASN1_DER_ERROR;
- warn();
- goto cleanup;
- }
- if (len4 != -1) /* definite */
- {
- len2 += len4;
-
- DECR_LEN(ider_len, len4+len3);
- _asn1_set_value_lv (p, der + counter, len2 + len3);
- counter += len2 + len3;
- }
- else /* == -1 */
- { /* indefinite length */
- ider_len += len2; /* undo DECR_LEN */
-
- if (counter == 0)
- {
- result = ASN1_DER_ERROR;
- warn();
- goto cleanup;
- }
-
- result =
- _asn1_get_indefinite_length_string (der + counter, ider_len, &len2);
- if (result != ASN1_SUCCESS)
- {
- warn();
- goto cleanup;
- }
-
- DECR_LEN(ider_len, len2);
- _asn1_set_value_lv (p, der + counter, len2);
- counter += len2;
-
- }
-
- /* Check if a couple of 0x00 are present due to an EXPLICIT TAG with
- an indefinite length method. */
- if (indefinite)
- {
- DECR_LEN(ider_len, 2);
- if (!der[counter] && !der[counter + 1])
- {
- counter += 2;
- }
- else
- {
- result = ASN1_DER_ERROR;
- warn();
- goto cleanup;
- }
- }
-
- move = RIGHT;
- break;
- default:
- move = (move == UP) ? RIGHT : DOWN;
- break;
- }
- }
-
- if (p)
- {
- p->end = counter - 1;
- }
-
- if (p == node && move != DOWN)
- break;
-
- if (move == DOWN)
- {
- if (p->down)
- p = p->down;
- else
- move = RIGHT;
- }
- if ((move == RIGHT) && !(p->type & CONST_SET))
- {
- if (p->right)
- p = p->right;
- else
- move = UP;
- }
- if (move == UP)
- p = _asn1_find_up (p);
- }
-
- _asn1_delete_not_used (*element);
-
- if ((ider_len < 0) ||
- (!(flags & ASN1_DECODE_FLAG_ALLOW_PADDING) && (ider_len != 0)))
- {
- warn();
- result = ASN1_DER_ERROR;
- goto cleanup;
- }
-
- *max_ider_len = total_len - ider_len;
-
- return ASN1_SUCCESS;
-
-cleanup:
- asn1_delete_structure (element);
- return result;
-}
-
-
-/**
- * asn1_der_decoding:
- * @element: pointer to an ASN1 structure.
- * @ider: vector that contains the DER encoding.
- * @ider_len: number of bytes of *@ider: @ider[0]..@ider[len-1].
- * @errorDescription: null-terminated string contains details when an
- * error occurred.
- *
- * Fill the structure *@element with values of a DER encoding
- * string. The structure must just be created with function
- * asn1_create_element().
- *
- * Note that the *@element variable is provided as a pointer for
- * historical reasons.
- *
- * Returns: %ASN1_SUCCESS if DER encoding OK, %ASN1_ELEMENT_NOT_FOUND
- * if @ELEMENT is %NULL, and %ASN1_TAG_ERROR or
- * %ASN1_DER_ERROR if the der encoding doesn't match the structure
- * name (*@ELEMENT deleted).
- **/
-int
-asn1_der_decoding (asn1_node * element, const void *ider, int ider_len,
- char *errorDescription)
-{
- return asn1_der_decoding2 (element, ider, &ider_len, 0, errorDescription);
-}
-
-/**
- * asn1_der_decoding_element:
- * @structure: pointer to an ASN1 structure
- * @elementName: name of the element to fill
- * @ider: vector that contains the DER encoding of the whole structure.
- * @len: number of bytes of *der: der[0]..der[len-1]
- * @errorDescription: null-terminated string contains details when an
- * error occurred.
- *
- * Fill the element named @ELEMENTNAME with values of a DER encoding
- * string. The structure must just be created with function
- * asn1_create_element(). The DER vector must contain the encoding
- * string of the whole @STRUCTURE. If an error occurs during the
- * decoding procedure, the *@STRUCTURE is deleted and set equal to
- * %NULL.
- *
- * This function is deprecated and may just be an alias to asn1_der_decoding
- * in future versions. Use asn1_der_decoding() instead.
- *
- * Returns: %ASN1_SUCCESS if DER encoding OK, %ASN1_ELEMENT_NOT_FOUND
- * if ELEMENT is %NULL or @elementName == NULL, and
- * %ASN1_TAG_ERROR or %ASN1_DER_ERROR if the der encoding doesn't
- * match the structure @structure (*ELEMENT deleted).
- **/
-int
-asn1_der_decoding_element (asn1_node * structure, const char *elementName,
- const void *ider, int len, char *errorDescription)
-{
- return asn1_der_decoding(structure, ider, len, errorDescription);
-}
-
-/**
- * asn1_der_decoding_startEnd:
- * @element: pointer to an ASN1 element
- * @ider: vector that contains the DER encoding.
- * @ider_len: number of bytes of *@ider: @ider[0]..@ider[len-1]
- * @name_element: an element of NAME structure.
- * @start: the position of the first byte of NAME_ELEMENT decoding
- * (@ider[*start])
- * @end: the position of the last byte of NAME_ELEMENT decoding
- * (@ider[*end])
- *
- * Find the start and end point of an element in a DER encoding
- * string. I mean that if you have a der encoding and you have already
- * used the function asn1_der_decoding() to fill a structure, it may
- * happen that you want to find the piece of string concerning an
- * element of the structure.
- *
- * One example is the sequence "tbsCertificate" inside an X509
- * certificate.
- *
- * Note that since libtasn1 3.7 the @ider and @ider_len parameters
- * can be omitted, if the element is already decoded using asn1_der_decoding().
- *
- * Returns: %ASN1_SUCCESS if DER encoding OK, %ASN1_ELEMENT_NOT_FOUND
- * if ELEMENT is %asn1_node EMPTY or @name_element is not a valid
- * element, %ASN1_TAG_ERROR or %ASN1_DER_ERROR if the der encoding
- * doesn't match the structure ELEMENT.
- **/
-int
-asn1_der_decoding_startEnd (asn1_node element, const void *ider, int ider_len,
- const char *name_element, int *start, int *end)
-{
- asn1_node node, node_to_find;
- int result = ASN1_DER_ERROR;
-
- node = element;
-
- if (node == NULL)
- return ASN1_ELEMENT_NOT_FOUND;
-
- node_to_find = asn1_find_node (node, name_element);
-
- if (node_to_find == NULL)
- return ASN1_ELEMENT_NOT_FOUND;
-
- *start = node_to_find->start;
- *end = node_to_find->end;
-
- if (*start == 0 && *end == 0)
- {
- if (ider == NULL || ider_len == 0)
- return ASN1_GENERIC_ERROR;
-
- /* it seems asn1_der_decoding() wasn't called before. Do it now */
- result = asn1_der_decoding (&node, ider, ider_len, NULL);
- if (result != ASN1_SUCCESS)
- {
- warn();
- return result;
- }
-
- node_to_find = asn1_find_node (node, name_element);
- if (node_to_find == NULL)
- return ASN1_ELEMENT_NOT_FOUND;
-
- *start = node_to_find->start;
- *end = node_to_find->end;
- }
-
- if (*end < *start)
- return ASN1_GENERIC_ERROR;
-
- return ASN1_SUCCESS;
-}
-
-/**
- * asn1_expand_any_defined_by:
- * @definitions: ASN1 definitions
- * @element: pointer to an ASN1 structure
- *
- * Expands every "ANY DEFINED BY" element of a structure created from
- * a DER decoding process (asn1_der_decoding function). The element
- * ANY must be defined by an OBJECT IDENTIFIER. The type used to
- * expand the element ANY is the first one following the definition of
- * the actual value of the OBJECT IDENTIFIER.
- *
- * Returns: %ASN1_SUCCESS if Substitution OK, %ASN1_ERROR_TYPE_ANY if
- * some "ANY DEFINED BY" element couldn't be expanded due to a
- * problem in OBJECT_ID -> TYPE association, or other error codes
- * depending on DER decoding.
- **/
-int
-asn1_expand_any_defined_by (asn1_node definitions, asn1_node * element)
-{
- char name[2 * ASN1_MAX_NAME_SIZE + 1],
- value[ASN1_MAX_NAME_SIZE];
- int retCode = ASN1_SUCCESS, result;
- int len, len2, len3;
- asn1_node p, p2, p3, aux = NULL;
- char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE];
- const char *definitionsName;
-
- if ((definitions == NULL) || (*element == NULL))
- return ASN1_ELEMENT_NOT_FOUND;
-
- definitionsName = definitions->name;
-
- p = *element;
- while (p)
- {
-
- switch (type_field (p->type))
- {
- case ASN1_ETYPE_ANY:
- if ((p->type & CONST_DEFINED_BY) && (p->value))
- {
- /* search the "DEF_BY" element */
- p2 = p->down;
- while ((p2) && (type_field (p2->type) != ASN1_ETYPE_CONSTANT))
- p2 = p2->right;
-
- if (!p2)
- {
- retCode = ASN1_ERROR_TYPE_ANY;
- break;
- }
-
- p3 = _asn1_find_up (p);
-
- if (!p3)
- {
- retCode = ASN1_ERROR_TYPE_ANY;
- break;
- }
-
- p3 = p3->down;
- while (p3)
- {
- if (!(strcmp (p3->name, p2->name)))
- break;
- p3 = p3->right;
- }
-
- if ((!p3) || (type_field (p3->type) != ASN1_ETYPE_OBJECT_ID) ||
- (p3->value == NULL))
- {
-
- p3 = _asn1_find_up (p);
- p3 = _asn1_find_up (p3);
-
- if (!p3)
- {
- retCode = ASN1_ERROR_TYPE_ANY;
- break;
- }
-
- p3 = p3->down;
-
- while (p3)
- {
- if (!(strcmp (p3->name, p2->name)))
- break;
- p3 = p3->right;
- }
-
- if ((!p3) || (type_field (p3->type) != ASN1_ETYPE_OBJECT_ID)
- || (p3->value == NULL))
- {
- retCode = ASN1_ERROR_TYPE_ANY;
- break;
- }
- }
-
- /* search the OBJECT_ID into definitions */
- p2 = definitions->down;
- while (p2)
- {
- if ((type_field (p2->type) == ASN1_ETYPE_OBJECT_ID) &&
- (p2->type & CONST_ASSIGN))
- {
- snprintf(name, sizeof(name), "%s.%s", definitionsName, p2->name);
-
- len = ASN1_MAX_NAME_SIZE;
- result =
- asn1_read_value (definitions, name, value, &len);
-
- if ((result == ASN1_SUCCESS)
- && (!_asn1_strcmp (p3->value, value)))
- {
- p2 = p2->right; /* pointer to the structure to
- use for expansion */
- while ((p2) && (p2->type & CONST_ASSIGN))
- p2 = p2->right;
-
- if (p2)
- {
- snprintf(name, sizeof(name), "%s.%s", definitionsName, p2->name);
-
- result =
- asn1_create_element (definitions, name, &aux);
- if (result == ASN1_SUCCESS)
- {
- _asn1_cpy_name (aux, p);
- len2 =
- asn1_get_length_der (p->value,
- p->value_len, &len3);
- if (len2 < 0)
- return ASN1_DER_ERROR;
-
- result =
- asn1_der_decoding (&aux, p->value + len3,
- len2,
- errorDescription);
- if (result == ASN1_SUCCESS)
- {
-
- _asn1_set_right (aux, p->right);
- _asn1_set_right (p, aux);
-
- result = asn1_delete_structure (&p);
- if (result == ASN1_SUCCESS)
- {
- p = aux;
- aux = NULL;
- break;
- }
- else
- { /* error with asn1_delete_structure */
- asn1_delete_structure (&aux);
- retCode = result;
- break;
- }
- }
- else
- { /* error with asn1_der_decoding */
- retCode = result;
- break;
- }
- }
- else
- { /* error with asn1_create_element */
- retCode = result;
- break;
- }
- }
- else
- { /* error with the pointer to the structure to exapand */
- retCode = ASN1_ERROR_TYPE_ANY;
- break;
- }
- }
- }
- p2 = p2->right;
- } /* end while */
-
- if (!p2)
- {
- retCode = ASN1_ERROR_TYPE_ANY;
- break;
- }
-
- }
- break;
- default:
- break;
- }
-
-
- if (p->down)
- {
- p = p->down;
- }
- else if (p == *element)
- {
- p = NULL;
- break;
- }
- else if (p->right)
- p = p->right;
- else
- {
- while (1)
- {
- p = _asn1_find_up (p);
- if (p == *element)
- {
- p = NULL;
- break;
- }
- if (p->right)
- {
- p = p->right;
- break;
- }
- }
- }
- }
-
- return retCode;
-}
-
-/**
- * asn1_expand_octet_string:
- * @definitions: ASN1 definitions
- * @element: pointer to an ASN1 structure
- * @octetName: name of the OCTECT STRING field to expand.
- * @objectName: name of the OBJECT IDENTIFIER field to use to define
- * the type for expansion.
- *
- * Expands an "OCTET STRING" element of a structure created from a DER
- * decoding process (the asn1_der_decoding() function). The type used
- * for expansion is the first one following the definition of the
- * actual value of the OBJECT IDENTIFIER indicated by OBJECTNAME.
- *
- * Returns: %ASN1_SUCCESS if substitution OK, %ASN1_ELEMENT_NOT_FOUND
- * if @objectName or @octetName are not correct,
- * %ASN1_VALUE_NOT_VALID if it wasn't possible to find the type to
- * use for expansion, or other errors depending on DER decoding.
- **/
-int
-asn1_expand_octet_string (asn1_node definitions, asn1_node * element,
- const char *octetName, const char *objectName)
-{
- char name[2 * ASN1_MAX_NAME_SIZE + 1], value[ASN1_MAX_NAME_SIZE];
- int retCode = ASN1_SUCCESS, result;
- int len, len2, len3;
- asn1_node p2, aux = NULL;
- asn1_node octetNode = NULL, objectNode = NULL;
- char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE];
-
- if ((definitions == NULL) || (*element == NULL))
- return ASN1_ELEMENT_NOT_FOUND;
-
- octetNode = asn1_find_node (*element, octetName);
- if (octetNode == NULL)
- return ASN1_ELEMENT_NOT_FOUND;
- if (type_field (octetNode->type) != ASN1_ETYPE_OCTET_STRING)
- return ASN1_ELEMENT_NOT_FOUND;
- if (octetNode->value == NULL)
- return ASN1_VALUE_NOT_FOUND;
-
- objectNode = asn1_find_node (*element, objectName);
- if (objectNode == NULL)
- return ASN1_ELEMENT_NOT_FOUND;
-
- if (type_field (objectNode->type) != ASN1_ETYPE_OBJECT_ID)
- return ASN1_ELEMENT_NOT_FOUND;
-
- if (objectNode->value == NULL)
- return ASN1_VALUE_NOT_FOUND;
-
-
- /* search the OBJECT_ID into definitions */
- p2 = definitions->down;
- while (p2)
- {
- if ((type_field (p2->type) == ASN1_ETYPE_OBJECT_ID) &&
- (p2->type & CONST_ASSIGN))
- {
- strcpy (name, definitions->name);
- strcat (name, ".");
- strcat (name, p2->name);
-
- len = sizeof (value);
- result = asn1_read_value (definitions, name, value, &len);
-
- if ((result == ASN1_SUCCESS)
- && (!_asn1_strcmp (objectNode->value, value)))
- {
-
- p2 = p2->right; /* pointer to the structure to
- use for expansion */
- while ((p2) && (p2->type & CONST_ASSIGN))
- p2 = p2->right;
-
- if (p2)
- {
- strcpy (name, definitions->name);
- strcat (name, ".");
- strcat (name, p2->name);
-
- result = asn1_create_element (definitions, name, &aux);
- if (result == ASN1_SUCCESS)
- {
- _asn1_cpy_name (aux, octetNode);
- len2 =
- asn1_get_length_der (octetNode->value,
- octetNode->value_len, &len3);
- if (len2 < 0)
- return ASN1_DER_ERROR;
-
- result =
- asn1_der_decoding (&aux, octetNode->value + len3,
- len2, errorDescription);
- if (result == ASN1_SUCCESS)
- {
-
- _asn1_set_right (aux, octetNode->right);
- _asn1_set_right (octetNode, aux);
-
- result = asn1_delete_structure (&octetNode);
- if (result == ASN1_SUCCESS)
- {
- aux = NULL;
- break;
- }
- else
- { /* error with asn1_delete_structure */
- asn1_delete_structure (&aux);
- retCode = result;
- break;
- }
- }
- else
- { /* error with asn1_der_decoding */
- retCode = result;
- break;
- }
- }
- else
- { /* error with asn1_create_element */
- retCode = result;
- break;
- }
- }
- else
- { /* error with the pointer to the structure to exapand */
- retCode = ASN1_VALUE_NOT_VALID;
- break;
- }
- }
- }
-
- p2 = p2->right;
-
- }
-
- if (!p2)
- retCode = ASN1_VALUE_NOT_VALID;
-
- return retCode;
-}
-
-/*-
- * _asn1_decode_simple_der:
- * @etype: The type of the string to be encoded (ASN1_ETYPE_)
- * @der: the encoded string
- * @_der_len: the bytes of the encoded string
- * @str: a pointer to the data
- * @str_len: the length of the data
- * @dflags: DECODE_FLAG_*
- *
- * Decodes a simple DER encoded type (e.g. a string, which is not constructed).
- * The output is a pointer inside the @der.
- *
- * Returns: %ASN1_SUCCESS if successful or an error value.
- -*/
-static int
-_asn1_decode_simple_der (unsigned int etype, const unsigned char *der,
- unsigned int _der_len, const unsigned char **str,
- unsigned int *str_len, unsigned dflags)
-{
- int tag_len, len_len;
- const unsigned char *p;
- int der_len = _der_len;
- unsigned char class;
- unsigned long tag;
- long ret;
-
- if (der == NULL || der_len == 0)
- return ASN1_VALUE_NOT_VALID;
-
- if (ETYPE_OK (etype) == 0 || ETYPE_IS_STRING(etype) == 0)
- return ASN1_VALUE_NOT_VALID;
-
- /* doesn't handle constructed classes */
- class = ETYPE_CLASS(etype);
- if (class != ASN1_CLASS_UNIVERSAL)
- return ASN1_VALUE_NOT_VALID;
-
- p = der;
-
- if (dflags & DECODE_FLAG_HAVE_TAG)
- {
- ret = asn1_get_tag_der (p, der_len, &class, &tag_len, &tag);
- if (ret != ASN1_SUCCESS)
- return ret;
-
- if (class != ETYPE_CLASS (etype) || tag != ETYPE_TAG (etype))
- {
- warn();
- return ASN1_DER_ERROR;
- }
-
- p += tag_len;
- der_len -= tag_len;
- if (der_len <= 0)
- return ASN1_DER_ERROR;
- }
-
- ret = asn1_get_length_der (p, der_len, &len_len);
- if (ret < 0)
- return ASN1_DER_ERROR;
-
- p += len_len;
- der_len -= len_len;
- if (der_len <= 0)
- return ASN1_DER_ERROR;
-
- *str_len = ret;
- *str = p;
-
- return ASN1_SUCCESS;
-}
-
-/**
- * asn1_decode_simple_der:
- * @etype: The type of the string to be encoded (ASN1_ETYPE_)
- * @der: the encoded string
- * @_der_len: the bytes of the encoded string
- * @str: a pointer to the data
- * @str_len: the length of the data
- *
- * Decodes a simple DER encoded type (e.g. a string, which is not constructed).
- * The output is a pointer inside the @der.
- *
- * Returns: %ASN1_SUCCESS if successful or an error value.
- **/
-int
-asn1_decode_simple_der (unsigned int etype, const unsigned char *der,
- unsigned int _der_len, const unsigned char **str,
- unsigned int *str_len)
-{
- return _asn1_decode_simple_der(etype, der, _der_len, str, str_len, DECODE_FLAG_HAVE_TAG);
-}
-
-static int append(uint8_t **dst, unsigned *dst_size, const unsigned char *src, unsigned src_size)
-{
- *dst = _asn1_realloc(*dst, *dst_size+src_size);
- if (*dst == NULL)
- return ASN1_MEM_ERROR;
- memcpy(*dst + *dst_size, src, src_size);
- *dst_size += src_size;
- return ASN1_SUCCESS;
-}
-
-/*-
- * _asn1_decode_simple_ber:
- * @etype: The type of the string to be encoded (ASN1_ETYPE_)
- * @der: the encoded string
- * @_der_len: the bytes of the encoded string
- * @str: a pointer to the data
- * @str_len: the length of the data
- * @ber_len: the total length occupied by BER (may be %NULL)
- * @have_tag: whether a DER tag is included
- *
- * Decodes a BER encoded type. The output is an allocated value
- * of the data. This decodes BER STRINGS only. Other types are
- * decoded as DER.
- *
- * Returns: %ASN1_SUCCESS if successful or an error value.
- -*/
-static int
-_asn1_decode_simple_ber (unsigned int etype, const unsigned char *der,
- unsigned int _der_len, unsigned char **str,
- unsigned int *str_len, unsigned int *ber_len,
- unsigned dflags)
-{
- int tag_len, len_len;
- const unsigned char *p;
- int der_len = _der_len;
- uint8_t *total = NULL;
- unsigned total_size = 0;
- unsigned char class;
- unsigned long tag;
- unsigned char *out = NULL;
- const unsigned char *cout = NULL;
- unsigned out_len;
- long result;
-
- if (ber_len) *ber_len = 0;
-
- if (der == NULL || der_len == 0)
- {
- warn();
- return ASN1_VALUE_NOT_VALID;
- }
-
- if (ETYPE_OK (etype) == 0)
- {
- warn();
- return ASN1_VALUE_NOT_VALID;
- }
-
- /* doesn't handle constructed + definite classes */
- class = ETYPE_CLASS (etype);
- if (class != ASN1_CLASS_UNIVERSAL)
- {
- warn();
- return ASN1_VALUE_NOT_VALID;
- }
-
- p = der;
-
- if (dflags & DECODE_FLAG_HAVE_TAG)
- {
- result = asn1_get_tag_der (p, der_len, &class, &tag_len, &tag);
- if (result != ASN1_SUCCESS)
- {
- warn();
- return result;
- }
-
- if (tag != ETYPE_TAG (etype))
- {
- warn();
- return ASN1_DER_ERROR;
- }
-
- p += tag_len;
-
- DECR_LEN(der_len, tag_len);
-
- if (ber_len) *ber_len += tag_len;
- }
-
- /* indefinite constructed */
- if ((((dflags & DECODE_FLAG_INDEFINITE) || class == ASN1_CLASS_STRUCTURED) && ETYPE_IS_STRING(etype)) &&
- !(dflags & DECODE_FLAG_LEVEL3))
- {
- len_len = 1;
-
- DECR_LEN(der_len, len_len);
- if (p[0] != 0x80)
- {
- warn();
- result = ASN1_DER_ERROR;
- goto cleanup;
- }
-
- p += len_len;
-
- if (ber_len) *ber_len += len_len;
-
- /* decode the available octet strings */
- do
- {
- unsigned tmp_len;
- unsigned flags = DECODE_FLAG_HAVE_TAG;
-
- if (dflags & DECODE_FLAG_LEVEL1)
- flags |= DECODE_FLAG_LEVEL2;
- else if (dflags & DECODE_FLAG_LEVEL2)
- flags |= DECODE_FLAG_LEVEL3;
- else
- flags |= DECODE_FLAG_LEVEL1;
-
- result = _asn1_decode_simple_ber(etype, p, der_len, &out, &out_len, &tmp_len,
- flags);
- if (result != ASN1_SUCCESS)
- {
- warn();
- goto cleanup;
- }
-
- p += tmp_len;
- DECR_LEN(der_len, tmp_len);
-
- if (ber_len) *ber_len += tmp_len;
-
- DECR_LEN(der_len, 2); /* we need the EOC */
-
- if (out_len > 0)
- {
- result = append(&total, &total_size, out, out_len);
- if (result != ASN1_SUCCESS)
- {
- warn();
- goto cleanup;
- }
- }
-
- free(out);
- out = NULL;
-
- if (p[0] == 0 && p[1] == 0) /* EOC */
- {
- if (ber_len) *ber_len += 2;
- break;
- }
-
- /* no EOC */
- der_len += 2;
-
- if (der_len == 2)
- {
- warn();
- result = ASN1_DER_ERROR;
- goto cleanup;
- }
- }
- while(1);
- }
- else if (class == ETYPE_CLASS(etype))
- {
- if (ber_len)
- {
- result = asn1_get_length_der (p, der_len, &len_len);
- if (result < 0)
- {
- warn();
- result = ASN1_DER_ERROR;
- goto cleanup;
- }
- *ber_len += result + len_len;
- }
-
- /* non-string values are decoded as DER */
- result = _asn1_decode_simple_der(etype, der, _der_len, &cout, &out_len, dflags);
- if (result != ASN1_SUCCESS)
- {
- warn();
- goto cleanup;
- }
-
- result = append(&total, &total_size, cout, out_len);
- if (result != ASN1_SUCCESS)
- {
- warn();
- goto cleanup;
- }
- }
- else
- {
- warn();
- result = ASN1_DER_ERROR;
- goto cleanup;
- }
-
- *str = total;
- *str_len = total_size;
-
- return ASN1_SUCCESS;
-cleanup:
- free(out);
- free(total);
- return result;
-}
-
-/**
- * asn1_decode_simple_ber:
- * @etype: The type of the string to be encoded (ASN1_ETYPE_)
- * @der: the encoded string
- * @_der_len: the bytes of the encoded string
- * @str: a pointer to the data
- * @str_len: the length of the data
- * @ber_len: the total length occupied by BER (may be %NULL)
- *
- * Decodes a BER encoded type. The output is an allocated value
- * of the data. This decodes BER STRINGS only. Other types are
- * decoded as DER.
- *
- * Returns: %ASN1_SUCCESS if successful or an error value.
- **/
-int
-asn1_decode_simple_ber (unsigned int etype, const unsigned char *der,
- unsigned int _der_len, unsigned char **str,
- unsigned int *str_len, unsigned int *ber_len)
-{
- return _asn1_decode_simple_ber(etype, der, _der_len, str, str_len, ber_len, DECODE_FLAG_HAVE_TAG);
-}
diff --git a/lib/element.c b/lib/element.c
deleted file mode 100644
index b09f826..0000000
--- a/lib/element.c
+++ /dev/null
@@ -1,1111 +0,0 @@
-/*
- * Copyright (C) 2000-2014 Free Software Foundation, Inc.
- *
- * This file is part of LIBTASN1.
- *
- * The LIBTASN1 library 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 library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- */
-
-/*****************************************************/
-/* File: element.c */
-/* Description: Functions with the read and write */
-/* functions. */
-/*****************************************************/
-
-
-#include <int.h>
-#include "parser_aux.h"
-#include <gstr.h>
-#include "structure.h"
-
-#include "element.h"
-
-void
-_asn1_hierarchical_name (asn1_node node, char *name, int name_size)
-{
- asn1_node p;
- char tmp_name[64];
-
- p = node;
-
- name[0] = 0;
-
- while (p != NULL)
- {
- if (p->name[0] != 0)
- {
- _asn1_str_cpy (tmp_name, sizeof (tmp_name), name),
- _asn1_str_cpy (name, name_size, p->name);
- _asn1_str_cat (name, name_size, ".");
- _asn1_str_cat (name, name_size, tmp_name);
- }
- p = _asn1_find_up (p);
- }
-
- if (name[0] == 0)
- _asn1_str_cpy (name, name_size, "ROOT");
-}
-
-
-/******************************************************************/
-/* Function : _asn1_convert_integer */
-/* Description: converts an integer from a null terminated string */
-/* to der decoding. The convertion from a null */
-/* terminated string to an integer is made with */
-/* the 'strtol' function. */
-/* Parameters: */
-/* value: null terminated string to convert. */
-/* value_out: convertion result (memory must be already */
-/* allocated). */
-/* value_out_size: number of bytes of value_out. */
-/* len: number of significant byte of value_out. */
-/* Return: ASN1_MEM_ERROR or ASN1_SUCCESS */
-/******************************************************************/
-int
-_asn1_convert_integer (const unsigned char *value, unsigned char *value_out,
- int value_out_size, int *len)
-{
- char negative;
- unsigned char val[SIZEOF_UNSIGNED_LONG_INT];
- long valtmp;
- int k, k2;
-
- valtmp = _asn1_strtol (value, NULL, 10);
-
- for (k = 0; k < SIZEOF_UNSIGNED_LONG_INT; k++)
- {
- val[SIZEOF_UNSIGNED_LONG_INT - k - 1] = (valtmp >> (8 * k)) & 0xFF;
- }
-
- if (val[0] & 0x80)
- negative = 1;
- else
- negative = 0;
-
- for (k = 0; k < SIZEOF_UNSIGNED_LONG_INT - 1; k++)
- {
- if (negative && (val[k] != 0xFF))
- break;
- else if (!negative && val[k])
- break;
- }
-
- if ((negative && !(val[k] & 0x80)) || (!negative && (val[k] & 0x80)))
- k--;
-
- *len = SIZEOF_UNSIGNED_LONG_INT - k;
-
- if (SIZEOF_UNSIGNED_LONG_INT - k > value_out_size)
- /* VALUE_OUT is too short to contain the value conversion */
- return ASN1_MEM_ERROR;
-
- if (value_out != NULL)
- {
- for (k2 = k; k2 < SIZEOF_UNSIGNED_LONG_INT; k2++)
- value_out[k2 - k] = val[k2];
- }
-
-#if 0
- printf ("_asn1_convert_integer: valueIn=%s, lenOut=%d", value, *len);
- for (k = 0; k < SIZEOF_UNSIGNED_LONG_INT; k++)
- printf (", vOut[%d]=%d", k, value_out[k]);
- printf ("\n");
-#endif
-
- return ASN1_SUCCESS;
-}
-
-/* Appends a new element into the sequence (or set) defined by this
- * node. The new element will have a name of '?number', where number
- * is a monotonically increased serial number.
- *
- * The last element in the list may be provided in @pcache, to avoid
- * traversing the list, an expensive operation in long lists.
- *
- * On success it returns in @pcache the added element (which is the
- * tail in the list of added elements).
- */
-int
-_asn1_append_sequence_set (asn1_node node, struct node_tail_cache_st *pcache)
-{
- asn1_node p, p2;
- char temp[LTOSTR_MAX_SIZE];
- long n;
-
- if (!node || !(node->down))
- return ASN1_GENERIC_ERROR;
-
- p = node->down;
- while ((type_field (p->type) == ASN1_ETYPE_TAG)
- || (type_field (p->type) == ASN1_ETYPE_SIZE))
- p = p->right;
-
- p2 = _asn1_copy_structure3 (p);
- if (p2 == NULL)
- return ASN1_GENERIC_ERROR;
-
- if (pcache == NULL || pcache->tail == NULL || pcache->head != node)
- {
- while (p->right)
- {
- p = p->right;
- }
- }
- else
- {
- p = pcache->tail;
- }
-
- _asn1_set_right (p, p2);
- if (pcache)
- {
- pcache->head = node;
- pcache->tail = p2;
- }
-
- if (p->name[0] == 0)
- _asn1_str_cpy (temp, sizeof (temp), "?1");
- else
- {
- n = strtol (p->name + 1, NULL, 0);
- n++;
- temp[0] = '?';
- _asn1_ltostr (n, temp + 1);
- }
- _asn1_set_name (p2, temp);
- /* p2->type |= CONST_OPTION; */
-
- return ASN1_SUCCESS;
-}
-
-
-/**
- * asn1_write_value:
- * @node_root: pointer to a structure
- * @name: the name of the element inside the structure that you want to set.
- * @ivalue: vector used to specify the value to set. If len is >0,
- * VALUE must be a two's complement form integer. if len=0 *VALUE
- * must be a null terminated string with an integer value.
- * @len: number of bytes of *value to use to set the value:
- * value[0]..value[len-1] or 0 if value is a null terminated string
- *
- * Set the value of one element inside a structure.
- *
- * If an element is OPTIONAL and you want to delete it, you must use
- * the value=NULL and len=0. Using "pkix.asn":
- *
- * result=asn1_write_value(cert, "tbsCertificate.issuerUniqueID",
- * NULL, 0);
- *
- * Description for each type:
- *
- * INTEGER: VALUE must contain a two's complement form integer.
- *
- * value[0]=0xFF , len=1 -> integer=-1.
- * value[0]=0xFF value[1]=0xFF , len=2 -> integer=-1.
- * value[0]=0x01 , len=1 -> integer= 1.
- * value[0]=0x00 value[1]=0x01 , len=2 -> integer= 1.
- * value="123" , len=0 -> integer= 123.
- *
- * ENUMERATED: As INTEGER (but only with not negative numbers).
- *
- * BOOLEAN: VALUE must be the null terminated string "TRUE" or
- * "FALSE" and LEN != 0.
- *
- * value="TRUE" , len=1 -> boolean=TRUE.
- * value="FALSE" , len=1 -> boolean=FALSE.
- *
- * OBJECT IDENTIFIER: VALUE must be a null terminated string with
- * each number separated by a dot (e.g. "1.2.3.543.1"). LEN != 0.
- *
- * value="1 2 840 10040 4 3" , len=1 -> OID=dsa-with-sha.
- *
- * UTCTime: VALUE must be a null terminated string in one of these
- * formats: "YYMMDDhhmmssZ", "YYMMDDhhmmssZ",
- * "YYMMDDhhmmss+hh'mm'", "YYMMDDhhmmss-hh'mm'",
- * "YYMMDDhhmm+hh'mm'", or "YYMMDDhhmm-hh'mm'". LEN != 0.
- *
- * value="9801011200Z" , len=1 -> time=Jannuary 1st, 1998
- * at 12h 00m Greenwich Mean Time
- *
- * GeneralizedTime: VALUE must be in one of this format:
- * "YYYYMMDDhhmmss.sZ", "YYYYMMDDhhmmss.sZ",
- * "YYYYMMDDhhmmss.s+hh'mm'", "YYYYMMDDhhmmss.s-hh'mm'",
- * "YYYYMMDDhhmm+hh'mm'", or "YYYYMMDDhhmm-hh'mm'" where ss.s
- * indicates the seconds with any precision like "10.1" or "01.02".
- * LEN != 0
- *
- * value="2001010112001.12-0700" , len=1 -> time=Jannuary
- * 1st, 2001 at 12h 00m 01.12s Pacific Daylight Time
- *
- * OCTET STRING: VALUE contains the octet string and LEN is the
- * number of octets.
- *
- * value="$\backslash$x01$\backslash$x02$\backslash$x03" ,
- * len=3 -> three bytes octet string
- *
- * GeneralString: VALUE contains the generalstring and LEN is the
- * number of octets.
- *
- * value="$\backslash$x01$\backslash$x02$\backslash$x03" ,
- * len=3 -> three bytes generalstring
- *
- * BIT STRING: VALUE contains the bit string organized by bytes and
- * LEN is the number of bits.
- *
- * value="$\backslash$xCF" , len=6 -> bit string="110011" (six
- * bits)
- *
- * CHOICE: if NAME indicates a choice type, VALUE must specify one of
- * the alternatives with a null terminated string. LEN != 0. Using
- * "pkix.asn"\:
- *
- * result=asn1_write_value(cert,
- * "certificate1.tbsCertificate.subject", "rdnSequence",
- * 1);
- *
- * ANY: VALUE indicates the der encoding of a structure. LEN != 0.
- *
- * SEQUENCE OF: VALUE must be the null terminated string "NEW" and
- * LEN != 0. With this instruction another element is appended in
- * the sequence. The name of this element will be "?1" if it's the
- * first one, "?2" for the second and so on.
- *
- * Using "pkix.asn"\:
- *
- * result=asn1_write_value(cert,
- * "certificate1.tbsCertificate.subject.rdnSequence", "NEW", 1);
- *
- * SET OF: the same as SEQUENCE OF. Using "pkix.asn":
- *
- * result=asn1_write_value(cert,
- * "tbsCertificate.subject.rdnSequence.?LAST", "NEW", 1);
- *
- * Returns: %ASN1_SUCCESS if the value was set,
- * %ASN1_ELEMENT_NOT_FOUND if @name is not a valid element, and
- * %ASN1_VALUE_NOT_VALID if @ivalue has a wrong format.
- **/
-int
-asn1_write_value (asn1_node node_root, const char *name,
- const void *ivalue, int len)
-{
- asn1_node node, p, p2;
- unsigned char *temp, *value_temp = NULL, *default_temp = NULL;
- int len2, k, k2, negative;
- size_t i;
- const unsigned char *value = ivalue;
- unsigned int type;
-
- node = asn1_find_node (node_root, name);
- if (node == NULL)
- return ASN1_ELEMENT_NOT_FOUND;
-
- if ((node->type & CONST_OPTION) && (value == NULL) && (len == 0))
- {
- asn1_delete_structure (&node);
- return ASN1_SUCCESS;
- }
-
- type = type_field (node->type);
-
- if ((type == ASN1_ETYPE_SEQUENCE_OF || type == ASN1_ETYPE_SET_OF) && (value == NULL) && (len == 0))
- {
- p = node->down;
- while ((type_field (p->type) == ASN1_ETYPE_TAG)
- || (type_field (p->type) == ASN1_ETYPE_SIZE))
- p = p->right;
-
- while (p->right)
- asn1_delete_structure (&p->right);
-
- return ASN1_SUCCESS;
- }
-
- /* Don't allow element deletion for other types */
- if (value == NULL)
- {
- return ASN1_VALUE_NOT_VALID;
- }
-
- switch (type)
- {
- case ASN1_ETYPE_BOOLEAN:
- if (!_asn1_strcmp (value, "TRUE"))
- {
- if (node->type & CONST_DEFAULT)
- {
- p = node->down;
- while (type_field (p->type) != ASN1_ETYPE_DEFAULT)
- p = p->right;
- if (p->type & CONST_TRUE)
- _asn1_set_value (node, NULL, 0);
- else
- _asn1_set_value (node, "T", 1);
- }
- else
- _asn1_set_value (node, "T", 1);
- }
- else if (!_asn1_strcmp (value, "FALSE"))
- {
- if (node->type & CONST_DEFAULT)
- {
- p = node->down;
- while (type_field (p->type) != ASN1_ETYPE_DEFAULT)
- p = p->right;
- if (p->type & CONST_FALSE)
- _asn1_set_value (node, NULL, 0);
- else
- _asn1_set_value (node, "F", 1);
- }
- else
- _asn1_set_value (node, "F", 1);
- }
- else
- return ASN1_VALUE_NOT_VALID;
- break;
- case ASN1_ETYPE_INTEGER:
- case ASN1_ETYPE_ENUMERATED:
- if (len == 0)
- {
- if ((isdigit (value[0])) || (value[0] == '-'))
- {
- value_temp = malloc (SIZEOF_UNSIGNED_LONG_INT);
- if (value_temp == NULL)
- return ASN1_MEM_ALLOC_ERROR;
-
- _asn1_convert_integer (value, value_temp,
- SIZEOF_UNSIGNED_LONG_INT, &len);
- }
- else
- { /* is an identifier like v1 */
- if (!(node->type & CONST_LIST))
- return ASN1_VALUE_NOT_VALID;
- p = node->down;
- while (p)
- {
- if (type_field (p->type) == ASN1_ETYPE_CONSTANT)
- {
- if (!_asn1_strcmp (p->name, value))
- {
- value_temp = malloc (SIZEOF_UNSIGNED_LONG_INT);
- if (value_temp == NULL)
- return ASN1_MEM_ALLOC_ERROR;
-
- _asn1_convert_integer (p->value,
- value_temp,
- SIZEOF_UNSIGNED_LONG_INT,
- &len);
- break;
- }
- }
- p = p->right;
- }
- if (p == NULL)
- return ASN1_VALUE_NOT_VALID;
- }
- }
- else
- { /* len != 0 */
- value_temp = malloc (len);
- if (value_temp == NULL)
- return ASN1_MEM_ALLOC_ERROR;
- memcpy (value_temp, value, len);
- }
-
- if (value_temp[0] & 0x80)
- negative = 1;
- else
- negative = 0;
-
- if (negative && (type_field (node->type) == ASN1_ETYPE_ENUMERATED))
- {
- free (value_temp);
- return ASN1_VALUE_NOT_VALID;
- }
-
- for (k = 0; k < len - 1; k++)
- if (negative && (value_temp[k] != 0xFF))
- break;
- else if (!negative && value_temp[k])
- break;
-
- if ((negative && !(value_temp[k] & 0x80)) ||
- (!negative && (value_temp[k] & 0x80)))
- k--;
-
- _asn1_set_value_lv (node, value_temp + k, len - k);
-
- if (node->type & CONST_DEFAULT)
- {
- p = node->down;
- while (type_field (p->type) != ASN1_ETYPE_DEFAULT)
- p = p->right;
- if ((isdigit (p->value[0])) || (p->value[0] == '-'))
- {
- default_temp = malloc (SIZEOF_UNSIGNED_LONG_INT);
- if (default_temp == NULL)
- {
- free (value_temp);
- return ASN1_MEM_ALLOC_ERROR;
- }
-
- _asn1_convert_integer (p->value, default_temp,
- SIZEOF_UNSIGNED_LONG_INT, &len2);
- }
- else
- { /* is an identifier like v1 */
- if (!(node->type & CONST_LIST))
- {
- free (value_temp);
- return ASN1_VALUE_NOT_VALID;
- }
- p2 = node->down;
- while (p2)
- {
- if (type_field (p2->type) == ASN1_ETYPE_CONSTANT)
- {
- if (!_asn1_strcmp (p2->name, p->value))
- {
- default_temp = malloc (SIZEOF_UNSIGNED_LONG_INT);
- if (default_temp == NULL)
- {
- free (value_temp);
- return ASN1_MEM_ALLOC_ERROR;
- }
-
- _asn1_convert_integer (p2->value,
- default_temp,
- SIZEOF_UNSIGNED_LONG_INT,
- &len2);
- break;
- }
- }
- p2 = p2->right;
- }
- if (p2 == NULL)
- {
- free (value_temp);
- return ASN1_VALUE_NOT_VALID;
- }
- }
-
-
- if ((len - k) == len2)
- {
- for (k2 = 0; k2 < len2; k2++)
- if (value_temp[k + k2] != default_temp[k2])
- {
- break;
- }
- if (k2 == len2)
- _asn1_set_value (node, NULL, 0);
- }
- free (default_temp);
- }
- free (value_temp);
- break;
- case ASN1_ETYPE_OBJECT_ID:
- for (i = 0; i < _asn1_strlen (value); i++)
- if ((!isdigit (value[i])) && (value[i] != '.') && (value[i] != '+'))
- return ASN1_VALUE_NOT_VALID;
- if (node->type & CONST_DEFAULT)
- {
- p = node->down;
- while (type_field (p->type) != ASN1_ETYPE_DEFAULT)
- p = p->right;
- if (!_asn1_strcmp (value, p->value))
- {
- _asn1_set_value (node, NULL, 0);
- break;
- }
- }
- _asn1_set_value (node, value, _asn1_strlen (value) + 1);
- break;
- case ASN1_ETYPE_UTC_TIME:
- {
- len = _asn1_strlen (value);
- if (len < 11)
- return ASN1_VALUE_NOT_VALID;
- for (k = 0; k < 10; k++)
- if (!isdigit (value[k]))
- return ASN1_VALUE_NOT_VALID;
- switch (len)
- {
- case 11:
- if (value[10] != 'Z')
- return ASN1_VALUE_NOT_VALID;
- break;
- case 13:
- if ((!isdigit (value[10])) || (!isdigit (value[11])) ||
- (value[12] != 'Z'))
- return ASN1_VALUE_NOT_VALID;
- break;
- case 15:
- if ((value[10] != '+') && (value[10] != '-'))
- return ASN1_VALUE_NOT_VALID;
- for (k = 11; k < 15; k++)
- if (!isdigit (value[k]))
- return ASN1_VALUE_NOT_VALID;
- break;
- case 17:
- if ((!isdigit (value[10])) || (!isdigit (value[11])))
- return ASN1_VALUE_NOT_VALID;
- if ((value[12] != '+') && (value[12] != '-'))
- return ASN1_VALUE_NOT_VALID;
- for (k = 13; k < 17; k++)
- if (!isdigit (value[k]))
- return ASN1_VALUE_NOT_VALID;
- break;
- default:
- return ASN1_VALUE_NOT_FOUND;
- }
- _asn1_set_value (node, value, len);
- }
- break;
- case ASN1_ETYPE_GENERALIZED_TIME:
- len = _asn1_strlen (value);
- _asn1_set_value (node, value, len);
- break;
- case ASN1_ETYPE_OCTET_STRING:
- case ASN1_ETYPE_GENERALSTRING:
- case ASN1_ETYPE_NUMERIC_STRING:
- case ASN1_ETYPE_IA5_STRING:
- case ASN1_ETYPE_TELETEX_STRING:
- case ASN1_ETYPE_PRINTABLE_STRING:
- case ASN1_ETYPE_UNIVERSAL_STRING:
- case ASN1_ETYPE_BMP_STRING:
- case ASN1_ETYPE_UTF8_STRING:
- case ASN1_ETYPE_VISIBLE_STRING:
- if (len == 0)
- len = _asn1_strlen (value);
- _asn1_set_value_lv (node, value, len);
- break;
- case ASN1_ETYPE_BIT_STRING:
- if (len == 0)
- len = _asn1_strlen (value);
- asn1_length_der ((len >> 3) + 2, NULL, &len2);
- temp = malloc ((len >> 3) + 2 + len2);
- if (temp == NULL)
- return ASN1_MEM_ALLOC_ERROR;
-
- asn1_bit_der (value, len, temp, &len2);
- _asn1_set_value_m (node, temp, len2);
- temp = NULL;
- break;
- case ASN1_ETYPE_CHOICE:
- p = node->down;
- while (p)
- {
- if (!_asn1_strcmp (p->name, value))
- {
- p2 = node->down;
- while (p2)
- {
- if (p2 != p)
- {
- asn1_delete_structure (&p2);
- p2 = node->down;
- }
- else
- p2 = p2->right;
- }
- break;
- }
- p = p->right;
- }
- if (!p)
- return ASN1_ELEMENT_NOT_FOUND;
- break;
- case ASN1_ETYPE_ANY:
- _asn1_set_value_lv (node, value, len);
- break;
- case ASN1_ETYPE_SEQUENCE_OF:
- case ASN1_ETYPE_SET_OF:
- if (_asn1_strcmp (value, "NEW"))
- return ASN1_VALUE_NOT_VALID;
- _asn1_append_sequence_set (node, NULL);
- break;
- default:
- return ASN1_ELEMENT_NOT_FOUND;
- break;
- }
-
- return ASN1_SUCCESS;
-}
-
-
-#define PUT_VALUE( ptr, ptr_size, data, data_size) \
- *len = data_size; \
- if (ptr_size < data_size) { \
- return ASN1_MEM_ERROR; \
- } else { \
- if (ptr && data_size > 0) \
- memcpy (ptr, data, data_size); \
- }
-
-#define PUT_STR_VALUE( ptr, ptr_size, data) \
- *len = _asn1_strlen (data) + 1; \
- if (ptr_size < *len) { \
- return ASN1_MEM_ERROR; \
- } else { \
- /* this strcpy is checked */ \
- if (ptr) { \
- _asn1_strcpy (ptr, data); \
- } \
- }
-
-#define PUT_AS_STR_VALUE( ptr, ptr_size, data, data_size) \
- *len = data_size + 1; \
- if (ptr_size < *len) { \
- return ASN1_MEM_ERROR; \
- } else { \
- /* this strcpy is checked */ \
- if (ptr) { \
- if (data_size > 0) \
- memcpy (ptr, data, data_size); \
- ptr[data_size] = 0; \
- } \
- }
-
-#define ADD_STR_VALUE( ptr, ptr_size, data) \
- *len += _asn1_strlen(data); \
- if (ptr_size < (int) *len) { \
- (*len)++; \
- return ASN1_MEM_ERROR; \
- } else { \
- /* this strcat is checked */ \
- if (ptr) _asn1_strcat (ptr, data); \
- }
-
-/**
- * asn1_read_value:
- * @root: pointer to a structure.
- * @name: the name of the element inside a structure that you want to read.
- * @ivalue: vector that will contain the element's content, must be a
- * pointer to memory cells already allocated (may be %NULL).
- * @len: number of bytes of *value: value[0]..value[len-1]. Initialy
- * holds the sizeof value.
- *
- * Returns the value of one element inside a structure.
- * If an element is OPTIONAL and this returns
- * %ASN1_ELEMENT_NOT_FOUND, it means that this element wasn't present
- * in the der encoding that created the structure. The first element
- * of a SEQUENCE_OF or SET_OF is named "?1". The second one "?2" and
- * so on. If the @root provided is a node to specific sequence element,
- * then the keyword "?CURRENT" is also acceptable and indicates the
- * current sequence element of this node.
- *
- * Note that there can be valid values with length zero. In these case
- * this function will succeed and @len will be zero.
- *
- * INTEGER: VALUE will contain a two's complement form integer.
- *
- * integer=-1 -> value[0]=0xFF , len=1.
- * integer=1 -> value[0]=0x01 , len=1.
- *
- * ENUMERATED: As INTEGER (but only with not negative numbers).
- *
- * BOOLEAN: VALUE will be the null terminated string "TRUE" or
- * "FALSE" and LEN=5 or LEN=6.
- *
- * OBJECT IDENTIFIER: VALUE will be a null terminated string with
- * each number separated by a dot (i.e. "1.2.3.543.1").
- *
- * LEN = strlen(VALUE)+1
- *
- * UTCTime: VALUE will be a null terminated string in one of these
- * formats: "YYMMDDhhmmss+hh'mm'" or "YYMMDDhhmmss-hh'mm'".
- * LEN=strlen(VALUE)+1.
- *
- * GeneralizedTime: VALUE will be a null terminated string in the
- * same format used to set the value.
- *
- * OCTET STRING: VALUE will contain the octet string and LEN will be
- * the number of octets.
- *
- * GeneralString: VALUE will contain the generalstring and LEN will
- * be the number of octets.
- *
- * BIT STRING: VALUE will contain the bit string organized by bytes
- * and LEN will be the number of bits.
- *
- * CHOICE: If NAME indicates a choice type, VALUE will specify the
- * alternative selected.
- *
- * ANY: If NAME indicates an any type, VALUE will indicate the DER
- * encoding of the structure actually used.
- *
- * Returns: %ASN1_SUCCESS if value is returned,
- * %ASN1_ELEMENT_NOT_FOUND if @name is not a valid element,
- * %ASN1_VALUE_NOT_FOUND if there isn't any value for the element
- * selected, and %ASN1_MEM_ERROR if The value vector isn't big enough
- * to store the result, and in this case @len will contain the number of
- * bytes needed. On the occasion that the stored data are of zero-length
- * this function may return %ASN1_SUCCESS even if the provided @len is zero.
- **/
-int
-asn1_read_value (asn1_node root, const char *name, void *ivalue, int *len)
-{
- return asn1_read_value_type (root, name, ivalue, len, NULL);
-}
-
-/**
- * asn1_read_value_type:
- * @root: pointer to a structure.
- * @name: the name of the element inside a structure that you want to read.
- * @ivalue: vector that will contain the element's content, must be a
- * pointer to memory cells already allocated (may be %NULL).
- * @len: number of bytes of *value: value[0]..value[len-1]. Initialy
- * holds the sizeof value.
- * @etype: The type of the value read (ASN1_ETYPE)
- *
- * Returns the type and value of one element inside a structure.
- * If an element is OPTIONAL and this returns
- * %ASN1_ELEMENT_NOT_FOUND, it means that this element wasn't present
- * in the der encoding that created the structure. The first element
- * of a SEQUENCE_OF or SET_OF is named "?1". The second one "?2" and
- * so on. If the @root provided is a node to specific sequence element,
- * then the keyword "?CURRENT" is also acceptable and indicates the
- * current sequence element of this node.
- *
- * Note that there can be valid values with length zero. In these case
- * this function will succeed and @len will be zero.
- *
- *
- * INTEGER: VALUE will contain a two's complement form integer.
- *
- * integer=-1 -> value[0]=0xFF , len=1.
- * integer=1 -> value[0]=0x01 , len=1.
- *
- * ENUMERATED: As INTEGER (but only with not negative numbers).
- *
- * BOOLEAN: VALUE will be the null terminated string "TRUE" or
- * "FALSE" and LEN=5 or LEN=6.
- *
- * OBJECT IDENTIFIER: VALUE will be a null terminated string with
- * each number separated by a dot (i.e. "1.2.3.543.1").
- *
- * LEN = strlen(VALUE)+1
- *
- * UTCTime: VALUE will be a null terminated string in one of these
- * formats: "YYMMDDhhmmss+hh'mm'" or "YYMMDDhhmmss-hh'mm'".
- * LEN=strlen(VALUE)+1.
- *
- * GeneralizedTime: VALUE will be a null terminated string in the
- * same format used to set the value.
- *
- * OCTET STRING: VALUE will contain the octet string and LEN will be
- * the number of octets.
- *
- * GeneralString: VALUE will contain the generalstring and LEN will
- * be the number of octets.
- *
- * BIT STRING: VALUE will contain the bit string organized by bytes
- * and LEN will be the number of bits.
- *
- * CHOICE: If NAME indicates a choice type, VALUE will specify the
- * alternative selected.
- *
- * ANY: If NAME indicates an any type, VALUE will indicate the DER
- * encoding of the structure actually used.
- *
- * Returns: %ASN1_SUCCESS if value is returned,
- * %ASN1_ELEMENT_NOT_FOUND if @name is not a valid element,
- * %ASN1_VALUE_NOT_FOUND if there isn't any value for the element
- * selected, and %ASN1_MEM_ERROR if The value vector isn't big enough
- * to store the result, and in this case @len will contain the number of
- * bytes needed. On the occasion that the stored data are of zero-length
- * this function may return %ASN1_SUCCESS even if the provided @len is zero.
- **/
-int
-asn1_read_value_type (asn1_node root, const char *name, void *ivalue,
- int *len, unsigned int *etype)
-{
- asn1_node node, p, p2;
- int len2, len3, result;
- int value_size = *len;
- unsigned char *value = ivalue;
- unsigned type;
-
- node = asn1_find_node (root, name);
- if (node == NULL)
- return ASN1_ELEMENT_NOT_FOUND;
-
- type = type_field (node->type);
-
- if ((type != ASN1_ETYPE_NULL) &&
- (type != ASN1_ETYPE_CHOICE) &&
- !(node->type & CONST_DEFAULT) && !(node->type & CONST_ASSIGN) &&
- (node->value == NULL))
- return ASN1_VALUE_NOT_FOUND;
-
- if (etype)
- *etype = type;
- switch (type)
- {
- case ASN1_ETYPE_NULL:
- PUT_STR_VALUE (value, value_size, "NULL");
- break;
- case ASN1_ETYPE_BOOLEAN:
- if ((node->type & CONST_DEFAULT) && (node->value == NULL))
- {
- p = node->down;
- while (type_field (p->type) != ASN1_ETYPE_DEFAULT)
- p = p->right;
- if (p->type & CONST_TRUE)
- {
- PUT_STR_VALUE (value, value_size, "TRUE");
- }
- else
- {
- PUT_STR_VALUE (value, value_size, "FALSE");
- }
- }
- else if (node->value[0] == 'T')
- {
- PUT_STR_VALUE (value, value_size, "TRUE");
- }
- else
- {
- PUT_STR_VALUE (value, value_size, "FALSE");
- }
- break;
- case ASN1_ETYPE_INTEGER:
- case ASN1_ETYPE_ENUMERATED:
- if ((node->type & CONST_DEFAULT) && (node->value == NULL))
- {
- p = node->down;
- while (type_field (p->type) != ASN1_ETYPE_DEFAULT)
- p = p->right;
- if ((isdigit (p->value[0])) || (p->value[0] == '-')
- || (p->value[0] == '+'))
- {
- result = _asn1_convert_integer
- (p->value, value, value_size, len);
- if (result != ASN1_SUCCESS)
- return result;
- }
- else
- { /* is an identifier like v1 */
- p2 = node->down;
- while (p2)
- {
- if (type_field (p2->type) == ASN1_ETYPE_CONSTANT)
- {
- if (!_asn1_strcmp (p2->name, p->value))
- {
- result = _asn1_convert_integer
- (p2->value, value, value_size,
- len);
- if (result != ASN1_SUCCESS)
- return result;
- break;
- }
- }
- p2 = p2->right;
- }
- }
- }
- else
- {
- len2 = -1;
- result = asn1_get_octet_der
- (node->value, node->value_len, &len2, value, value_size,
- len);
- if (result != ASN1_SUCCESS)
- return result;
- }
- break;
- case ASN1_ETYPE_OBJECT_ID:
- if (node->type & CONST_ASSIGN)
- {
- *len = 0;
- if (value)
- value[0] = 0;
- p = node->down;
- while (p)
- {
- if (type_field (p->type) == ASN1_ETYPE_CONSTANT)
- {
- ADD_STR_VALUE (value, value_size, p->value);
- if (p->right)
- {
- ADD_STR_VALUE (value, value_size, ".");
- }
- }
- p = p->right;
- }
- (*len)++;
- }
- else if ((node->type & CONST_DEFAULT) && (node->value == NULL))
- {
- p = node->down;
- while (type_field (p->type) != ASN1_ETYPE_DEFAULT)
- p = p->right;
- PUT_STR_VALUE (value, value_size, p->value);
- }
- else
- {
- PUT_STR_VALUE (value, value_size, node->value);
- }
- break;
- case ASN1_ETYPE_GENERALIZED_TIME:
- case ASN1_ETYPE_UTC_TIME:
- PUT_AS_STR_VALUE (value, value_size, node->value, node->value_len);
- break;
- case ASN1_ETYPE_OCTET_STRING:
- case ASN1_ETYPE_GENERALSTRING:
- case ASN1_ETYPE_NUMERIC_STRING:
- case ASN1_ETYPE_IA5_STRING:
- case ASN1_ETYPE_TELETEX_STRING:
- case ASN1_ETYPE_PRINTABLE_STRING:
- case ASN1_ETYPE_UNIVERSAL_STRING:
- case ASN1_ETYPE_BMP_STRING:
- case ASN1_ETYPE_UTF8_STRING:
- case ASN1_ETYPE_VISIBLE_STRING:
- len2 = -1;
- result = asn1_get_octet_der
- (node->value, node->value_len, &len2, value, value_size,
- len);
- if (result != ASN1_SUCCESS)
- return result;
- break;
- case ASN1_ETYPE_BIT_STRING:
- len2 = -1;
- result = asn1_get_bit_der
- (node->value, node->value_len, &len2, value, value_size,
- len);
- if (result != ASN1_SUCCESS)
- return result;
- break;
- case ASN1_ETYPE_CHOICE:
- PUT_STR_VALUE (value, value_size, node->down->name);
- break;
- case ASN1_ETYPE_ANY:
- len3 = -1;
- len2 = asn1_get_length_der (node->value, node->value_len, &len3);
- if (len2 < 0)
- return ASN1_DER_ERROR;
- PUT_VALUE (value, value_size, node->value + len3, len2);
- break;
- default:
- return ASN1_ELEMENT_NOT_FOUND;
- break;
- }
- return ASN1_SUCCESS;
-}
-
-
-/**
- * asn1_read_tag:
- * @root: pointer to a structure
- * @name: the name of the element inside a structure.
- * @tagValue: variable that will contain the TAG value.
- * @classValue: variable that will specify the TAG type.
- *
- * Returns the TAG and the CLASS of one element inside a structure.
- * CLASS can have one of these constants: %ASN1_CLASS_APPLICATION,
- * %ASN1_CLASS_UNIVERSAL, %ASN1_CLASS_PRIVATE or
- * %ASN1_CLASS_CONTEXT_SPECIFIC.
- *
- * Returns: %ASN1_SUCCESS if successful, %ASN1_ELEMENT_NOT_FOUND if
- * @name is not a valid element.
- **/
-int
-asn1_read_tag (asn1_node root, const char *name, int *tagValue,
- int *classValue)
-{
- asn1_node node, p, pTag;
-
- node = asn1_find_node (root, name);
- if (node == NULL)
- return ASN1_ELEMENT_NOT_FOUND;
-
- p = node->down;
-
- /* pTag will points to the IMPLICIT TAG */
- pTag = NULL;
- if (node->type & CONST_TAG)
- {
- while (p)
- {
- if (type_field (p->type) == ASN1_ETYPE_TAG)
- {
- if ((p->type & CONST_IMPLICIT) && (pTag == NULL))
- pTag = p;
- else if (p->type & CONST_EXPLICIT)
- pTag = NULL;
- }
- p = p->right;
- }
- }
-
- if (pTag)
- {
- *tagValue = _asn1_strtoul (pTag->value, NULL, 10);
-
- if (pTag->type & CONST_APPLICATION)
- *classValue = ASN1_CLASS_APPLICATION;
- else if (pTag->type & CONST_UNIVERSAL)
- *classValue = ASN1_CLASS_UNIVERSAL;
- else if (pTag->type & CONST_PRIVATE)
- *classValue = ASN1_CLASS_PRIVATE;
- else
- *classValue = ASN1_CLASS_CONTEXT_SPECIFIC;
- }
- else
- {
- unsigned type = type_field (node->type);
- *classValue = ASN1_CLASS_UNIVERSAL;
-
- switch (type)
- {
- CASE_HANDLED_ETYPES:
- *tagValue = _asn1_tags[type].tag;
- break;
- case ASN1_ETYPE_TAG:
- case ASN1_ETYPE_CHOICE:
- case ASN1_ETYPE_ANY:
- *tagValue = -1;
- break;
- default:
- break;
- }
- }
-
- return ASN1_SUCCESS;
-}
-
-/**
- * asn1_read_node_value:
- * @node: pointer to a node.
- * @data: a point to a asn1_data_node_st
- *
- * Returns the value a data node inside a asn1_node structure.
- * The data returned should be handled as constant values.
- *
- * Returns: %ASN1_SUCCESS if the node exists.
- **/
-int
-asn1_read_node_value (asn1_node node, asn1_data_node_st * data)
-{
- data->name = node->name;
- data->value = node->value;
- data->value_len = node->value_len;
- data->type = type_field (node->type);
-
- return ASN1_SUCCESS;
-}
diff --git a/lib/element.h b/lib/element.h
deleted file mode 100644
index 4e45367..0000000
--- a/lib/element.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2000-2014 Free Software Foundation, Inc.
- *
- * This file is part of LIBTASN1.
- *
- * The LIBTASN1 library 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 library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- */
-
-#ifndef _ELEMENT_H
-#define _ELEMENT_H
-
-
-struct node_tail_cache_st
-{
- asn1_node head; /* the first element of the sequence */
- asn1_node tail;
-};
-
-int _asn1_append_sequence_set (asn1_node node, struct node_tail_cache_st *pcached);
-
-int _asn1_convert_integer (const unsigned char *value,
- unsigned char *value_out,
- int value_out_size, int *len);
-
-void _asn1_hierarchical_name (asn1_node node, char *name, int name_size);
-
-#endif
diff --git a/lib/errors.c b/lib/errors.c
deleted file mode 100644
index fef45ae..0000000
--- a/lib/errors.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2002-2014 Free Software Foundation, Inc.
- *
- * This file is part of LIBTASN1.
- *
- * The LIBTASN1 library 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 library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- */
-
-#include <int.h>
-#ifdef STDC_HEADERS
-#include <stdarg.h>
-#endif
-
-#define LIBTASN1_ERROR_ENTRY(name) { #name, name }
-
-struct libtasn1_error_entry
-{
- const char *name;
- int number;
-};
-typedef struct libtasn1_error_entry libtasn1_error_entry;
-
-static const libtasn1_error_entry error_algorithms[] = {
- LIBTASN1_ERROR_ENTRY (ASN1_SUCCESS),
- LIBTASN1_ERROR_ENTRY (ASN1_FILE_NOT_FOUND),
- LIBTASN1_ERROR_ENTRY (ASN1_ELEMENT_NOT_FOUND),
- LIBTASN1_ERROR_ENTRY (ASN1_IDENTIFIER_NOT_FOUND),
- LIBTASN1_ERROR_ENTRY (ASN1_DER_ERROR),
- LIBTASN1_ERROR_ENTRY (ASN1_VALUE_NOT_FOUND),
- LIBTASN1_ERROR_ENTRY (ASN1_GENERIC_ERROR),
- LIBTASN1_ERROR_ENTRY (ASN1_VALUE_NOT_VALID),
- LIBTASN1_ERROR_ENTRY (ASN1_TAG_ERROR),
- LIBTASN1_ERROR_ENTRY (ASN1_TAG_IMPLICIT),
- LIBTASN1_ERROR_ENTRY (ASN1_ERROR_TYPE_ANY),
- LIBTASN1_ERROR_ENTRY (ASN1_SYNTAX_ERROR),
- LIBTASN1_ERROR_ENTRY (ASN1_MEM_ERROR),
- LIBTASN1_ERROR_ENTRY (ASN1_MEM_ALLOC_ERROR),
- LIBTASN1_ERROR_ENTRY (ASN1_DER_OVERFLOW),
- LIBTASN1_ERROR_ENTRY (ASN1_NAME_TOO_LONG),
- LIBTASN1_ERROR_ENTRY (ASN1_ARRAY_ERROR),
- LIBTASN1_ERROR_ENTRY (ASN1_ELEMENT_NOT_EMPTY),
- LIBTASN1_ERROR_ENTRY (ASN1_TIME_ENCODING_ERROR),
- {0, 0}
-};
-
-/**
- * asn1_perror:
- * @error: is an error returned by a libtasn1 function.
- *
- * Prints a string to stderr with a description of an error. This
- * function is like perror(). The only difference is that it accepts
- * an error returned by a libtasn1 function.
- *
- * Since: 1.6
- **/
-void
-asn1_perror (int error)
-{
- const char *str = asn1_strerror (error);
- fprintf (stderr, "LIBTASN1 ERROR: %s\n", str ? str : "(null)");
-}
-
-/**
- * asn1_strerror:
- * @error: is an error returned by a libtasn1 function.
- *
- * Returns a string with a description of an error. This function is
- * similar to strerror. The only difference is that it accepts an
- * error (number) returned by a libtasn1 function.
- *
- * Returns: Pointer to static zero-terminated string describing error
- * code.
- *
- * Since: 1.6
- **/
-const char *
-asn1_strerror (int error)
-{
- const libtasn1_error_entry *p;
-
- for (p = error_algorithms; p->name != NULL; p++)
- if (p->number == error)
- return p->name + sizeof ("ASN1_") - 1;
-
- return NULL;
-}
diff --git a/lib/gllib/Makefile.am b/lib/gllib/Makefile.am
deleted file mode 100644
index d395304..0000000
--- a/lib/gllib/Makefile.am
+++ /dev/null
@@ -1,419 +0,0 @@
-## DO NOT EDIT! GENERATED AUTOMATICALLY!
-## Process this file with automake to produce Makefile.in.
-# Copyright (C) 2002-2017 Free Software Foundation, Inc.
-#
-# This file is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 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 General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this file. If not, see <http://www.gnu.org/licenses/>.
-#
-# As a special exception to the GNU General Public License,
-# this file may be distributed as part of a program that
-# contains a configuration script generated by Autoconf, under
-# the same distribution terms as the rest of that program.
-#
-# Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --lib=libgnu --source-base=lib/gllib --m4-base=lib/glm4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=2 --no-conditional-dependencies --libtool --macro-prefix=lgl --no-vc-files hash-pjw-bare intprops lib-symbol-versions lib-symbol-visibility minmax stdint strverscmp
-
-AUTOMAKE_OPTIONS = 1.9.6 gnits
-
-SUBDIRS =
-noinst_HEADERS =
-noinst_LIBRARIES =
-noinst_LTLIBRARIES =
-EXTRA_DIST =
-BUILT_SOURCES =
-SUFFIXES =
-MOSTLYCLEANFILES = core *.stackdump
-MOSTLYCLEANDIRS =
-CLEANFILES =
-DISTCLEANFILES =
-MAINTAINERCLEANFILES =
-
-AM_CPPFLAGS =
-AM_CFLAGS =
-
-noinst_LTLIBRARIES += libgnu.la
-
-libgnu_la_SOURCES =
-libgnu_la_LIBADD = $(lgl_LTLIBOBJS)
-libgnu_la_DEPENDENCIES = $(lgl_LTLIBOBJS)
-EXTRA_libgnu_la_SOURCES =
-libgnu_la_LDFLAGS = $(AM_LDFLAGS)
-libgnu_la_LDFLAGS += -no-undefined
-
-## begin gnulib module absolute-header
-
-# Use this preprocessor expression to decide whether #include_next works.
-# Do not rely on a 'configure'-time test for this, since the expression
-# might appear in an installed header, which is used by some other compiler.
-HAVE_INCLUDE_NEXT = (__GNUC__ || 60000000 <= __DECC_VER)
-
-## end gnulib module absolute-header
-
-## begin gnulib module hash-pjw-bare
-
-libgnu_la_SOURCES += hash-pjw-bare.h hash-pjw-bare.c
-
-## end gnulib module hash-pjw-bare
-
-## begin gnulib module intprops
-
-
-EXTRA_DIST += intprops.h
-
-## end gnulib module intprops
-
-## begin gnulib module lib-symbol-visibility
-
-# The value of $(CFLAG_VISIBILITY) needs to be added to the CFLAGS for the
-# compilation of all sources that make up the library. This line here does it
-# only for the gnulib part of it. The developer is responsible for adding
-# $(CFLAG_VISIBILITY) to the Makefile.ams of the other portions of the library.
-AM_CFLAGS += $(CFLAG_VISIBILITY)
-
-## end gnulib module lib-symbol-visibility
-
-## begin gnulib module limits-h
-
-BUILT_SOURCES += $(LIMITS_H)
-
-# We need the following in order to create <limits.h> when the system
-# doesn't have one that is compatible with GNU.
-if GL_GENERATE_LIMITS_H
-limits.h: limits.in.h $(top_builddir)/config.status
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
- sed -e 's|@''GUARD_PREFIX''@|GL_LGL|g' \
- -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
- -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
- -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
- -e 's|@''NEXT_LIMITS_H''@|$(NEXT_LIMITS_H)|g' \
- < $(srcdir)/limits.in.h; \
- } > $@-t && \
- mv $@-t $@
-else
-limits.h: $(top_builddir)/config.status
- rm -f $@
-endif
-MOSTLYCLEANFILES += limits.h limits.h-t
-
-EXTRA_DIST += limits.in.h
-
-## end gnulib module limits-h
-
-## begin gnulib module minmax
-
-libgnu_la_SOURCES += minmax.h
-
-## end gnulib module minmax
-
-## begin gnulib module snippet/arg-nonnull
-
-# The BUILT_SOURCES created by this Makefile snippet are not used via #include
-# statements but through direct file reference. Therefore this snippet must be
-# present in all Makefile.am that need it. This is ensured by the applicability
-# 'all' defined above.
-
-BUILT_SOURCES += arg-nonnull.h
-# The arg-nonnull.h that gets inserted into generated .h files is the same as
-# build-aux/snippet/arg-nonnull.h, except that it has the copyright header cut
-# off.
-arg-nonnull.h: $(top_srcdir)/build-aux/snippet/arg-nonnull.h
- $(AM_V_GEN)rm -f $@-t $@ && \
- sed -n -e '/GL_ARG_NONNULL/,$$p' \
- < $(top_srcdir)/build-aux/snippet/arg-nonnull.h \
- > $@-t && \
- mv $@-t $@
-MOSTLYCLEANFILES += arg-nonnull.h arg-nonnull.h-t
-
-ARG_NONNULL_H=arg-nonnull.h
-
-EXTRA_DIST += $(top_srcdir)/build-aux/snippet/arg-nonnull.h
-
-## end gnulib module snippet/arg-nonnull
-
-## begin gnulib module snippet/c++defs
-
-# The BUILT_SOURCES created by this Makefile snippet are not used via #include
-# statements but through direct file reference. Therefore this snippet must be
-# present in all Makefile.am that need it. This is ensured by the applicability
-# 'all' defined above.
-
-BUILT_SOURCES += c++defs.h
-# The c++defs.h that gets inserted into generated .h files is the same as
-# build-aux/snippet/c++defs.h, except that it has the copyright header cut off.
-c++defs.h: $(top_srcdir)/build-aux/snippet/c++defs.h
- $(AM_V_GEN)rm -f $@-t $@ && \
- sed -n -e '/_GL_CXXDEFS/,$$p' \
- < $(top_srcdir)/build-aux/snippet/c++defs.h \
- > $@-t && \
- mv $@-t $@
-MOSTLYCLEANFILES += c++defs.h c++defs.h-t
-
-CXXDEFS_H=c++defs.h
-
-EXTRA_DIST += $(top_srcdir)/build-aux/snippet/c++defs.h
-
-## end gnulib module snippet/c++defs
-
-## begin gnulib module snippet/warn-on-use
-
-BUILT_SOURCES += warn-on-use.h
-# The warn-on-use.h that gets inserted into generated .h files is the same as
-# build-aux/snippet/warn-on-use.h, except that it has the copyright header cut
-# off.
-warn-on-use.h: $(top_srcdir)/build-aux/snippet/warn-on-use.h
- $(AM_V_GEN)rm -f $@-t $@ && \
- sed -n -e '/^.ifndef/,$$p' \
- < $(top_srcdir)/build-aux/snippet/warn-on-use.h \
- > $@-t && \
- mv $@-t $@
-MOSTLYCLEANFILES += warn-on-use.h warn-on-use.h-t
-
-WARN_ON_USE_H=warn-on-use.h
-
-EXTRA_DIST += $(top_srcdir)/build-aux/snippet/warn-on-use.h
-
-## end gnulib module snippet/warn-on-use
-
-## begin gnulib module stddef
-
-BUILT_SOURCES += $(STDDEF_H)
-
-# We need the following in order to create <stddef.h> when the system
-# doesn't have one that works with the given compiler.
-if GL_GENERATE_STDDEF_H
-stddef.h: stddef.in.h $(top_builddir)/config.status
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
- sed -e 's|@''GUARD_PREFIX''@|GL_LGL|g' \
- -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
- -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
- -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
- -e 's|@''NEXT_STDDEF_H''@|$(NEXT_STDDEF_H)|g' \
- -e 's|@''HAVE_MAX_ALIGN_T''@|$(HAVE_MAX_ALIGN_T)|g' \
- -e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \
- -e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \
- < $(srcdir)/stddef.in.h; \
- } > $@-t && \
- mv $@-t $@
-else
-stddef.h: $(top_builddir)/config.status
- rm -f $@
-endif
-MOSTLYCLEANFILES += stddef.h stddef.h-t
-
-EXTRA_DIST += stddef.in.h
-
-## end gnulib module stddef
-
-## begin gnulib module stdint
-
-BUILT_SOURCES += $(STDINT_H)
-
-# We need the following in order to create <stdint.h> when the system
-# doesn't have one that works with the given compiler.
-if GL_GENERATE_STDINT_H
-stdint.h: stdint.in.h $(top_builddir)/config.status
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''GUARD_PREFIX''@|GL_LGL|g' \
- -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \
- -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
- -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
- -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
- -e 's|@''NEXT_STDINT_H''@|$(NEXT_STDINT_H)|g' \
- -e 's/@''HAVE_C99_STDINT_H''@/$(HAVE_C99_STDINT_H)/g' \
- -e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \
- -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
- -e 's/@''HAVE_SYS_INTTYPES_H''@/$(HAVE_SYS_INTTYPES_H)/g' \
- -e 's/@''HAVE_SYS_BITYPES_H''@/$(HAVE_SYS_BITYPES_H)/g' \
- -e 's/@''HAVE_WCHAR_H''@/$(HAVE_WCHAR_H)/g' \
- -e 's/@''HAVE_LONG_LONG_INT''@/$(HAVE_LONG_LONG_INT)/g' \
- -e 's/@''HAVE_UNSIGNED_LONG_LONG_INT''@/$(HAVE_UNSIGNED_LONG_LONG_INT)/g' \
- -e 's/@''APPLE_UNIVERSAL_BUILD''@/$(APPLE_UNIVERSAL_BUILD)/g' \
- -e 's/@''BITSIZEOF_PTRDIFF_T''@/$(BITSIZEOF_PTRDIFF_T)/g' \
- -e 's/@''PTRDIFF_T_SUFFIX''@/$(PTRDIFF_T_SUFFIX)/g' \
- -e 's/@''BITSIZEOF_SIG_ATOMIC_T''@/$(BITSIZEOF_SIG_ATOMIC_T)/g' \
- -e 's/@''HAVE_SIGNED_SIG_ATOMIC_T''@/$(HAVE_SIGNED_SIG_ATOMIC_T)/g' \
- -e 's/@''SIG_ATOMIC_T_SUFFIX''@/$(SIG_ATOMIC_T_SUFFIX)/g' \
- -e 's/@''BITSIZEOF_SIZE_T''@/$(BITSIZEOF_SIZE_T)/g' \
- -e 's/@''SIZE_T_SUFFIX''@/$(SIZE_T_SUFFIX)/g' \
- -e 's/@''BITSIZEOF_WCHAR_T''@/$(BITSIZEOF_WCHAR_T)/g' \
- -e 's/@''HAVE_SIGNED_WCHAR_T''@/$(HAVE_SIGNED_WCHAR_T)/g' \
- -e 's/@''WCHAR_T_SUFFIX''@/$(WCHAR_T_SUFFIX)/g' \
- -e 's/@''BITSIZEOF_WINT_T''@/$(BITSIZEOF_WINT_T)/g' \
- -e 's/@''HAVE_SIGNED_WINT_T''@/$(HAVE_SIGNED_WINT_T)/g' \
- -e 's/@''WINT_T_SUFFIX''@/$(WINT_T_SUFFIX)/g' \
- -e 's/@''GNULIB_OVERRIDES_WINT_T''@/$(GNULIB_OVERRIDES_WINT_T)/g' \
- < $(srcdir)/stdint.in.h; \
- } > $@-t && \
- mv $@-t $@
-else
-stdint.h: $(top_builddir)/config.status
- rm -f $@
-endif
-MOSTLYCLEANFILES += stdint.h stdint.h-t
-
-EXTRA_DIST += stdint.in.h
-
-## end gnulib module stdint
-
-## begin gnulib module string
-
-BUILT_SOURCES += string.h
-
-# We need the following in order to create <string.h> when the system
-# doesn't have one that works with the given compiler.
-string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
- sed -e 's|@''GUARD_PREFIX''@|GL_LGL|g' \
- -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
- -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
- -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
- -e 's|@''NEXT_STRING_H''@|$(NEXT_STRING_H)|g' \
- -e 's/@''GNULIB_FFSL''@/$(GNULIB_FFSL)/g' \
- -e 's/@''GNULIB_FFSLL''@/$(GNULIB_FFSLL)/g' \
- -e 's/@''GNULIB_MBSLEN''@/$(GNULIB_MBSLEN)/g' \
- -e 's/@''GNULIB_MBSNLEN''@/$(GNULIB_MBSNLEN)/g' \
- -e 's/@''GNULIB_MBSCHR''@/$(GNULIB_MBSCHR)/g' \
- -e 's/@''GNULIB_MBSRCHR''@/$(GNULIB_MBSRCHR)/g' \
- -e 's/@''GNULIB_MBSSTR''@/$(GNULIB_MBSSTR)/g' \
- -e 's/@''GNULIB_MBSCASECMP''@/$(GNULIB_MBSCASECMP)/g' \
- -e 's/@''GNULIB_MBSNCASECMP''@/$(GNULIB_MBSNCASECMP)/g' \
- -e 's/@''GNULIB_MBSPCASECMP''@/$(GNULIB_MBSPCASECMP)/g' \
- -e 's/@''GNULIB_MBSCASESTR''@/$(GNULIB_MBSCASESTR)/g' \
- -e 's/@''GNULIB_MBSCSPN''@/$(GNULIB_MBSCSPN)/g' \
- -e 's/@''GNULIB_MBSPBRK''@/$(GNULIB_MBSPBRK)/g' \
- -e 's/@''GNULIB_MBSSPN''@/$(GNULIB_MBSSPN)/g' \
- -e 's/@''GNULIB_MBSSEP''@/$(GNULIB_MBSSEP)/g' \
- -e 's/@''GNULIB_MBSTOK_R''@/$(GNULIB_MBSTOK_R)/g' \
- -e 's/@''GNULIB_MEMCHR''@/$(GNULIB_MEMCHR)/g' \
- -e 's/@''GNULIB_MEMMEM''@/$(GNULIB_MEMMEM)/g' \
- -e 's/@''GNULIB_MEMPCPY''@/$(GNULIB_MEMPCPY)/g' \
- -e 's/@''GNULIB_MEMRCHR''@/$(GNULIB_MEMRCHR)/g' \
- -e 's/@''GNULIB_RAWMEMCHR''@/$(GNULIB_RAWMEMCHR)/g' \
- -e 's/@''GNULIB_STPCPY''@/$(GNULIB_STPCPY)/g' \
- -e 's/@''GNULIB_STPNCPY''@/$(GNULIB_STPNCPY)/g' \
- -e 's/@''GNULIB_STRCHRNUL''@/$(GNULIB_STRCHRNUL)/g' \
- -e 's/@''GNULIB_STRDUP''@/$(GNULIB_STRDUP)/g' \
- -e 's/@''GNULIB_STRNCAT''@/$(GNULIB_STRNCAT)/g' \
- -e 's/@''GNULIB_STRNDUP''@/$(GNULIB_STRNDUP)/g' \
- -e 's/@''GNULIB_STRNLEN''@/$(GNULIB_STRNLEN)/g' \
- -e 's/@''GNULIB_STRPBRK''@/$(GNULIB_STRPBRK)/g' \
- -e 's/@''GNULIB_STRSEP''@/$(GNULIB_STRSEP)/g' \
- -e 's/@''GNULIB_STRSTR''@/$(GNULIB_STRSTR)/g' \
- -e 's/@''GNULIB_STRCASESTR''@/$(GNULIB_STRCASESTR)/g' \
- -e 's/@''GNULIB_STRTOK_R''@/$(GNULIB_STRTOK_R)/g' \
- -e 's/@''GNULIB_STRERROR''@/$(GNULIB_STRERROR)/g' \
- -e 's/@''GNULIB_STRERROR_R''@/$(GNULIB_STRERROR_R)/g' \
- -e 's/@''GNULIB_STRSIGNAL''@/$(GNULIB_STRSIGNAL)/g' \
- -e 's/@''GNULIB_STRVERSCMP''@/$(GNULIB_STRVERSCMP)/g' \
- < $(srcdir)/string.in.h | \
- sed -e 's|@''HAVE_FFSL''@|$(HAVE_FFSL)|g' \
- -e 's|@''HAVE_FFSLL''@|$(HAVE_FFSLL)|g' \
- -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \
- -e 's|@''HAVE_MEMCHR''@|$(HAVE_MEMCHR)|g' \
- -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \
- -e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \
- -e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \
- -e 's|@''HAVE_RAWMEMCHR''@|$(HAVE_RAWMEMCHR)|g' \
- -e 's|@''HAVE_STPCPY''@|$(HAVE_STPCPY)|g' \
- -e 's|@''HAVE_STPNCPY''@|$(HAVE_STPNCPY)|g' \
- -e 's|@''HAVE_STRCHRNUL''@|$(HAVE_STRCHRNUL)|g' \
- -e 's|@''HAVE_DECL_STRDUP''@|$(HAVE_DECL_STRDUP)|g' \
- -e 's|@''HAVE_DECL_STRNDUP''@|$(HAVE_DECL_STRNDUP)|g' \
- -e 's|@''HAVE_DECL_STRNLEN''@|$(HAVE_DECL_STRNLEN)|g' \
- -e 's|@''HAVE_STRPBRK''@|$(HAVE_STRPBRK)|g' \
- -e 's|@''HAVE_STRSEP''@|$(HAVE_STRSEP)|g' \
- -e 's|@''HAVE_STRCASESTR''@|$(HAVE_STRCASESTR)|g' \
- -e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \
- -e 's|@''HAVE_DECL_STRERROR_R''@|$(HAVE_DECL_STRERROR_R)|g' \
- -e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \
- -e 's|@''HAVE_STRVERSCMP''@|$(HAVE_STRVERSCMP)|g' \
- -e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \
- -e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \
- -e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \
- -e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \
- -e 's|@''REPLACE_STRCHRNUL''@|$(REPLACE_STRCHRNUL)|g' \
- -e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \
- -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \
- -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \
- -e 's|@''REPLACE_STRERROR_R''@|$(REPLACE_STRERROR_R)|g' \
- -e 's|@''REPLACE_STRNCAT''@|$(REPLACE_STRNCAT)|g' \
- -e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \
- -e 's|@''REPLACE_STRNLEN''@|$(REPLACE_STRNLEN)|g' \
- -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \
- -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \
- -e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \
- -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
- -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
- -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
- < $(srcdir)/string.in.h; \
- } > $@-t && \
- mv $@-t $@
-MOSTLYCLEANFILES += string.h string.h-t
-
-EXTRA_DIST += string.in.h
-
-## end gnulib module string
-
-## begin gnulib module strverscmp
-
-
-EXTRA_DIST += strverscmp.c
-
-EXTRA_libgnu_la_SOURCES += strverscmp.c
-
-## end gnulib module strverscmp
-
-## begin gnulib module sys_types
-
-BUILT_SOURCES += sys/types.h
-
-# We need the following in order to create <sys/types.h> when the system
-# doesn't have one that works with the given compiler.
-sys/types.h: sys_types.in.h $(top_builddir)/config.status
- $(AM_V_at)$(MKDIR_P) sys
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''GUARD_PREFIX''@|GL_LGL|g' \
- -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
- -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
- -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
- -e 's|@''NEXT_SYS_TYPES_H''@|$(NEXT_SYS_TYPES_H)|g' \
- -e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \
- < $(srcdir)/sys_types.in.h; \
- } > $@-t && \
- mv $@-t $@
-MOSTLYCLEANFILES += sys/types.h sys/types.h-t
-
-EXTRA_DIST += sys_types.in.h
-
-## end gnulib module sys_types
-
-## begin gnulib module verify
-
-
-EXTRA_DIST += verify.h
-
-## end gnulib module verify
-
-
-mostlyclean-local: mostlyclean-generic
- @for dir in '' $(MOSTLYCLEANDIRS); do \
- if test -n "$$dir" && test -d $$dir; then \
- echo "rmdir $$dir"; rmdir $$dir; \
- fi; \
- done; \
- :
diff --git a/lib/gllib/hash-pjw-bare.c b/lib/gllib/hash-pjw-bare.c
deleted file mode 100644
index df98147..0000000
--- a/lib/gllib/hash-pjw-bare.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/* hash-pjw-bare.c -- compute a hash value from a provided buffer.
-
- Copyright (C) 2012-2017 Free Software Foundation, Inc.
-
- This program 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 program 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/>. */
-
-#include <config.h>
-
-#include "hash-pjw-bare.h"
-
-#include <limits.h>
-
-#define SIZE_BITS (sizeof (size_t) * CHAR_BIT)
-
-/* Return a hash of the N bytes of X using the method described by
- Bruno Haible in http://www.haible.de/bruno/hashfunc.html.
- Note that while many hash functions reduce their result via modulo
- to a 0..table_size-1 range, this function does not do that. */
-
-size_t
-hash_pjw_bare (const void *x, size_t n)
-{
- const unsigned char *s = x;
- size_t h = 0;
- unsigned i;
-
- for (i = 0; i < n; i++)
- h = s[i] + ((h << 9) | (h >> (SIZE_BITS - 9)));
-
- return h;
-}
diff --git a/lib/gllib/hash-pjw-bare.h b/lib/gllib/hash-pjw-bare.h
deleted file mode 100644
index 7b6d92e..0000000
--- a/lib/gllib/hash-pjw-bare.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/* hash-pjw-bare.h -- declaration for a simple hash function
- Copyright (C) 2012-2017 Free Software Foundation, Inc.
-
- This program 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 program 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/>. */
-
-#include <stddef.h>
-
-/* Compute a hash code for a buffer starting at X and of size N,
- and return the hash code. Note that unlike hash_pjw(), it does not
- return it modulo a table size.
- The result is platform dependent: it depends on the size of the 'size_t'
- type. */
-extern size_t hash_pjw_bare (const void *x, size_t n) _GL_ATTRIBUTE_PURE;
diff --git a/lib/gllib/intprops.h b/lib/gllib/intprops.h
deleted file mode 100644
index eb06b69..0000000
--- a/lib/gllib/intprops.h
+++ /dev/null
@@ -1,458 +0,0 @@
-/* intprops.h -- properties of integer types
-
- Copyright (C) 2001-2017 Free Software Foundation, Inc.
-
- This program 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 program 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/>. */
-
-/* Written by Paul Eggert. */
-
-#ifndef _GL_INTPROPS_H
-#define _GL_INTPROPS_H
-
-#include <limits.h>
-#include <verify.h>
-
-/* Return a value with the common real type of E and V and the value of V. */
-#define _GL_INT_CONVERT(e, v) (0 * (e) + (v))
-
-/* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see
- <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00406.html>. */
-#define _GL_INT_NEGATE_CONVERT(e, v) (0 * (e) - (v))
-
-/* The extra casts in the following macros work around compiler bugs,
- e.g., in Cray C 5.0.3.0. */
-
-/* True if the arithmetic type T is an integer type. bool counts as
- an integer. */
-#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
-
-/* True if the real type T is signed. */
-#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
-
-/* Return 1 if the real expression E, after promotion, has a
- signed or floating type. */
-#define EXPR_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0)
-
-
-/* Minimum and maximum values for integer types and expressions. */
-
-/* The width in bits of the integer type or expression T.
- Padding bits are not supported; this is checked at compile-time below. */
-#define TYPE_WIDTH(t) (sizeof (t) * CHAR_BIT)
-
-/* The maximum and minimum values for the integer type T. */
-#define TYPE_MINIMUM(t) ((t) ~ TYPE_MAXIMUM (t))
-#define TYPE_MAXIMUM(t) \
- ((t) (! TYPE_SIGNED (t) \
- ? (t) -1 \
- : ((((t) 1 << (TYPE_WIDTH (t) - 2)) - 1) * 2 + 1)))
-
-/* The maximum and minimum values for the type of the expression E,
- after integer promotion. E should not have side effects. */
-#define _GL_INT_MINIMUM(e) \
- (EXPR_SIGNED (e) \
- ? ~ _GL_SIGNED_INT_MAXIMUM (e) \
- : _GL_INT_CONVERT (e, 0))
-#define _GL_INT_MAXIMUM(e) \
- (EXPR_SIGNED (e) \
- ? _GL_SIGNED_INT_MAXIMUM (e) \
- : _GL_INT_NEGATE_CONVERT (e, 1))
-#define _GL_SIGNED_INT_MAXIMUM(e) \
- (((_GL_INT_CONVERT (e, 1) << (TYPE_WIDTH ((e) + 0) - 2)) - 1) * 2 + 1)
-
-/* Work around OpenVMS incompatibility with C99. */
-#if !defined LLONG_MAX && defined __INT64_MAX
-# define LLONG_MAX __INT64_MAX
-# define LLONG_MIN __INT64_MIN
-#endif
-
-/* This include file assumes that signed types are two's complement without
- padding bits; the above macros have undefined behavior otherwise.
- If this is a problem for you, please let us know how to fix it for your host.
- As a sanity check, test the assumption for some signed types that
- <limits.h> bounds. */
-verify (TYPE_MINIMUM (signed char) == SCHAR_MIN);
-verify (TYPE_MAXIMUM (signed char) == SCHAR_MAX);
-verify (TYPE_MINIMUM (short int) == SHRT_MIN);
-verify (TYPE_MAXIMUM (short int) == SHRT_MAX);
-verify (TYPE_MINIMUM (int) == INT_MIN);
-verify (TYPE_MAXIMUM (int) == INT_MAX);
-verify (TYPE_MINIMUM (long int) == LONG_MIN);
-verify (TYPE_MAXIMUM (long int) == LONG_MAX);
-#ifdef LLONG_MAX
-verify (TYPE_MINIMUM (long long int) == LLONG_MIN);
-verify (TYPE_MAXIMUM (long long int) == LLONG_MAX);
-#endif
-/* Similarly, sanity-check one ISO/IEC TS 18661-1:2014 macro if defined. */
-#ifdef UINT_WIDTH
-verify (TYPE_WIDTH (unsigned int) == UINT_WIDTH);
-#endif
-
-/* Does the __typeof__ keyword work? This could be done by
- 'configure', but for now it's easier to do it by hand. */
-#if (2 <= __GNUC__ \
- || (1210 <= __IBMC__ && defined __IBM__TYPEOF__) \
- || (0x5110 <= __SUNPRO_C && !__STDC__))
-# define _GL_HAVE___TYPEOF__ 1
-#else
-# define _GL_HAVE___TYPEOF__ 0
-#endif
-
-/* Return 1 if the integer type or expression T might be signed. Return 0
- if it is definitely unsigned. This macro does not evaluate its argument,
- and expands to an integer constant expression. */
-#if _GL_HAVE___TYPEOF__
-# define _GL_SIGNED_TYPE_OR_EXPR(t) TYPE_SIGNED (__typeof__ (t))
-#else
-# define _GL_SIGNED_TYPE_OR_EXPR(t) 1
-#endif
-
-/* Bound on length of the string representing an unsigned integer
- value representable in B bits. log10 (2.0) < 146/485. The
- smallest value of B where this bound is not tight is 2621. */
-#define INT_BITS_STRLEN_BOUND(b) (((b) * 146 + 484) / 485)
-
-/* Bound on length of the string representing an integer type or expression T.
- Subtract 1 for the sign bit if T is signed, and then add 1 more for
- a minus sign if needed.
-
- Because _GL_SIGNED_TYPE_OR_EXPR sometimes returns 0 when its argument is
- signed, this macro may overestimate the true bound by one byte when
- applied to unsigned types of size 2, 4, 16, ... bytes. */
-#define INT_STRLEN_BOUND(t) \
- (INT_BITS_STRLEN_BOUND (TYPE_WIDTH (t) - _GL_SIGNED_TYPE_OR_EXPR (t)) \
- + _GL_SIGNED_TYPE_OR_EXPR (t))
-
-/* Bound on buffer size needed to represent an integer type or expression T,
- including the terminating null. */
-#define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1)
-
-
-/* Range overflow checks.
-
- The INT_<op>_RANGE_OVERFLOW macros return 1 if the corresponding C
- operators might not yield numerically correct answers due to
- arithmetic overflow. They do not rely on undefined or
- implementation-defined behavior. Their implementations are simple
- and straightforward, but they are a bit harder to use than the
- INT_<op>_OVERFLOW macros described below.
-
- Example usage:
-
- long int i = ...;
- long int j = ...;
- if (INT_MULTIPLY_RANGE_OVERFLOW (i, j, LONG_MIN, LONG_MAX))
- printf ("multiply would overflow");
- else
- printf ("product is %ld", i * j);
-
- Restrictions on *_RANGE_OVERFLOW macros:
-
- These macros do not check for all possible numerical problems or
- undefined or unspecified behavior: they do not check for division
- by zero, for bad shift counts, or for shifting negative numbers.
-
- These macros may evaluate their arguments zero or multiple times,
- so the arguments should not have side effects. The arithmetic
- arguments (including the MIN and MAX arguments) must be of the same
- integer type after the usual arithmetic conversions, and the type
- must have minimum value MIN and maximum MAX. Unsigned types should
- use a zero MIN of the proper type.
-
- These macros are tuned for constant MIN and MAX. For commutative
- operations such as A + B, they are also tuned for constant B. */
-
-/* Return 1 if A + B would overflow in [MIN,MAX] arithmetic.
- See above for restrictions. */
-#define INT_ADD_RANGE_OVERFLOW(a, b, min, max) \
- ((b) < 0 \
- ? (a) < (min) - (b) \
- : (max) - (b) < (a))
-
-/* Return 1 if A - B would overflow in [MIN,MAX] arithmetic.
- See above for restrictions. */
-#define INT_SUBTRACT_RANGE_OVERFLOW(a, b, min, max) \
- ((b) < 0 \
- ? (max) + (b) < (a) \
- : (a) < (min) + (b))
-
-/* Return 1 if - A would overflow in [MIN,MAX] arithmetic.
- See above for restrictions. */
-#define INT_NEGATE_RANGE_OVERFLOW(a, min, max) \
- ((min) < 0 \
- ? (a) < - (max) \
- : 0 < (a))
-
-/* Return 1 if A * B would overflow in [MIN,MAX] arithmetic.
- See above for restrictions. Avoid && and || as they tickle
- bugs in Sun C 5.11 2010/08/13 and other compilers; see
- <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00401.html>. */
-#define INT_MULTIPLY_RANGE_OVERFLOW(a, b, min, max) \
- ((b) < 0 \
- ? ((a) < 0 \
- ? (a) < (max) / (b) \
- : (b) == -1 \
- ? 0 \
- : (min) / (b) < (a)) \
- : (b) == 0 \
- ? 0 \
- : ((a) < 0 \
- ? (a) < (min) / (b) \
- : (max) / (b) < (a)))
-
-/* Return 1 if A / B would overflow in [MIN,MAX] arithmetic.
- See above for restrictions. Do not check for division by zero. */
-#define INT_DIVIDE_RANGE_OVERFLOW(a, b, min, max) \
- ((min) < 0 && (b) == -1 && (a) < - (max))
-
-/* Return 1 if A % B would overflow in [MIN,MAX] arithmetic.
- See above for restrictions. Do not check for division by zero.
- Mathematically, % should never overflow, but on x86-like hosts
- INT_MIN % -1 traps, and the C standard permits this, so treat this
- as an overflow too. */
-#define INT_REMAINDER_RANGE_OVERFLOW(a, b, min, max) \
- INT_DIVIDE_RANGE_OVERFLOW (a, b, min, max)
-
-/* Return 1 if A << B would overflow in [MIN,MAX] arithmetic.
- See above for restrictions. Here, MIN and MAX are for A only, and B need
- not be of the same type as the other arguments. The C standard says that
- behavior is undefined for shifts unless 0 <= B < wordwidth, and that when
- A is negative then A << B has undefined behavior and A >> B has
- implementation-defined behavior, but do not check these other
- restrictions. */
-#define INT_LEFT_SHIFT_RANGE_OVERFLOW(a, b, min, max) \
- ((a) < 0 \
- ? (a) < (min) >> (b) \
- : (max) >> (b) < (a))
-
-/* True if __builtin_add_overflow (A, B, P) works when P is non-null. */
-#define _GL_HAS_BUILTIN_OVERFLOW (5 <= __GNUC__)
-
-/* True if __builtin_add_overflow_p (A, B, C) works. */
-#define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__)
-
-/* The _GL*_OVERFLOW macros have the same restrictions as the
- *_RANGE_OVERFLOW macros, except that they do not assume that operands
- (e.g., A and B) have the same type as MIN and MAX. Instead, they assume
- that the result (e.g., A + B) has that type. */
-#if _GL_HAS_BUILTIN_OVERFLOW_P
-# define _GL_ADD_OVERFLOW(a, b, min, max) \
- __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)
-# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \
- __builtin_sub_overflow_p (a, b, (__typeof__ ((a) - (b))) 0)
-# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \
- __builtin_mul_overflow_p (a, b, (__typeof__ ((a) * (b))) 0)
-#else
-# define _GL_ADD_OVERFLOW(a, b, min, max) \
- ((min) < 0 ? INT_ADD_RANGE_OVERFLOW (a, b, min, max) \
- : (a) < 0 ? (b) <= (a) + (b) \
- : (b) < 0 ? (a) <= (a) + (b) \
- : (a) + (b) < (b))
-# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \
- ((min) < 0 ? INT_SUBTRACT_RANGE_OVERFLOW (a, b, min, max) \
- : (a) < 0 ? 1 \
- : (b) < 0 ? (a) - (b) <= (a) \
- : (a) < (b))
-# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \
- (((min) == 0 && (((a) < 0 && 0 < (b)) || ((b) < 0 && 0 < (a)))) \
- || INT_MULTIPLY_RANGE_OVERFLOW (a, b, min, max))
-#endif
-#define _GL_DIVIDE_OVERFLOW(a, b, min, max) \
- ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \
- : (a) < 0 ? (b) <= (a) + (b) - 1 \
- : (b) < 0 && (a) + (b) <= (a))
-#define _GL_REMAINDER_OVERFLOW(a, b, min, max) \
- ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \
- : (a) < 0 ? (a) % (b) != ((max) - (b) + 1) % (b) \
- : (b) < 0 && ! _GL_UNSIGNED_NEG_MULTIPLE (a, b, max))
-
-/* Return a nonzero value if A is a mathematical multiple of B, where
- A is unsigned, B is negative, and MAX is the maximum value of A's
- type. A's type must be the same as (A % B)'s type. Normally (A %
- -B == 0) suffices, but things get tricky if -B would overflow. */
-#define _GL_UNSIGNED_NEG_MULTIPLE(a, b, max) \
- (((b) < -_GL_SIGNED_INT_MAXIMUM (b) \
- ? (_GL_SIGNED_INT_MAXIMUM (b) == (max) \
- ? (a) \
- : (a) % (_GL_INT_CONVERT (a, _GL_SIGNED_INT_MAXIMUM (b)) + 1)) \
- : (a) % - (b)) \
- == 0)
-
-/* Check for integer overflow, and report low order bits of answer.
-
- The INT_<op>_OVERFLOW macros return 1 if the corresponding C operators
- might not yield numerically correct answers due to arithmetic overflow.
- The INT_<op>_WRAPV macros also store the low-order bits of the answer.
- These macros work correctly on all known practical hosts, and do not rely
- on undefined behavior due to signed arithmetic overflow.
-
- Example usage, assuming A and B are long int:
-
- if (INT_MULTIPLY_OVERFLOW (a, b))
- printf ("result would overflow\n");
- else
- printf ("result is %ld (no overflow)\n", a * b);
-
- Example usage with WRAPV flavor:
-
- long int result;
- bool overflow = INT_MULTIPLY_WRAPV (a, b, &result);
- printf ("result is %ld (%s)\n", result,
- overflow ? "after overflow" : "no overflow");
-
- Restrictions on these macros:
-
- These macros do not check for all possible numerical problems or
- undefined or unspecified behavior: they do not check for division
- by zero, for bad shift counts, or for shifting negative numbers.
-
- These macros may evaluate their arguments zero or multiple times, so the
- arguments should not have side effects.
-
- The WRAPV macros are not constant expressions. They support only
- +, binary -, and *. The result type must be signed.
-
- These macros are tuned for their last argument being a constant.
-
- Return 1 if the integer expressions A * B, A - B, -A, A * B, A / B,
- A % B, and A << B would overflow, respectively. */
-
-#define INT_ADD_OVERFLOW(a, b) \
- _GL_BINARY_OP_OVERFLOW (a, b, _GL_ADD_OVERFLOW)
-#define INT_SUBTRACT_OVERFLOW(a, b) \
- _GL_BINARY_OP_OVERFLOW (a, b, _GL_SUBTRACT_OVERFLOW)
-#if _GL_HAS_BUILTIN_OVERFLOW_P
-# define INT_NEGATE_OVERFLOW(a) INT_SUBTRACT_OVERFLOW (0, a)
-#else
-# define INT_NEGATE_OVERFLOW(a) \
- INT_NEGATE_RANGE_OVERFLOW (a, _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
-#endif
-#define INT_MULTIPLY_OVERFLOW(a, b) \
- _GL_BINARY_OP_OVERFLOW (a, b, _GL_MULTIPLY_OVERFLOW)
-#define INT_DIVIDE_OVERFLOW(a, b) \
- _GL_BINARY_OP_OVERFLOW (a, b, _GL_DIVIDE_OVERFLOW)
-#define INT_REMAINDER_OVERFLOW(a, b) \
- _GL_BINARY_OP_OVERFLOW (a, b, _GL_REMAINDER_OVERFLOW)
-#define INT_LEFT_SHIFT_OVERFLOW(a, b) \
- INT_LEFT_SHIFT_RANGE_OVERFLOW (a, b, \
- _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
-
-/* Return 1 if the expression A <op> B would overflow,
- where OP_RESULT_OVERFLOW (A, B, MIN, MAX) does the actual test,
- assuming MIN and MAX are the minimum and maximum for the result type.
- Arguments should be free of side effects. */
-#define _GL_BINARY_OP_OVERFLOW(a, b, op_result_overflow) \
- op_result_overflow (a, b, \
- _GL_INT_MINIMUM (0 * (b) + (a)), \
- _GL_INT_MAXIMUM (0 * (b) + (a)))
-
-/* Store the low-order bits of A + B, A - B, A * B, respectively, into *R.
- Return 1 if the result overflows. See above for restrictions. */
-#define INT_ADD_WRAPV(a, b, r) \
- _GL_INT_OP_WRAPV (a, b, r, +, __builtin_add_overflow, INT_ADD_OVERFLOW)
-#define INT_SUBTRACT_WRAPV(a, b, r) \
- _GL_INT_OP_WRAPV (a, b, r, -, __builtin_sub_overflow, INT_SUBTRACT_OVERFLOW)
-#define INT_MULTIPLY_WRAPV(a, b, r) \
- _GL_INT_OP_WRAPV (a, b, r, *, __builtin_mul_overflow, INT_MULTIPLY_OVERFLOW)
-
-/* Nonzero if this compiler has GCC bug 68193 or Clang bug 25390. See:
- https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193
- https://llvm.org/bugs/show_bug.cgi?id=25390
- For now, assume all versions of GCC-like compilers generate bogus
- warnings for _Generic. This matters only for older compilers that
- lack __builtin_add_overflow. */
-#if __GNUC__
-# define _GL__GENERIC_BOGUS 1
-#else
-# define _GL__GENERIC_BOGUS 0
-#endif
-
-/* Store the low-order bits of A <op> B into *R, where OP specifies
- the operation. BUILTIN is the builtin operation, and OVERFLOW the
- overflow predicate. Return 1 if the result overflows. See above
- for restrictions. */
-#if _GL_HAS_BUILTIN_OVERFLOW
-# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) builtin (a, b, r)
-#elif 201112 <= __STDC_VERSION__ && !_GL__GENERIC_BOGUS
-# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) \
- (_Generic \
- (*(r), \
- signed char: \
- _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned char, \
- signed char, SCHAR_MIN, SCHAR_MAX), \
- short int: \
- _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned short int, \
- short int, SHRT_MIN, SHRT_MAX), \
- int: \
- _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
- int, INT_MIN, INT_MAX), \
- long int: \
- _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
- long int, LONG_MIN, LONG_MAX), \
- long long int: \
- _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
- long long int, LLONG_MIN, LLONG_MAX)))
-#else
-# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) \
- (sizeof *(r) == sizeof (signed char) \
- ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned char, \
- signed char, SCHAR_MIN, SCHAR_MAX) \
- : sizeof *(r) == sizeof (short int) \
- ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned short int, \
- short int, SHRT_MIN, SHRT_MAX) \
- : sizeof *(r) == sizeof (int) \
- ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
- int, INT_MIN, INT_MAX) \
- : _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow))
-# ifdef LLONG_MAX
-# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \
- (sizeof *(r) == sizeof (long int) \
- ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
- long int, LONG_MIN, LONG_MAX) \
- : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
- long long int, LLONG_MIN, LLONG_MAX))
-# else
-# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \
- _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
- long int, LONG_MIN, LONG_MAX)
-# endif
-#endif
-
-/* Store the low-order bits of A <op> B into *R, where the operation
- is given by OP. Use the unsigned type UT for calculation to avoid
- overflow problems. *R's type is T, with extremal values TMIN and
- TMAX. T must be a signed integer type. Return 1 if the result
- overflows. */
-#define _GL_INT_OP_CALC(a, b, r, op, overflow, ut, t, tmin, tmax) \
- (sizeof ((a) op (b)) < sizeof (t) \
- ? _GL_INT_OP_CALC1 ((t) (a), (t) (b), r, op, overflow, ut, t, tmin, tmax) \
- : _GL_INT_OP_CALC1 (a, b, r, op, overflow, ut, t, tmin, tmax))
-#define _GL_INT_OP_CALC1(a, b, r, op, overflow, ut, t, tmin, tmax) \
- ((overflow (a, b) \
- || (EXPR_SIGNED ((a) op (b)) && ((a) op (b)) < (tmin)) \
- || (tmax) < ((a) op (b))) \
- ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t, tmin, tmax), 1) \
- : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t, tmin, tmax), 0))
-
-/* Return A <op> B, where the operation is given by OP. Use the
- unsigned type UT for calculation to avoid overflow problems.
- Convert the result to type T without overflow by subtracting TMIN
- from large values before converting, and adding it afterwards.
- Compilers can optimize all the operations except OP. */
-#define _GL_INT_OP_WRAPV_VIA_UNSIGNED(a, b, op, ut, t, tmin, tmax) \
- (((ut) (a) op (ut) (b)) <= (tmax) \
- ? (t) ((ut) (a) op (ut) (b)) \
- : ((t) (((ut) (a) op (ut) (b)) - (tmin)) + (tmin)))
-
-#endif /* _GL_INTPROPS_H */
diff --git a/lib/gllib/limits.in.h b/lib/gllib/limits.in.h
deleted file mode 100644
index 02faeb6..0000000
--- a/lib/gllib/limits.in.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* A GNU-like <limits.h>.
-
- Copyright 2016-2017 Free Software Foundation, Inc.
-
- This program 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, or
- (at your option) any later version.
-
- This program 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 _@GUARD_PREFIX@_LIMITS_H
-
-#if __GNUC__ >= 3
-@PRAGMA_SYSTEM_HEADER@
-#endif
-@PRAGMA_COLUMNS@
-
-/* The include_next requires a split double-inclusion guard. */
-#@INCLUDE_NEXT@ @NEXT_LIMITS_H@
-
-#ifndef _@GUARD_PREFIX@_LIMITS_H
-#define _@GUARD_PREFIX@_LIMITS_H
-
-/* The number of usable bits in an unsigned or signed integer type
- with minimum value MIN and maximum value MAX, as an int expression
- suitable in #if. Cover all known practical hosts. This
- implementation exploits the fact that MAX is 1 less than a power of
- 2, and merely counts the number of 1 bits in MAX; "COBn" means
- "count the number of 1 bits in the low-order n bits"). */
-#define _GL_INTEGER_WIDTH(min, max) (((min) < 0) + _GL_COB128 (max))
-#define _GL_COB128(n) (_GL_COB64 ((n) >> 31 >> 31 >> 2) + _GL_COB64 (n))
-#define _GL_COB64(n) (_GL_COB32 ((n) >> 31 >> 1) + _GL_COB32 (n))
-#define _GL_COB32(n) (_GL_COB16 ((n) >> 16) + _GL_COB16 (n))
-#define _GL_COB16(n) (_GL_COB8 ((n) >> 8) + _GL_COB8 (n))
-#define _GL_COB8(n) (_GL_COB4 ((n) >> 4) + _GL_COB4 (n))
-#define _GL_COB4(n) (!!((n) & 8) + !!((n) & 4) + !!((n) & 2) + !!((n) & 1))
-
-/* Macros specified by ISO/IEC TS 18661-1:2014. */
-
-#if (! defined ULLONG_WIDTH \
- && (defined _GNU_SOURCE || defined __STDC_WANT_IEC_60559_BFP_EXT__))
-# define CHAR_WIDTH _GL_INTEGER_WIDTH (CHAR_MIN, CHAR_MAX)
-# define SCHAR_WIDTH _GL_INTEGER_WIDTH (SCHAR_MIN, SCHAR_MAX)
-# define UCHAR_WIDTH _GL_INTEGER_WIDTH (0, UCHAR_MAX)
-# define SHRT_WIDTH _GL_INTEGER_WIDTH (SHRT_MIN, SHRT_MAX)
-# define USHRT_WIDTH _GL_INTEGER_WIDTH (0, USHRT_MAX)
-# define INT_WIDTH _GL_INTEGER_WIDTH (INT_MIN, INT_MAX)
-# define UINT_WIDTH _GL_INTEGER_WIDTH (0, UINT_MAX)
-# define LONG_WIDTH _GL_INTEGER_WIDTH (LONG_MIN, LONG_MAX)
-# define ULONG_WIDTH _GL_INTEGER_WIDTH (0, ULONG_MAX)
-# define LLONG_WIDTH _GL_INTEGER_WIDTH (LLONG_MIN, LLONG_MAX)
-# define ULLONG_WIDTH _GL_INTEGER_WIDTH (0, ULLONG_MAX)
-#endif /* !ULLONG_WIDTH && (_GNU_SOURCE || __STDC_WANT_IEC_60559_BFP_EXT__) */
-
-#endif /* _@GUARD_PREFIX@_LIMITS_H */
-#endif /* _@GUARD_PREFIX@_LIMITS_H */
diff --git a/lib/gllib/minmax.h b/lib/gllib/minmax.h
deleted file mode 100644
index c5344c4..0000000
--- a/lib/gllib/minmax.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* MIN, MAX macros.
- Copyright (C) 1995, 1998, 2001, 2003, 2005, 2009-2017 Free Software
- Foundation, Inc.
-
- This program 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, or (at your option)
- any later version.
-
- This program 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 _MINMAX_H
-#define _MINMAX_H
-
-/* Note: MIN, MAX are also defined in <sys/param.h> on some systems
- (glibc, IRIX, HP-UX, OSF/1). Therefore you might get warnings about
- MIN, MAX macro redefinitions on some systems; the workaround is to
- #include this file as the last one among the #include list. */
-
-/* Before we define the following symbols we get the <limits.h> file
- since otherwise we get redefinitions on some systems if <limits.h> is
- included after this file. Likewise for <sys/param.h>.
- If more than one of these system headers define MIN and MAX, pick just
- one of the headers (because the definitions most likely are the same). */
-#if HAVE_MINMAX_IN_LIMITS_H
-# include <limits.h>
-#elif HAVE_MINMAX_IN_SYS_PARAM_H
-# include <sys/param.h>
-#endif
-
-/* Note: MIN and MAX should be used with two arguments of the
- same type. They might not return the minimum and maximum of their two
- arguments, if the arguments have different types or have unusual
- floating-point values. For example, on a typical host with 32-bit 'int',
- 64-bit 'long long', and 64-bit IEEE 754 'double' types:
-
- MAX (-1, 2147483648) returns 4294967295.
- MAX (9007199254740992.0, 9007199254740993) returns 9007199254740992.0.
- MAX (NaN, 0.0) returns 0.0.
- MAX (+0.0, -0.0) returns -0.0.
-
- and in each case the answer is in some sense bogus. */
-
-/* MAX(a,b) returns the maximum of A and B. */
-#ifndef MAX
-# define MAX(a,b) ((a) > (b) ? (a) : (b))
-#endif
-
-/* MIN(a,b) returns the minimum of A and B. */
-#ifndef MIN
-# define MIN(a,b) ((a) < (b) ? (a) : (b))
-#endif
-
-#endif /* _MINMAX_H */
diff --git a/lib/gllib/stddef.in.h b/lib/gllib/stddef.in.h
deleted file mode 100644
index c828192..0000000
--- a/lib/gllib/stddef.in.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues.
-
- Copyright (C) 2009-2017 Free Software Foundation, Inc.
-
- This program 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, or (at your option)
- any later version.
-
- This program 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/>. */
-
-/* Written by Eric Blake. */
-
-/*
- * POSIX 2008 <stddef.h> for platforms that have issues.
- * <http://www.opengroup.org/susv3xbd/stddef.h.html>
- */
-
-#if __GNUC__ >= 3
-@PRAGMA_SYSTEM_HEADER@
-#endif
-@PRAGMA_COLUMNS@
-
-#if defined __need_wchar_t || defined __need_size_t \
- || defined __need_ptrdiff_t || defined __need_NULL \
- || defined __need_wint_t
-/* Special invocation convention inside gcc header files. In
- particular, gcc provides a version of <stddef.h> that blindly
- redefines NULL even when __need_wint_t was defined, even though
- wint_t is not normally provided by <stddef.h>. Hence, we must
- remember if special invocation has ever been used to obtain wint_t,
- in which case we need to clean up NULL yet again. */
-
-# if !(defined _@GUARD_PREFIX@_STDDEF_H && defined _GL_STDDEF_WINT_T)
-# ifdef __need_wint_t
-# define _GL_STDDEF_WINT_T
-# endif
-# @INCLUDE_NEXT@ @NEXT_STDDEF_H@
-# endif
-
-#else
-/* Normal invocation convention. */
-
-# ifndef _@GUARD_PREFIX@_STDDEF_H
-
-/* The include_next requires a split double-inclusion guard. */
-
-# @INCLUDE_NEXT@ @NEXT_STDDEF_H@
-
-/* On NetBSD 5.0, the definition of NULL lacks proper parentheses. */
-# if (@REPLACE_NULL@ \
- && (!defined _@GUARD_PREFIX@_STDDEF_H || defined _GL_STDDEF_WINT_T))
-# undef NULL
-# ifdef __cplusplus
- /* ISO C++ says that the macro NULL must expand to an integer constant
- expression, hence '((void *) 0)' is not allowed in C++. */
-# if __GNUG__ >= 3
- /* GNU C++ has a __null macro that behaves like an integer ('int' or
- 'long') but has the same size as a pointer. Use that, to avoid
- warnings. */
-# define NULL __null
-# else
-# define NULL 0L
-# endif
-# else
-# define NULL ((void *) 0)
-# endif
-# endif
-
-# ifndef _@GUARD_PREFIX@_STDDEF_H
-# define _@GUARD_PREFIX@_STDDEF_H
-
-/* Some platforms lack wchar_t. */
-#if !@HAVE_WCHAR_T@
-# define wchar_t int
-#endif
-
-/* Some platforms lack max_align_t. The check for _GCC_MAX_ALIGN_T is
- a hack in case the configure-time test was done with g++ even though
- we are currently compiling with gcc. */
-#if ! (@HAVE_MAX_ALIGN_T@ || defined _GCC_MAX_ALIGN_T)
-/* On the x86, the maximum storage alignment of double, long, etc. is 4,
- but GCC's C11 ABI for x86 says that max_align_t has an alignment of 8,
- and the C11 standard allows this. Work around this problem by
- using __alignof__ (which returns 8 for double) rather than _Alignof
- (which returns 4), and align each union member accordingly. */
-# ifdef __GNUC__
-# define _GL_STDDEF_ALIGNAS(type) \
- __attribute__ ((__aligned__ (__alignof__ (type))))
-# else
-# define _GL_STDDEF_ALIGNAS(type) /* */
-# endif
-typedef union
-{
- char *__p _GL_STDDEF_ALIGNAS (char *);
- double __d _GL_STDDEF_ALIGNAS (double);
- long double __ld _GL_STDDEF_ALIGNAS (long double);
- long int __i _GL_STDDEF_ALIGNAS (long int);
-} max_align_t;
-#endif
-
-# endif /* _@GUARD_PREFIX@_STDDEF_H */
-# endif /* _@GUARD_PREFIX@_STDDEF_H */
-#endif /* __need_XXX */
diff --git a/lib/gllib/stdint.in.h b/lib/gllib/stdint.in.h
deleted file mode 100644
index 1251a92..0000000
--- a/lib/gllib/stdint.in.h
+++ /dev/null
@@ -1,707 +0,0 @@
-/* Copyright (C) 2001-2002, 2004-2017 Free Software Foundation, Inc.
- Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood.
- This file is part of gnulib.
-
- This program 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, or (at your option)
- any later version.
-
- This program 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/>. */
-
-/*
- * ISO C 99 <stdint.h> for platforms that lack it.
- * <http://www.opengroup.org/susv3xbd/stdint.h.html>
- */
-
-#ifndef _@GUARD_PREFIX@_STDINT_H
-
-#if __GNUC__ >= 3
-@PRAGMA_SYSTEM_HEADER@
-#endif
-@PRAGMA_COLUMNS@
-
-/* When including a system file that in turn includes <inttypes.h>,
- use the system <inttypes.h>, not our substitute. This avoids
- problems with (for example) VMS, whose <sys/bitypes.h> includes
- <inttypes.h>. */
-#define _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
-
-/* On Android (Bionic libc), <sys/types.h> includes this file before
- having defined 'time_t'. Therefore in this case avoid including
- other system header files; just include the system's <stdint.h>.
- Ideally we should test __BIONIC__ here, but it is only defined after
- <sys/cdefs.h> has been included; hence test __ANDROID__ instead. */
-#if defined __ANDROID__ && defined _GL_INCLUDING_SYS_TYPES_H
-# @INCLUDE_NEXT@ @NEXT_STDINT_H@
-#else
-
-/* Get those types that are already defined in other system include
- files, so that we can "#define int8_t signed char" below without
- worrying about a later system include file containing a "typedef
- signed char int8_t;" that will get messed up by our macro. Our
- macros should all be consistent with the system versions, except
- for the "fast" types and macros, which we recommend against using
- in public interfaces due to compiler differences. */
-
-#if @HAVE_STDINT_H@
-# if defined __sgi && ! defined __c99
- /* Bypass IRIX's <stdint.h> if in C89 mode, since it merely annoys users
- with "This header file is to be used only for c99 mode compilations"
- diagnostics. */
-# define __STDINT_H__
-# endif
-
- /* Some pre-C++11 <stdint.h> implementations need this. */
-# ifdef __cplusplus
-# ifndef __STDC_CONSTANT_MACROS
-# define __STDC_CONSTANT_MACROS 1
-# endif
-# ifndef __STDC_LIMIT_MACROS
-# define __STDC_LIMIT_MACROS 1
-# endif
-# endif
-
- /* Other systems may have an incomplete or buggy <stdint.h>.
- Include it before <inttypes.h>, since any "#include <stdint.h>"
- in <inttypes.h> would reinclude us, skipping our contents because
- _@GUARD_PREFIX@_STDINT_H is defined.
- The include_next requires a split double-inclusion guard. */
-# @INCLUDE_NEXT@ @NEXT_STDINT_H@
-#endif
-
-#if ! defined _@GUARD_PREFIX@_STDINT_H && ! defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H
-#define _@GUARD_PREFIX@_STDINT_H
-
-/* Get SCHAR_MIN, SCHAR_MAX, UCHAR_MAX, INT_MIN, INT_MAX,
- LONG_MIN, LONG_MAX, ULONG_MAX, _GL_INTEGER_WIDTH. */
-#include <limits.h>
-
-/* Override WINT_MIN and WINT_MAX if gnulib's <wchar.h> or <wctype.h> overrides
- wint_t. */
-#if @GNULIB_OVERRIDES_WINT_T@
-# undef WINT_MIN
-# undef WINT_MAX
-# define WINT_MIN 0x0U
-# define WINT_MAX 0xffffffffU
-#endif
-
-#if ! @HAVE_C99_STDINT_H@
-
-/* <sys/types.h> defines some of the stdint.h types as well, on glibc,
- IRIX 6.5, and OpenBSD 3.8 (via <machine/types.h>).
- AIX 5.2 <sys/types.h> isn't needed and causes troubles.
- Mac OS X 10.4.6 <sys/types.h> includes <stdint.h> (which is us), but
- relies on the system <stdint.h> definitions, so include
- <sys/types.h> after @NEXT_STDINT_H@. */
-# if @HAVE_SYS_TYPES_H@ && ! defined _AIX
-# include <sys/types.h>
-# endif
-
-# if @HAVE_INTTYPES_H@
- /* In OpenBSD 3.8, <inttypes.h> includes <machine/types.h>, which defines
- int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__.
- <inttypes.h> also defines intptr_t and uintptr_t. */
-# include <inttypes.h>
-# elif @HAVE_SYS_INTTYPES_H@
- /* Solaris 7 <sys/inttypes.h> has the types except the *_fast*_t types, and
- the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX. */
-# include <sys/inttypes.h>
-# endif
-
-# if @HAVE_SYS_BITYPES_H@ && ! defined __BIT_TYPES_DEFINED__
- /* Linux libc4 >= 4.6.7 and libc5 have a <sys/bitypes.h> that defines
- int{8,16,32,64}_t and __BIT_TYPES_DEFINED__. In libc5 >= 5.2.2 it is
- included by <sys/types.h>. */
-# include <sys/bitypes.h>
-# endif
-
-# undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
-
-/* Minimum and maximum values for an integer type under the usual assumption.
- Return an unspecified value if BITS == 0, adding a check to pacify
- picky compilers. */
-
-# define _STDINT_MIN(signed, bits, zero) \
- ((signed) ? ~ _STDINT_MAX (signed, bits, zero) : (zero))
-
-# define _STDINT_MAX(signed, bits, zero) \
- (((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1)
-
-#if !GNULIB_defined_stdint_types
-
-/* 7.18.1.1. Exact-width integer types */
-
-/* Here we assume a standard architecture where the hardware integer
- types have 8, 16, 32, optionally 64 bits. */
-
-# undef int8_t
-# undef uint8_t
-typedef signed char gl_int8_t;
-typedef unsigned char gl_uint8_t;
-# define int8_t gl_int8_t
-# define uint8_t gl_uint8_t
-
-# undef int16_t
-# undef uint16_t
-typedef short int gl_int16_t;
-typedef unsigned short int gl_uint16_t;
-# define int16_t gl_int16_t
-# define uint16_t gl_uint16_t
-
-# undef int32_t
-# undef uint32_t
-typedef int gl_int32_t;
-typedef unsigned int gl_uint32_t;
-# define int32_t gl_int32_t
-# define uint32_t gl_uint32_t
-
-/* If the system defines INT64_MAX, assume int64_t works. That way,
- if the underlying platform defines int64_t to be a 64-bit long long
- int, the code below won't mistakenly define it to be a 64-bit long
- int, which would mess up C++ name mangling. We must use #ifdef
- rather than #if, to avoid an error with HP-UX 10.20 cc. */
-
-# ifdef INT64_MAX
-# define GL_INT64_T
-# else
-/* Do not undefine int64_t if gnulib is not being used with 64-bit
- types, since otherwise it breaks platforms like Tandem/NSK. */
-# if LONG_MAX >> 31 >> 31 == 1
-# undef int64_t
-typedef long int gl_int64_t;
-# define int64_t gl_int64_t
-# define GL_INT64_T
-# elif defined _MSC_VER
-# undef int64_t
-typedef __int64 gl_int64_t;
-# define int64_t gl_int64_t
-# define GL_INT64_T
-# elif @HAVE_LONG_LONG_INT@
-# undef int64_t
-typedef long long int gl_int64_t;
-# define int64_t gl_int64_t
-# define GL_INT64_T
-# endif
-# endif
-
-# ifdef UINT64_MAX
-# define GL_UINT64_T
-# else
-# if ULONG_MAX >> 31 >> 31 >> 1 == 1
-# undef uint64_t
-typedef unsigned long int gl_uint64_t;
-# define uint64_t gl_uint64_t
-# define GL_UINT64_T
-# elif defined _MSC_VER
-# undef uint64_t
-typedef unsigned __int64 gl_uint64_t;
-# define uint64_t gl_uint64_t
-# define GL_UINT64_T
-# elif @HAVE_UNSIGNED_LONG_LONG_INT@
-# undef uint64_t
-typedef unsigned long long int gl_uint64_t;
-# define uint64_t gl_uint64_t
-# define GL_UINT64_T
-# endif
-# endif
-
-/* Avoid collision with Solaris 2.5.1 <pthread.h> etc. */
-# define _UINT8_T
-# define _UINT32_T
-# define _UINT64_T
-
-
-/* 7.18.1.2. Minimum-width integer types */
-
-/* Here we assume a standard architecture where the hardware integer
- types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
- are the same as the corresponding N_t types. */
-
-# undef int_least8_t
-# undef uint_least8_t
-# undef int_least16_t
-# undef uint_least16_t
-# undef int_least32_t
-# undef uint_least32_t
-# undef int_least64_t
-# undef uint_least64_t
-# define int_least8_t int8_t
-# define uint_least8_t uint8_t
-# define int_least16_t int16_t
-# define uint_least16_t uint16_t
-# define int_least32_t int32_t
-# define uint_least32_t uint32_t
-# ifdef GL_INT64_T
-# define int_least64_t int64_t
-# endif
-# ifdef GL_UINT64_T
-# define uint_least64_t uint64_t
-# endif
-
-/* 7.18.1.3. Fastest minimum-width integer types */
-
-/* Note: Other <stdint.h> substitutes may define these types differently.
- It is not recommended to use these types in public header files. */
-
-/* Here we assume a standard architecture where the hardware integer
- types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
- are taken from the same list of types. The following code normally
- uses types consistent with glibc, as that lessens the chance of
- incompatibility with older GNU hosts. */
-
-# undef int_fast8_t
-# undef uint_fast8_t
-# undef int_fast16_t
-# undef uint_fast16_t
-# undef int_fast32_t
-# undef uint_fast32_t
-# undef int_fast64_t
-# undef uint_fast64_t
-typedef signed char gl_int_fast8_t;
-typedef unsigned char gl_uint_fast8_t;
-
-# ifdef __sun
-/* Define types compatible with SunOS 5.10, so that code compiled under
- earlier SunOS versions works with code compiled under SunOS 5.10. */
-typedef int gl_int_fast32_t;
-typedef unsigned int gl_uint_fast32_t;
-# else
-typedef long int gl_int_fast32_t;
-typedef unsigned long int gl_uint_fast32_t;
-# endif
-typedef gl_int_fast32_t gl_int_fast16_t;
-typedef gl_uint_fast32_t gl_uint_fast16_t;
-
-# define int_fast8_t gl_int_fast8_t
-# define uint_fast8_t gl_uint_fast8_t
-# define int_fast16_t gl_int_fast16_t
-# define uint_fast16_t gl_uint_fast16_t
-# define int_fast32_t gl_int_fast32_t
-# define uint_fast32_t gl_uint_fast32_t
-# ifdef GL_INT64_T
-# define int_fast64_t int64_t
-# endif
-# ifdef GL_UINT64_T
-# define uint_fast64_t uint64_t
-# endif
-
-/* 7.18.1.4. Integer types capable of holding object pointers */
-
-/* kLIBC's stdint.h defines _INTPTR_T_DECLARED and needs its own
- definitions of intptr_t and uintptr_t (which use int and unsigned)
- to avoid clashes with declarations of system functions like sbrk. */
-# ifndef _INTPTR_T_DECLARED
-# undef intptr_t
-# undef uintptr_t
-typedef long int gl_intptr_t;
-typedef unsigned long int gl_uintptr_t;
-# define intptr_t gl_intptr_t
-# define uintptr_t gl_uintptr_t
-# endif
-
-/* 7.18.1.5. Greatest-width integer types */
-
-/* Note: These types are compiler dependent. It may be unwise to use them in
- public header files. */
-
-/* If the system defines INTMAX_MAX, assume that intmax_t works, and
- similarly for UINTMAX_MAX and uintmax_t. This avoids problems with
- assuming one type where another is used by the system. */
-
-# ifndef INTMAX_MAX
-# undef INTMAX_C
-# undef intmax_t
-# if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
-typedef long long int gl_intmax_t;
-# define intmax_t gl_intmax_t
-# elif defined GL_INT64_T
-# define intmax_t int64_t
-# else
-typedef long int gl_intmax_t;
-# define intmax_t gl_intmax_t
-# endif
-# endif
-
-# ifndef UINTMAX_MAX
-# undef UINTMAX_C
-# undef uintmax_t
-# if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
-typedef unsigned long long int gl_uintmax_t;
-# define uintmax_t gl_uintmax_t
-# elif defined GL_UINT64_T
-# define uintmax_t uint64_t
-# else
-typedef unsigned long int gl_uintmax_t;
-# define uintmax_t gl_uintmax_t
-# endif
-# endif
-
-/* Verify that intmax_t and uintmax_t have the same size. Too much code
- breaks if this is not the case. If this check fails, the reason is likely
- to be found in the autoconf macros. */
-typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
- ? 1 : -1];
-
-# define GNULIB_defined_stdint_types 1
-# endif /* !GNULIB_defined_stdint_types */
-
-/* 7.18.2. Limits of specified-width integer types */
-
-/* 7.18.2.1. Limits of exact-width integer types */
-
-/* Here we assume a standard architecture where the hardware integer
- types have 8, 16, 32, optionally 64 bits. */
-
-# undef INT8_MIN
-# undef INT8_MAX
-# undef UINT8_MAX
-# define INT8_MIN (~ INT8_MAX)
-# define INT8_MAX 127
-# define UINT8_MAX 255
-
-# undef INT16_MIN
-# undef INT16_MAX
-# undef UINT16_MAX
-# define INT16_MIN (~ INT16_MAX)
-# define INT16_MAX 32767
-# define UINT16_MAX 65535
-
-# undef INT32_MIN
-# undef INT32_MAX
-# undef UINT32_MAX
-# define INT32_MIN (~ INT32_MAX)
-# define INT32_MAX 2147483647
-# define UINT32_MAX 4294967295U
-
-# if defined GL_INT64_T && ! defined INT64_MAX
-/* Prefer (- INTMAX_C (1) << 63) over (~ INT64_MAX) because SunPRO C 5.0
- evaluates the latter incorrectly in preprocessor expressions. */
-# define INT64_MIN (- INTMAX_C (1) << 63)
-# define INT64_MAX INTMAX_C (9223372036854775807)
-# endif
-
-# if defined GL_UINT64_T && ! defined UINT64_MAX
-# define UINT64_MAX UINTMAX_C (18446744073709551615)
-# endif
-
-/* 7.18.2.2. Limits of minimum-width integer types */
-
-/* Here we assume a standard architecture where the hardware integer
- types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
- are the same as the corresponding N_t types. */
-
-# undef INT_LEAST8_MIN
-# undef INT_LEAST8_MAX
-# undef UINT_LEAST8_MAX
-# define INT_LEAST8_MIN INT8_MIN
-# define INT_LEAST8_MAX INT8_MAX
-# define UINT_LEAST8_MAX UINT8_MAX
-
-# undef INT_LEAST16_MIN
-# undef INT_LEAST16_MAX
-# undef UINT_LEAST16_MAX
-# define INT_LEAST16_MIN INT16_MIN
-# define INT_LEAST16_MAX INT16_MAX
-# define UINT_LEAST16_MAX UINT16_MAX
-
-# undef INT_LEAST32_MIN
-# undef INT_LEAST32_MAX
-# undef UINT_LEAST32_MAX
-# define INT_LEAST32_MIN INT32_MIN
-# define INT_LEAST32_MAX INT32_MAX
-# define UINT_LEAST32_MAX UINT32_MAX
-
-# undef INT_LEAST64_MIN
-# undef INT_LEAST64_MAX
-# ifdef GL_INT64_T
-# define INT_LEAST64_MIN INT64_MIN
-# define INT_LEAST64_MAX INT64_MAX
-# endif
-
-# undef UINT_LEAST64_MAX
-# ifdef GL_UINT64_T
-# define UINT_LEAST64_MAX UINT64_MAX
-# endif
-
-/* 7.18.2.3. Limits of fastest minimum-width integer types */
-
-/* Here we assume a standard architecture where the hardware integer
- types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
- are taken from the same list of types. */
-
-# undef INT_FAST8_MIN
-# undef INT_FAST8_MAX
-# undef UINT_FAST8_MAX
-# define INT_FAST8_MIN SCHAR_MIN
-# define INT_FAST8_MAX SCHAR_MAX
-# define UINT_FAST8_MAX UCHAR_MAX
-
-# undef INT_FAST16_MIN
-# undef INT_FAST16_MAX
-# undef UINT_FAST16_MAX
-# define INT_FAST16_MIN INT_FAST32_MIN
-# define INT_FAST16_MAX INT_FAST32_MAX
-# define UINT_FAST16_MAX UINT_FAST32_MAX
-
-# undef INT_FAST32_MIN
-# undef INT_FAST32_MAX
-# undef UINT_FAST32_MAX
-# ifdef __sun
-# define INT_FAST32_MIN INT_MIN
-# define INT_FAST32_MAX INT_MAX
-# define UINT_FAST32_MAX UINT_MAX
-# else
-# define INT_FAST32_MIN LONG_MIN
-# define INT_FAST32_MAX LONG_MAX
-# define UINT_FAST32_MAX ULONG_MAX
-# endif
-
-# undef INT_FAST64_MIN
-# undef INT_FAST64_MAX
-# ifdef GL_INT64_T
-# define INT_FAST64_MIN INT64_MIN
-# define INT_FAST64_MAX INT64_MAX
-# endif
-
-# undef UINT_FAST64_MAX
-# ifdef GL_UINT64_T
-# define UINT_FAST64_MAX UINT64_MAX
-# endif
-
-/* 7.18.2.4. Limits of integer types capable of holding object pointers */
-
-# undef INTPTR_MIN
-# undef INTPTR_MAX
-# undef UINTPTR_MAX
-# define INTPTR_MIN LONG_MIN
-# define INTPTR_MAX LONG_MAX
-# define UINTPTR_MAX ULONG_MAX
-
-/* 7.18.2.5. Limits of greatest-width integer types */
-
-# ifndef INTMAX_MAX
-# undef INTMAX_MIN
-# ifdef INT64_MAX
-# define INTMAX_MIN INT64_MIN
-# define INTMAX_MAX INT64_MAX
-# else
-# define INTMAX_MIN INT32_MIN
-# define INTMAX_MAX INT32_MAX
-# endif
-# endif
-
-# ifndef UINTMAX_MAX
-# ifdef UINT64_MAX
-# define UINTMAX_MAX UINT64_MAX
-# else
-# define UINTMAX_MAX UINT32_MAX
-# endif
-# endif
-
-/* 7.18.3. Limits of other integer types */
-
-/* ptrdiff_t limits */
-# undef PTRDIFF_MIN
-# undef PTRDIFF_MAX
-# if @APPLE_UNIVERSAL_BUILD@
-# ifdef _LP64
-# define PTRDIFF_MIN _STDINT_MIN (1, 64, 0l)
-# define PTRDIFF_MAX _STDINT_MAX (1, 64, 0l)
-# else
-# define PTRDIFF_MIN _STDINT_MIN (1, 32, 0)
-# define PTRDIFF_MAX _STDINT_MAX (1, 32, 0)
-# endif
-# else
-# define PTRDIFF_MIN \
- _STDINT_MIN (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@)
-# define PTRDIFF_MAX \
- _STDINT_MAX (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@)
-# endif
-
-/* sig_atomic_t limits */
-# undef SIG_ATOMIC_MIN
-# undef SIG_ATOMIC_MAX
-# define SIG_ATOMIC_MIN \
- _STDINT_MIN (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \
- 0@SIG_ATOMIC_T_SUFFIX@)
-# define SIG_ATOMIC_MAX \
- _STDINT_MAX (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \
- 0@SIG_ATOMIC_T_SUFFIX@)
-
-
-/* size_t limit */
-# undef SIZE_MAX
-# if @APPLE_UNIVERSAL_BUILD@
-# ifdef _LP64
-# define SIZE_MAX _STDINT_MAX (0, 64, 0ul)
-# else
-# define SIZE_MAX _STDINT_MAX (0, 32, 0ul)
-# endif
-# else
-# define SIZE_MAX _STDINT_MAX (0, @BITSIZEOF_SIZE_T@, 0@SIZE_T_SUFFIX@)
-# endif
-
-/* wchar_t limits */
-/* Get WCHAR_MIN, WCHAR_MAX.
- This include is not on the top, above, because on OSF/1 4.0 we have a
- sequence of nested includes
- <wchar.h> -> <stdio.h> -> <getopt.h> -> <stdlib.h>, and the latter includes
- <stdint.h> and assumes its types are already defined. */
-# if @HAVE_WCHAR_H@ && ! (defined WCHAR_MIN && defined WCHAR_MAX)
- /* BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
- included before <wchar.h>. */
-# include <stddef.h>
-# include <stdio.h>
-# include <time.h>
-# define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H
-# include <wchar.h>
-# undef _GL_JUST_INCLUDE_SYSTEM_WCHAR_H
-# endif
-# undef WCHAR_MIN
-# undef WCHAR_MAX
-# define WCHAR_MIN \
- _STDINT_MIN (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@)
-# define WCHAR_MAX \
- _STDINT_MAX (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@)
-
-/* wint_t limits */
-# undef WINT_MIN
-# undef WINT_MAX
-# define WINT_MIN \
- _STDINT_MIN (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@)
-# define WINT_MAX \
- _STDINT_MAX (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@)
-
-/* 7.18.4. Macros for integer constants */
-
-/* 7.18.4.1. Macros for minimum-width integer constants */
-/* According to ISO C 99 Technical Corrigendum 1 */
-
-/* Here we assume a standard architecture where the hardware integer
- types have 8, 16, 32, optionally 64 bits, and int is 32 bits. */
-
-# undef INT8_C
-# undef UINT8_C
-# define INT8_C(x) x
-# define UINT8_C(x) x
-
-# undef INT16_C
-# undef UINT16_C
-# define INT16_C(x) x
-# define UINT16_C(x) x
-
-# undef INT32_C
-# undef UINT32_C
-# define INT32_C(x) x
-# define UINT32_C(x) x ## U
-
-# undef INT64_C
-# undef UINT64_C
-# if LONG_MAX >> 31 >> 31 == 1
-# define INT64_C(x) x##L
-# elif defined _MSC_VER
-# define INT64_C(x) x##i64
-# elif @HAVE_LONG_LONG_INT@
-# define INT64_C(x) x##LL
-# endif
-# if ULONG_MAX >> 31 >> 31 >> 1 == 1
-# define UINT64_C(x) x##UL
-# elif defined _MSC_VER
-# define UINT64_C(x) x##ui64
-# elif @HAVE_UNSIGNED_LONG_LONG_INT@
-# define UINT64_C(x) x##ULL
-# endif
-
-/* 7.18.4.2. Macros for greatest-width integer constants */
-
-# ifndef INTMAX_C
-# if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
-# define INTMAX_C(x) x##LL
-# elif defined GL_INT64_T
-# define INTMAX_C(x) INT64_C(x)
-# else
-# define INTMAX_C(x) x##L
-# endif
-# endif
-
-# ifndef UINTMAX_C
-# if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
-# define UINTMAX_C(x) x##ULL
-# elif defined GL_UINT64_T
-# define UINTMAX_C(x) UINT64_C(x)
-# else
-# define UINTMAX_C(x) x##UL
-# endif
-# endif
-
-#endif /* !@HAVE_C99_STDINT_H@ */
-
-/* Macros specified by ISO/IEC TS 18661-1:2014. */
-
-#if (!defined UINTMAX_WIDTH \
- && (defined _GNU_SOURCE || defined __STDC_WANT_IEC_60559_BFP_EXT__))
-# ifdef INT8_MAX
-# define INT8_WIDTH _GL_INTEGER_WIDTH (INT8_MIN, INT8_MAX)
-# endif
-# ifdef UINT8_MAX
-# define UINT8_WIDTH _GL_INTEGER_WIDTH (0, UINT8_MAX)
-# endif
-# ifdef INT16_MAX
-# define INT16_WIDTH _GL_INTEGER_WIDTH (INT16_MIN, INT16_MAX)
-# endif
-# ifdef UINT16_MAX
-# define UINT16_WIDTH _GL_INTEGER_WIDTH (0, UINT16_MAX)
-# endif
-# ifdef INT32_MAX
-# define INT32_WIDTH _GL_INTEGER_WIDTH (INT32_MIN, INT32_MAX)
-# endif
-# ifdef UINT32_MAX
-# define UINT32_WIDTH _GL_INTEGER_WIDTH (0, UINT32_MAX)
-# endif
-# ifdef INT64_MAX
-# define INT64_WIDTH _GL_INTEGER_WIDTH (INT64_MIN, INT64_MAX)
-# endif
-# ifdef UINT64_MAX
-# define UINT64_WIDTH _GL_INTEGER_WIDTH (0, UINT64_MAX)
-# endif
-# define INT_LEAST8_WIDTH _GL_INTEGER_WIDTH (INT_LEAST8_MIN, INT_LEAST8_MAX)
-# define UINT_LEAST8_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST8_MAX)
-# define INT_LEAST16_WIDTH _GL_INTEGER_WIDTH (INT_LEAST16_MIN, INT_LEAST16_MAX)
-# define UINT_LEAST16_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST16_MAX)
-# define INT_LEAST32_WIDTH _GL_INTEGER_WIDTH (INT_LEAST32_MIN, INT_LEAST32_MAX)
-# define UINT_LEAST32_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST32_MAX)
-# define INT_LEAST64_WIDTH _GL_INTEGER_WIDTH (INT_LEAST64_MIN, INT_LEAST64_MAX)
-# define UINT_LEAST64_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST64_MAX)
-# define INT_FAST8_WIDTH _GL_INTEGER_WIDTH (INT_FAST8_MIN, INT_FAST8_MAX)
-# define UINT_FAST8_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST8_MAX)
-# define INT_FAST16_WIDTH _GL_INTEGER_WIDTH (INT_FAST16_MIN, INT_FAST16_MAX)
-# define UINT_FAST16_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST16_MAX)
-# define INT_FAST32_WIDTH _GL_INTEGER_WIDTH (INT_FAST32_MIN, INT_FAST32_MAX)
-# define UINT_FAST32_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST32_MAX)
-# define INT_FAST64_WIDTH _GL_INTEGER_WIDTH (INT_FAST64_MIN, INT_FAST64_MAX)
-# define UINT_FAST64_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST64_MAX)
-# define INTPTR_WIDTH _GL_INTEGER_WIDTH (INTPTR_MIN, INTPTR_MAX)
-# define UINTPTR_WIDTH _GL_INTEGER_WIDTH (0, UINTPTR_MAX)
-# define INTMAX_WIDTH _GL_INTEGER_WIDTH (INTMAX_MIN, INTMAX_MAX)
-# define UINTMAX_WIDTH _GL_INTEGER_WIDTH (0, UINTMAX_MAX)
-# define PTRDIFF_WIDTH _GL_INTEGER_WIDTH (PTRDIFF_MIN, PTRDIFF_MAX)
-# define SIZE_WIDTH _GL_INTEGER_WIDTH (0, SIZE_MAX)
-# define WCHAR_WIDTH _GL_INTEGER_WIDTH (WCHAR_MIN, WCHAR_MAX)
-# ifdef WINT_MAX
-# define WINT_WIDTH _GL_INTEGER_WIDTH (WINT_MIN, WINT_MAX)
-# endif
-# ifdef SIG_ATOMIC_MAX
-# define SIG_ATOMIC_WIDTH _GL_INTEGER_WIDTH (SIG_ATOMIC_MIN, SIG_ATOMIC_MAX)
-# endif
-#endif /* !WINT_WIDTH && (_GNU_SOURCE || __STDC_WANT_IEC_60559_BFP_EXT__) */
-
-#endif /* _@GUARD_PREFIX@_STDINT_H */
-#endif /* !(defined __ANDROID__ && ...) */
-#endif /* !defined _@GUARD_PREFIX@_STDINT_H && !defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H */
diff --git a/lib/gllib/string.in.h b/lib/gllib/string.in.h
deleted file mode 100644
index 259ccdf..0000000
--- a/lib/gllib/string.in.h
+++ /dev/null
@@ -1,1046 +0,0 @@
-/* A GNU-like <string.h>.
-
- Copyright (C) 1995-1996, 2001-2017 Free Software Foundation, Inc.
-
- This program 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, or (at your option)
- any later version.
-
- This program 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/>. */
-
-#if __GNUC__ >= 3
-@PRAGMA_SYSTEM_HEADER@
-#endif
-@PRAGMA_COLUMNS@
-
-#if defined _GL_ALREADY_INCLUDING_STRING_H
-/* Special invocation convention:
- - On OS X/NetBSD we have a sequence of nested includes
- <string.h> -> <strings.h> -> "string.h"
- In this situation system _chk variants due to -D_FORTIFY_SOURCE
- might be used after any replacements defined here. */
-
-#@INCLUDE_NEXT@ @NEXT_STRING_H@
-
-#else
-/* Normal invocation convention. */
-
-#ifndef _@GUARD_PREFIX@_STRING_H
-
-#define _GL_ALREADY_INCLUDING_STRING_H
-
-/* The include_next requires a split double-inclusion guard. */
-#@INCLUDE_NEXT@ @NEXT_STRING_H@
-
-#undef _GL_ALREADY_INCLUDING_STRING_H
-
-#ifndef _@GUARD_PREFIX@_STRING_H
-#define _@GUARD_PREFIX@_STRING_H
-
-/* NetBSD 5.0 mis-defines NULL. */
-#include <stddef.h>
-
-/* MirBSD defines mbslen as a macro. */
-#if @GNULIB_MBSLEN@ && defined __MirBSD__
-# include <wchar.h>
-#endif
-
-/* The __attribute__ feature is available in gcc versions 2.5 and later.
- The attribute __pure__ was added in gcc 2.96. */
-#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
-# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
-#else
-# define _GL_ATTRIBUTE_PURE /* empty */
-#endif
-
-/* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>. */
-/* But in any case avoid namespace pollution on glibc systems. */
-#if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \
- && ! defined __GLIBC__
-# include <unistd.h>
-#endif
-
-/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
-
-/* The definition of _GL_ARG_NONNULL is copied here. */
-
-/* The definition of _GL_WARN_ON_USE is copied here. */
-
-
-/* Find the index of the least-significant set bit. */
-#if @GNULIB_FFSL@
-# if !@HAVE_FFSL@
-_GL_FUNCDECL_SYS (ffsl, int, (long int i));
-# endif
-_GL_CXXALIAS_SYS (ffsl, int, (long int i));
-_GL_CXXALIASWARN (ffsl);
-#elif defined GNULIB_POSIXCHECK
-# undef ffsl
-# if HAVE_RAW_DECL_FFSL
-_GL_WARN_ON_USE (ffsl, "ffsl is not portable - use the ffsl module");
-# endif
-#endif
-
-
-/* Find the index of the least-significant set bit. */
-#if @GNULIB_FFSLL@
-# if !@HAVE_FFSLL@
-_GL_FUNCDECL_SYS (ffsll, int, (long long int i));
-# endif
-_GL_CXXALIAS_SYS (ffsll, int, (long long int i));
-_GL_CXXALIASWARN (ffsll);
-#elif defined GNULIB_POSIXCHECK
-# undef ffsll
-# if HAVE_RAW_DECL_FFSLL
-_GL_WARN_ON_USE (ffsll, "ffsll is not portable - use the ffsll module");
-# endif
-#endif
-
-
-/* Return the first instance of C within N bytes of S, or NULL. */
-#if @GNULIB_MEMCHR@
-# if @REPLACE_MEMCHR@
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# define memchr rpl_memchr
-# endif
-_GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n)
- _GL_ATTRIBUTE_PURE
- _GL_ARG_NONNULL ((1)));
-_GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n));
-# else
-# if ! @HAVE_MEMCHR@
-_GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n)
- _GL_ATTRIBUTE_PURE
- _GL_ARG_NONNULL ((1)));
-# endif
- /* On some systems, this function is defined as an overloaded function:
- extern "C" { const void * std::memchr (const void *, int, size_t); }
- extern "C++" { void * std::memchr (void *, int, size_t); } */
-_GL_CXXALIAS_SYS_CAST2 (memchr,
- void *, (void const *__s, int __c, size_t __n),
- void const *, (void const *__s, int __c, size_t __n));
-# endif
-# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
- && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
-_GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n));
-_GL_CXXALIASWARN1 (memchr, void const *,
- (void const *__s, int __c, size_t __n));
-# else
-_GL_CXXALIASWARN (memchr);
-# endif
-#elif defined GNULIB_POSIXCHECK
-# undef memchr
-/* Assume memchr is always declared. */
-_GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - "
- "use gnulib module memchr for portability" );
-#endif
-
-/* Return the first occurrence of NEEDLE in HAYSTACK. */
-#if @GNULIB_MEMMEM@
-# if @REPLACE_MEMMEM@
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# define memmem rpl_memmem
-# endif
-_GL_FUNCDECL_RPL (memmem, void *,
- (void const *__haystack, size_t __haystack_len,
- void const *__needle, size_t __needle_len)
- _GL_ATTRIBUTE_PURE
- _GL_ARG_NONNULL ((1, 3)));
-_GL_CXXALIAS_RPL (memmem, void *,
- (void const *__haystack, size_t __haystack_len,
- void const *__needle, size_t __needle_len));
-# else
-# if ! @HAVE_DECL_MEMMEM@
-_GL_FUNCDECL_SYS (memmem, void *,
- (void const *__haystack, size_t __haystack_len,
- void const *__needle, size_t __needle_len)
- _GL_ATTRIBUTE_PURE
- _GL_ARG_NONNULL ((1, 3)));
-# endif
-_GL_CXXALIAS_SYS (memmem, void *,
- (void const *__haystack, size_t __haystack_len,
- void const *__needle, size_t __needle_len));
-# endif
-_GL_CXXALIASWARN (memmem);
-#elif defined GNULIB_POSIXCHECK
-# undef memmem
-# if HAVE_RAW_DECL_MEMMEM
-_GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - "
- "use gnulib module memmem-simple for portability, "
- "and module memmem for speed" );
-# endif
-#endif
-
-/* Copy N bytes of SRC to DEST, return pointer to bytes after the
- last written byte. */
-#if @GNULIB_MEMPCPY@
-# if ! @HAVE_MEMPCPY@
-_GL_FUNCDECL_SYS (mempcpy, void *,
- (void *restrict __dest, void const *restrict __src,
- size_t __n)
- _GL_ARG_NONNULL ((1, 2)));
-# endif
-_GL_CXXALIAS_SYS (mempcpy, void *,
- (void *restrict __dest, void const *restrict __src,
- size_t __n));
-_GL_CXXALIASWARN (mempcpy);
-#elif defined GNULIB_POSIXCHECK
-# undef mempcpy
-# if HAVE_RAW_DECL_MEMPCPY
-_GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - "
- "use gnulib module mempcpy for portability");
-# endif
-#endif
-
-/* Search backwards through a block for a byte (specified as an int). */
-#if @GNULIB_MEMRCHR@
-# if ! @HAVE_DECL_MEMRCHR@
-_GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t)
- _GL_ATTRIBUTE_PURE
- _GL_ARG_NONNULL ((1)));
-# endif
- /* On some systems, this function is defined as an overloaded function:
- extern "C++" { const void * std::memrchr (const void *, int, size_t); }
- extern "C++" { void * std::memrchr (void *, int, size_t); } */
-_GL_CXXALIAS_SYS_CAST2 (memrchr,
- void *, (void const *, int, size_t),
- void const *, (void const *, int, size_t));
-# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
- && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
-_GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t));
-_GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t));
-# else
-_GL_CXXALIASWARN (memrchr);
-# endif
-#elif defined GNULIB_POSIXCHECK
-# undef memrchr
-# if HAVE_RAW_DECL_MEMRCHR
-_GL_WARN_ON_USE (memrchr, "memrchr is unportable - "
- "use gnulib module memrchr for portability");
-# endif
-#endif
-
-/* Find the first occurrence of C in S. More efficient than
- memchr(S,C,N), at the expense of undefined behavior if C does not
- occur within N bytes. */
-#if @GNULIB_RAWMEMCHR@
-# if ! @HAVE_RAWMEMCHR@
-_GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in)
- _GL_ATTRIBUTE_PURE
- _GL_ARG_NONNULL ((1)));
-# endif
- /* On some systems, this function is defined as an overloaded function:
- extern "C++" { const void * std::rawmemchr (const void *, int); }
- extern "C++" { void * std::rawmemchr (void *, int); } */
-_GL_CXXALIAS_SYS_CAST2 (rawmemchr,
- void *, (void const *__s, int __c_in),
- void const *, (void const *__s, int __c_in));
-# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
- && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
-_GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in));
-_GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in));
-# else
-_GL_CXXALIASWARN (rawmemchr);
-# endif
-#elif defined GNULIB_POSIXCHECK
-# undef rawmemchr
-# if HAVE_RAW_DECL_RAWMEMCHR
-_GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - "
- "use gnulib module rawmemchr for portability");
-# endif
-#endif
-
-/* Copy SRC to DST, returning the address of the terminating '\0' in DST. */
-#if @GNULIB_STPCPY@
-# if ! @HAVE_STPCPY@
-_GL_FUNCDECL_SYS (stpcpy, char *,
- (char *restrict __dst, char const *restrict __src)
- _GL_ARG_NONNULL ((1, 2)));
-# endif
-_GL_CXXALIAS_SYS (stpcpy, char *,
- (char *restrict __dst, char const *restrict __src));
-_GL_CXXALIASWARN (stpcpy);
-#elif defined GNULIB_POSIXCHECK
-# undef stpcpy
-# if HAVE_RAW_DECL_STPCPY
-_GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - "
- "use gnulib module stpcpy for portability");
-# endif
-#endif
-
-/* Copy no more than N bytes of SRC to DST, returning a pointer past the
- last non-NUL byte written into DST. */
-#if @GNULIB_STPNCPY@
-# if @REPLACE_STPNCPY@
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# undef stpncpy
-# define stpncpy rpl_stpncpy
-# endif
-_GL_FUNCDECL_RPL (stpncpy, char *,
- (char *restrict __dst, char const *restrict __src,
- size_t __n)
- _GL_ARG_NONNULL ((1, 2)));
-_GL_CXXALIAS_RPL (stpncpy, char *,
- (char *restrict __dst, char const *restrict __src,
- size_t __n));
-# else
-# if ! @HAVE_STPNCPY@
-_GL_FUNCDECL_SYS (stpncpy, char *,
- (char *restrict __dst, char const *restrict __src,
- size_t __n)
- _GL_ARG_NONNULL ((1, 2)));
-# endif
-_GL_CXXALIAS_SYS (stpncpy, char *,
- (char *restrict __dst, char const *restrict __src,
- size_t __n));
-# endif
-_GL_CXXALIASWARN (stpncpy);
-#elif defined GNULIB_POSIXCHECK
-# undef stpncpy
-# if HAVE_RAW_DECL_STPNCPY
-_GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - "
- "use gnulib module stpncpy for portability");
-# endif
-#endif
-
-#if defined GNULIB_POSIXCHECK
-/* strchr() does not work with multibyte strings if the locale encoding is
- GB18030 and the character to be searched is a digit. */
-# undef strchr
-/* Assume strchr is always declared. */
-_GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings "
- "in some multibyte locales - "
- "use mbschr if you care about internationalization");
-#endif
-
-/* Find the first occurrence of C in S or the final NUL byte. */
-#if @GNULIB_STRCHRNUL@
-# if @REPLACE_STRCHRNUL@
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# define strchrnul rpl_strchrnul
-# endif
-_GL_FUNCDECL_RPL (strchrnul, char *, (const char *__s, int __c_in)
- _GL_ATTRIBUTE_PURE
- _GL_ARG_NONNULL ((1)));
-_GL_CXXALIAS_RPL (strchrnul, char *,
- (const char *str, int ch));
-# else
-# if ! @HAVE_STRCHRNUL@
-_GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in)
- _GL_ATTRIBUTE_PURE
- _GL_ARG_NONNULL ((1)));
-# endif
- /* On some systems, this function is defined as an overloaded function:
- extern "C++" { const char * std::strchrnul (const char *, int); }
- extern "C++" { char * std::strchrnul (char *, int); } */
-_GL_CXXALIAS_SYS_CAST2 (strchrnul,
- char *, (char const *__s, int __c_in),
- char const *, (char const *__s, int __c_in));
-# endif
-# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
- && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
-_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in));
-_GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in));
-# else
-_GL_CXXALIASWARN (strchrnul);
-# endif
-#elif defined GNULIB_POSIXCHECK
-# undef strchrnul
-# if HAVE_RAW_DECL_STRCHRNUL
-_GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - "
- "use gnulib module strchrnul for portability");
-# endif
-#endif
-
-/* Duplicate S, returning an identical malloc'd string. */
-#if @GNULIB_STRDUP@
-# if @REPLACE_STRDUP@
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# undef strdup
-# define strdup rpl_strdup
-# endif
-_GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
-_GL_CXXALIAS_RPL (strdup, char *, (char const *__s));
-# else
-# if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup
- /* strdup exists as a function and as a macro. Get rid of the macro. */
-# undef strdup
-# endif
-# if !(@HAVE_DECL_STRDUP@ || defined strdup)
-_GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
-# endif
-_GL_CXXALIAS_SYS (strdup, char *, (char const *__s));
-# endif
-_GL_CXXALIASWARN (strdup);
-#elif defined GNULIB_POSIXCHECK
-# undef strdup
-# if HAVE_RAW_DECL_STRDUP
-_GL_WARN_ON_USE (strdup, "strdup is unportable - "
- "use gnulib module strdup for portability");
-# endif
-#endif
-
-/* Append no more than N characters from SRC onto DEST. */
-#if @GNULIB_STRNCAT@
-# if @REPLACE_STRNCAT@
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# undef strncat
-# define strncat rpl_strncat
-# endif
-_GL_FUNCDECL_RPL (strncat, char *, (char *dest, const char *src, size_t n)
- _GL_ARG_NONNULL ((1, 2)));
-_GL_CXXALIAS_RPL (strncat, char *, (char *dest, const char *src, size_t n));
-# else
-_GL_CXXALIAS_SYS (strncat, char *, (char *dest, const char *src, size_t n));
-# endif
-_GL_CXXALIASWARN (strncat);
-#elif defined GNULIB_POSIXCHECK
-# undef strncat
-# if HAVE_RAW_DECL_STRNCAT
-_GL_WARN_ON_USE (strncat, "strncat is unportable - "
- "use gnulib module strncat for portability");
-# endif
-#endif
-
-/* Return a newly allocated copy of at most N bytes of STRING. */
-#if @GNULIB_STRNDUP@
-# if @REPLACE_STRNDUP@
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# undef strndup
-# define strndup rpl_strndup
-# endif
-_GL_FUNCDECL_RPL (strndup, char *, (char const *__s, size_t __n)
- _GL_ARG_NONNULL ((1)));
-_GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n));
-# else
-# if ! @HAVE_DECL_STRNDUP@
-_GL_FUNCDECL_SYS (strndup, char *, (char const *__s, size_t __n)
- _GL_ARG_NONNULL ((1)));
-# endif
-_GL_CXXALIAS_SYS (strndup, char *, (char const *__s, size_t __n));
-# endif
-_GL_CXXALIASWARN (strndup);
-#elif defined GNULIB_POSIXCHECK
-# undef strndup
-# if HAVE_RAW_DECL_STRNDUP
-_GL_WARN_ON_USE (strndup, "strndup is unportable - "
- "use gnulib module strndup for portability");
-# endif
-#endif
-
-/* Find the length (number of bytes) of STRING, but scan at most
- MAXLEN bytes. If no '\0' terminator is found in that many bytes,
- return MAXLEN. */
-#if @GNULIB_STRNLEN@
-# if @REPLACE_STRNLEN@
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# undef strnlen
-# define strnlen rpl_strnlen
-# endif
-_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__s, size_t __maxlen)
- _GL_ATTRIBUTE_PURE
- _GL_ARG_NONNULL ((1)));
-_GL_CXXALIAS_RPL (strnlen, size_t, (char const *__s, size_t __maxlen));
-# else
-# if ! @HAVE_DECL_STRNLEN@
-_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__s, size_t __maxlen)
- _GL_ATTRIBUTE_PURE
- _GL_ARG_NONNULL ((1)));
-# endif
-_GL_CXXALIAS_SYS (strnlen, size_t, (char const *__s, size_t __maxlen));
-# endif
-_GL_CXXALIASWARN (strnlen);
-#elif defined GNULIB_POSIXCHECK
-# undef strnlen
-# if HAVE_RAW_DECL_STRNLEN
-_GL_WARN_ON_USE (strnlen, "strnlen is unportable - "
- "use gnulib module strnlen for portability");
-# endif
-#endif
-
-#if defined GNULIB_POSIXCHECK
-/* strcspn() assumes the second argument is a list of single-byte characters.
- Even in this simple case, it does not work with multibyte strings if the
- locale encoding is GB18030 and one of the characters to be searched is a
- digit. */
-# undef strcspn
-/* Assume strcspn is always declared. */
-_GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings "
- "in multibyte locales - "
- "use mbscspn if you care about internationalization");
-#endif
-
-/* Find the first occurrence in S of any character in ACCEPT. */
-#if @GNULIB_STRPBRK@
-# if ! @HAVE_STRPBRK@
-_GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept)
- _GL_ATTRIBUTE_PURE
- _GL_ARG_NONNULL ((1, 2)));
-# endif
- /* On some systems, this function is defined as an overloaded function:
- extern "C" { const char * strpbrk (const char *, const char *); }
- extern "C++" { char * strpbrk (char *, const char *); } */
-_GL_CXXALIAS_SYS_CAST2 (strpbrk,
- char *, (char const *__s, char const *__accept),
- const char *, (char const *__s, char const *__accept));
-# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
- && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
-_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept));
-_GL_CXXALIASWARN1 (strpbrk, char const *,
- (char const *__s, char const *__accept));
-# else
-_GL_CXXALIASWARN (strpbrk);
-# endif
-# if defined GNULIB_POSIXCHECK
-/* strpbrk() assumes the second argument is a list of single-byte characters.
- Even in this simple case, it does not work with multibyte strings if the
- locale encoding is GB18030 and one of the characters to be searched is a
- digit. */
-# undef strpbrk
-_GL_WARN_ON_USE (strpbrk, "strpbrk cannot work correctly on character strings "
- "in multibyte locales - "
- "use mbspbrk if you care about internationalization");
-# endif
-#elif defined GNULIB_POSIXCHECK
-# undef strpbrk
-# if HAVE_RAW_DECL_STRPBRK
-_GL_WARN_ON_USE (strpbrk, "strpbrk is unportable - "
- "use gnulib module strpbrk for portability");
-# endif
-#endif
-
-#if defined GNULIB_POSIXCHECK
-/* strspn() assumes the second argument is a list of single-byte characters.
- Even in this simple case, it cannot work with multibyte strings. */
-# undef strspn
-/* Assume strspn is always declared. */
-_GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings "
- "in multibyte locales - "
- "use mbsspn if you care about internationalization");
-#endif
-
-#if defined GNULIB_POSIXCHECK
-/* strrchr() does not work with multibyte strings if the locale encoding is
- GB18030 and the character to be searched is a digit. */
-# undef strrchr
-/* Assume strrchr is always declared. */
-_GL_WARN_ON_USE (strrchr, "strrchr cannot work correctly on character strings "
- "in some multibyte locales - "
- "use mbsrchr if you care about internationalization");
-#endif
-
-/* Search the next delimiter (char listed in DELIM) starting at *STRINGP.
- If one is found, overwrite it with a NUL, and advance *STRINGP
- to point to the next char after it. Otherwise, set *STRINGP to NULL.
- If *STRINGP was already NULL, nothing happens.
- Return the old value of *STRINGP.
-
- This is a variant of strtok() that is multithread-safe and supports
- empty fields.
-
- Caveat: It modifies the original string.
- Caveat: These functions cannot be used on constant strings.
- Caveat: The identity of the delimiting character is lost.
- Caveat: It doesn't work with multibyte strings unless all of the delimiter
- characters are ASCII characters < 0x30.
-
- See also strtok_r(). */
-#if @GNULIB_STRSEP@
-# if ! @HAVE_STRSEP@
-_GL_FUNCDECL_SYS (strsep, char *,
- (char **restrict __stringp, char const *restrict __delim)
- _GL_ARG_NONNULL ((1, 2)));
-# endif
-_GL_CXXALIAS_SYS (strsep, char *,
- (char **restrict __stringp, char const *restrict __delim));
-_GL_CXXALIASWARN (strsep);
-# if defined GNULIB_POSIXCHECK
-# undef strsep
-_GL_WARN_ON_USE (strsep, "strsep cannot work correctly on character strings "
- "in multibyte locales - "
- "use mbssep if you care about internationalization");
-# endif
-#elif defined GNULIB_POSIXCHECK
-# undef strsep
-# if HAVE_RAW_DECL_STRSEP
-_GL_WARN_ON_USE (strsep, "strsep is unportable - "
- "use gnulib module strsep for portability");
-# endif
-#endif
-
-#if @GNULIB_STRSTR@
-# if @REPLACE_STRSTR@
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# define strstr rpl_strstr
-# endif
-_GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle)
- _GL_ATTRIBUTE_PURE
- _GL_ARG_NONNULL ((1, 2)));
-_GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle));
-# else
- /* On some systems, this function is defined as an overloaded function:
- extern "C++" { const char * strstr (const char *, const char *); }
- extern "C++" { char * strstr (char *, const char *); } */
-_GL_CXXALIAS_SYS_CAST2 (strstr,
- char *, (const char *haystack, const char *needle),
- const char *, (const char *haystack, const char *needle));
-# endif
-# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
- && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
-_GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle));
-_GL_CXXALIASWARN1 (strstr, const char *,
- (const char *haystack, const char *needle));
-# else
-_GL_CXXALIASWARN (strstr);
-# endif
-#elif defined GNULIB_POSIXCHECK
-/* strstr() does not work with multibyte strings if the locale encoding is
- different from UTF-8:
- POSIX says that it operates on "strings", and "string" in POSIX is defined
- as a sequence of bytes, not of characters. */
-# undef strstr
-/* Assume strstr is always declared. */
-_GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot "
- "work correctly on character strings in most "
- "multibyte locales - "
- "use mbsstr if you care about internationalization, "
- "or use strstr if you care about speed");
-#endif
-
-/* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive
- comparison. */
-#if @GNULIB_STRCASESTR@
-# if @REPLACE_STRCASESTR@
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# define strcasestr rpl_strcasestr
-# endif
-_GL_FUNCDECL_RPL (strcasestr, char *,
- (const char *haystack, const char *needle)
- _GL_ATTRIBUTE_PURE
- _GL_ARG_NONNULL ((1, 2)));
-_GL_CXXALIAS_RPL (strcasestr, char *,
- (const char *haystack, const char *needle));
-# else
-# if ! @HAVE_STRCASESTR@
-_GL_FUNCDECL_SYS (strcasestr, char *,
- (const char *haystack, const char *needle)
- _GL_ATTRIBUTE_PURE
- _GL_ARG_NONNULL ((1, 2)));
-# endif
- /* On some systems, this function is defined as an overloaded function:
- extern "C++" { const char * strcasestr (const char *, const char *); }
- extern "C++" { char * strcasestr (char *, const char *); } */
-_GL_CXXALIAS_SYS_CAST2 (strcasestr,
- char *, (const char *haystack, const char *needle),
- const char *, (const char *haystack, const char *needle));
-# endif
-# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
- && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
-_GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle));
-_GL_CXXALIASWARN1 (strcasestr, const char *,
- (const char *haystack, const char *needle));
-# else
-_GL_CXXALIASWARN (strcasestr);
-# endif
-#elif defined GNULIB_POSIXCHECK
-/* strcasestr() does not work with multibyte strings:
- It is a glibc extension, and glibc implements it only for unibyte
- locales. */
-# undef strcasestr
-# if HAVE_RAW_DECL_STRCASESTR
-_GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character "
- "strings in multibyte locales - "
- "use mbscasestr if you care about "
- "internationalization, or use c-strcasestr if you want "
- "a locale independent function");
-# endif
-#endif
-
-/* Parse S into tokens separated by characters in DELIM.
- If S is NULL, the saved pointer in SAVE_PTR is used as
- the next starting point. For example:
- char s[] = "-abc-=-def";
- char *sp;
- x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def"
- x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL
- x = strtok_r(NULL, "=", &sp); // x = NULL
- // s = "abc\0-def\0"
-
- This is a variant of strtok() that is multithread-safe.
-
- For the POSIX documentation for this function, see:
- http://www.opengroup.org/susv3xsh/strtok.html
-
- Caveat: It modifies the original string.
- Caveat: These functions cannot be used on constant strings.
- Caveat: The identity of the delimiting character is lost.
- Caveat: It doesn't work with multibyte strings unless all of the delimiter
- characters are ASCII characters < 0x30.
-
- See also strsep(). */
-#if @GNULIB_STRTOK_R@
-# if @REPLACE_STRTOK_R@
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# undef strtok_r
-# define strtok_r rpl_strtok_r
-# endif
-_GL_FUNCDECL_RPL (strtok_r, char *,
- (char *restrict s, char const *restrict delim,
- char **restrict save_ptr)
- _GL_ARG_NONNULL ((2, 3)));
-_GL_CXXALIAS_RPL (strtok_r, char *,
- (char *restrict s, char const *restrict delim,
- char **restrict save_ptr));
-# else
-# if @UNDEFINE_STRTOK_R@ || defined GNULIB_POSIXCHECK
-# undef strtok_r
-# endif
-# if ! @HAVE_DECL_STRTOK_R@
-_GL_FUNCDECL_SYS (strtok_r, char *,
- (char *restrict s, char const *restrict delim,
- char **restrict save_ptr)
- _GL_ARG_NONNULL ((2, 3)));
-# endif
-_GL_CXXALIAS_SYS (strtok_r, char *,
- (char *restrict s, char const *restrict delim,
- char **restrict save_ptr));
-# endif
-_GL_CXXALIASWARN (strtok_r);
-# if defined GNULIB_POSIXCHECK
-_GL_WARN_ON_USE (strtok_r, "strtok_r cannot work correctly on character "
- "strings in multibyte locales - "
- "use mbstok_r if you care about internationalization");
-# endif
-#elif defined GNULIB_POSIXCHECK
-# undef strtok_r
-# if HAVE_RAW_DECL_STRTOK_R
-_GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - "
- "use gnulib module strtok_r for portability");
-# endif
-#endif
-
-
-/* The following functions are not specified by POSIX. They are gnulib
- extensions. */
-
-#if @GNULIB_MBSLEN@
-/* Return the number of multibyte characters in the character string STRING.
- This considers multibyte characters, unlike strlen, which counts bytes. */
-# ifdef __MirBSD__ /* MirBSD defines mbslen as a macro. Override it. */
-# undef mbslen
-# endif
-# if @HAVE_MBSLEN@ /* AIX, OSF/1, MirBSD define mbslen already in libc. */
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# define mbslen rpl_mbslen
-# endif
-_GL_FUNCDECL_RPL (mbslen, size_t, (const char *string)
- _GL_ATTRIBUTE_PURE
- _GL_ARG_NONNULL ((1)));
-_GL_CXXALIAS_RPL (mbslen, size_t, (const char *string));
-# else
-_GL_FUNCDECL_SYS (mbslen, size_t, (const char *string)
- _GL_ATTRIBUTE_PURE
- _GL_ARG_NONNULL ((1)));
-_GL_CXXALIAS_SYS (mbslen, size_t, (const char *string));
-# endif
-_GL_CXXALIASWARN (mbslen);
-#endif
-
-#if @GNULIB_MBSNLEN@
-/* Return the number of multibyte characters in the character string starting
- at STRING and ending at STRING + LEN. */
-_GL_EXTERN_C size_t mbsnlen (const char *string, size_t len)
- _GL_ATTRIBUTE_PURE
- _GL_ARG_NONNULL ((1));
-#endif
-
-#if @GNULIB_MBSCHR@
-/* Locate the first single-byte character C in the character string STRING,
- and return a pointer to it. Return NULL if C is not found in STRING.
- Unlike strchr(), this function works correctly in multibyte locales with
- encodings such as GB18030. */
-# if defined __hpux
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# define mbschr rpl_mbschr /* avoid collision with HP-UX function */
-# endif
-_GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c)
- _GL_ATTRIBUTE_PURE
- _GL_ARG_NONNULL ((1)));
-_GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c));
-# else
-_GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c)
- _GL_ATTRIBUTE_PURE
- _GL_ARG_NONNULL ((1)));
-_GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c));
-# endif
-_GL_CXXALIASWARN (mbschr);
-#endif
-
-#if @GNULIB_MBSRCHR@
-/* Locate the last single-byte character C in the character string STRING,
- and return a pointer to it. Return NULL if C is not found in STRING.
- Unlike strrchr(), this function works correctly in multibyte locales with
- encodings such as GB18030. */
-# if defined __hpux || defined __INTERIX
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# define mbsrchr rpl_mbsrchr /* avoid collision with system function */
-# endif
-_GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c)
- _GL_ATTRIBUTE_PURE
- _GL_ARG_NONNULL ((1)));
-_GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c));
-# else
-_GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c)
- _GL_ATTRIBUTE_PURE
- _GL_ARG_NONNULL ((1)));
-_GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c));
-# endif
-_GL_CXXALIASWARN (mbsrchr);
-#endif
-
-#if @GNULIB_MBSSTR@
-/* Find the first occurrence of the character string NEEDLE in the character
- string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK.
- Unlike strstr(), this function works correctly in multibyte locales with
- encodings different from UTF-8. */
-_GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle)
- _GL_ATTRIBUTE_PURE
- _GL_ARG_NONNULL ((1, 2));
-#endif
-
-#if @GNULIB_MBSCASECMP@
-/* Compare the character strings S1 and S2, ignoring case, returning less than,
- equal to or greater than zero if S1 is lexicographically less than, equal to
- or greater than S2.
- Note: This function may, in multibyte locales, return 0 for strings of
- different lengths!
- Unlike strcasecmp(), this function works correctly in multibyte locales. */
-_GL_EXTERN_C int mbscasecmp (const char *s1, const char *s2)
- _GL_ATTRIBUTE_PURE
- _GL_ARG_NONNULL ((1, 2));
-#endif
-
-#if @GNULIB_MBSNCASECMP@
-/* Compare the initial segment of the character string S1 consisting of at most
- N characters with the initial segment of the character string S2 consisting
- of at most N characters, ignoring case, returning less than, equal to or
- greater than zero if the initial segment of S1 is lexicographically less
- than, equal to or greater than the initial segment of S2.
- Note: This function may, in multibyte locales, return 0 for initial segments
- of different lengths!
- Unlike strncasecmp(), this function works correctly in multibyte locales.
- But beware that N is not a byte count but a character count! */
-_GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n)
- _GL_ATTRIBUTE_PURE
- _GL_ARG_NONNULL ((1, 2));
-#endif
-
-#if @GNULIB_MBSPCASECMP@
-/* Compare the initial segment of the character string STRING consisting of
- at most mbslen (PREFIX) characters with the character string PREFIX,
- ignoring case. If the two match, return a pointer to the first byte
- after this prefix in STRING. Otherwise, return NULL.
- Note: This function may, in multibyte locales, return non-NULL if STRING
- is of smaller length than PREFIX!
- Unlike strncasecmp(), this function works correctly in multibyte
- locales. */
-_GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix)
- _GL_ATTRIBUTE_PURE
- _GL_ARG_NONNULL ((1, 2));
-#endif
-
-#if @GNULIB_MBSCASESTR@
-/* Find the first occurrence of the character string NEEDLE in the character
- string HAYSTACK, using case-insensitive comparison.
- Note: This function may, in multibyte locales, return success even if
- strlen (haystack) < strlen (needle) !
- Unlike strcasestr(), this function works correctly in multibyte locales. */
-_GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle)
- _GL_ATTRIBUTE_PURE
- _GL_ARG_NONNULL ((1, 2));
-#endif
-
-#if @GNULIB_MBSCSPN@
-/* Find the first occurrence in the character string STRING of any character
- in the character string ACCEPT. Return the number of bytes from the
- beginning of the string to this occurrence, or to the end of the string
- if none exists.
- Unlike strcspn(), this function works correctly in multibyte locales. */
-_GL_EXTERN_C size_t mbscspn (const char *string, const char *accept)
- _GL_ATTRIBUTE_PURE
- _GL_ARG_NONNULL ((1, 2));
-#endif
-
-#if @GNULIB_MBSPBRK@
-/* Find the first occurrence in the character string STRING of any character
- in the character string ACCEPT. Return the pointer to it, or NULL if none
- exists.
- Unlike strpbrk(), this function works correctly in multibyte locales. */
-# if defined __hpux
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
-# endif
-_GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept)
- _GL_ATTRIBUTE_PURE
- _GL_ARG_NONNULL ((1, 2)));
-_GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept));
-# else
-_GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept)
- _GL_ATTRIBUTE_PURE
- _GL_ARG_NONNULL ((1, 2)));
-_GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept));
-# endif
-_GL_CXXALIASWARN (mbspbrk);
-#endif
-
-#if @GNULIB_MBSSPN@
-/* Find the first occurrence in the character string STRING of any character
- not in the character string REJECT. Return the number of bytes from the
- beginning of the string to this occurrence, or to the end of the string
- if none exists.
- Unlike strspn(), this function works correctly in multibyte locales. */
-_GL_EXTERN_C size_t mbsspn (const char *string, const char *reject)
- _GL_ATTRIBUTE_PURE
- _GL_ARG_NONNULL ((1, 2));
-#endif
-
-#if @GNULIB_MBSSEP@
-/* Search the next delimiter (multibyte character listed in the character
- string DELIM) starting at the character string *STRINGP.
- If one is found, overwrite it with a NUL, and advance *STRINGP to point
- to the next multibyte character after it. Otherwise, set *STRINGP to NULL.
- If *STRINGP was already NULL, nothing happens.
- Return the old value of *STRINGP.
-
- This is a variant of mbstok_r() that supports empty fields.
-
- Caveat: It modifies the original string.
- Caveat: These functions cannot be used on constant strings.
- Caveat: The identity of the delimiting character is lost.
-
- See also mbstok_r(). */
-_GL_EXTERN_C char * mbssep (char **stringp, const char *delim)
- _GL_ARG_NONNULL ((1, 2));
-#endif
-
-#if @GNULIB_MBSTOK_R@
-/* Parse the character string STRING into tokens separated by characters in
- the character string DELIM.
- If STRING is NULL, the saved pointer in SAVE_PTR is used as
- the next starting point. For example:
- char s[] = "-abc-=-def";
- char *sp;
- x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def"
- x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL
- x = mbstok_r(NULL, "=", &sp); // x = NULL
- // s = "abc\0-def\0"
-
- Caveat: It modifies the original string.
- Caveat: These functions cannot be used on constant strings.
- Caveat: The identity of the delimiting character is lost.
-
- See also mbssep(). */
-_GL_EXTERN_C char * mbstok_r (char *string, const char *delim, char **save_ptr)
- _GL_ARG_NONNULL ((2, 3));
-#endif
-
-/* Map any int, typically from errno, into an error message. */
-#if @GNULIB_STRERROR@
-# if @REPLACE_STRERROR@
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# undef strerror
-# define strerror rpl_strerror
-# endif
-_GL_FUNCDECL_RPL (strerror, char *, (int));
-_GL_CXXALIAS_RPL (strerror, char *, (int));
-# else
-_GL_CXXALIAS_SYS (strerror, char *, (int));
-# endif
-_GL_CXXALIASWARN (strerror);
-#elif defined GNULIB_POSIXCHECK
-# undef strerror
-/* Assume strerror is always declared. */
-_GL_WARN_ON_USE (strerror, "strerror is unportable - "
- "use gnulib module strerror to guarantee non-NULL result");
-#endif
-
-/* Map any int, typically from errno, into an error message. Multithread-safe.
- Uses the POSIX declaration, not the glibc declaration. */
-#if @GNULIB_STRERROR_R@
-# if @REPLACE_STRERROR_R@
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# undef strerror_r
-# define strerror_r rpl_strerror_r
-# endif
-_GL_FUNCDECL_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen)
- _GL_ARG_NONNULL ((2)));
-_GL_CXXALIAS_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen));
-# else
-# if !@HAVE_DECL_STRERROR_R@
-_GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen)
- _GL_ARG_NONNULL ((2)));
-# endif
-_GL_CXXALIAS_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen));
-# endif
-# if @HAVE_DECL_STRERROR_R@
-_GL_CXXALIASWARN (strerror_r);
-# endif
-#elif defined GNULIB_POSIXCHECK
-# undef strerror_r
-# if HAVE_RAW_DECL_STRERROR_R
-_GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - "
- "use gnulib module strerror_r-posix for portability");
-# endif
-#endif
-
-#if @GNULIB_STRSIGNAL@
-# if @REPLACE_STRSIGNAL@
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# define strsignal rpl_strsignal
-# endif
-_GL_FUNCDECL_RPL (strsignal, char *, (int __sig));
-_GL_CXXALIAS_RPL (strsignal, char *, (int __sig));
-# else
-# if ! @HAVE_DECL_STRSIGNAL@
-_GL_FUNCDECL_SYS (strsignal, char *, (int __sig));
-# endif
-/* Need to cast, because on Cygwin 1.5.x systems, the return type is
- 'const char *'. */
-_GL_CXXALIAS_SYS_CAST (strsignal, char *, (int __sig));
-# endif
-_GL_CXXALIASWARN (strsignal);
-#elif defined GNULIB_POSIXCHECK
-# undef strsignal
-# if HAVE_RAW_DECL_STRSIGNAL
-_GL_WARN_ON_USE (strsignal, "strsignal is unportable - "
- "use gnulib module strsignal for portability");
-# endif
-#endif
-
-#if @GNULIB_STRVERSCMP@
-# if !@HAVE_STRVERSCMP@
-_GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *)
- _GL_ATTRIBUTE_PURE
- _GL_ARG_NONNULL ((1, 2)));
-# endif
-_GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *));
-_GL_CXXALIASWARN (strverscmp);
-#elif defined GNULIB_POSIXCHECK
-# undef strverscmp
-# if HAVE_RAW_DECL_STRVERSCMP
-_GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - "
- "use gnulib module strverscmp for portability");
-# endif
-#endif
-
-
-#endif /* _@GUARD_PREFIX@_STRING_H */
-#endif /* _@GUARD_PREFIX@_STRING_H */
-#endif
diff --git a/lib/gllib/strverscmp.c b/lib/gllib/strverscmp.c
deleted file mode 100644
index 0d8ac1c..0000000
--- a/lib/gllib/strverscmp.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/* Compare strings while treating digits characters numerically.
- Copyright (C) 1997-2017 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Jean-François Bignolles <bignolle@ecoledoc.ibp.fr>, 1997.
-
- The GNU C Library 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.
-
- The GNU C Library 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 the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#if !_LIBC
-# include <config.h>
-#endif
-
-#include <string.h>
-#include <ctype.h>
-
-/* states: S_N: normal, S_I: comparing integral part, S_F: comparing
- fractional parts, S_Z: idem but with leading Zeroes only */
-#define S_N 0x0
-#define S_I 0x3
-#define S_F 0x6
-#define S_Z 0x9
-
-/* result_type: CMP: return diff; LEN: compare using len_diff/diff */
-#define CMP 2
-#define LEN 3
-
-#ifndef weak_alias
-# define __strverscmp strverscmp
-#endif
-
-/* Compare S1 and S2 as strings holding indices/version numbers,
- returning less than, equal to or greater than zero if S1 is less than,
- equal to or greater than S2 (for more info, see the texinfo doc).
-*/
-
-int
-__strverscmp (const char *s1, const char *s2)
-{
- const unsigned char *p1 = (const unsigned char *) s1;
- const unsigned char *p2 = (const unsigned char *) s2;
- unsigned char c1, c2;
- int state;
- int diff;
-
- /* Symbol(s) 0 [1-9] others
- Transition (10) 0 (01) d (00) x */
- static const unsigned char next_state[] =
- {
- /* state x d 0 */
- /* S_N */ S_N, S_I, S_Z,
- /* S_I */ S_N, S_I, S_I,
- /* S_F */ S_N, S_F, S_F,
- /* S_Z */ S_N, S_F, S_Z
- };
-
- static const signed char result_type[] =
- {
- /* state x/x x/d x/0 d/x d/d d/0 0/x 0/d 0/0 */
-
- /* S_N */ CMP, CMP, CMP, CMP, LEN, CMP, CMP, CMP, CMP,
- /* S_I */ CMP, -1, -1, +1, LEN, LEN, +1, LEN, LEN,
- /* S_F */ CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP,
- /* S_Z */ CMP, +1, +1, -1, CMP, CMP, -1, CMP, CMP
- };
-
- if (p1 == p2)
- return 0;
-
- c1 = *p1++;
- c2 = *p2++;
- /* Hint: '0' is a digit too. */
- state = S_N + ((c1 == '0') + (isdigit (c1) != 0));
-
- while ((diff = c1 - c2) == 0)
- {
- if (c1 == '\0')
- return diff;
-
- state = next_state[state];
- c1 = *p1++;
- c2 = *p2++;
- state += (c1 == '0') + (isdigit (c1) != 0);
- }
-
- state = result_type[state * 3 + (((c2 == '0') + (isdigit (c2) != 0)))];
-
- switch (state)
- {
- case CMP:
- return diff;
-
- case LEN:
- while (isdigit (*p1++))
- if (!isdigit (*p2++))
- return 1;
-
- return isdigit (*p2) ? -1 : diff;
-
- default:
- return state;
- }
-}
-#ifdef weak_alias
-libc_hidden_def (__strverscmp)
-weak_alias (__strverscmp, strverscmp)
-#endif
diff --git a/lib/gllib/sys_types.in.h b/lib/gllib/sys_types.in.h
deleted file mode 100644
index abdd7f0..0000000
--- a/lib/gllib/sys_types.in.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* Provide a more complete sys/types.h.
-
- Copyright (C) 2011-2017 Free Software Foundation, Inc.
-
- This program 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, or (at your option)
- any later version.
-
- This program 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/>. */
-
-#if __GNUC__ >= 3
-@PRAGMA_SYSTEM_HEADER@
-#endif
-@PRAGMA_COLUMNS@
-
-#ifndef _@GUARD_PREFIX@_SYS_TYPES_H
-
-/* The include_next requires a split double-inclusion guard. */
-# define _GL_INCLUDING_SYS_TYPES_H
-#@INCLUDE_NEXT@ @NEXT_SYS_TYPES_H@
-# undef _GL_INCLUDING_SYS_TYPES_H
-
-#ifndef _@GUARD_PREFIX@_SYS_TYPES_H
-#define _@GUARD_PREFIX@_SYS_TYPES_H
-
-/* Override off_t if Large File Support is requested on native Windows. */
-#if @WINDOWS_64_BIT_OFF_T@
-/* Same as int64_t in <stdint.h>. */
-# if defined _MSC_VER
-# define off_t __int64
-# else
-# define off_t long long int
-# endif
-/* Indicator, for gnulib internal purposes. */
-# define _GL_WINDOWS_64_BIT_OFF_T 1
-#endif
-
-/* MSVC 9 defines size_t in <stddef.h>, not in <sys/types.h>. */
-/* But avoid namespace pollution on glibc systems. */
-#if ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) \
- && ! defined __GLIBC__
-# include <stddef.h>
-#endif
-
-#endif /* _@GUARD_PREFIX@_SYS_TYPES_H */
-#endif /* _@GUARD_PREFIX@_SYS_TYPES_H */
diff --git a/lib/gllib/verify.h b/lib/gllib/verify.h
deleted file mode 100644
index a9ef798..0000000
--- a/lib/gllib/verify.h
+++ /dev/null
@@ -1,279 +0,0 @@
-/* Compile-time assert-like macros.
-
- Copyright (C) 2005-2006, 2009-2017 Free Software Foundation, Inc.
-
- This program 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 program 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/>. */
-
-/* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */
-
-#ifndef _GL_VERIFY_H
-#define _GL_VERIFY_H
-
-
-/* Define _GL_HAVE__STATIC_ASSERT to 1 if _Static_assert works as per C11.
- This is supported by GCC 4.6.0 and later, in C mode, and its use
- here generates easier-to-read diagnostics when verify (R) fails.
-
- Define _GL_HAVE_STATIC_ASSERT to 1 if static_assert works as per C++11.
- This will likely be supported by future GCC versions, in C++ mode.
-
- Use this only with GCC. If we were willing to slow 'configure'
- down we could also use it with other compilers, but since this
- affects only the quality of diagnostics, why bother? */
-#if (4 < __GNUC__ + (6 <= __GNUC_MINOR__) \
- && (201112L <= __STDC_VERSION__ || !defined __STRICT_ANSI__) \
- && !defined __cplusplus)
-# define _GL_HAVE__STATIC_ASSERT 1
-#endif
-/* The condition (99 < __GNUC__) is temporary, until we know about the
- first G++ release that supports static_assert. */
-#if (99 < __GNUC__) && defined __cplusplus
-# define _GL_HAVE_STATIC_ASSERT 1
-#endif
-
-/* FreeBSD 9.1 <sys/cdefs.h>, included by <stddef.h> and lots of other
- system headers, defines a conflicting _Static_assert that is no
- better than ours; override it. */
-#ifndef _GL_HAVE_STATIC_ASSERT
-# include <stddef.h>
-# undef _Static_assert
-#endif
-
-/* Each of these macros verifies that its argument R is nonzero. To
- be portable, R should be an integer constant expression. Unlike
- assert (R), there is no run-time overhead.
-
- If _Static_assert works, verify (R) uses it directly. Similarly,
- _GL_VERIFY_TRUE works by packaging a _Static_assert inside a struct
- that is an operand of sizeof.
-
- The code below uses several ideas for C++ compilers, and for C
- compilers that do not support _Static_assert:
-
- * The first step is ((R) ? 1 : -1). Given an expression R, of
- integral or boolean or floating-point type, this yields an
- expression of integral type, whose value is later verified to be
- constant and nonnegative.
-
- * Next this expression W is wrapped in a type
- struct _gl_verify_type {
- unsigned int _gl_verify_error_if_negative: W;
- }.
- If W is negative, this yields a compile-time error. No compiler can
- deal with a bit-field of negative size.
-
- One might think that an array size check would have the same
- effect, that is, that the type struct { unsigned int dummy[W]; }
- would work as well. However, inside a function, some compilers
- (such as C++ compilers and GNU C) allow local parameters and
- variables inside array size expressions. With these compilers,
- an array size check would not properly diagnose this misuse of
- the verify macro:
-
- void function (int n) { verify (n < 0); }
-
- * For the verify macro, the struct _gl_verify_type will need to
- somehow be embedded into a declaration. To be portable, this
- declaration must declare an object, a constant, a function, or a
- typedef name. If the declared entity uses the type directly,
- such as in
-
- struct dummy {...};
- typedef struct {...} dummy;
- extern struct {...} *dummy;
- extern void dummy (struct {...} *);
- extern struct {...} *dummy (void);
-
- two uses of the verify macro would yield colliding declarations
- if the entity names are not disambiguated. A workaround is to
- attach the current line number to the entity name:
-
- #define _GL_CONCAT0(x, y) x##y
- #define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y)
- extern struct {...} * _GL_CONCAT (dummy, __LINE__);
-
- But this has the problem that two invocations of verify from
- within the same macro would collide, since the __LINE__ value
- would be the same for both invocations. (The GCC __COUNTER__
- macro solves this problem, but is not portable.)
-
- A solution is to use the sizeof operator. It yields a number,
- getting rid of the identity of the type. Declarations like
-
- extern int dummy [sizeof (struct {...})];
- extern void dummy (int [sizeof (struct {...})]);
- extern int (*dummy (void)) [sizeof (struct {...})];
-
- can be repeated.
-
- * Should the implementation use a named struct or an unnamed struct?
- Which of the following alternatives can be used?
-
- extern int dummy [sizeof (struct {...})];
- extern int dummy [sizeof (struct _gl_verify_type {...})];
- extern void dummy (int [sizeof (struct {...})]);
- extern void dummy (int [sizeof (struct _gl_verify_type {...})]);
- extern int (*dummy (void)) [sizeof (struct {...})];
- extern int (*dummy (void)) [sizeof (struct _gl_verify_type {...})];
-
- In the second and sixth case, the struct type is exported to the
- outer scope; two such declarations therefore collide. GCC warns
- about the first, third, and fourth cases. So the only remaining
- possibility is the fifth case:
-
- extern int (*dummy (void)) [sizeof (struct {...})];
-
- * GCC warns about duplicate declarations of the dummy function if
- -Wredundant-decls is used. GCC 4.3 and later have a builtin
- __COUNTER__ macro that can let us generate unique identifiers for
- each dummy function, to suppress this warning.
-
- * This implementation exploits the fact that older versions of GCC,
- which do not support _Static_assert, also do not warn about the
- last declaration mentioned above.
-
- * GCC warns if -Wnested-externs is enabled and verify() is used
- within a function body; but inside a function, you can always
- arrange to use verify_expr() instead.
-
- * In C++, any struct definition inside sizeof is invalid.
- Use a template type to work around the problem. */
-
-/* Concatenate two preprocessor tokens. */
-#define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y)
-#define _GL_CONCAT0(x, y) x##y
-
-/* _GL_COUNTER is an integer, preferably one that changes each time we
- use it. Use __COUNTER__ if it works, falling back on __LINE__
- otherwise. __LINE__ isn't perfect, but it's better than a
- constant. */
-#if defined __COUNTER__ && __COUNTER__ != __COUNTER__
-# define _GL_COUNTER __COUNTER__
-#else
-# define _GL_COUNTER __LINE__
-#endif
-
-/* Generate a symbol with the given prefix, making it unique if
- possible. */
-#define _GL_GENSYM(prefix) _GL_CONCAT (prefix, _GL_COUNTER)
-
-/* Verify requirement R at compile-time, as an integer constant expression
- that returns 1. If R is false, fail at compile-time, preferably
- with a diagnostic that includes the string-literal DIAGNOSTIC. */
-
-#define _GL_VERIFY_TRUE(R, DIAGNOSTIC) \
- (!!sizeof (_GL_VERIFY_TYPE (R, DIAGNOSTIC)))
-
-#ifdef __cplusplus
-# if !GNULIB_defined_struct__gl_verify_type
-template <int w>
- struct _gl_verify_type {
- unsigned int _gl_verify_error_if_negative: w;
- };
-# define GNULIB_defined_struct__gl_verify_type 1
-# endif
-# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
- _gl_verify_type<(R) ? 1 : -1>
-#elif defined _GL_HAVE__STATIC_ASSERT
-# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
- struct { \
- _Static_assert (R, DIAGNOSTIC); \
- int _gl_dummy; \
- }
-#else
-# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
- struct { unsigned int _gl_verify_error_if_negative: (R) ? 1 : -1; }
-#endif
-
-/* Verify requirement R at compile-time, as a declaration without a
- trailing ';'. If R is false, fail at compile-time, preferably
- with a diagnostic that includes the string-literal DIAGNOSTIC.
-
- Unfortunately, unlike C11, this implementation must appear as an
- ordinary declaration, and cannot appear inside struct { ... }. */
-
-#ifdef _GL_HAVE__STATIC_ASSERT
-# define _GL_VERIFY _Static_assert
-#else
-# define _GL_VERIFY(R, DIAGNOSTIC) \
- extern int (*_GL_GENSYM (_gl_verify_function) (void)) \
- [_GL_VERIFY_TRUE (R, DIAGNOSTIC)]
-#endif
-
-/* _GL_STATIC_ASSERT_H is defined if this code is copied into assert.h. */
-#ifdef _GL_STATIC_ASSERT_H
-# if !defined _GL_HAVE__STATIC_ASSERT && !defined _Static_assert
-# define _Static_assert(R, DIAGNOSTIC) _GL_VERIFY (R, DIAGNOSTIC)
-# endif
-# if !defined _GL_HAVE_STATIC_ASSERT && !defined static_assert
-# define static_assert _Static_assert /* C11 requires this #define. */
-# endif
-#endif
-
-/* @assert.h omit start@ */
-
-/* Each of these macros verifies that its argument R is nonzero. To
- be portable, R should be an integer constant expression. Unlike
- assert (R), there is no run-time overhead.
-
- There are two macros, since no single macro can be used in all
- contexts in C. verify_true (R) is for scalar contexts, including
- integer constant expression contexts. verify (R) is for declaration
- contexts, e.g., the top level. */
-
-/* Verify requirement R at compile-time, as an integer constant expression.
- Return 1. This is equivalent to verify_expr (R, 1).
-
- verify_true is obsolescent; please use verify_expr instead. */
-
-#define verify_true(R) _GL_VERIFY_TRUE (R, "verify_true (" #R ")")
-
-/* Verify requirement R at compile-time. Return the value of the
- expression E. */
-
-#define verify_expr(R, E) \
- (_GL_VERIFY_TRUE (R, "verify_expr (" #R ", " #E ")") ? (E) : (E))
-
-/* Verify requirement R at compile-time, as a declaration without a
- trailing ';'. */
-
-#define verify(R) _GL_VERIFY (R, "verify (" #R ")")
-
-#ifndef __has_builtin
-# define __has_builtin(x) 0
-#endif
-
-/* Assume that R always holds. This lets the compiler optimize
- accordingly. R should not have side-effects; it may or may not be
- evaluated. Behavior is undefined if R is false. */
-
-#if (__has_builtin (__builtin_unreachable) \
- || 4 < __GNUC__ + (5 <= __GNUC_MINOR__))
-# define assume(R) ((R) ? (void) 0 : __builtin_unreachable ())
-#elif 1200 <= _MSC_VER
-# define assume(R) __assume (R)
-#elif ((defined GCC_LINT || defined lint) \
- && (__has_builtin (__builtin_trap) \
- || 3 < __GNUC__ + (3 < __GNUC_MINOR__ + (4 <= __GNUC_PATCHLEVEL__))))
- /* Doing it this way helps various packages when configured with
- --enable-gcc-warnings, which compiles with -Dlint. It's nicer
- when 'assume' silences warnings even with older GCCs. */
-# define assume(R) ((R) ? (void) 0 : __builtin_trap ())
-#else
-# define assume(R) ((void) (0 && (R)))
-#endif
-
-/* @assert.h omit end@ */
-
-#endif
diff --git a/lib/glm4/00gnulib.m4 b/lib/glm4/00gnulib.m4
deleted file mode 100644
index bb3512f..0000000
--- a/lib/glm4/00gnulib.m4
+++ /dev/null
@@ -1,46 +0,0 @@
-# 00gnulib.m4 serial 3
-dnl Copyright (C) 2009-2017 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-dnl This file must be named something that sorts before all other
-dnl gnulib-provided .m4 files. It is needed until such time as we can
-dnl assume Autoconf 2.64, with its improved AC_DEFUN_ONCE and
-dnl m4_divert semantics.
-
-# Until autoconf 2.63, handling of the diversion stack required m4_init
-# to be called first; but this does not happen with aclocal. Wrapping
-# the entire execution in another layer of the diversion stack fixes this.
-# Worse, prior to autoconf 2.62, m4_wrap depended on the underlying m4
-# for whether it was FIFO or LIFO; in order to properly balance with
-# m4_init, we need to undo our push just before anything wrapped within
-# the m4_init body. The way to ensure this is to wrap both sides of
-# m4_init with a one-shot macro that does the pop at the right time.
-m4_ifndef([_m4_divert_diversion],
-[m4_divert_push([KILL])
-m4_define([gl_divert_fixup], [m4_divert_pop()m4_define([$0])])
-m4_define([m4_init],
- [gl_divert_fixup()]m4_defn([m4_init])[gl_divert_fixup()])])
-
-
-# AC_DEFUN_ONCE([NAME], VALUE)
-# ----------------------------
-# Define NAME to expand to VALUE on the first use (whether by direct
-# expansion, or by AC_REQUIRE), and to nothing on all subsequent uses.
-# Avoid bugs in AC_REQUIRE in Autoconf 2.63 and earlier. This
-# definition is slower than the version in Autoconf 2.64, because it
-# can only use interfaces that existed since 2.59; but it achieves the
-# same effect. Quoting is necessary to avoid confusing Automake.
-m4_version_prereq([2.63.263], [],
-[m4_define([AC][_DEFUN_ONCE],
- [AC][_DEFUN([$1],
- [AC_REQUIRE([_gl_DEFUN_ONCE([$1])],
- [m4_indir([_gl_DEFUN_ONCE([$1])])])])]dnl
-[AC][_DEFUN([_gl_DEFUN_ONCE([$1])], [$2])])])
-
-# gl_00GNULIB
-# -----------
-# Witness macro that this file has been included. Needed to force
-# Automake to include this file prior to all other gnulib .m4 files.
-AC_DEFUN([gl_00GNULIB])
diff --git a/lib/glm4/absolute-header.m4 b/lib/glm4/absolute-header.m4
deleted file mode 100644
index c73adc8..0000000
--- a/lib/glm4/absolute-header.m4
+++ /dev/null
@@ -1,102 +0,0 @@
-# absolute-header.m4 serial 16
-dnl Copyright (C) 2006-2017 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-dnl From Derek Price.
-
-# gl_ABSOLUTE_HEADER(HEADER1 HEADER2 ...)
-# ---------------------------------------
-# Find the absolute name of a header file, testing first if the header exists.
-# If the header were sys/inttypes.h, this macro would define
-# ABSOLUTE_SYS_INTTYPES_H to the '""' quoted absolute name of sys/inttypes.h
-# in config.h
-# (e.g. '#define ABSOLUTE_SYS_INTTYPES_H "///usr/include/sys/inttypes.h"').
-# The three "///" are to pacify Sun C 5.8, which otherwise would say
-# "warning: #include of /usr/include/... may be non-portable".
-# Use '""', not '<>', so that the /// cannot be confused with a C99 comment.
-# Note: This macro assumes that the header file is not empty after
-# preprocessing, i.e. it does not only define preprocessor macros but also
-# provides some type/enum definitions or function/variable declarations.
-AC_DEFUN([gl_ABSOLUTE_HEADER],
-[AC_REQUIRE([AC_CANONICAL_HOST])
-AC_LANG_PREPROC_REQUIRE()dnl
-dnl FIXME: gl_absolute_header and ac_header_exists must be used unquoted
-dnl until we can assume autoconf 2.64 or newer.
-m4_foreach_w([gl_HEADER_NAME], [$1],
- [AS_VAR_PUSHDEF([gl_absolute_header],
- [gl_cv_absolute_]m4_defn([gl_HEADER_NAME]))dnl
- AC_CACHE_CHECK([absolute name of <]m4_defn([gl_HEADER_NAME])[>],
- m4_defn([gl_absolute_header]),
- [AS_VAR_PUSHDEF([ac_header_exists],
- [ac_cv_header_]m4_defn([gl_HEADER_NAME]))dnl
- AC_CHECK_HEADERS_ONCE(m4_defn([gl_HEADER_NAME]))dnl
- if test AS_VAR_GET(ac_header_exists) = yes; then
- gl_ABSOLUTE_HEADER_ONE(m4_defn([gl_HEADER_NAME]))
- fi
- AS_VAR_POPDEF([ac_header_exists])dnl
- ])dnl
- AC_DEFINE_UNQUOTED(AS_TR_CPP([ABSOLUTE_]m4_defn([gl_HEADER_NAME])),
- ["AS_VAR_GET(gl_absolute_header)"],
- [Define this to an absolute name of <]m4_defn([gl_HEADER_NAME])[>.])
- AS_VAR_POPDEF([gl_absolute_header])dnl
-])dnl
-])# gl_ABSOLUTE_HEADER
-
-# gl_ABSOLUTE_HEADER_ONE(HEADER)
-# ------------------------------
-# Like gl_ABSOLUTE_HEADER, except that:
-# - it assumes that the header exists,
-# - it uses the current CPPFLAGS,
-# - it does not cache the result,
-# - it is silent.
-AC_DEFUN([gl_ABSOLUTE_HEADER_ONE],
-[
- AC_REQUIRE([AC_CANONICAL_HOST])
- AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include <]]m4_dquote([$1])[[>]])])
- dnl AIX "xlc -E" and "cc -E" omit #line directives for header files
- dnl that contain only a #include of other header files and no
- dnl non-comment tokens of their own. This leads to a failure to
- dnl detect the absolute name of <dirent.h>, <signal.h>, <poll.h>
- dnl and others. The workaround is to force preservation of comments
- dnl through option -C. This ensures all necessary #line directives
- dnl are present. GCC supports option -C as well.
- case "$host_os" in
- aix*) gl_absname_cpp="$ac_cpp -C" ;;
- *) gl_absname_cpp="$ac_cpp" ;;
- esac
-changequote(,)
- case "$host_os" in
- mingw*)
- dnl For the sake of native Windows compilers (excluding gcc),
- dnl treat backslash as a directory separator, like /.
- dnl Actually, these compilers use a double-backslash as
- dnl directory separator, inside the
- dnl # line "filename"
- dnl directives.
- gl_dirsep_regex='[/\\]'
- ;;
- *)
- gl_dirsep_regex='\/'
- ;;
- esac
- dnl A sed expression that turns a string into a basic regular
- dnl expression, for use within "/.../".
- gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g'
- gl_header_literal_regex=`echo '$1' \
- | sed -e "$gl_make_literal_regex_sed"`
- gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{
- s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/
- s|^/[^/]|//&|
- p
- q
- }'
-changequote([,])
- dnl eval is necessary to expand gl_absname_cpp.
- dnl Ultrix and Pyramid sh refuse to redirect output of eval,
- dnl so use subshell.
- AS_VAR_SET([gl_cv_absolute_]AS_TR_SH([[$1]]),
-[`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
- sed -n "$gl_absolute_header_sed"`])
-])
diff --git a/lib/glm4/extensions.m4 b/lib/glm4/extensions.m4
deleted file mode 100644
index c60f537..0000000
--- a/lib/glm4/extensions.m4
+++ /dev/null
@@ -1,173 +0,0 @@
-# serial 15 -*- Autoconf -*-
-# Enable extensions on systems that normally disable them.
-
-# Copyright (C) 2003, 2006-2017 Free Software Foundation, Inc.
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from git
-# Autoconf. Perhaps we can remove this once we can assume Autoconf
-# 2.70 or later everywhere, but since Autoconf mutates rapidly
-# enough in this area it's likely we'll need to redefine
-# AC_USE_SYSTEM_EXTENSIONS for quite some time.
-
-# If autoconf reports a warning
-# warning: AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS
-# or warning: AC_RUN_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS
-# the fix is
-# 1) to ensure that AC_USE_SYSTEM_EXTENSIONS is never directly invoked
-# but always AC_REQUIREd,
-# 2) to ensure that for each occurrence of
-# AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
-# or
-# AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
-# the corresponding gnulib module description has 'extensions' among
-# its dependencies. This will ensure that the gl_USE_SYSTEM_EXTENSIONS
-# invocation occurs in gl_EARLY, not in gl_INIT.
-
-# AC_USE_SYSTEM_EXTENSIONS
-# ------------------------
-# Enable extensions on systems that normally disable them,
-# typically due to standards-conformance issues.
-#
-# Remember that #undef in AH_VERBATIM gets replaced with #define by
-# AC_DEFINE. The goal here is to define all known feature-enabling
-# macros, then, if reports of conflicts are made, disable macros that
-# cause problems on some platforms (such as __EXTENSIONS__).
-AC_DEFUN_ONCE([AC_USE_SYSTEM_EXTENSIONS],
-[AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
-AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
-
- AC_CHECK_HEADER([minix/config.h], [MINIX=yes], [MINIX=])
- if test "$MINIX" = yes; then
- AC_DEFINE([_POSIX_SOURCE], [1],
- [Define to 1 if you need to in order for 'stat' and other
- things to work.])
- AC_DEFINE([_POSIX_1_SOURCE], [2],
- [Define to 2 if the system does not provide POSIX.1 features
- except with this defined.])
- AC_DEFINE([_MINIX], [1],
- [Define to 1 if on MINIX.])
- AC_DEFINE([_NETBSD_SOURCE], [1],
- [Define to 1 to make NetBSD features available. MINIX 3 needs this.])
- fi
-
-dnl Use a different key than __EXTENSIONS__, as that name broke existing
-dnl configure.ac when using autoheader 2.62.
- AH_VERBATIM([USE_SYSTEM_EXTENSIONS],
-[/* Enable extensions on AIX 3, Interix. */
-#ifndef _ALL_SOURCE
-# undef _ALL_SOURCE
-#endif
-/* Enable general extensions on macOS. */
-#ifndef _DARWIN_C_SOURCE
-# undef _DARWIN_C_SOURCE
-#endif
-/* Enable GNU extensions on systems that have them. */
-#ifndef _GNU_SOURCE
-# undef _GNU_SOURCE
-#endif
-/* Enable threading extensions on Solaris. */
-#ifndef _POSIX_PTHREAD_SEMANTICS
-# undef _POSIX_PTHREAD_SEMANTICS
-#endif
-/* Enable extensions specified by ISO/IEC TS 18661-5:2014. */
-#ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
-# undef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
-#endif
-/* Enable extensions specified by ISO/IEC TS 18661-1:2014. */
-#ifndef __STDC_WANT_IEC_60559_BFP_EXT__
-# undef __STDC_WANT_IEC_60559_BFP_EXT__
-#endif
-/* Enable extensions specified by ISO/IEC TS 18661-2:2015. */
-#ifndef __STDC_WANT_IEC_60559_DFP_EXT__
-# undef __STDC_WANT_IEC_60559_DFP_EXT__
-#endif
-/* Enable extensions specified by ISO/IEC TS 18661-4:2015. */
-#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__
-# undef __STDC_WANT_IEC_60559_FUNCS_EXT__
-#endif
-/* Enable extensions specified by ISO/IEC TS 18661-3:2015. */
-#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__
-# undef __STDC_WANT_IEC_60559_TYPES_EXT__
-#endif
-/* Enable extensions specified by ISO/IEC TR 24731-2:2010. */
-#ifndef __STDC_WANT_LIB_EXT2__
-# undef __STDC_WANT_LIB_EXT2__
-#endif
-/* Enable extensions specified by ISO/IEC 24747:2009. */
-#ifndef __STDC_WANT_MATH_SPEC_FUNCS__
-# undef __STDC_WANT_MATH_SPEC_FUNCS__
-#endif
-/* Enable extensions on HP NonStop. */
-#ifndef _TANDEM_SOURCE
-# undef _TANDEM_SOURCE
-#endif
-/* Enable X/Open extensions if necessary. HP-UX 11.11 defines
- mbstate_t only if _XOPEN_SOURCE is defined to 500, regardless of
- whether compiling with -Ae or -D_HPUX_SOURCE=1. */
-#ifndef _XOPEN_SOURCE
-# undef _XOPEN_SOURCE
-#endif
-/* Enable general extensions on Solaris. */
-#ifndef __EXTENSIONS__
-# undef __EXTENSIONS__
-#endif
-])
- AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__],
- [ac_cv_safe_to_define___extensions__],
- [AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM([[
-# define __EXTENSIONS__ 1
- ]AC_INCLUDES_DEFAULT])],
- [ac_cv_safe_to_define___extensions__=yes],
- [ac_cv_safe_to_define___extensions__=no])])
- test $ac_cv_safe_to_define___extensions__ = yes &&
- AC_DEFINE([__EXTENSIONS__])
- AC_DEFINE([_ALL_SOURCE])
- AC_DEFINE([_DARWIN_C_SOURCE])
- AC_DEFINE([_GNU_SOURCE])
- AC_DEFINE([_POSIX_PTHREAD_SEMANTICS])
- AC_DEFINE([__STDC_WANT_IEC_60559_ATTRIBS_EXT__])
- AC_DEFINE([__STDC_WANT_IEC_60559_BFP_EXT__])
- AC_DEFINE([__STDC_WANT_IEC_60559_DFP_EXT__])
- AC_DEFINE([__STDC_WANT_IEC_60559_FUNCS_EXT__])
- AC_DEFINE([__STDC_WANT_IEC_60559_TYPES_EXT__])
- AC_DEFINE([__STDC_WANT_LIB_EXT2__])
- AC_DEFINE([__STDC_WANT_MATH_SPEC_FUNCS__])
- AC_DEFINE([_TANDEM_SOURCE])
- AC_CACHE_CHECK([whether _XOPEN_SOURCE should be defined],
- [ac_cv_should_define__xopen_source],
- [ac_cv_should_define__xopen_source=no
- AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM([[
- #include <wchar.h>
- mbstate_t x;]])],
- [],
- [AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM([[
- #define _XOPEN_SOURCE 500
- #include <wchar.h>
- mbstate_t x;]])],
- [ac_cv_should_define__xopen_source=yes])])])
- test $ac_cv_should_define__xopen_source = yes &&
- AC_DEFINE([_XOPEN_SOURCE], [500])
-])# AC_USE_SYSTEM_EXTENSIONS
-
-# gl_USE_SYSTEM_EXTENSIONS
-# ------------------------
-# Enable extensions on systems that normally disable them,
-# typically due to standards-conformance issues.
-AC_DEFUN_ONCE([gl_USE_SYSTEM_EXTENSIONS],
-[
- dnl Require this macro before AC_USE_SYSTEM_EXTENSIONS.
- dnl gnulib does not need it. But if it gets required by third-party macros
- dnl after AC_USE_SYSTEM_EXTENSIONS is required, autoconf 2.62..2.63 emit a
- dnl warning: "AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS".
- dnl Note: We can do this only for one of the macros AC_AIX, AC_GNU_SOURCE,
- dnl AC_MINIX. If people still use AC_AIX or AC_MINIX, they are out of luck.
- AC_REQUIRE([AC_GNU_SOURCE])
-
- AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
-])
diff --git a/lib/glm4/extern-inline.m4 b/lib/glm4/extern-inline.m4
deleted file mode 100644
index 00f9609..0000000
--- a/lib/glm4/extern-inline.m4
+++ /dev/null
@@ -1,102 +0,0 @@
-dnl 'extern inline' a la ISO C99.
-
-dnl Copyright 2012-2017 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-AC_DEFUN([gl_EXTERN_INLINE],
-[
- AH_VERBATIM([extern_inline],
-[/* Please see the Gnulib manual for how to use these macros.
-
- Suppress extern inline with HP-UX cc, as it appears to be broken; see
- <http://lists.gnu.org/archive/html/bug-texinfo/2013-02/msg00030.html>.
-
- Suppress extern inline with Sun C in standards-conformance mode, as it
- mishandles inline functions that call each other. E.g., for 'inline void f
- (void) { } inline void g (void) { f (); }', c99 incorrectly complains
- 'reference to static identifier "f" in extern inline function'.
- This bug was observed with Sun C 5.12 SunOS_i386 2011/11/16.
-
- Suppress extern inline (with or without __attribute__ ((__gnu_inline__)))
- on configurations that mistakenly use 'static inline' to implement
- functions or macros in standard C headers like <ctype.h>. For example,
- if isdigit is mistakenly implemented via a static inline function,
- a program containing an extern inline function that calls isdigit
- may not work since the C standard prohibits extern inline functions
- from calling static functions. This bug is known to occur on:
-
- OS X 10.8 and earlier; see:
- http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html
-
- DragonFly; see
- http://muscles.dragonflybsd.org/bulk/bleeding-edge-potential/latest-per-pkg/ah-tty-0.3.12.log
-
- FreeBSD; see:
- http://lists.gnu.org/archive/html/bug-gnulib/2014-07/msg00104.html
-
- OS X 10.9 has a macro __header_inline indicating the bug is fixed for C and
- for clang but remains for g++; see <http://trac.macports.org/ticket/41033>.
- Assume DragonFly and FreeBSD will be similar. */
-#if (((defined __APPLE__ && defined __MACH__) \
- || defined __DragonFly__ || defined __FreeBSD__) \
- && (defined __header_inline \
- ? (defined __cplusplus && defined __GNUC_STDC_INLINE__ \
- && ! defined __clang__) \
- : ((! defined _DONT_USE_CTYPE_INLINE_ \
- && (defined __GNUC__ || defined __cplusplus)) \
- || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \
- && defined __GNUC__ && ! defined __cplusplus))))
-# define _GL_EXTERN_INLINE_STDHEADER_BUG
-#endif
-#if ((__GNUC__ \
- ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \
- : (199901L <= __STDC_VERSION__ \
- && !defined __HP_cc \
- && !defined __PGI \
- && !(defined __SUNPRO_C && __STDC__))) \
- && !defined _GL_EXTERN_INLINE_STDHEADER_BUG)
-# define _GL_INLINE inline
-# define _GL_EXTERN_INLINE extern inline
-# define _GL_EXTERN_INLINE_IN_USE
-#elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \
- && !defined _GL_EXTERN_INLINE_STDHEADER_BUG)
-# if defined __GNUC_GNU_INLINE__ && __GNUC_GNU_INLINE__
- /* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */
-# define _GL_INLINE extern inline __attribute__ ((__gnu_inline__))
-# else
-# define _GL_INLINE extern inline
-# endif
-# define _GL_EXTERN_INLINE extern
-# define _GL_EXTERN_INLINE_IN_USE
-#else
-# define _GL_INLINE static _GL_UNUSED
-# define _GL_EXTERN_INLINE static _GL_UNUSED
-#endif
-
-/* In GCC 4.6 (inclusive) to 5.1 (exclusive),
- suppress bogus "no previous prototype for 'FOO'"
- and "no previous declaration for 'FOO'" diagnostics,
- when FOO is an inline function in the header; see
- <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113> and
- <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63877>. */
-#if __GNUC__ == 4 && 6 <= __GNUC_MINOR__
-# if defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__
-# define _GL_INLINE_HEADER_CONST_PRAGMA
-# else
-# define _GL_INLINE_HEADER_CONST_PRAGMA \
- _Pragma ("GCC diagnostic ignored \"-Wsuggest-attribute=const\"")
-# endif
-# define _GL_INLINE_HEADER_BEGIN \
- _Pragma ("GCC diagnostic push") \
- _Pragma ("GCC diagnostic ignored \"-Wmissing-prototypes\"") \
- _Pragma ("GCC diagnostic ignored \"-Wmissing-declarations\"") \
- _GL_INLINE_HEADER_CONST_PRAGMA
-# define _GL_INLINE_HEADER_END \
- _Pragma ("GCC diagnostic pop")
-#else
-# define _GL_INLINE_HEADER_BEGIN
-# define _GL_INLINE_HEADER_END
-#endif])
-])
diff --git a/lib/glm4/gnulib-cache.m4 b/lib/glm4/gnulib-cache.m4
deleted file mode 100644
index 4c39644..0000000
--- a/lib/glm4/gnulib-cache.m4
+++ /dev/null
@@ -1,56 +0,0 @@
-# Copyright (C) 2002-2017 Free Software Foundation, Inc.
-#
-# This file is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 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 General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this file. If not, see <http://www.gnu.org/licenses/>.
-#
-# As a special exception to the GNU General Public License,
-# this file may be distributed as part of a program that
-# contains a configuration script generated by Autoconf, under
-# the same distribution terms as the rest of that program.
-#
-# Generated by gnulib-tool.
-#
-# This file represents the specification of how gnulib-tool is used.
-# It acts as a cache: It is written and read by gnulib-tool.
-# In projects that use version control, this file is meant to be put under
-# version control, like the configure.ac and various Makefile.am files.
-
-
-# Specification in the form of a command-line invocation:
-# gnulib-tool --import --lib=libgnu --source-base=lib/gllib --m4-base=lib/glm4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=2 --no-conditional-dependencies --libtool --macro-prefix=lgl --no-vc-files hash-pjw-bare intprops lib-symbol-versions lib-symbol-visibility minmax stdint strverscmp
-
-# Specification in the form of a few gnulib-tool.m4 macro invocations:
-gl_LOCAL_DIR([])
-gl_MODULES([
- hash-pjw-bare
- intprops
- lib-symbol-versions
- lib-symbol-visibility
- minmax
- stdint
- strverscmp
-])
-gl_AVOID([])
-gl_SOURCE_BASE([lib/gllib])
-gl_M4_BASE([lib/glm4])
-gl_PO_BASE([])
-gl_DOC_BASE([doc])
-gl_TESTS_BASE([tests])
-gl_LIB([libgnu])
-gl_LGPL([2])
-gl_MAKEFILE_NAME([])
-gl_LIBTOOL
-gl_MACRO_PREFIX([lgl])
-gl_PO_DOMAIN([])
-gl_WITNESS_C_MACRO([])
-gl_VC_FILES([false])
diff --git a/lib/glm4/gnulib-common.m4 b/lib/glm4/gnulib-common.m4
deleted file mode 100644
index 7d9b40b..0000000
--- a/lib/glm4/gnulib-common.m4
+++ /dev/null
@@ -1,462 +0,0 @@
-# gnulib-common.m4 serial 36
-dnl Copyright (C) 2007-2017 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-# gl_COMMON
-# is expanded unconditionally through gnulib-tool magic.
-AC_DEFUN([gl_COMMON], [
- dnl Use AC_REQUIRE here, so that the code is expanded once only.
- AC_REQUIRE([gl_00GNULIB])
- AC_REQUIRE([gl_COMMON_BODY])
-])
-AC_DEFUN([gl_COMMON_BODY], [
- AH_VERBATIM([_Noreturn],
-[/* The _Noreturn keyword of C11. */
-#if ! (defined _Noreturn \
- || (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__))
-# if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \
- || 0x5110 <= __SUNPRO_C)
-# define _Noreturn __attribute__ ((__noreturn__))
-# elif defined _MSC_VER && 1200 <= _MSC_VER
-# define _Noreturn __declspec (noreturn)
-# else
-# define _Noreturn
-# endif
-#endif
-])
- AH_VERBATIM([isoc99_inline],
-[/* Work around a bug in Apple GCC 4.0.1 build 5465: In C99 mode, it supports
- the ISO C 99 semantics of 'extern inline' (unlike the GNU C semantics of
- earlier versions), but does not display it by setting __GNUC_STDC_INLINE__.
- __APPLE__ && __MACH__ test for Mac OS X.
- __APPLE_CC__ tests for the Apple compiler and its version.
- __STDC_VERSION__ tests for the C99 mode. */
-#if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__
-# define __GNUC_STDC_INLINE__ 1
-#endif])
- AH_VERBATIM([unused_parameter],
-[/* Define as a marker that can be attached to declarations that might not
- be used. This helps to reduce warnings, such as from
- GCC -Wunused-parameter. */
-#if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
-# define _GL_UNUSED __attribute__ ((__unused__))
-#else
-# define _GL_UNUSED
-#endif
-/* The name _UNUSED_PARAMETER_ is an earlier spelling, although the name
- is a misnomer outside of parameter lists. */
-#define _UNUSED_PARAMETER_ _GL_UNUSED
-
-/* gcc supports the "unused" attribute on possibly unused labels, and
- g++ has since version 4.5. Note to support C++ as well as C,
- _GL_UNUSED_LABEL should be used with a trailing ; */
-#if !defined __cplusplus || __GNUC__ > 4 \
- || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
-# define _GL_UNUSED_LABEL _GL_UNUSED
-#else
-# define _GL_UNUSED_LABEL
-#endif
-
-/* The __pure__ attribute was added in gcc 2.96. */
-#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
-# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
-#else
-# define _GL_ATTRIBUTE_PURE /* empty */
-#endif
-
-/* The __const__ attribute was added in gcc 2.95. */
-#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
-# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__))
-#else
-# define _GL_ATTRIBUTE_CONST /* empty */
-#endif
-])
- dnl Preparation for running test programs:
- dnl Tell glibc to write diagnostics from -D_FORTIFY_SOURCE=2 to stderr, not
- dnl to /dev/tty, so they can be redirected to log files. Such diagnostics
- dnl arise e.g., in the macros gl_PRINTF_DIRECTIVE_N, gl_SNPRINTF_DIRECTIVE_N.
- LIBC_FATAL_STDERR_=1
- export LIBC_FATAL_STDERR_
-])
-
-# gl_MODULE_INDICATOR_CONDITION
-# expands to a C preprocessor expression that evaluates to 1 or 0, depending
-# whether a gnulib module that has been requested shall be considered present
-# or not.
-m4_define([gl_MODULE_INDICATOR_CONDITION], [1])
-
-# gl_MODULE_INDICATOR_SET_VARIABLE([modulename])
-# sets the shell variable that indicates the presence of the given module to
-# a C preprocessor expression that will evaluate to 1.
-AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE],
-[
- gl_MODULE_INDICATOR_SET_VARIABLE_AUX(
- [GNULIB_[]m4_translit([[$1]],
- [abcdefghijklmnopqrstuvwxyz./-],
- [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])],
- [gl_MODULE_INDICATOR_CONDITION])
-])
-
-# gl_MODULE_INDICATOR_SET_VARIABLE_AUX([variable])
-# modifies the shell variable to include the gl_MODULE_INDICATOR_CONDITION.
-# The shell variable's value is a C preprocessor expression that evaluates
-# to 0 or 1.
-AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE_AUX],
-[
- m4_if(m4_defn([gl_MODULE_INDICATOR_CONDITION]), [1],
- [
- dnl Simplify the expression VALUE || 1 to 1.
- $1=1
- ],
- [gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR([$1],
- [gl_MODULE_INDICATOR_CONDITION])])
-])
-
-# gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR([variable], [condition])
-# modifies the shell variable to include the given condition. The shell
-# variable's value is a C preprocessor expression that evaluates to 0 or 1.
-AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR],
-[
- dnl Simplify the expression 1 || CONDITION to 1.
- if test "$[]$1" != 1; then
- dnl Simplify the expression 0 || CONDITION to CONDITION.
- if test "$[]$1" = 0; then
- $1=$2
- else
- $1="($[]$1 || $2)"
- fi
- fi
-])
-
-# gl_MODULE_INDICATOR([modulename])
-# defines a C macro indicating the presence of the given module
-# in a location where it can be used.
-# | Value | Value |
-# | in lib/ | in tests/ |
-# --------------------------------------------+---------+-----------+
-# Module present among main modules: | 1 | 1 |
-# --------------------------------------------+---------+-----------+
-# Module present among tests-related modules: | 0 | 1 |
-# --------------------------------------------+---------+-----------+
-# Module not present at all: | 0 | 0 |
-# --------------------------------------------+---------+-----------+
-AC_DEFUN([gl_MODULE_INDICATOR],
-[
- AC_DEFINE_UNQUOTED([GNULIB_]m4_translit([[$1]],
- [abcdefghijklmnopqrstuvwxyz./-],
- [ABCDEFGHIJKLMNOPQRSTUVWXYZ___]),
- [gl_MODULE_INDICATOR_CONDITION],
- [Define to a C preprocessor expression that evaluates to 1 or 0,
- depending whether the gnulib module $1 shall be considered present.])
-])
-
-# gl_MODULE_INDICATOR_FOR_TESTS([modulename])
-# defines a C macro indicating the presence of the given module
-# in lib or tests. This is useful to determine whether the module
-# should be tested.
-# | Value | Value |
-# | in lib/ | in tests/ |
-# --------------------------------------------+---------+-----------+
-# Module present among main modules: | 1 | 1 |
-# --------------------------------------------+---------+-----------+
-# Module present among tests-related modules: | 1 | 1 |
-# --------------------------------------------+---------+-----------+
-# Module not present at all: | 0 | 0 |
-# --------------------------------------------+---------+-----------+
-AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS],
-[
- AC_DEFINE([GNULIB_TEST_]m4_translit([[$1]],
- [abcdefghijklmnopqrstuvwxyz./-],
- [ABCDEFGHIJKLMNOPQRSTUVWXYZ___]), [1],
- [Define to 1 when the gnulib module $1 should be tested.])
-])
-
-# gl_ASSERT_NO_GNULIB_POSIXCHECK
-# asserts that there will never be a need to #define GNULIB_POSIXCHECK.
-# and thereby enables an optimization of configure and config.h.
-# Used by Emacs.
-AC_DEFUN([gl_ASSERT_NO_GNULIB_POSIXCHECK],
-[
- dnl Override gl_WARN_ON_USE_PREPARE.
- dnl But hide this definition from 'aclocal'.
- AC_DEFUN([gl_W][ARN_ON_USE_PREPARE], [])
-])
-
-# gl_ASSERT_NO_GNULIB_TESTS
-# asserts that there will be no gnulib tests in the scope of the configure.ac
-# and thereby enables an optimization of config.h.
-# Used by Emacs.
-AC_DEFUN([gl_ASSERT_NO_GNULIB_TESTS],
-[
- dnl Override gl_MODULE_INDICATOR_FOR_TESTS.
- AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS], [])
-])
-
-# Test whether <features.h> exists.
-# Set HAVE_FEATURES_H.
-AC_DEFUN([gl_FEATURES_H],
-[
- AC_CHECK_HEADERS_ONCE([features.h])
- if test $ac_cv_header_features_h = yes; then
- HAVE_FEATURES_H=1
- else
- HAVE_FEATURES_H=0
- fi
- AC_SUBST([HAVE_FEATURES_H])
-])
-
-# m4_foreach_w
-# is a backport of autoconf-2.59c's m4_foreach_w.
-# Remove this macro when we can assume autoconf >= 2.60.
-m4_ifndef([m4_foreach_w],
- [m4_define([m4_foreach_w],
- [m4_foreach([$1], m4_split(m4_normalize([$2]), [ ]), [$3])])])
-
-# AS_VAR_IF(VAR, VALUE, [IF-MATCH], [IF-NOT-MATCH])
-# ----------------------------------------------------
-# Backport of autoconf-2.63b's macro.
-# Remove this macro when we can assume autoconf >= 2.64.
-m4_ifndef([AS_VAR_IF],
-[m4_define([AS_VAR_IF],
-[AS_IF([test x"AS_VAR_GET([$1])" = x""$2], [$3], [$4])])])
-
-# gl_PROG_CC_C99
-# Modifies the value of the shell variable CC in an attempt to make $CC
-# understand ISO C99 source code.
-# This is like AC_PROG_CC_C99, except that
-# - AC_PROG_CC_C99 did not exist in Autoconf versions < 2.60,
-# - AC_PROG_CC_C99 does not mix well with AC_PROG_CC_STDC
-# <http://lists.gnu.org/archive/html/bug-gnulib/2011-09/msg00367.html>,
-# but many more packages use AC_PROG_CC_STDC than AC_PROG_CC_C99
-# <http://lists.gnu.org/archive/html/bug-gnulib/2011-09/msg00441.html>.
-# Remaining problems:
-# - When AC_PROG_CC_STDC is invoked twice, it adds the C99 enabling options
-# to CC twice
-# <http://lists.gnu.org/archive/html/bug-gnulib/2011-09/msg00431.html>.
-# - AC_PROG_CC_STDC is likely to change now that C11 is an ISO standard.
-AC_DEFUN([gl_PROG_CC_C99],
-[
- dnl Change that version number to the minimum Autoconf version that supports
- dnl mixing AC_PROG_CC_C99 calls with AC_PROG_CC_STDC calls.
- m4_version_prereq([9.0],
- [AC_REQUIRE([AC_PROG_CC_C99])],
- [AC_REQUIRE([AC_PROG_CC_STDC])])
-])
-
-# gl_PROG_AR_RANLIB
-# Determines the values for AR, ARFLAGS, RANLIB that fit with the compiler.
-# The user can set the variables AR, ARFLAGS, RANLIB if he wants to override
-# the values.
-AC_DEFUN([gl_PROG_AR_RANLIB],
-[
- dnl Minix 3 comes with two toolchains: The Amsterdam Compiler Kit compiler
- dnl as "cc", and GCC as "gcc". They have different object file formats and
- dnl library formats. In particular, the GNU binutils programs ar and ranlib
- dnl produce libraries that work only with gcc, not with cc.
- AC_REQUIRE([AC_PROG_CC])
- AC_BEFORE([$0], [AM_PROG_AR])
- AC_CACHE_CHECK([for Minix Amsterdam compiler], [gl_cv_c_amsterdam_compiler],
- [
- AC_EGREP_CPP([Amsterdam],
- [
-#ifdef __ACK__
-Amsterdam
-#endif
- ],
- [gl_cv_c_amsterdam_compiler=yes],
- [gl_cv_c_amsterdam_compiler=no])
- ])
-
- dnl Don't compete with AM_PROG_AR's decision about AR/ARFLAGS if we are not
- dnl building with __ACK__.
- if test $gl_cv_c_amsterdam_compiler = yes; then
- if test -z "$AR"; then
- AR='cc -c.a'
- fi
- if test -z "$ARFLAGS"; then
- ARFLAGS='-o'
- fi
- else
- dnl AM_PROG_AR was added in automake v1.11.2. AM_PROG_AR does not AC_SUBST
- dnl ARFLAGS variable (it is filed into Makefile.in directly by automake
- dnl script on-demand, if not specified by ./configure of course).
- dnl Don't AC_REQUIRE the AM_PROG_AR otherwise the code for __ACK__ above
- dnl will be ignored. Also, pay attention to call AM_PROG_AR in else block
- dnl because AM_PROG_AR is written so it could re-set AR variable even for
- dnl __ACK__. It may seem like its easier to avoid calling the macro here,
- dnl but we need to AC_SUBST both AR/ARFLAGS (thus those must have some good
- dnl default value and automake should usually know them).
- m4_ifdef([AM_PROG_AR], [AM_PROG_AR], [:])
- fi
-
- dnl In case the code above has not helped with setting AR/ARFLAGS, use
- dnl Automake-documented default values for AR and ARFLAGS, but prefer
- dnl ${host}-ar over ar (useful for cross-compiling).
- AC_CHECK_TOOL([AR], [ar], [ar])
- if test -z "$ARFLAGS"; then
- ARFLAGS='cr'
- fi
-
- AC_SUBST([AR])
- AC_SUBST([ARFLAGS])
- if test -z "$RANLIB"; then
- if test $gl_cv_c_amsterdam_compiler = yes; then
- RANLIB=':'
- else
- dnl Use the ranlib program if it is available.
- AC_PROG_RANLIB
- fi
- fi
- AC_SUBST([RANLIB])
-])
-
-# AC_PROG_MKDIR_P
-# is a backport of autoconf-2.60's AC_PROG_MKDIR_P, with a fix
-# for interoperability with automake-1.9.6 from autoconf-2.62.
-# Remove this macro when we can assume autoconf >= 2.62 or
-# autoconf >= 2.60 && automake >= 1.10.
-# AC_AUTOCONF_VERSION was introduced in 2.62, so use that as the witness.
-m4_ifndef([AC_AUTOCONF_VERSION],[
-m4_ifdef([AC_PROG_MKDIR_P], [
- dnl For automake-1.9.6 && autoconf < 2.62: Ensure MKDIR_P is AC_SUBSTed.
- m4_define([AC_PROG_MKDIR_P],
- m4_defn([AC_PROG_MKDIR_P])[
- AC_SUBST([MKDIR_P])])], [
- dnl For autoconf < 2.60: Backport of AC_PROG_MKDIR_P.
- AC_DEFUN_ONCE([AC_PROG_MKDIR_P],
- [AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake
- MKDIR_P='$(mkdir_p)'
- AC_SUBST([MKDIR_P])])])
-])
-
-# AC_C_RESTRICT
-# This definition is copied from post-2.69 Autoconf and overrides the
-# AC_C_RESTRICT macro from autoconf 2.60..2.69. It can be removed
-# once autoconf >= 2.70 can be assumed. It's painful to check version
-# numbers, and in practice this macro is more up-to-date than Autoconf
-# is, so override Autoconf unconditionally.
-AC_DEFUN([AC_C_RESTRICT],
-[AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict],
- [ac_cv_c_restrict=no
- # The order here caters to the fact that C++ does not require restrict.
- for ac_kw in __restrict __restrict__ _Restrict restrict; do
- AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM(
- [[typedef int *int_ptr;
- int foo (int_ptr $ac_kw ip) { return ip[0]; }
- int bar (int [$ac_kw]); /* Catch GCC bug 14050. */
- int bar (int ip[$ac_kw]) { return ip[0]; }
- ]],
- [[int s[1];
- int *$ac_kw t = s;
- t[0] = 0;
- return foo (t) + bar (t);
- ]])],
- [ac_cv_c_restrict=$ac_kw])
- test "$ac_cv_c_restrict" != no && break
- done
- ])
- AH_VERBATIM([restrict],
-[/* Define to the equivalent of the C99 'restrict' keyword, or to
- nothing if this is not supported. Do not define if restrict is
- supported directly. */
-#undef restrict
-/* Work around a bug in Sun C++: it does not support _Restrict or
- __restrict__, even though the corresponding Sun C compiler ends up with
- "#define restrict _Restrict" or "#define restrict __restrict__" in the
- previous line. Perhaps some future version of Sun C++ will work with
- restrict; if so, hopefully it defines __RESTRICT like Sun C does. */
-#if defined __SUNPRO_CC && !defined __RESTRICT
-# define _Restrict
-# define __restrict__
-#endif])
- case $ac_cv_c_restrict in
- restrict) ;;
- no) AC_DEFINE([restrict], []) ;;
- *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;;
- esac
-])# AC_C_RESTRICT
-
-# gl_BIGENDIAN
-# is like AC_C_BIGENDIAN, except that it can be AC_REQUIREd.
-# Note that AC_REQUIRE([AC_C_BIGENDIAN]) does not work reliably because some
-# macros invoke AC_C_BIGENDIAN with arguments.
-AC_DEFUN([gl_BIGENDIAN],
-[
- AC_C_BIGENDIAN
-])
-
-# gl_CACHE_VAL_SILENT(cache-id, command-to-set-it)
-# is like AC_CACHE_VAL(cache-id, command-to-set-it), except that it does not
-# output a spurious "(cached)" mark in the midst of other configure output.
-# This macro should be used instead of AC_CACHE_VAL when it is not surrounded
-# by an AC_MSG_CHECKING/AC_MSG_RESULT pair.
-AC_DEFUN([gl_CACHE_VAL_SILENT],
-[
- saved_as_echo_n="$as_echo_n"
- as_echo_n=':'
- AC_CACHE_VAL([$1], [$2])
- as_echo_n="$saved_as_echo_n"
-])
-
-# AS_VAR_COPY was added in autoconf 2.63b
-m4_define_default([AS_VAR_COPY],
-[AS_LITERAL_IF([$1[]$2], [$1=$$2], [eval $1=\$$2])])
-
-# AC_PROG_SED was added in autoconf 2.59b
-m4_ifndef([AC_PROG_SED],
-[AC_DEFUN([AC_PROG_SED],
-[AC_CACHE_CHECK([for a sed that does not truncate output], ac_cv_path_SED,
- [dnl ac_script should not contain more than 99 commands (for HP-UX sed),
- dnl but more than about 7000 bytes, to catch a limit in Solaris 8 /usr/ucb/sed.
- ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
- for ac_i in 1 2 3 4 5 6 7; do
- ac_script="$ac_script$as_nl$ac_script"
- done
- echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed
- AS_UNSET([ac_script])
- if test -z "$SED"; then
- ac_path_SED_found=false
- _AS_PATH_WALK([], [
- for ac_prog in sed gsed; do
- for ac_exec_ext in '' $ac_executable_extensions; do
- ac_path_SED="$as_dir/$ac_prog$ac_exec_ext"
- AS_EXECUTABLE_P(["$ac_path_SED"]) || continue
- case `"$ac_path_SED" --version 2>&1` in
- *GNU*) ac_cv_path_SED=$ac_path_SED ac_path_SED_found=:;;
- *)
- ac_count=0
- _AS_ECHO_N([0123456789]) >conftest.in
- while :
- do
- cat conftest.in conftest.in >conftest.tmp
- mv conftest.tmp conftest.in
- cp conftest.in conftest.nl
- echo >> conftest.nl
- "$ac_path_SED" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
- diff conftest.out conftest.nl >/dev/null 2>&1 || break
- ac_count=`expr $ac_count + 1`
- if test $ac_count -gt ${ac_path_SED_max-0}; then
- # Best so far, but keep looking for better
- ac_cv_path_SED=$ac_path_SED
- ac_path_SED_max=$ac_count
- fi
- test $ac_count -gt 10 && break
- done
- rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
- esac
- $ac_path_SED_found && break 3
- done
- done])
- if test -z "$ac_cv_path_SED"; then
- AC_ERROR([no acceptable sed could be found in \$PATH])
- fi
- else
- ac_cv_path_SED=$SED
- fi
- SED="$ac_cv_path_SED"
- AC_SUBST([SED])dnl
- rm -f conftest.sed
-])])])
diff --git a/lib/glm4/gnulib-comp.m4 b/lib/glm4/gnulib-comp.m4
deleted file mode 100644
index 38f4c34..0000000
--- a/lib/glm4/gnulib-comp.m4
+++ /dev/null
@@ -1,272 +0,0 @@
-# DO NOT EDIT! GENERATED AUTOMATICALLY!
-# Copyright (C) 2002-2017 Free Software Foundation, Inc.
-#
-# This file is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 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 General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this file. If not, see <http://www.gnu.org/licenses/>.
-#
-# As a special exception to the GNU General Public License,
-# this file may be distributed as part of a program that
-# contains a configuration script generated by Autoconf, under
-# the same distribution terms as the rest of that program.
-#
-# Generated by gnulib-tool.
-#
-# This file represents the compiled summary of the specification in
-# gnulib-cache.m4. It lists the computed macro invocations that need
-# to be invoked from configure.ac.
-# In projects that use version control, this file can be treated like
-# other built files.
-
-
-# This macro should be invoked from ./configure.ac, in the section
-# "Checks for programs", right after AC_PROG_CC, and certainly before
-# any checks for libraries, header files, types and library functions.
-AC_DEFUN([lgl_EARLY],
-[
- m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace
- m4_pattern_allow([^gl_ES$])dnl a valid locale name
- m4_pattern_allow([^gl_LIBOBJS$])dnl a variable
- m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable
-
- # Pre-early section.
- AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
- AC_REQUIRE([gl_PROG_AR_RANLIB])
-
- # Code from module absolute-header:
- # Code from module extensions:
- # Code from module extern-inline:
- # Code from module hash-pjw-bare:
- # Code from module include_next:
- # Code from module intprops:
- # Code from module lib-symbol-versions:
- # Code from module lib-symbol-visibility:
- # Code from module limits-h:
- # Code from module minmax:
- # Code from module multiarch:
- # Code from module snippet/arg-nonnull:
- # Code from module snippet/c++defs:
- # Code from module snippet/warn-on-use:
- # Code from module ssize_t:
- # Code from module stddef:
- # Code from module stdint:
- # Code from module string:
- # Code from module strverscmp:
- # Code from module sys_types:
- # Code from module verify:
-])
-
-# This macro should be invoked from ./configure.ac, in the section
-# "Check for header files, types and library functions".
-AC_DEFUN([lgl_INIT],
-[
- AM_CONDITIONAL([GL_COND_LIBTOOL], [true])
- gl_cond_libtool=true
- gl_m4_base='lib/glm4'
- m4_pushdef([AC_LIBOBJ], m4_defn([lgl_LIBOBJ]))
- m4_pushdef([AC_REPLACE_FUNCS], m4_defn([lgl_REPLACE_FUNCS]))
- m4_pushdef([AC_LIBSOURCES], m4_defn([lgl_LIBSOURCES]))
- m4_pushdef([lgl_LIBSOURCES_LIST], [])
- m4_pushdef([lgl_LIBSOURCES_DIR], [])
- gl_COMMON
- gl_source_base='lib/gllib'
- AC_REQUIRE([gl_EXTERN_INLINE])
- gl_LD_VERSION_SCRIPT
- gl_VISIBILITY
- gl_LIMITS_H
- gl_MINMAX
- gl_MULTIARCH
- gt_TYPE_SSIZE_T
- gl_STDDEF_H
- gl_STDINT_H
- gl_HEADER_STRING_H
- gl_FUNC_STRVERSCMP
- if test $HAVE_STRVERSCMP = 0; then
- AC_LIBOBJ([strverscmp])
- gl_PREREQ_STRVERSCMP
- fi
- gl_STRING_MODULE_INDICATOR([strverscmp])
- gl_SYS_TYPES_H
- AC_PROG_MKDIR_P
- # End of code from modules
- m4_ifval(lgl_LIBSOURCES_LIST, [
- m4_syscmd([test ! -d ]m4_defn([lgl_LIBSOURCES_DIR])[ ||
- for gl_file in ]lgl_LIBSOURCES_LIST[ ; do
- if test ! -r ]m4_defn([lgl_LIBSOURCES_DIR])[/$gl_file ; then
- echo "missing file ]m4_defn([lgl_LIBSOURCES_DIR])[/$gl_file" >&2
- exit 1
- fi
- done])dnl
- m4_if(m4_sysval, [0], [],
- [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])
- ])
- m4_popdef([lgl_LIBSOURCES_DIR])
- m4_popdef([lgl_LIBSOURCES_LIST])
- m4_popdef([AC_LIBSOURCES])
- m4_popdef([AC_REPLACE_FUNCS])
- m4_popdef([AC_LIBOBJ])
- AC_CONFIG_COMMANDS_PRE([
- lgl_libobjs=
- lgl_ltlibobjs=
- if test -n "$lgl_LIBOBJS"; then
- # Remove the extension.
- sed_drop_objext='s/\.o$//;s/\.obj$//'
- for i in `for i in $lgl_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
- lgl_libobjs="$lgl_libobjs $i.$ac_objext"
- lgl_ltlibobjs="$lgl_ltlibobjs $i.lo"
- done
- fi
- AC_SUBST([lgl_LIBOBJS], [$lgl_libobjs])
- AC_SUBST([lgl_LTLIBOBJS], [$lgl_ltlibobjs])
- ])
- gltests_libdeps=
- gltests_ltlibdeps=
- m4_pushdef([AC_LIBOBJ], m4_defn([lgltests_LIBOBJ]))
- m4_pushdef([AC_REPLACE_FUNCS], m4_defn([lgltests_REPLACE_FUNCS]))
- m4_pushdef([AC_LIBSOURCES], m4_defn([lgltests_LIBSOURCES]))
- m4_pushdef([lgltests_LIBSOURCES_LIST], [])
- m4_pushdef([lgltests_LIBSOURCES_DIR], [])
- gl_COMMON
- gl_source_base='tests'
-changequote(,)dnl
- lgltests_WITNESS=IN_`echo "${PACKAGE-$PACKAGE_TARNAME}" | LC_ALL=C tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | LC_ALL=C sed -e 's/[^A-Z0-9_]/_/g'`_GNULIB_TESTS
-changequote([, ])dnl
- AC_SUBST([lgltests_WITNESS])
- gl_module_indicator_condition=$lgltests_WITNESS
- m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$gl_module_indicator_condition])
- m4_popdef([gl_MODULE_INDICATOR_CONDITION])
- m4_ifval(lgltests_LIBSOURCES_LIST, [
- m4_syscmd([test ! -d ]m4_defn([lgltests_LIBSOURCES_DIR])[ ||
- for gl_file in ]lgltests_LIBSOURCES_LIST[ ; do
- if test ! -r ]m4_defn([lgltests_LIBSOURCES_DIR])[/$gl_file ; then
- echo "missing file ]m4_defn([lgltests_LIBSOURCES_DIR])[/$gl_file" >&2
- exit 1
- fi
- done])dnl
- m4_if(m4_sysval, [0], [],
- [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])
- ])
- m4_popdef([lgltests_LIBSOURCES_DIR])
- m4_popdef([lgltests_LIBSOURCES_LIST])
- m4_popdef([AC_LIBSOURCES])
- m4_popdef([AC_REPLACE_FUNCS])
- m4_popdef([AC_LIBOBJ])
- AC_CONFIG_COMMANDS_PRE([
- lgltests_libobjs=
- lgltests_ltlibobjs=
- if test -n "$lgltests_LIBOBJS"; then
- # Remove the extension.
- sed_drop_objext='s/\.o$//;s/\.obj$//'
- for i in `for i in $lgltests_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
- lgltests_libobjs="$lgltests_libobjs $i.$ac_objext"
- lgltests_ltlibobjs="$lgltests_ltlibobjs $i.lo"
- done
- fi
- AC_SUBST([lgltests_LIBOBJS], [$lgltests_libobjs])
- AC_SUBST([lgltests_LTLIBOBJS], [$lgltests_ltlibobjs])
- ])
-])
-
-# Like AC_LIBOBJ, except that the module name goes
-# into lgl_LIBOBJS instead of into LIBOBJS.
-AC_DEFUN([lgl_LIBOBJ], [
- AS_LITERAL_IF([$1], [lgl_LIBSOURCES([$1.c])])dnl
- lgl_LIBOBJS="$lgl_LIBOBJS $1.$ac_objext"
-])
-
-# Like AC_REPLACE_FUNCS, except that the module name goes
-# into lgl_LIBOBJS instead of into LIBOBJS.
-AC_DEFUN([lgl_REPLACE_FUNCS], [
- m4_foreach_w([gl_NAME], [$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl
- AC_CHECK_FUNCS([$1], , [lgl_LIBOBJ($ac_func)])
-])
-
-# Like AC_LIBSOURCES, except the directory where the source file is
-# expected is derived from the gnulib-tool parameterization,
-# and alloca is special cased (for the alloca-opt module).
-# We could also entirely rely on EXTRA_lib..._SOURCES.
-AC_DEFUN([lgl_LIBSOURCES], [
- m4_foreach([_gl_NAME], [$1], [
- m4_if(_gl_NAME, [alloca.c], [], [
- m4_define([lgl_LIBSOURCES_DIR], [lib/gllib])
- m4_append([lgl_LIBSOURCES_LIST], _gl_NAME, [ ])
- ])
- ])
-])
-
-# Like AC_LIBOBJ, except that the module name goes
-# into lgltests_LIBOBJS instead of into LIBOBJS.
-AC_DEFUN([lgltests_LIBOBJ], [
- AS_LITERAL_IF([$1], [lgltests_LIBSOURCES([$1.c])])dnl
- lgltests_LIBOBJS="$lgltests_LIBOBJS $1.$ac_objext"
-])
-
-# Like AC_REPLACE_FUNCS, except that the module name goes
-# into lgltests_LIBOBJS instead of into LIBOBJS.
-AC_DEFUN([lgltests_REPLACE_FUNCS], [
- m4_foreach_w([gl_NAME], [$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl
- AC_CHECK_FUNCS([$1], , [lgltests_LIBOBJ($ac_func)])
-])
-
-# Like AC_LIBSOURCES, except the directory where the source file is
-# expected is derived from the gnulib-tool parameterization,
-# and alloca is special cased (for the alloca-opt module).
-# We could also entirely rely on EXTRA_lib..._SOURCES.
-AC_DEFUN([lgltests_LIBSOURCES], [
- m4_foreach([_gl_NAME], [$1], [
- m4_if(_gl_NAME, [alloca.c], [], [
- m4_define([lgltests_LIBSOURCES_DIR], [tests])
- m4_append([lgltests_LIBSOURCES_LIST], _gl_NAME, [ ])
- ])
- ])
-])
-
-# This macro records the list of files which have been installed by
-# gnulib-tool and may be removed by future gnulib-tool invocations.
-AC_DEFUN([lgl_FILE_LIST], [
- build-aux/snippet/arg-nonnull.h
- build-aux/snippet/c++defs.h
- build-aux/snippet/warn-on-use.h
- lib/hash-pjw-bare.c
- lib/hash-pjw-bare.h
- lib/intprops.h
- lib/limits.in.h
- lib/minmax.h
- lib/stddef.in.h
- lib/stdint.in.h
- lib/string.in.h
- lib/strverscmp.c
- lib/sys_types.in.h
- lib/verify.h
- m4/00gnulib.m4
- m4/absolute-header.m4
- m4/extensions.m4
- m4/extern-inline.m4
- m4/gnulib-common.m4
- m4/include_next.m4
- m4/ld-version-script.m4
- m4/limits-h.m4
- m4/longlong.m4
- m4/minmax.m4
- m4/multiarch.m4
- m4/off_t.m4
- m4/ssize_t.m4
- m4/stddef_h.m4
- m4/stdint.m4
- m4/string_h.m4
- m4/strverscmp.m4
- m4/sys_types_h.m4
- m4/visibility.m4
- m4/warn-on-use.m4
- m4/wchar_t.m4
- m4/wint_t.m4
-])
diff --git a/lib/glm4/gnulib-tool.m4 b/lib/glm4/gnulib-tool.m4
deleted file mode 100644
index 2e2d8f6..0000000
--- a/lib/glm4/gnulib-tool.m4
+++ /dev/null
@@ -1,57 +0,0 @@
-# gnulib-tool.m4 serial 2
-dnl Copyright (C) 2004-2005, 2009-2017 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-dnl The following macros need not be invoked explicitly.
-dnl Invoking them does nothing except to declare default arguments
-dnl for "gnulib-tool --import".
-
-dnl Usage: gl_LOCAL_DIR([DIR])
-AC_DEFUN([gl_LOCAL_DIR], [])
-
-dnl Usage: gl_MODULES([module1 module2 ...])
-AC_DEFUN([gl_MODULES], [])
-
-dnl Usage: gl_AVOID([module1 module2 ...])
-AC_DEFUN([gl_AVOID], [])
-
-dnl Usage: gl_SOURCE_BASE([DIR])
-AC_DEFUN([gl_SOURCE_BASE], [])
-
-dnl Usage: gl_M4_BASE([DIR])
-AC_DEFUN([gl_M4_BASE], [])
-
-dnl Usage: gl_PO_BASE([DIR])
-AC_DEFUN([gl_PO_BASE], [])
-
-dnl Usage: gl_DOC_BASE([DIR])
-AC_DEFUN([gl_DOC_BASE], [])
-
-dnl Usage: gl_TESTS_BASE([DIR])
-AC_DEFUN([gl_TESTS_BASE], [])
-
-dnl Usage: gl_WITH_TESTS
-AC_DEFUN([gl_WITH_TESTS], [])
-
-dnl Usage: gl_LIB([LIBNAME])
-AC_DEFUN([gl_LIB], [])
-
-dnl Usage: gl_LGPL or gl_LGPL([VERSION])
-AC_DEFUN([gl_LGPL], [])
-
-dnl Usage: gl_MAKEFILE_NAME([FILENAME])
-AC_DEFUN([gl_MAKEFILE_NAME], [])
-
-dnl Usage: gl_LIBTOOL
-AC_DEFUN([gl_LIBTOOL], [])
-
-dnl Usage: gl_MACRO_PREFIX([PREFIX])
-AC_DEFUN([gl_MACRO_PREFIX], [])
-
-dnl Usage: gl_PO_DOMAIN([DOMAIN])
-AC_DEFUN([gl_PO_DOMAIN], [])
-
-dnl Usage: gl_VC_FILES([BOOLEAN])
-AC_DEFUN([gl_VC_FILES], [])
diff --git a/lib/glm4/include_next.m4 b/lib/glm4/include_next.m4
deleted file mode 100644
index e687e23..0000000
--- a/lib/glm4/include_next.m4
+++ /dev/null
@@ -1,223 +0,0 @@
-# include_next.m4 serial 23
-dnl Copyright (C) 2006-2017 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-dnl From Paul Eggert and Derek Price.
-
-dnl Sets INCLUDE_NEXT and PRAGMA_SYSTEM_HEADER.
-dnl
-dnl INCLUDE_NEXT expands to 'include_next' if the compiler supports it, or to
-dnl 'include' otherwise.
-dnl
-dnl INCLUDE_NEXT_AS_FIRST_DIRECTIVE expands to 'include_next' if the compiler
-dnl supports it in the special case that it is the first include directive in
-dnl the given file, or to 'include' otherwise.
-dnl
-dnl PRAGMA_SYSTEM_HEADER can be used in files that contain #include_next,
-dnl so as to avoid GCC warnings when the gcc option -pedantic is used.
-dnl '#pragma GCC system_header' has the same effect as if the file was found
-dnl through the include search path specified with '-isystem' options (as
-dnl opposed to the search path specified with '-I' options). Namely, gcc
-dnl does not warn about some things, and on some systems (Solaris and Interix)
-dnl __STDC__ evaluates to 0 instead of to 1. The latter is an undesired side
-dnl effect; we are therefore careful to use 'defined __STDC__' or '1' instead
-dnl of plain '__STDC__'.
-dnl
-dnl PRAGMA_COLUMNS can be used in files that override system header files, so
-dnl as to avoid compilation errors on HP NonStop systems when the gnulib file
-dnl is included by a system header file that does a "#pragma COLUMNS 80" (which
-dnl has the effect of truncating the lines of that file and all files that it
-dnl includes to 80 columns) and the gnulib file has lines longer than 80
-dnl columns.
-
-AC_DEFUN([gl_INCLUDE_NEXT],
-[
- AC_LANG_PREPROC_REQUIRE()
- AC_CACHE_CHECK([whether the preprocessor supports include_next],
- [gl_cv_have_include_next],
- [rm -rf conftestd1a conftestd1b conftestd2
- mkdir conftestd1a conftestd1b conftestd2
- dnl IBM C 9.0, 10.1 (original versions, prior to the 2009-01 updates) on
- dnl AIX 6.1 support include_next when used as first preprocessor directive
- dnl in a file, but not when preceded by another include directive. Check
- dnl for this bug by including <stdio.h>.
- dnl Additionally, with this same compiler, include_next is a no-op when
- dnl used in a header file that was included by specifying its absolute
- dnl file name. Despite these two bugs, include_next is used in the
- dnl compiler's <math.h>. By virtue of the second bug, we need to use
- dnl include_next as well in this case.
- cat <<EOF > conftestd1a/conftest.h
-#define DEFINED_IN_CONFTESTD1
-#include_next <conftest.h>
-#ifdef DEFINED_IN_CONFTESTD2
-int foo;
-#else
-#error "include_next doesn't work"
-#endif
-EOF
- cat <<EOF > conftestd1b/conftest.h
-#define DEFINED_IN_CONFTESTD1
-#include <stdio.h>
-#include_next <conftest.h>
-#ifdef DEFINED_IN_CONFTESTD2
-int foo;
-#else
-#error "include_next doesn't work"
-#endif
-EOF
- cat <<EOF > conftestd2/conftest.h
-#ifndef DEFINED_IN_CONFTESTD1
-#error "include_next test doesn't work"
-#endif
-#define DEFINED_IN_CONFTESTD2
-EOF
- gl_save_CPPFLAGS="$CPPFLAGS"
- CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2"
-dnl We intentionally avoid using AC_LANG_SOURCE here.
- AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include <conftest.h>]],
- [gl_cv_have_include_next=yes],
- [CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2"
- AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include <conftest.h>]],
- [gl_cv_have_include_next=buggy],
- [gl_cv_have_include_next=no])
- ])
- CPPFLAGS="$gl_save_CPPFLAGS"
- rm -rf conftestd1a conftestd1b conftestd2
- ])
- PRAGMA_SYSTEM_HEADER=
- if test $gl_cv_have_include_next = yes; then
- INCLUDE_NEXT=include_next
- INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next
- if test -n "$GCC"; then
- PRAGMA_SYSTEM_HEADER='#pragma GCC system_header'
- fi
- else
- if test $gl_cv_have_include_next = buggy; then
- INCLUDE_NEXT=include
- INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next
- else
- INCLUDE_NEXT=include
- INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include
- fi
- fi
- AC_SUBST([INCLUDE_NEXT])
- AC_SUBST([INCLUDE_NEXT_AS_FIRST_DIRECTIVE])
- AC_SUBST([PRAGMA_SYSTEM_HEADER])
- AC_CACHE_CHECK([whether system header files limit the line length],
- [gl_cv_pragma_columns],
- [dnl HP NonStop systems, which define __TANDEM, have this misfeature.
- AC_EGREP_CPP([choke me],
- [
-#ifdef __TANDEM
-choke me
-#endif
- ],
- [gl_cv_pragma_columns=yes],
- [gl_cv_pragma_columns=no])
- ])
- if test $gl_cv_pragma_columns = yes; then
- PRAGMA_COLUMNS="#pragma COLUMNS 10000"
- else
- PRAGMA_COLUMNS=
- fi
- AC_SUBST([PRAGMA_COLUMNS])
-])
-
-# gl_CHECK_NEXT_HEADERS(HEADER1 HEADER2 ...)
-# ------------------------------------------
-# For each arg foo.h, if #include_next works, define NEXT_FOO_H to be
-# '<foo.h>'; otherwise define it to be
-# '"///usr/include/foo.h"', or whatever other absolute file name is suitable.
-# Also, if #include_next works as first preprocessing directive in a file,
-# define NEXT_AS_FIRST_DIRECTIVE_FOO_H to be '<foo.h>'; otherwise define it to
-# be
-# '"///usr/include/foo.h"', or whatever other absolute file name is suitable.
-# That way, a header file with the following line:
-# #@INCLUDE_NEXT@ @NEXT_FOO_H@
-# or
-# #@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_FOO_H@
-# behaves (after sed substitution) as if it contained
-# #include_next <foo.h>
-# even if the compiler does not support include_next.
-# The three "///" are to pacify Sun C 5.8, which otherwise would say
-# "warning: #include of /usr/include/... may be non-portable".
-# Use '""', not '<>', so that the /// cannot be confused with a C99 comment.
-# Note: This macro assumes that the header file is not empty after
-# preprocessing, i.e. it does not only define preprocessor macros but also
-# provides some type/enum definitions or function/variable declarations.
-#
-# This macro also checks whether each header exists, by invoking
-# AC_CHECK_HEADERS_ONCE or AC_CHECK_HEADERS on each argument.
-AC_DEFUN([gl_CHECK_NEXT_HEADERS],
-[
- gl_NEXT_HEADERS_INTERNAL([$1], [check])
-])
-
-# gl_NEXT_HEADERS(HEADER1 HEADER2 ...)
-# ------------------------------------
-# Like gl_CHECK_NEXT_HEADERS, except do not check whether the headers exist.
-# This is suitable for headers like <stddef.h> that are standardized by C89
-# and therefore can be assumed to exist.
-AC_DEFUN([gl_NEXT_HEADERS],
-[
- gl_NEXT_HEADERS_INTERNAL([$1], [assume])
-])
-
-# The guts of gl_CHECK_NEXT_HEADERS and gl_NEXT_HEADERS.
-AC_DEFUN([gl_NEXT_HEADERS_INTERNAL],
-[
- AC_REQUIRE([gl_INCLUDE_NEXT])
- AC_REQUIRE([AC_CANONICAL_HOST])
-
- m4_if([$2], [check],
- [AC_CHECK_HEADERS_ONCE([$1])
- ])
-
-dnl FIXME: gl_next_header and gl_header_exists must be used unquoted
-dnl until we can assume autoconf 2.64 or newer.
- m4_foreach_w([gl_HEADER_NAME], [$1],
- [AS_VAR_PUSHDEF([gl_next_header],
- [gl_cv_next_]m4_defn([gl_HEADER_NAME]))
- if test $gl_cv_have_include_next = yes; then
- AS_VAR_SET(gl_next_header, ['<'gl_HEADER_NAME'>'])
- else
- AC_CACHE_CHECK(
- [absolute name of <]m4_defn([gl_HEADER_NAME])[>],
- m4_defn([gl_next_header]),
- [m4_if([$2], [check],
- [AS_VAR_PUSHDEF([gl_header_exists],
- [ac_cv_header_]m4_defn([gl_HEADER_NAME]))
- if test AS_VAR_GET(gl_header_exists) = yes; then
- AS_VAR_POPDEF([gl_header_exists])
- ])
- gl_ABSOLUTE_HEADER_ONE(gl_HEADER_NAME)
- AS_VAR_COPY([gl_header], [gl_cv_absolute_]AS_TR_SH(gl_HEADER_NAME))
- AS_VAR_SET(gl_next_header, ['"'$gl_header'"'])
- m4_if([$2], [check],
- [else
- AS_VAR_SET(gl_next_header, ['<'gl_HEADER_NAME'>'])
- fi
- ])
- ])
- fi
- AC_SUBST(
- AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])),
- [AS_VAR_GET(gl_next_header)])
- if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
- # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
- gl_next_as_first_directive='<'gl_HEADER_NAME'>'
- else
- # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
- gl_next_as_first_directive=AS_VAR_GET(gl_next_header)
- fi
- AC_SUBST(
- AS_TR_CPP([NEXT_AS_FIRST_DIRECTIVE_]m4_defn([gl_HEADER_NAME])),
- [$gl_next_as_first_directive])
- AS_VAR_POPDEF([gl_next_header])])
-])
-
-# Autoconf 2.68 added warnings for our use of AC_COMPILE_IFELSE;
-# this fallback is safe for all earlier autoconf versions.
-m4_define_default([AC_LANG_DEFINES_PROVIDED])
diff --git a/lib/glm4/ld-version-script.m4 b/lib/glm4/ld-version-script.m4
deleted file mode 100644
index caccec1..0000000
--- a/lib/glm4/ld-version-script.m4
+++ /dev/null
@@ -1,48 +0,0 @@
-# ld-version-script.m4 serial 4
-dnl Copyright (C) 2008-2017 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-dnl From Simon Josefsson
-
-# FIXME: The test below returns a false positive for mingw
-# cross-compiles, 'local:' statements does not reduce number of
-# exported symbols in a DLL. Use --disable-ld-version-script to work
-# around the problem.
-
-# gl_LD_VERSION_SCRIPT
-# --------------------
-# Check if LD supports linker scripts, and define automake conditional
-# HAVE_LD_VERSION_SCRIPT if so.
-AC_DEFUN([gl_LD_VERSION_SCRIPT],
-[
- AC_ARG_ENABLE([ld-version-script],
- [AS_HELP_STRING([--enable-ld-version-script],
- [enable linker version script (default is enabled when possible)])],
- [have_ld_version_script=$enableval],
- [AC_CACHE_CHECK([if LD -Wl,--version-script works],
- [gl_cv_sys_ld_version_script],
- [gl_cv_sys_ld_version_script=no
- save_LDFLAGS=$LDFLAGS
- LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map"
- echo foo >conftest.map
- AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
- [],
- [cat > conftest.map <<EOF
-VERS_1 {
- global: sym;
-};
-
-VERS_2 {
- global: sym;
-} VERS_1;
-EOF
- AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
- [gl_cv_sys_ld_version_script=yes])])
- rm -f conftest.map
- LDFLAGS=$save_LDFLAGS])
- have_ld_version_script=$gl_cv_sys_ld_version_script])
- AM_CONDITIONAL([HAVE_LD_VERSION_SCRIPT],
- [test "$have_ld_version_script" = yes])
-])
diff --git a/lib/glm4/limits-h.m4 b/lib/glm4/limits-h.m4
deleted file mode 100644
index 443f91b..0000000
--- a/lib/glm4/limits-h.m4
+++ /dev/null
@@ -1,31 +0,0 @@
-dnl Check whether limits.h has needed features.
-
-dnl Copyright 2016-2017 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-dnl From Paul Eggert.
-
-AC_DEFUN_ONCE([gl_LIMITS_H],
-[
- gl_CHECK_NEXT_HEADERS([limits.h])
-
- AC_CACHE_CHECK([whether limits.h has ULLONG_WIDTH etc.],
- [gl_cv_header_limits_width],
- [AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM([[#ifndef __STDC_WANT_IEC_60559_BFP_EXT__
- #define __STDC_WANT_IEC_60559_BFP_EXT__ 1
- #endif
- #include <limits.h>
- int ullw = ULLONG_WIDTH;]])],
- [gl_cv_header_limits_width=yes],
- [gl_cv_header_limits_width=no])])
- if test "$gl_cv_header_limits_width" = yes; then
- LIMITS_H=
- else
- LIMITS_H=limits.h
- fi
- AC_SUBST([LIMITS_H])
- AM_CONDITIONAL([GL_GENERATE_LIMITS_H], [test -n "$LIMITS_H"])
-])
diff --git a/lib/glm4/longlong.m4 b/lib/glm4/longlong.m4
deleted file mode 100644
index 9a3294b..0000000
--- a/lib/glm4/longlong.m4
+++ /dev/null
@@ -1,113 +0,0 @@
-# longlong.m4 serial 17
-dnl Copyright (C) 1999-2007, 2009-2017 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-dnl From Paul Eggert.
-
-# Define HAVE_LONG_LONG_INT if 'long long int' works.
-# This fixes a bug in Autoconf 2.61, and can be faster
-# than what's in Autoconf 2.62 through 2.68.
-
-# Note: If the type 'long long int' exists but is only 32 bits large
-# (as on some very old compilers), HAVE_LONG_LONG_INT will not be
-# defined. In this case you can treat 'long long int' like 'long int'.
-
-AC_DEFUN([AC_TYPE_LONG_LONG_INT],
-[
- AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
- AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int],
- [ac_cv_type_long_long_int=yes
- if test "x${ac_cv_prog_cc_c99-no}" = xno; then
- ac_cv_type_long_long_int=$ac_cv_type_unsigned_long_long_int
- if test $ac_cv_type_long_long_int = yes; then
- dnl Catch a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004.
- dnl If cross compiling, assume the bug is not important, since
- dnl nobody cross compiles for this platform as far as we know.
- AC_RUN_IFELSE(
- [AC_LANG_PROGRAM(
- [[@%:@include <limits.h>
- @%:@ifndef LLONG_MAX
- @%:@ define HALF \
- (1LL << (sizeof (long long int) * CHAR_BIT - 2))
- @%:@ define LLONG_MAX (HALF - 1 + HALF)
- @%:@endif]],
- [[long long int n = 1;
- int i;
- for (i = 0; ; i++)
- {
- long long int m = n << i;
- if (m >> i != n)
- return 1;
- if (LLONG_MAX / 2 < m)
- break;
- }
- return 0;]])],
- [],
- [ac_cv_type_long_long_int=no],
- [:])
- fi
- fi])
- if test $ac_cv_type_long_long_int = yes; then
- AC_DEFINE([HAVE_LONG_LONG_INT], [1],
- [Define to 1 if the system has the type 'long long int'.])
- fi
-])
-
-# Define HAVE_UNSIGNED_LONG_LONG_INT if 'unsigned long long int' works.
-# This fixes a bug in Autoconf 2.61, and can be faster
-# than what's in Autoconf 2.62 through 2.68.
-
-# Note: If the type 'unsigned long long int' exists but is only 32 bits
-# large (as on some very old compilers), AC_TYPE_UNSIGNED_LONG_LONG_INT
-# will not be defined. In this case you can treat 'unsigned long long int'
-# like 'unsigned long int'.
-
-AC_DEFUN([AC_TYPE_UNSIGNED_LONG_LONG_INT],
-[
- AC_CACHE_CHECK([for unsigned long long int],
- [ac_cv_type_unsigned_long_long_int],
- [ac_cv_type_unsigned_long_long_int=yes
- if test "x${ac_cv_prog_cc_c99-no}" = xno; then
- AC_LINK_IFELSE(
- [_AC_TYPE_LONG_LONG_SNIPPET],
- [],
- [ac_cv_type_unsigned_long_long_int=no])
- fi])
- if test $ac_cv_type_unsigned_long_long_int = yes; then
- AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], [1],
- [Define to 1 if the system has the type 'unsigned long long int'.])
- fi
-])
-
-# Expands to a C program that can be used to test for simultaneous support
-# of 'long long' and 'unsigned long long'. We don't want to say that
-# 'long long' is available if 'unsigned long long' is not, or vice versa,
-# because too many programs rely on the symmetry between signed and unsigned
-# integer types (excluding 'bool').
-AC_DEFUN([_AC_TYPE_LONG_LONG_SNIPPET],
-[
- AC_LANG_PROGRAM(
- [[/* For now, do not test the preprocessor; as of 2007 there are too many
- implementations with broken preprocessors. Perhaps this can
- be revisited in 2012. In the meantime, code should not expect
- #if to work with literals wider than 32 bits. */
- /* Test literals. */
- long long int ll = 9223372036854775807ll;
- long long int nll = -9223372036854775807LL;
- unsigned long long int ull = 18446744073709551615ULL;
- /* Test constant expressions. */
- typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll)
- ? 1 : -1)];
- typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1
- ? 1 : -1)];
- int i = 63;]],
- [[/* Test availability of runtime routines for shift and division. */
- long long int llmax = 9223372036854775807ll;
- unsigned long long int ullmax = 18446744073709551615ull;
- return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i)
- | (llmax / ll) | (llmax % ll)
- | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i)
- | (ullmax / ull) | (ullmax % ull));]])
-])
diff --git a/lib/glm4/minmax.m4 b/lib/glm4/minmax.m4
deleted file mode 100644
index 6845fce..0000000
--- a/lib/glm4/minmax.m4
+++ /dev/null
@@ -1,44 +0,0 @@
-# minmax.m4 serial 4
-dnl Copyright (C) 2005, 2009-2017 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-AC_PREREQ([2.53])
-
-AC_DEFUN([gl_MINMAX],
-[
- AC_REQUIRE([gl_PREREQ_MINMAX])
-])
-
-# Prerequisites of lib/minmax.h.
-AC_DEFUN([gl_PREREQ_MINMAX],
-[
- gl_MINMAX_IN_HEADER([limits.h])
- gl_MINMAX_IN_HEADER([sys/param.h])
-])
-
-dnl gl_MINMAX_IN_HEADER(HEADER)
-dnl The parameter has to be a literal header name; it cannot be macro,
-dnl nor a shell variable. (Because autoheader collects only AC_DEFINE
-dnl invocations with a literal macro name.)
-AC_DEFUN([gl_MINMAX_IN_HEADER],
-[
- m4_pushdef([header], AS_TR_SH([$1]))
- m4_pushdef([HEADER], AS_TR_CPP([$1]))
- AC_CACHE_CHECK([whether <$1> defines MIN and MAX],
- [gl_cv_minmax_in_]header,
- [AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM(
- [[#include <$1>
- int x = MIN (42, 17);]],
- [[]])],
- [gl_cv_minmax_in_]header[=yes],
- [gl_cv_minmax_in_]header[=no])])
- if test $gl_cv_minmax_in_[]header = yes; then
- AC_DEFINE([HAVE_MINMAX_IN_]HEADER, 1,
- [Define to 1 if <$1> defines the MIN and MAX macros.])
- fi
- m4_popdef([HEADER])
- m4_popdef([header])
-])
diff --git a/lib/glm4/multiarch.m4 b/lib/glm4/multiarch.m4
deleted file mode 100644
index 30006cb..0000000
--- a/lib/glm4/multiarch.m4
+++ /dev/null
@@ -1,62 +0,0 @@
-# multiarch.m4 serial 7
-dnl Copyright (C) 2008-2017 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-# Determine whether the compiler is or may be producing universal binaries.
-#
-# On Mac OS X 10.5 and later systems, the user can create libraries and
-# executables that work on multiple system types--known as "fat" or
-# "universal" binaries--by specifying multiple '-arch' options to the
-# compiler but only a single '-arch' option to the preprocessor. Like
-# this:
-#
-# ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
-# CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
-# CPP="gcc -E" CXXCPP="g++ -E"
-#
-# Detect this situation and set APPLE_UNIVERSAL_BUILD accordingly.
-
-AC_DEFUN_ONCE([gl_MULTIARCH],
-[
- dnl Code similar to autoconf-2.63 AC_C_BIGENDIAN.
- gl_cv_c_multiarch=no
- AC_COMPILE_IFELSE(
- [AC_LANG_SOURCE(
- [[#ifndef __APPLE_CC__
- not a universal capable compiler
- #endif
- typedef int dummy;
- ]])],
- [
- dnl Check for potential -arch flags. It is not universal unless
- dnl there are at least two -arch flags with different values.
- arch=
- prev=
- for word in ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}; do
- if test -n "$prev"; then
- case $word in
- i?86 | x86_64 | ppc | ppc64)
- if test -z "$arch" || test "$arch" = "$word"; then
- arch="$word"
- else
- gl_cv_c_multiarch=yes
- fi
- ;;
- esac
- prev=
- else
- if test "x$word" = "x-arch"; then
- prev=arch
- fi
- fi
- done
- ])
- if test $gl_cv_c_multiarch = yes; then
- APPLE_UNIVERSAL_BUILD=1
- else
- APPLE_UNIVERSAL_BUILD=0
- fi
- AC_SUBST([APPLE_UNIVERSAL_BUILD])
-])
diff --git a/lib/glm4/off_t.m4 b/lib/glm4/off_t.m4
deleted file mode 100644
index 92c45ef..0000000
--- a/lib/glm4/off_t.m4
+++ /dev/null
@@ -1,18 +0,0 @@
-# off_t.m4 serial 1
-dnl Copyright (C) 2012-2017 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-dnl Check whether to override the 'off_t' type.
-dnl Set WINDOWS_64_BIT_OFF_T.
-
-AC_DEFUN([gl_TYPE_OFF_T],
-[
- m4_ifdef([gl_LARGEFILE], [
- AC_REQUIRE([gl_LARGEFILE])
- ], [
- WINDOWS_64_BIT_OFF_T=0
- ])
- AC_SUBST([WINDOWS_64_BIT_OFF_T])
-])
diff --git a/lib/glm4/ssize_t.m4 b/lib/glm4/ssize_t.m4
deleted file mode 100644
index 66ba9d4..0000000
--- a/lib/glm4/ssize_t.m4
+++ /dev/null
@@ -1,23 +0,0 @@
-# ssize_t.m4 serial 5 (gettext-0.18.2)
-dnl Copyright (C) 2001-2003, 2006, 2010-2017 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-dnl From Bruno Haible.
-dnl Test whether ssize_t is defined.
-
-AC_DEFUN([gt_TYPE_SSIZE_T],
-[
- AC_CACHE_CHECK([for ssize_t], [gt_cv_ssize_t],
- [AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM(
- [[#include <sys/types.h>]],
- [[int x = sizeof (ssize_t *) + sizeof (ssize_t);
- return !x;]])],
- [gt_cv_ssize_t=yes], [gt_cv_ssize_t=no])])
- if test $gt_cv_ssize_t = no; then
- AC_DEFINE([ssize_t], [int],
- [Define as a signed type of the same size as size_t.])
- fi
-])
diff --git a/lib/glm4/stddef_h.m4 b/lib/glm4/stddef_h.m4
deleted file mode 100644
index f45def1..0000000
--- a/lib/glm4/stddef_h.m4
+++ /dev/null
@@ -1,51 +0,0 @@
-dnl A placeholder for <stddef.h>, for platforms that have issues.
-# stddef_h.m4 serial 5
-dnl Copyright (C) 2009-2017 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-AC_DEFUN([gl_STDDEF_H],
-[
- AC_REQUIRE([gl_STDDEF_H_DEFAULTS])
- AC_REQUIRE([gt_TYPE_WCHAR_T])
- STDDEF_H=
- AC_CHECK_TYPE([max_align_t], [], [HAVE_MAX_ALIGN_T=0; STDDEF_H=stddef.h],
- [[#include <stddef.h>
- ]])
- if test $gt_cv_c_wchar_t = no; then
- HAVE_WCHAR_T=0
- STDDEF_H=stddef.h
- fi
- AC_CACHE_CHECK([whether NULL can be used in arbitrary expressions],
- [gl_cv_decl_null_works],
- [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h>
- int test[2 * (sizeof NULL == sizeof (void *)) -1];
-]])],
- [gl_cv_decl_null_works=yes],
- [gl_cv_decl_null_works=no])])
- if test $gl_cv_decl_null_works = no; then
- REPLACE_NULL=1
- STDDEF_H=stddef.h
- fi
- AC_SUBST([STDDEF_H])
- AM_CONDITIONAL([GL_GENERATE_STDDEF_H], [test -n "$STDDEF_H"])
- if test -n "$STDDEF_H"; then
- gl_NEXT_HEADERS([stddef.h])
- fi
-])
-
-AC_DEFUN([gl_STDDEF_MODULE_INDICATOR],
-[
- dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
- AC_REQUIRE([gl_STDDEF_H_DEFAULTS])
- gl_MODULE_INDICATOR_SET_VARIABLE([$1])
-])
-
-AC_DEFUN([gl_STDDEF_H_DEFAULTS],
-[
- dnl Assume proper GNU behavior unless another module says otherwise.
- REPLACE_NULL=0; AC_SUBST([REPLACE_NULL])
- HAVE_MAX_ALIGN_T=1; AC_SUBST([HAVE_MAX_ALIGN_T])
- HAVE_WCHAR_T=1; AC_SUBST([HAVE_WCHAR_T])
-])
diff --git a/lib/glm4/stdint.m4 b/lib/glm4/stdint.m4
deleted file mode 100644
index 4ac854d..0000000
--- a/lib/glm4/stdint.m4
+++ /dev/null
@@ -1,541 +0,0 @@
-# stdint.m4 serial 50
-dnl Copyright (C) 2001-2017 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-dnl From Paul Eggert and Bruno Haible.
-dnl Test whether <stdint.h> is supported or must be substituted.
-
-AC_DEFUN_ONCE([gl_STDINT_H],
-[
- AC_PREREQ([2.59])dnl
-
- AC_REQUIRE([gl_LIMITS_H])
- AC_REQUIRE([gt_TYPE_WINT_T])
-
- dnl Check for long long int and unsigned long long int.
- AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
- if test $ac_cv_type_long_long_int = yes; then
- HAVE_LONG_LONG_INT=1
- else
- HAVE_LONG_LONG_INT=0
- fi
- AC_SUBST([HAVE_LONG_LONG_INT])
- AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
- if test $ac_cv_type_unsigned_long_long_int = yes; then
- HAVE_UNSIGNED_LONG_LONG_INT=1
- else
- HAVE_UNSIGNED_LONG_LONG_INT=0
- fi
- AC_SUBST([HAVE_UNSIGNED_LONG_LONG_INT])
-
- dnl Check for <wchar.h>, in the same way as gl_WCHAR_H does.
- AC_CHECK_HEADERS_ONCE([wchar.h])
- if test $ac_cv_header_wchar_h = yes; then
- HAVE_WCHAR_H=1
- else
- HAVE_WCHAR_H=0
- fi
- AC_SUBST([HAVE_WCHAR_H])
-
- dnl Check for <inttypes.h>.
- dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_inttypes_h.
- if test $ac_cv_header_inttypes_h = yes; then
- HAVE_INTTYPES_H=1
- else
- HAVE_INTTYPES_H=0
- fi
- AC_SUBST([HAVE_INTTYPES_H])
-
- dnl Check for <sys/types.h>.
- dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_sys_types_h.
- if test $ac_cv_header_sys_types_h = yes; then
- HAVE_SYS_TYPES_H=1
- else
- HAVE_SYS_TYPES_H=0
- fi
- AC_SUBST([HAVE_SYS_TYPES_H])
-
- gl_CHECK_NEXT_HEADERS([stdint.h])
- if test $ac_cv_header_stdint_h = yes; then
- HAVE_STDINT_H=1
- else
- HAVE_STDINT_H=0
- fi
- AC_SUBST([HAVE_STDINT_H])
-
- dnl Now see whether we need a substitute <stdint.h>.
- if test $ac_cv_header_stdint_h = yes; then
- AC_CACHE_CHECK([whether stdint.h conforms to C99],
- [gl_cv_header_working_stdint_h],
- [gl_cv_header_working_stdint_h=no
- AC_COMPILE_IFELSE([
- AC_LANG_PROGRAM([[
-#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
-#define __STDC_CONSTANT_MACROS 1
-#define __STDC_LIMIT_MACROS 1
-#include <stdint.h>
-/* Dragonfly defines WCHAR_MIN, WCHAR_MAX only in <wchar.h>. */
-#if !(defined WCHAR_MIN && defined WCHAR_MAX)
-#error "WCHAR_MIN, WCHAR_MAX not defined in <stdint.h>"
-#endif
-]
-gl_STDINT_INCLUDES
-[
-#ifdef INT8_MAX
-int8_t a1 = INT8_MAX;
-int8_t a1min = INT8_MIN;
-#endif
-#ifdef INT16_MAX
-int16_t a2 = INT16_MAX;
-int16_t a2min = INT16_MIN;
-#endif
-#ifdef INT32_MAX
-int32_t a3 = INT32_MAX;
-int32_t a3min = INT32_MIN;
-#endif
-#ifdef INT64_MAX
-int64_t a4 = INT64_MAX;
-int64_t a4min = INT64_MIN;
-#endif
-#ifdef UINT8_MAX
-uint8_t b1 = UINT8_MAX;
-#else
-typedef int b1[(unsigned char) -1 != 255 ? 1 : -1];
-#endif
-#ifdef UINT16_MAX
-uint16_t b2 = UINT16_MAX;
-#endif
-#ifdef UINT32_MAX
-uint32_t b3 = UINT32_MAX;
-#endif
-#ifdef UINT64_MAX
-uint64_t b4 = UINT64_MAX;
-#endif
-int_least8_t c1 = INT8_C (0x7f);
-int_least8_t c1max = INT_LEAST8_MAX;
-int_least8_t c1min = INT_LEAST8_MIN;
-int_least16_t c2 = INT16_C (0x7fff);
-int_least16_t c2max = INT_LEAST16_MAX;
-int_least16_t c2min = INT_LEAST16_MIN;
-int_least32_t c3 = INT32_C (0x7fffffff);
-int_least32_t c3max = INT_LEAST32_MAX;
-int_least32_t c3min = INT_LEAST32_MIN;
-int_least64_t c4 = INT64_C (0x7fffffffffffffff);
-int_least64_t c4max = INT_LEAST64_MAX;
-int_least64_t c4min = INT_LEAST64_MIN;
-uint_least8_t d1 = UINT8_C (0xff);
-uint_least8_t d1max = UINT_LEAST8_MAX;
-uint_least16_t d2 = UINT16_C (0xffff);
-uint_least16_t d2max = UINT_LEAST16_MAX;
-uint_least32_t d3 = UINT32_C (0xffffffff);
-uint_least32_t d3max = UINT_LEAST32_MAX;
-uint_least64_t d4 = UINT64_C (0xffffffffffffffff);
-uint_least64_t d4max = UINT_LEAST64_MAX;
-int_fast8_t e1 = INT_FAST8_MAX;
-int_fast8_t e1min = INT_FAST8_MIN;
-int_fast16_t e2 = INT_FAST16_MAX;
-int_fast16_t e2min = INT_FAST16_MIN;
-int_fast32_t e3 = INT_FAST32_MAX;
-int_fast32_t e3min = INT_FAST32_MIN;
-int_fast64_t e4 = INT_FAST64_MAX;
-int_fast64_t e4min = INT_FAST64_MIN;
-uint_fast8_t f1 = UINT_FAST8_MAX;
-uint_fast16_t f2 = UINT_FAST16_MAX;
-uint_fast32_t f3 = UINT_FAST32_MAX;
-uint_fast64_t f4 = UINT_FAST64_MAX;
-#ifdef INTPTR_MAX
-intptr_t g = INTPTR_MAX;
-intptr_t gmin = INTPTR_MIN;
-#endif
-#ifdef UINTPTR_MAX
-uintptr_t h = UINTPTR_MAX;
-#endif
-intmax_t i = INTMAX_MAX;
-uintmax_t j = UINTMAX_MAX;
-
-/* Check that SIZE_MAX has the correct type, if possible. */
-#if 201112 <= __STDC_VERSION__
-int k = _Generic (SIZE_MAX, size_t: 0);
-#elif (2 <= __GNUC__ || defined __IBM__TYPEOF__ \
- || (0x5110 <= __SUNPRO_C && !__STDC__))
-extern size_t k;
-extern __typeof__ (SIZE_MAX) k;
-#endif
-
-#include <limits.h> /* for CHAR_BIT */
-#define TYPE_MINIMUM(t) \
- ((t) ((t) 0 < (t) -1 ? (t) 0 : ~ TYPE_MAXIMUM (t)))
-#define TYPE_MAXIMUM(t) \
- ((t) ((t) 0 < (t) -1 \
- ? (t) -1 \
- : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1)))
-struct s {
- int check_PTRDIFF:
- PTRDIFF_MIN == TYPE_MINIMUM (ptrdiff_t)
- && PTRDIFF_MAX == TYPE_MAXIMUM (ptrdiff_t)
- ? 1 : -1;
- /* Detect bug in FreeBSD 6.0 / ia64. */
- int check_SIG_ATOMIC:
- SIG_ATOMIC_MIN == TYPE_MINIMUM (sig_atomic_t)
- && SIG_ATOMIC_MAX == TYPE_MAXIMUM (sig_atomic_t)
- ? 1 : -1;
- int check_SIZE: SIZE_MAX == TYPE_MAXIMUM (size_t) ? 1 : -1;
- int check_WCHAR:
- WCHAR_MIN == TYPE_MINIMUM (wchar_t)
- && WCHAR_MAX == TYPE_MAXIMUM (wchar_t)
- ? 1 : -1;
- /* Detect bug in mingw. */
- int check_WINT:
- WINT_MIN == TYPE_MINIMUM (wint_t)
- && WINT_MAX == TYPE_MAXIMUM (wint_t)
- ? 1 : -1;
-
- /* Detect bugs in glibc 2.4 and Solaris 10 stdint.h, among others. */
- int check_UINT8_C:
- (-1 < UINT8_C (0)) == (-1 < (uint_least8_t) 0) ? 1 : -1;
- int check_UINT16_C:
- (-1 < UINT16_C (0)) == (-1 < (uint_least16_t) 0) ? 1 : -1;
-
- /* Detect bugs in OpenBSD 3.9 stdint.h. */
-#ifdef UINT8_MAX
- int check_uint8: (uint8_t) -1 == UINT8_MAX ? 1 : -1;
-#endif
-#ifdef UINT16_MAX
- int check_uint16: (uint16_t) -1 == UINT16_MAX ? 1 : -1;
-#endif
-#ifdef UINT32_MAX
- int check_uint32: (uint32_t) -1 == UINT32_MAX ? 1 : -1;
-#endif
-#ifdef UINT64_MAX
- int check_uint64: (uint64_t) -1 == UINT64_MAX ? 1 : -1;
-#endif
- int check_uint_least8: (uint_least8_t) -1 == UINT_LEAST8_MAX ? 1 : -1;
- int check_uint_least16: (uint_least16_t) -1 == UINT_LEAST16_MAX ? 1 : -1;
- int check_uint_least32: (uint_least32_t) -1 == UINT_LEAST32_MAX ? 1 : -1;
- int check_uint_least64: (uint_least64_t) -1 == UINT_LEAST64_MAX ? 1 : -1;
- int check_uint_fast8: (uint_fast8_t) -1 == UINT_FAST8_MAX ? 1 : -1;
- int check_uint_fast16: (uint_fast16_t) -1 == UINT_FAST16_MAX ? 1 : -1;
- int check_uint_fast32: (uint_fast32_t) -1 == UINT_FAST32_MAX ? 1 : -1;
- int check_uint_fast64: (uint_fast64_t) -1 == UINT_FAST64_MAX ? 1 : -1;
- int check_uintptr: (uintptr_t) -1 == UINTPTR_MAX ? 1 : -1;
- int check_uintmax: (uintmax_t) -1 == UINTMAX_MAX ? 1 : -1;
- int check_size: (size_t) -1 == SIZE_MAX ? 1 : -1;
-};
- ]])],
- [dnl Determine whether the various *_MIN, *_MAX macros are usable
- dnl in preprocessor expression. We could do it by compiling a test
- dnl program for each of these macros. It is faster to run a program
- dnl that inspects the macro expansion.
- dnl This detects a bug on HP-UX 11.23/ia64.
- AC_RUN_IFELSE([
- AC_LANG_PROGRAM([[
-#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
-#define __STDC_CONSTANT_MACROS 1
-#define __STDC_LIMIT_MACROS 1
-#include <stdint.h>
-]
-gl_STDINT_INCLUDES
-[
-#include <stdio.h>
-#include <string.h>
-#define MVAL(macro) MVAL1(macro)
-#define MVAL1(expression) #expression
-static const char *macro_values[] =
- {
-#ifdef INT8_MAX
- MVAL (INT8_MAX),
-#endif
-#ifdef INT16_MAX
- MVAL (INT16_MAX),
-#endif
-#ifdef INT32_MAX
- MVAL (INT32_MAX),
-#endif
-#ifdef INT64_MAX
- MVAL (INT64_MAX),
-#endif
-#ifdef UINT8_MAX
- MVAL (UINT8_MAX),
-#endif
-#ifdef UINT16_MAX
- MVAL (UINT16_MAX),
-#endif
-#ifdef UINT32_MAX
- MVAL (UINT32_MAX),
-#endif
-#ifdef UINT64_MAX
- MVAL (UINT64_MAX),
-#endif
- NULL
- };
-]], [[
- const char **mv;
- for (mv = macro_values; *mv != NULL; mv++)
- {
- const char *value = *mv;
- /* Test whether it looks like a cast expression. */
- if (strncmp (value, "((unsigned int)"/*)*/, 15) == 0
- || strncmp (value, "((unsigned short)"/*)*/, 17) == 0
- || strncmp (value, "((unsigned char)"/*)*/, 16) == 0
- || strncmp (value, "((int)"/*)*/, 6) == 0
- || strncmp (value, "((signed short)"/*)*/, 15) == 0
- || strncmp (value, "((signed char)"/*)*/, 14) == 0)
- return mv - macro_values + 1;
- }
- return 0;
-]])],
- [gl_cv_header_working_stdint_h=yes],
- [],
- [dnl When cross-compiling, assume it works.
- gl_cv_header_working_stdint_h=yes
- ])
- ])
- ])
- fi
-
- HAVE_C99_STDINT_H=0
- HAVE_SYS_BITYPES_H=0
- HAVE_SYS_INTTYPES_H=0
- STDINT_H=stdint.h
- if test "$gl_cv_header_working_stdint_h" = yes; then
- HAVE_C99_STDINT_H=1
- dnl Now see whether the system <stdint.h> works without
- dnl __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS defined.
- AC_CACHE_CHECK([whether stdint.h predates C++11],
- [gl_cv_header_stdint_predates_cxx11_h],
- [gl_cv_header_stdint_predates_cxx11_h=yes
- AC_COMPILE_IFELSE([
- AC_LANG_PROGRAM([[
-#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
-#include <stdint.h>
-]
-gl_STDINT_INCLUDES
-[
-intmax_t im = INTMAX_MAX;
-int32_t i32 = INT32_C (0x7fffffff);
- ]])],
- [gl_cv_header_stdint_predates_cxx11_h=no])])
-
- if test "$gl_cv_header_stdint_predates_cxx11_h" = yes; then
- AC_DEFINE([__STDC_CONSTANT_MACROS], [1],
- [Define to 1 if the system <stdint.h> predates C++11.])
- AC_DEFINE([__STDC_LIMIT_MACROS], [1],
- [Define to 1 if the system <stdint.h> predates C++11.])
- fi
- AC_CACHE_CHECK([whether stdint.h has UINTMAX_WIDTH etc.],
- [gl_cv_header_stdint_width],
- [gl_cv_header_stdint_width=no
- AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM([[
- /* Work if build is not clean. */
- #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1
- #ifndef __STDC_WANT_IEC_60559_BFP_EXT__
- #define __STDC_WANT_IEC_60559_BFP_EXT__ 1
- #endif
- #include <stdint.h>
- ]gl_STDINT_INCLUDES[
- int iw = UINTMAX_WIDTH;
- ]])],
- [gl_cv_header_stdint_width=yes])])
- if test "$gl_cv_header_stdint_width" = yes; then
- STDINT_H=
- fi
- else
- dnl Check for <sys/inttypes.h>, and for
- dnl <sys/bitypes.h> (used in Linux libc4 >= 4.6.7 and libc5).
- AC_CHECK_HEADERS([sys/inttypes.h sys/bitypes.h])
- if test $ac_cv_header_sys_inttypes_h = yes; then
- HAVE_SYS_INTTYPES_H=1
- fi
- if test $ac_cv_header_sys_bitypes_h = yes; then
- HAVE_SYS_BITYPES_H=1
- fi
- gl_STDINT_TYPE_PROPERTIES
- fi
-
- dnl The substitute stdint.h needs the substitute limit.h's _GL_INTEGER_WIDTH.
- LIMITS_H=limits.h
- AM_CONDITIONAL([GL_GENERATE_LIMITS_H], [test -n "$LIMITS_H"])
-
- AC_SUBST([HAVE_C99_STDINT_H])
- AC_SUBST([HAVE_SYS_BITYPES_H])
- AC_SUBST([HAVE_SYS_INTTYPES_H])
- AC_SUBST([STDINT_H])
- AM_CONDITIONAL([GL_GENERATE_STDINT_H], [test -n "$STDINT_H"])
-])
-
-dnl gl_STDINT_BITSIZEOF(TYPES, INCLUDES)
-dnl Determine the size of each of the given types in bits.
-AC_DEFUN([gl_STDINT_BITSIZEOF],
-[
- dnl Use a shell loop, to avoid bloating configure, and
- dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
- dnl config.h.in,
- dnl - extra AC_SUBST calls, so that the right substitutions are made.
- m4_foreach_w([gltype], [$1],
- [AH_TEMPLATE([BITSIZEOF_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]),
- [Define to the number of bits in type ']gltype['.])])
- for gltype in $1 ; do
- AC_CACHE_CHECK([for bit size of $gltype], [gl_cv_bitsizeof_${gltype}],
- [AC_COMPUTE_INT([result], [sizeof ($gltype) * CHAR_BIT],
- [$2
-#include <limits.h>], [result=unknown])
- eval gl_cv_bitsizeof_${gltype}=\$result
- ])
- eval result=\$gl_cv_bitsizeof_${gltype}
- if test $result = unknown; then
- dnl Use a nonempty default, because some compilers, such as IRIX 5 cc,
- dnl do a syntax check even on unused #if conditions and give an error
- dnl on valid C code like this:
- dnl #if 0
- dnl # if > 32
- dnl # endif
- dnl #endif
- result=0
- fi
- GLTYPE=`echo "$gltype" | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
- AC_DEFINE_UNQUOTED([BITSIZEOF_${GLTYPE}], [$result])
- eval BITSIZEOF_${GLTYPE}=\$result
- done
- m4_foreach_w([gltype], [$1],
- [AC_SUBST([BITSIZEOF_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))])
-])
-
-dnl gl_CHECK_TYPES_SIGNED(TYPES, INCLUDES)
-dnl Determine the signedness of each of the given types.
-dnl Define HAVE_SIGNED_TYPE if type is signed.
-AC_DEFUN([gl_CHECK_TYPES_SIGNED],
-[
- dnl Use a shell loop, to avoid bloating configure, and
- dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
- dnl config.h.in,
- dnl - extra AC_SUBST calls, so that the right substitutions are made.
- m4_foreach_w([gltype], [$1],
- [AH_TEMPLATE([HAVE_SIGNED_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]),
- [Define to 1 if ']gltype[' is a signed integer type.])])
- for gltype in $1 ; do
- AC_CACHE_CHECK([whether $gltype is signed], [gl_cv_type_${gltype}_signed],
- [AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM([$2[
- int verify[2 * (($gltype) -1 < ($gltype) 0) - 1];]])],
- result=yes, result=no)
- eval gl_cv_type_${gltype}_signed=\$result
- ])
- eval result=\$gl_cv_type_${gltype}_signed
- GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
- if test "$result" = yes; then
- AC_DEFINE_UNQUOTED([HAVE_SIGNED_${GLTYPE}], [1])
- eval HAVE_SIGNED_${GLTYPE}=1
- else
- eval HAVE_SIGNED_${GLTYPE}=0
- fi
- done
- m4_foreach_w([gltype], [$1],
- [AC_SUBST([HAVE_SIGNED_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))])
-])
-
-dnl gl_INTEGER_TYPE_SUFFIX(TYPES, INCLUDES)
-dnl Determine the suffix to use for integer constants of the given types.
-dnl Define t_SUFFIX for each such type.
-AC_DEFUN([gl_INTEGER_TYPE_SUFFIX],
-[
- dnl Use a shell loop, to avoid bloating configure, and
- dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
- dnl config.h.in,
- dnl - extra AC_SUBST calls, so that the right substitutions are made.
- m4_foreach_w([gltype], [$1],
- [AH_TEMPLATE(m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX],
- [Define to l, ll, u, ul, ull, etc., as suitable for
- constants of type ']gltype['.])])
- for gltype in $1 ; do
- AC_CACHE_CHECK([for $gltype integer literal suffix],
- [gl_cv_type_${gltype}_suffix],
- [eval gl_cv_type_${gltype}_suffix=no
- eval result=\$gl_cv_type_${gltype}_signed
- if test "$result" = yes; then
- glsufu=
- else
- glsufu=u
- fi
- for glsuf in "$glsufu" ${glsufu}l ${glsufu}ll ${glsufu}i64; do
- case $glsuf in
- '') gltype1='int';;
- l) gltype1='long int';;
- ll) gltype1='long long int';;
- i64) gltype1='__int64';;
- u) gltype1='unsigned int';;
- ul) gltype1='unsigned long int';;
- ull) gltype1='unsigned long long int';;
- ui64)gltype1='unsigned __int64';;
- esac
- AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM([$2[
- extern $gltype foo;
- extern $gltype1 foo;]])],
- [eval gl_cv_type_${gltype}_suffix=\$glsuf])
- eval result=\$gl_cv_type_${gltype}_suffix
- test "$result" != no && break
- done])
- GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
- eval result=\$gl_cv_type_${gltype}_suffix
- test "$result" = no && result=
- eval ${GLTYPE}_SUFFIX=\$result
- AC_DEFINE_UNQUOTED([${GLTYPE}_SUFFIX], [$result])
- done
- m4_foreach_w([gltype], [$1],
- [AC_SUBST(m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX])])
-])
-
-dnl gl_STDINT_INCLUDES
-AC_DEFUN([gl_STDINT_INCLUDES],
-[[
- /* BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
- included before <wchar.h>. */
- #include <stddef.h>
- #include <signal.h>
- #if HAVE_WCHAR_H
- # include <stdio.h>
- # include <time.h>
- # include <wchar.h>
- #endif
-]])
-
-dnl gl_STDINT_TYPE_PROPERTIES
-dnl Compute HAVE_SIGNED_t, BITSIZEOF_t and t_SUFFIX, for all the types t
-dnl of interest to stdint.in.h.
-AC_DEFUN([gl_STDINT_TYPE_PROPERTIES],
-[
- AC_REQUIRE([gl_MULTIARCH])
- if test $APPLE_UNIVERSAL_BUILD = 0; then
- gl_STDINT_BITSIZEOF([ptrdiff_t size_t],
- [gl_STDINT_INCLUDES])
- fi
- gl_STDINT_BITSIZEOF([sig_atomic_t wchar_t wint_t],
- [gl_STDINT_INCLUDES])
- gl_CHECK_TYPES_SIGNED([sig_atomic_t wchar_t wint_t],
- [gl_STDINT_INCLUDES])
- gl_cv_type_ptrdiff_t_signed=yes
- gl_cv_type_size_t_signed=no
- if test $APPLE_UNIVERSAL_BUILD = 0; then
- gl_INTEGER_TYPE_SUFFIX([ptrdiff_t size_t],
- [gl_STDINT_INCLUDES])
- fi
- gl_INTEGER_TYPE_SUFFIX([sig_atomic_t wchar_t wint_t],
- [gl_STDINT_INCLUDES])
-
- dnl If wint_t is smaller than 'int', it cannot satisfy the ISO C 99
- dnl requirement that wint_t is "unchanged by default argument promotions".
- dnl In this case gnulib's <wchar.h> and <wctype.h> override wint_t.
- dnl Set the variable BITSIZEOF_WINT_T accordingly.
- if test $GNULIB_OVERRIDES_WINT_T = 1; then
- BITSIZEOF_WINT_T=32
- fi
-])
-
-dnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in.
-dnl Remove this when we can assume autoconf >= 2.61.
-m4_ifdef([AC_COMPUTE_INT], [], [
- AC_DEFUN([AC_COMPUTE_INT], [_AC_COMPUTE_INT([$2],[$1],[$3],[$4])])
-])
diff --git a/lib/glm4/string_h.m4 b/lib/glm4/string_h.m4
deleted file mode 100644
index 3d2ad22..0000000
--- a/lib/glm4/string_h.m4
+++ /dev/null
@@ -1,120 +0,0 @@
-# Configure a GNU-like replacement for <string.h>.
-
-# Copyright (C) 2007-2017 Free Software Foundation, Inc.
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 21
-
-# Written by Paul Eggert.
-
-AC_DEFUN([gl_HEADER_STRING_H],
-[
- dnl Use AC_REQUIRE here, so that the default behavior below is expanded
- dnl once only, before all statements that occur in other macros.
- AC_REQUIRE([gl_HEADER_STRING_H_BODY])
-])
-
-AC_DEFUN([gl_HEADER_STRING_H_BODY],
-[
- AC_REQUIRE([AC_C_RESTRICT])
- AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
- gl_NEXT_HEADERS([string.h])
-
- dnl Check for declarations of anything we want to poison if the
- dnl corresponding gnulib module is not in use, and which is not
- dnl guaranteed by C89.
- gl_WARN_ON_USE_PREPARE([[#include <string.h>
- ]],
- [ffsl ffsll memmem mempcpy memrchr rawmemchr stpcpy stpncpy strchrnul
- strdup strncat strndup strnlen strpbrk strsep strcasestr strtok_r
- strerror_r strsignal strverscmp])
-])
-
-AC_DEFUN([gl_STRING_MODULE_INDICATOR],
-[
- dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
- AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
- gl_MODULE_INDICATOR_SET_VARIABLE([$1])
- dnl Define it also as a C macro, for the benefit of the unit tests.
- gl_MODULE_INDICATOR_FOR_TESTS([$1])
-])
-
-AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
-[
- GNULIB_FFSL=0; AC_SUBST([GNULIB_FFSL])
- GNULIB_FFSLL=0; AC_SUBST([GNULIB_FFSLL])
- GNULIB_MEMCHR=0; AC_SUBST([GNULIB_MEMCHR])
- GNULIB_MEMMEM=0; AC_SUBST([GNULIB_MEMMEM])
- GNULIB_MEMPCPY=0; AC_SUBST([GNULIB_MEMPCPY])
- GNULIB_MEMRCHR=0; AC_SUBST([GNULIB_MEMRCHR])
- GNULIB_RAWMEMCHR=0; AC_SUBST([GNULIB_RAWMEMCHR])
- GNULIB_STPCPY=0; AC_SUBST([GNULIB_STPCPY])
- GNULIB_STPNCPY=0; AC_SUBST([GNULIB_STPNCPY])
- GNULIB_STRCHRNUL=0; AC_SUBST([GNULIB_STRCHRNUL])
- GNULIB_STRDUP=0; AC_SUBST([GNULIB_STRDUP])
- GNULIB_STRNCAT=0; AC_SUBST([GNULIB_STRNCAT])
- GNULIB_STRNDUP=0; AC_SUBST([GNULIB_STRNDUP])
- GNULIB_STRNLEN=0; AC_SUBST([GNULIB_STRNLEN])
- GNULIB_STRPBRK=0; AC_SUBST([GNULIB_STRPBRK])
- GNULIB_STRSEP=0; AC_SUBST([GNULIB_STRSEP])
- GNULIB_STRSTR=0; AC_SUBST([GNULIB_STRSTR])
- GNULIB_STRCASESTR=0; AC_SUBST([GNULIB_STRCASESTR])
- GNULIB_STRTOK_R=0; AC_SUBST([GNULIB_STRTOK_R])
- GNULIB_MBSLEN=0; AC_SUBST([GNULIB_MBSLEN])
- GNULIB_MBSNLEN=0; AC_SUBST([GNULIB_MBSNLEN])
- GNULIB_MBSCHR=0; AC_SUBST([GNULIB_MBSCHR])
- GNULIB_MBSRCHR=0; AC_SUBST([GNULIB_MBSRCHR])
- GNULIB_MBSSTR=0; AC_SUBST([GNULIB_MBSSTR])
- GNULIB_MBSCASECMP=0; AC_SUBST([GNULIB_MBSCASECMP])
- GNULIB_MBSNCASECMP=0; AC_SUBST([GNULIB_MBSNCASECMP])
- GNULIB_MBSPCASECMP=0; AC_SUBST([GNULIB_MBSPCASECMP])
- GNULIB_MBSCASESTR=0; AC_SUBST([GNULIB_MBSCASESTR])
- GNULIB_MBSCSPN=0; AC_SUBST([GNULIB_MBSCSPN])
- GNULIB_MBSPBRK=0; AC_SUBST([GNULIB_MBSPBRK])
- GNULIB_MBSSPN=0; AC_SUBST([GNULIB_MBSSPN])
- GNULIB_MBSSEP=0; AC_SUBST([GNULIB_MBSSEP])
- GNULIB_MBSTOK_R=0; AC_SUBST([GNULIB_MBSTOK_R])
- GNULIB_STRERROR=0; AC_SUBST([GNULIB_STRERROR])
- GNULIB_STRERROR_R=0; AC_SUBST([GNULIB_STRERROR_R])
- GNULIB_STRSIGNAL=0; AC_SUBST([GNULIB_STRSIGNAL])
- GNULIB_STRVERSCMP=0; AC_SUBST([GNULIB_STRVERSCMP])
- HAVE_MBSLEN=0; AC_SUBST([HAVE_MBSLEN])
- dnl Assume proper GNU behavior unless another module says otherwise.
- HAVE_FFSL=1; AC_SUBST([HAVE_FFSL])
- HAVE_FFSLL=1; AC_SUBST([HAVE_FFSLL])
- HAVE_MEMCHR=1; AC_SUBST([HAVE_MEMCHR])
- HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM])
- HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY])
- HAVE_DECL_MEMRCHR=1; AC_SUBST([HAVE_DECL_MEMRCHR])
- HAVE_RAWMEMCHR=1; AC_SUBST([HAVE_RAWMEMCHR])
- HAVE_STPCPY=1; AC_SUBST([HAVE_STPCPY])
- HAVE_STPNCPY=1; AC_SUBST([HAVE_STPNCPY])
- HAVE_STRCHRNUL=1; AC_SUBST([HAVE_STRCHRNUL])
- HAVE_DECL_STRDUP=1; AC_SUBST([HAVE_DECL_STRDUP])
- HAVE_DECL_STRNDUP=1; AC_SUBST([HAVE_DECL_STRNDUP])
- HAVE_DECL_STRNLEN=1; AC_SUBST([HAVE_DECL_STRNLEN])
- HAVE_STRPBRK=1; AC_SUBST([HAVE_STRPBRK])
- HAVE_STRSEP=1; AC_SUBST([HAVE_STRSEP])
- HAVE_STRCASESTR=1; AC_SUBST([HAVE_STRCASESTR])
- HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R])
- HAVE_DECL_STRERROR_R=1; AC_SUBST([HAVE_DECL_STRERROR_R])
- HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL])
- HAVE_STRVERSCMP=1; AC_SUBST([HAVE_STRVERSCMP])
- REPLACE_MEMCHR=0; AC_SUBST([REPLACE_MEMCHR])
- REPLACE_MEMMEM=0; AC_SUBST([REPLACE_MEMMEM])
- REPLACE_STPNCPY=0; AC_SUBST([REPLACE_STPNCPY])
- REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP])
- REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR])
- REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR])
- REPLACE_STRCHRNUL=0; AC_SUBST([REPLACE_STRCHRNUL])
- REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR])
- REPLACE_STRERROR_R=0; AC_SUBST([REPLACE_STRERROR_R])
- REPLACE_STRNCAT=0; AC_SUBST([REPLACE_STRNCAT])
- REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP])
- REPLACE_STRNLEN=0; AC_SUBST([REPLACE_STRNLEN])
- REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL])
- REPLACE_STRTOK_R=0; AC_SUBST([REPLACE_STRTOK_R])
- UNDEFINE_STRTOK_R=0; AC_SUBST([UNDEFINE_STRTOK_R])
-])
diff --git a/lib/glm4/strverscmp.m4 b/lib/glm4/strverscmp.m4
deleted file mode 100644
index cbcca3f..0000000
--- a/lib/glm4/strverscmp.m4
+++ /dev/null
@@ -1,22 +0,0 @@
-# strverscmp.m4 serial 8
-dnl Copyright (C) 2002, 2005-2017 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-AC_DEFUN([gl_FUNC_STRVERSCMP],
-[
- dnl Persuade glibc <string.h> to declare strverscmp().
- AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
-
- AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
- AC_CHECK_FUNCS([strverscmp])
- if test $ac_cv_func_strverscmp = no; then
- HAVE_STRVERSCMP=0
- fi
-])
-
-# Prerequisites of lib/strverscmp.c.
-AC_DEFUN([gl_PREREQ_STRVERSCMP], [
- :
-])
diff --git a/lib/glm4/sys_types_h.m4 b/lib/glm4/sys_types_h.m4
deleted file mode 100644
index 2eb4e9e..0000000
--- a/lib/glm4/sys_types_h.m4
+++ /dev/null
@@ -1,49 +0,0 @@
-# sys_types_h.m4 serial 6
-dnl Copyright (C) 2011-2017 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-AC_DEFUN_ONCE([gl_SYS_TYPES_H],
-[
- AC_REQUIRE([gl_SYS_TYPES_H_DEFAULTS])
- gl_NEXT_HEADERS([sys/types.h])
-
- dnl Ensure the type pid_t gets defined.
- AC_REQUIRE([AC_TYPE_PID_T])
-
- dnl Ensure the type mode_t gets defined.
- AC_REQUIRE([AC_TYPE_MODE_T])
-
- dnl Whether to override the 'off_t' type.
- AC_REQUIRE([gl_TYPE_OFF_T])
-])
-
-AC_DEFUN([gl_SYS_TYPES_H_DEFAULTS],
-[
-])
-
-# This works around a buggy version in autoconf <= 2.69.
-# See <https://lists.gnu.org/archive/html/autoconf/2016-08/msg00014.html>
-
-m4_version_prereq([2.70], [], [
-
-# This is taken from the following Autoconf patch:
-# http://git.sv.gnu.org/cgit/autoconf.git/commit/?id=e17a30e98
-
-m4_undefine([AC_HEADER_MAJOR])
-AC_DEFUN([AC_HEADER_MAJOR],
-[AC_CHECK_HEADERS_ONCE([sys/types.h])
-AC_CHECK_HEADER([sys/mkdev.h],
- [AC_DEFINE([MAJOR_IN_MKDEV], [1],
- [Define to 1 if `major', `minor', and `makedev' are declared in
- <mkdev.h>.])])
-if test $ac_cv_header_sys_mkdev_h = no; then
- AC_CHECK_HEADER([sys/sysmacros.h],
- [AC_DEFINE([MAJOR_IN_SYSMACROS], [1],
- [Define to 1 if `major', `minor', and `makedev' are declared in
- <sysmacros.h>.])])
-fi
-])
-
-])
diff --git a/lib/glm4/visibility.m4 b/lib/glm4/visibility.m4
deleted file mode 100644
index ce00e72..0000000
--- a/lib/glm4/visibility.m4
+++ /dev/null
@@ -1,77 +0,0 @@
-# visibility.m4 serial 5 (gettext-0.18.2)
-dnl Copyright (C) 2005, 2008, 2010-2017 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-dnl From Bruno Haible.
-
-dnl Tests whether the compiler supports the command-line option
-dnl -fvisibility=hidden and the function and variable attributes
-dnl __attribute__((__visibility__("hidden"))) and
-dnl __attribute__((__visibility__("default"))).
-dnl Does *not* test for __visibility__("protected") - which has tricky
-dnl semantics (see the 'vismain' test in glibc) and does not exist e.g. on
-dnl Mac OS X.
-dnl Does *not* test for __visibility__("internal") - which has processor
-dnl dependent semantics.
-dnl Does *not* test for #pragma GCC visibility push(hidden) - which is
-dnl "really only recommended for legacy code".
-dnl Set the variable CFLAG_VISIBILITY.
-dnl Defines and sets the variable HAVE_VISIBILITY.
-
-AC_DEFUN([gl_VISIBILITY],
-[
- AC_REQUIRE([AC_PROG_CC])
- CFLAG_VISIBILITY=
- HAVE_VISIBILITY=0
- if test -n "$GCC"; then
- dnl First, check whether -Werror can be added to the command line, or
- dnl whether it leads to an error because of some other option that the
- dnl user has put into $CC $CFLAGS $CPPFLAGS.
- AC_MSG_CHECKING([whether the -Werror option is usable])
- AC_CACHE_VAL([gl_cv_cc_vis_werror], [
- gl_save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -Werror"
- AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM([[]], [[]])],
- [gl_cv_cc_vis_werror=yes],
- [gl_cv_cc_vis_werror=no])
- CFLAGS="$gl_save_CFLAGS"])
- AC_MSG_RESULT([$gl_cv_cc_vis_werror])
- dnl Now check whether visibility declarations are supported.
- AC_MSG_CHECKING([for simple visibility declarations])
- AC_CACHE_VAL([gl_cv_cc_visibility], [
- gl_save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -fvisibility=hidden"
- dnl We use the option -Werror and a function dummyfunc, because on some
- dnl platforms (Cygwin 1.7) the use of -fvisibility triggers a warning
- dnl "visibility attribute not supported in this configuration; ignored"
- dnl at the first function definition in every compilation unit, and we
- dnl don't want to use the option in this case.
- if test $gl_cv_cc_vis_werror = yes; then
- CFLAGS="$CFLAGS -Werror"
- fi
- AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM(
- [[extern __attribute__((__visibility__("hidden"))) int hiddenvar;
- extern __attribute__((__visibility__("default"))) int exportedvar;
- extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void);
- extern __attribute__((__visibility__("default"))) int exportedfunc (void);
- void dummyfunc (void) {}
- ]],
- [[]])],
- [gl_cv_cc_visibility=yes],
- [gl_cv_cc_visibility=no])
- CFLAGS="$gl_save_CFLAGS"])
- AC_MSG_RESULT([$gl_cv_cc_visibility])
- if test $gl_cv_cc_visibility = yes; then
- CFLAG_VISIBILITY="-fvisibility=hidden"
- HAVE_VISIBILITY=1
- fi
- fi
- AC_SUBST([CFLAG_VISIBILITY])
- AC_SUBST([HAVE_VISIBILITY])
- AC_DEFINE_UNQUOTED([HAVE_VISIBILITY], [$HAVE_VISIBILITY],
- [Define to 1 or 0, depending whether the compiler supports simple visibility declarations.])
-])
diff --git a/lib/glm4/warn-on-use.m4 b/lib/glm4/warn-on-use.m4
deleted file mode 100644
index 25ce737..0000000
--- a/lib/glm4/warn-on-use.m4
+++ /dev/null
@@ -1,47 +0,0 @@
-# warn-on-use.m4 serial 5
-dnl Copyright (C) 2010-2017 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-# gl_WARN_ON_USE_PREPARE(INCLUDES, NAMES)
-# ---------------------------------------
-# For each whitespace-separated element in the list of NAMES, define
-# HAVE_RAW_DECL_name if the function has a declaration among INCLUDES
-# even after being undefined as a macro.
-#
-# See warn-on-use.h for some hints on how to poison function names, as
-# well as ideas on poisoning global variables and macros. NAMES may
-# include global variables, but remember that only functions work with
-# _GL_WARN_ON_USE. Typically, INCLUDES only needs to list a single
-# header, but if the replacement header pulls in other headers because
-# some systems declare functions in the wrong header, then INCLUDES
-# should do likewise.
-#
-# It is generally safe to assume declarations for functions declared
-# in the intersection of C89 and C11 (such as printf) without
-# needing gl_WARN_ON_USE_PREPARE.
-AC_DEFUN([gl_WARN_ON_USE_PREPARE],
-[
- m4_foreach_w([gl_decl], [$2],
- [AH_TEMPLATE([HAVE_RAW_DECL_]AS_TR_CPP(m4_defn([gl_decl])),
- [Define to 1 if ]m4_defn([gl_decl])[ is declared even after
- undefining macros.])])dnl
-dnl FIXME: gl_Symbol must be used unquoted until we can assume
-dnl autoconf 2.64 or newer.
- for gl_func in m4_flatten([$2]); do
- AS_VAR_PUSHDEF([gl_Symbol], [gl_cv_have_raw_decl_$gl_func])dnl
- AC_CACHE_CHECK([whether $gl_func is declared without a macro],
- gl_Symbol,
- [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$1],
-[@%:@undef $gl_func
- (void) $gl_func;])],
- [AS_VAR_SET(gl_Symbol, [yes])], [AS_VAR_SET(gl_Symbol, [no])])])
- AS_VAR_IF(gl_Symbol, [yes],
- [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1])
- dnl shortcut - if the raw declaration exists, then set a cache
- dnl variable to allow skipping any later AC_CHECK_DECL efforts
- eval ac_cv_have_decl_$gl_func=yes])
- AS_VAR_POPDEF([gl_Symbol])dnl
- done
-])
diff --git a/lib/glm4/wchar_t.m4 b/lib/glm4/wchar_t.m4
deleted file mode 100644
index 11783d2..0000000
--- a/lib/glm4/wchar_t.m4
+++ /dev/null
@@ -1,24 +0,0 @@
-# wchar_t.m4 serial 4 (gettext-0.18.2)
-dnl Copyright (C) 2002-2003, 2008-2017 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-dnl From Bruno Haible.
-dnl Test whether <stddef.h> has the 'wchar_t' type.
-dnl Prerequisite: AC_PROG_CC
-
-AC_DEFUN([gt_TYPE_WCHAR_T],
-[
- AC_CACHE_CHECK([for wchar_t], [gt_cv_c_wchar_t],
- [AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM(
- [[#include <stddef.h>
- wchar_t foo = (wchar_t)'\0';]],
- [[]])],
- [gt_cv_c_wchar_t=yes],
- [gt_cv_c_wchar_t=no])])
- if test $gt_cv_c_wchar_t = yes; then
- AC_DEFINE([HAVE_WCHAR_T], [1], [Define if you have the 'wchar_t' type.])
- fi
-])
diff --git a/lib/glm4/wint_t.m4 b/lib/glm4/wint_t.m4
deleted file mode 100644
index 65e25a4..0000000
--- a/lib/glm4/wint_t.m4
+++ /dev/null
@@ -1,62 +0,0 @@
-# wint_t.m4 serial 6
-dnl Copyright (C) 2003, 2007-2017 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-dnl From Bruno Haible.
-dnl Test whether <wchar.h> has the 'wint_t' type and whether gnulib's
-dnl <wchar.h> or <wctype.h> would, if present, override 'wint_t'.
-dnl Prerequisite: AC_PROG_CC
-
-AC_DEFUN([gt_TYPE_WINT_T],
-[
- AC_CACHE_CHECK([for wint_t], [gt_cv_c_wint_t],
- [AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM(
- [[
-/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
- <wchar.h>.
- BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be included
- before <wchar.h>. */
-#include <stddef.h>
-#include <stdio.h>
-#include <time.h>
-#include <wchar.h>
- wint_t foo = (wchar_t)'\0';]],
- [[]])],
- [gt_cv_c_wint_t=yes],
- [gt_cv_c_wint_t=no])])
- if test $gt_cv_c_wint_t = yes; then
- AC_DEFINE([HAVE_WINT_T], [1], [Define if you have the 'wint_t' type.])
-
- dnl Determine whether gnulib's <wchar.h> or <wctype.h> would, if present,
- dnl override 'wint_t'.
- AC_CACHE_CHECK([whether wint_t is too small],
- [gl_cv_type_wint_t_too_small],
- [AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM([[
-/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
- <wchar.h>.
- BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
- included before <wchar.h>. */
-#if !(defined __GLIBC__ && !defined __UCLIBC__)
-# include <stddef.h>
-# include <stdio.h>
-# include <time.h>
-#endif
-#include <wchar.h>
- int verify[sizeof (wint_t) < sizeof (int) ? -1 : 1];
- ]])],
- [gl_cv_type_wint_t_too_small=no],
- [gl_cv_type_wint_t_too_small=yes])])
- if test $gl_cv_type_wint_t_too_small = yes; then
- GNULIB_OVERRIDES_WINT_T=1
- else
- GNULIB_OVERRIDES_WINT_T=0
- fi
- else
- GNULIB_OVERRIDES_WINT_T=0
- fi
- AC_SUBST([GNULIB_OVERRIDES_WINT_T])
-])
diff --git a/lib/gstr.c b/lib/gstr.c
deleted file mode 100644
index e91a3a1..0000000
--- a/lib/gstr.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2002-2014 Free Software Foundation, Inc.
- *
- * This file is part of LIBTASN1.
- *
- * The LIBTASN1 library 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 library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- */
-
-#include <int.h>
-#include "gstr.h"
-
-/* These function are like strcat, strcpy. They only
- * do bounds checking (they shouldn't cause buffer overruns),
- * and they always produce null terminated strings.
- *
- * They should be used only with null terminated strings.
- */
-void
-_asn1_str_cat (char *dest, size_t dest_tot_size, const char *src)
-{
- size_t str_size = strlen (src);
- size_t dest_size = strlen (dest);
-
- if (dest_tot_size - dest_size > str_size)
- {
- strcat (dest, src);
- }
- else
- {
- if (dest_tot_size - dest_size > 0)
- {
- strncat (dest, src, (dest_tot_size - dest_size) - 1);
- dest[dest_tot_size - 1] = 0;
- }
- }
-}
-
-/* Returns the bytes copied (not including the null terminator) */
-unsigned int
-_asn1_str_cpy (char *dest, size_t dest_tot_size, const char *src)
-{
- size_t str_size = strlen (src);
-
- if (dest_tot_size > str_size)
- {
- strcpy (dest, src);
- return str_size;
- }
- else
- {
- if (dest_tot_size > 0)
- {
- str_size = dest_tot_size - 1;
- memcpy (dest, src, str_size);
- dest[str_size] = 0;
- return str_size;
- }
- else
- return 0;
- }
-}
diff --git a/lib/gstr.h b/lib/gstr.h
deleted file mode 100644
index 00c335c..0000000
--- a/lib/gstr.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2002-2014 Free Software Foundation, Inc.
- *
- * This file is part of LIBTASN1.
- *
- * The LIBTASN1 library 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 library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- */
-
-unsigned int _asn1_str_cpy (char *dest, size_t dest_tot_size,
- const char *src);
-void _asn1_str_cat (char *dest, size_t dest_tot_size, const char *src);
-
-#define Estrcpy(x,y) _asn1_str_cpy(x,ASN1_MAX_ERROR_DESCRIPTION_SIZE,y)
-#define Estrcat(x,y) _asn1_str_cat(x,ASN1_MAX_ERROR_DESCRIPTION_SIZE,y)
-
-inline static
-void safe_memset(void *data, int c, size_t size)
-{
- volatile unsigned volatile_zero = 0;
- volatile char *vdata = (volatile char*)data;
-
- /* This is based on a nice trick for safe memset,
- * sent by David Jacobson in the openssl-dev mailing list.
- */
-
- if (size > 0) do {
- memset(data, c, size);
- } while(vdata[volatile_zero] != c);
-}
diff --git a/lib/int.h b/lib/int.h
deleted file mode 100644
index 7d2eea3..0000000
--- a/lib/int.h
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Copyright (C) 2002-2014 Free Software Foundation, Inc.
- *
- * This file is part of LIBTASN1.
- *
- * The LIBTASN1 library 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 library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- */
-
-#ifndef INT_H
-#define INT_H
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <stdint.h>
-
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-#include <libtasn1.h>
-
-#define ASN1_SMALL_VALUE_SIZE 16
-
-/* This structure is also in libtasn1.h, but then contains less
- fields. You cannot make any modifications to these first fields
- without breaking ABI. */
-struct asn1_node_st
-{
- /* public fields: */
- char name[ASN1_MAX_NAME_SIZE + 1]; /* Node name */
- unsigned int name_hash;
- unsigned int type; /* Node type */
- unsigned char *value; /* Node value */
- int value_len;
- asn1_node down; /* Pointer to the son node */
- asn1_node right; /* Pointer to the brother node */
- asn1_node left; /* Pointer to the next list element */
- /* private fields: */
- unsigned char small_value[ASN1_SMALL_VALUE_SIZE]; /* For small values */
-
- /* values used during decoding/coding */
- int tmp_ival;
- unsigned start; /* the start of the DER sequence - if decoded */
- unsigned end; /* the end of the DER sequence - if decoded */
-};
-
-typedef struct tag_and_class_st
-{
- unsigned tag;
- unsigned class;
- const char *desc;
-} tag_and_class_st;
-
-/* the types that are handled in _asn1_tags */
-#define CASE_HANDLED_ETYPES \
- case ASN1_ETYPE_NULL: \
- case ASN1_ETYPE_BOOLEAN: \
- case ASN1_ETYPE_INTEGER: \
- case ASN1_ETYPE_ENUMERATED: \
- case ASN1_ETYPE_OBJECT_ID: \
- case ASN1_ETYPE_OCTET_STRING: \
- case ASN1_ETYPE_GENERALSTRING: \
- case ASN1_ETYPE_NUMERIC_STRING: \
- case ASN1_ETYPE_IA5_STRING: \
- case ASN1_ETYPE_TELETEX_STRING: \
- case ASN1_ETYPE_PRINTABLE_STRING: \
- case ASN1_ETYPE_UNIVERSAL_STRING: \
- case ASN1_ETYPE_BMP_STRING: \
- case ASN1_ETYPE_UTF8_STRING: \
- case ASN1_ETYPE_VISIBLE_STRING: \
- case ASN1_ETYPE_BIT_STRING: \
- case ASN1_ETYPE_SEQUENCE: \
- case ASN1_ETYPE_SEQUENCE_OF: \
- case ASN1_ETYPE_SET: \
- case ASN1_ETYPE_UTC_TIME: \
- case ASN1_ETYPE_GENERALIZED_TIME: \
- case ASN1_ETYPE_SET_OF
-
-#define ETYPE_TAG(etype) (_asn1_tags[etype].tag)
-#define ETYPE_CLASS(etype) (_asn1_tags[etype].class)
-#define ETYPE_OK(etype) (((etype) != ASN1_ETYPE_INVALID && \
- (etype) <= _asn1_tags_size && \
- _asn1_tags[(etype)].desc != NULL)?1:0)
-
-#define ETYPE_IS_STRING(etype) ((etype == ASN1_ETYPE_GENERALSTRING || \
- etype == ASN1_ETYPE_NUMERIC_STRING || etype == ASN1_ETYPE_IA5_STRING || \
- etype == ASN1_ETYPE_TELETEX_STRING || etype == ASN1_ETYPE_PRINTABLE_STRING || \
- etype == ASN1_ETYPE_UNIVERSAL_STRING || etype == ASN1_ETYPE_BMP_STRING || \
- etype == ASN1_ETYPE_UTF8_STRING || etype == ASN1_ETYPE_VISIBLE_STRING || \
- etype == ASN1_ETYPE_OCTET_STRING)?1:0)
-
-extern unsigned int _asn1_tags_size;
-extern const tag_and_class_st _asn1_tags[];
-
-#define _asn1_strlen(s) strlen((const char *) s)
-#define _asn1_strtol(n,e,b) strtol((const char *) n, e, b)
-#define _asn1_strtoul(n,e,b) strtoul((const char *) n, e, b)
-#define _asn1_strcmp(a,b) strcmp((const char *)a, (const char *)b)
-#define _asn1_strcpy(a,b) strcpy((char *)a, (const char *)b)
-#define _asn1_strcat(a,b) strcat((char *)a, (const char *)b)
-
-#if SIZEOF_UNSIGNED_LONG_INT == 8
-# define _asn1_strtou64(n,e,b) strtoul((const char *) n, e, b)
-#else
-# define _asn1_strtou64(n,e,b) strtoull((const char *) n, e, b)
-#endif
-
-#define MAX_LOG_SIZE 1024 /* maximum number of characters of a log message */
-
-/* Define used for visiting trees. */
-#define UP 1
-#define RIGHT 2
-#define DOWN 3
-
-/***********************************************************************/
-/* List of constants to better specify the type of typedef asn1_node_st. */
-/***********************************************************************/
-/* Used with TYPE_TAG */
-#define CONST_UNIVERSAL (1<<8)
-#define CONST_PRIVATE (1<<9)
-#define CONST_APPLICATION (1<<10)
-#define CONST_EXPLICIT (1<<11)
-#define CONST_IMPLICIT (1<<12)
-
-#define CONST_TAG (1<<13) /* Used in ASN.1 assignement */
-#define CONST_OPTION (1<<14)
-#define CONST_DEFAULT (1<<15)
-#define CONST_TRUE (1<<16)
-#define CONST_FALSE (1<<17)
-
-#define CONST_LIST (1<<18) /* Used with TYPE_INTEGER and TYPE_BIT_STRING */
-#define CONST_MIN_MAX (1<<19)
-
-#define CONST_1_PARAM (1<<20)
-
-#define CONST_SIZE (1<<21)
-
-#define CONST_DEFINED_BY (1<<22)
-
-/* Those two are deprecated and used for backwards compatibility */
-#define CONST_GENERALIZED (1<<23)
-#define CONST_UTC (1<<24)
-
-/* #define CONST_IMPORTS (1<<25) */
-
-#define CONST_NOT_USED (1<<26)
-#define CONST_SET (1<<27)
-#define CONST_ASSIGN (1<<28)
-
-#define CONST_DOWN (1<<29)
-#define CONST_RIGHT (1<<30)
-
-
-#define ASN1_ETYPE_TIME 17
-/****************************************/
-/* Returns the first 8 bits. */
-/* Used with the field type of asn1_node_st */
-/****************************************/
-inline static unsigned int
-type_field (unsigned int ntype)
-{
- return (ntype & 0xff);
-}
-
-/* To convert old types from a static structure */
-inline static unsigned int
-convert_old_type (unsigned int ntype)
-{
- unsigned int type = ntype & 0xff;
- if (type == ASN1_ETYPE_TIME)
- {
- if (ntype & CONST_UTC)
- type = ASN1_ETYPE_UTC_TIME;
- else
- type = ASN1_ETYPE_GENERALIZED_TIME;
-
- ntype &= ~(CONST_UTC | CONST_GENERALIZED);
- ntype &= 0xffffff00;
- ntype |= type;
-
- return ntype;
- }
- else
- return ntype;
-}
-
-static inline
-void *_asn1_realloc(void *ptr, size_t size)
-{
- void *ret;
-
- if (size == 0)
- return ptr;
-
- ret = realloc(ptr, size);
- if (ret == NULL)
- {
- free(ptr);
- }
- return ret;
-}
-
-#endif /* INT_H */
diff --git a/lib/libtasn1.h b/lib/libtasn1.h
deleted file mode 100644
index ea26b78..0000000
--- a/lib/libtasn1.h
+++ /dev/null
@@ -1,405 +0,0 @@
-/*
- * Copyright (C) 2002-2014 Free Software Foundation, Inc.
- *
- * This file is part of LIBTASN1.
- *
- * LIBTASN1 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.
- *
- * LIBTASN1 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 LIBTASN1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- *
- */
-
-#ifndef LIBTASN1_H
-#define LIBTASN1_H
-
-#ifndef ASN1_API
-#if defined ASN1_BUILDING && defined HAVE_VISIBILITY && HAVE_VISIBILITY
-#define ASN1_API __attribute__((__visibility__("default")))
-#elif defined ASN1_BUILDING && defined _MSC_VER && ! defined ASN1_STATIC
-#define ASN1_API __declspec(dllexport)
-#elif defined _MSC_VER && ! defined ASN1_STATIC
-#define ASN1_API __declspec(dllimport)
-#else
-#define ASN1_API
-#endif
-#endif
-
-#include <sys/types.h>
-#include <time.h>
-#include <stdio.h> /* for FILE* */
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#define ASN1_VERSION "4.13"
-
-#if defined(__GNUC__) && !defined(ASN1_INTERNAL_BUILD)
-# define _ASN1_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
-# if _ASN1_GCC_VERSION >= 30100
-# define _ASN1_GCC_ATTR_DEPRECATED __attribute__ ((__deprecated__))
-# endif
-#endif
-
-#ifndef _ASN1_GCC_ATTR_DEPRECATED
-#define _ASN1_GCC_ATTR_DEPRECATED
-#endif
-
- /*****************************************/
- /* Errors returned by libtasn1 functions */
- /*****************************************/
-#define ASN1_SUCCESS 0
-#define ASN1_FILE_NOT_FOUND 1
-#define ASN1_ELEMENT_NOT_FOUND 2
-#define ASN1_IDENTIFIER_NOT_FOUND 3
-#define ASN1_DER_ERROR 4
-#define ASN1_VALUE_NOT_FOUND 5
-#define ASN1_GENERIC_ERROR 6
-#define ASN1_VALUE_NOT_VALID 7
-#define ASN1_TAG_ERROR 8
-#define ASN1_TAG_IMPLICIT 9
-#define ASN1_ERROR_TYPE_ANY 10
-#define ASN1_SYNTAX_ERROR 11
-#define ASN1_MEM_ERROR 12
-#define ASN1_MEM_ALLOC_ERROR 13
-#define ASN1_DER_OVERFLOW 14
-#define ASN1_NAME_TOO_LONG 15
-#define ASN1_ARRAY_ERROR 16
-#define ASN1_ELEMENT_NOT_EMPTY 17
-#define ASN1_TIME_ENCODING_ERROR 18
-
- /*************************************/
- /* Constants used in asn1_visit_tree */
- /*************************************/
-#define ASN1_PRINT_NAME 1
-#define ASN1_PRINT_NAME_TYPE 2
-#define ASN1_PRINT_NAME_TYPE_VALUE 3
-#define ASN1_PRINT_ALL 4
-
- /*****************************************/
- /* Constants returned by asn1_read_tag */
- /*****************************************/
-#define ASN1_CLASS_UNIVERSAL 0x00 /* old: 1 */
-#define ASN1_CLASS_APPLICATION 0x40 /* old: 2 */
-#define ASN1_CLASS_CONTEXT_SPECIFIC 0x80 /* old: 3 */
-#define ASN1_CLASS_PRIVATE 0xC0 /* old: 4 */
-#define ASN1_CLASS_STRUCTURED 0x20
-
- /*****************************************/
- /* Constants returned by asn1_read_tag */
- /*****************************************/
-#define ASN1_TAG_BOOLEAN 0x01
-#define ASN1_TAG_INTEGER 0x02
-#define ASN1_TAG_SEQUENCE 0x10
-#define ASN1_TAG_SET 0x11
-#define ASN1_TAG_OCTET_STRING 0x04
-#define ASN1_TAG_BIT_STRING 0x03
-#define ASN1_TAG_UTCTime 0x17
-#define ASN1_TAG_GENERALIZEDTime 0x18
-#define ASN1_TAG_OBJECT_ID 0x06
-#define ASN1_TAG_ENUMERATED 0x0A
-#define ASN1_TAG_NULL 0x05
-#define ASN1_TAG_GENERALSTRING 0x1B
-#define ASN1_TAG_NUMERIC_STRING 0x12
-#define ASN1_TAG_IA5_STRING 0x16
-#define ASN1_TAG_TELETEX_STRING 0x14
-#define ASN1_TAG_PRINTABLE_STRING 0x13
-#define ASN1_TAG_UNIVERSAL_STRING 0x1C
-#define ASN1_TAG_BMP_STRING 0x1E
-#define ASN1_TAG_UTF8_STRING 0x0C
-#define ASN1_TAG_VISIBLE_STRING 0x1A
-
- /******************************************************/
- /* Structure definition used for the node of the tree */
- /* that represent an ASN.1 DEFINITION. */
- /******************************************************/
-
- typedef struct asn1_node_st asn1_node_st;
-
- typedef asn1_node_st *asn1_node;
-
- /* maximum number of characters of a name */
- /* inside a file with ASN1 definitons */
-#define ASN1_MAX_NAME_SIZE 64
-
-
- /*****************************************/
- /* For the on-disk format of ASN.1 trees */
- /*****************************************/
- struct asn1_static_node_st
- {
- const char *name; /* Node name */
- unsigned int type; /* Node type */
- const void *value; /* Node value */
- };
- typedef struct asn1_static_node_st asn1_static_node;
-
-/* List of constants for field type of node_asn */
-#define ASN1_ETYPE_INVALID 0
-#define ASN1_ETYPE_CONSTANT 1
-#define ASN1_ETYPE_IDENTIFIER 2
-#define ASN1_ETYPE_INTEGER 3
-#define ASN1_ETYPE_BOOLEAN 4
-#define ASN1_ETYPE_SEQUENCE 5
-#define ASN1_ETYPE_BIT_STRING 6
-#define ASN1_ETYPE_OCTET_STRING 7
-#define ASN1_ETYPE_TAG 8
-#define ASN1_ETYPE_DEFAULT 9
-#define ASN1_ETYPE_SIZE 10
-#define ASN1_ETYPE_SEQUENCE_OF 11
-#define ASN1_ETYPE_OBJECT_ID 12
-#define ASN1_ETYPE_ANY 13
-#define ASN1_ETYPE_SET 14
-#define ASN1_ETYPE_SET_OF 15
-#define ASN1_ETYPE_DEFINITIONS 16
-#define ASN1_ETYPE_CHOICE 18
-#define ASN1_ETYPE_IMPORTS 19
-#define ASN1_ETYPE_NULL 20
-#define ASN1_ETYPE_ENUMERATED 21
-#define ASN1_ETYPE_GENERALSTRING 27
-#define ASN1_ETYPE_NUMERIC_STRING 28
-#define ASN1_ETYPE_IA5_STRING 29
-#define ASN1_ETYPE_TELETEX_STRING 30
-#define ASN1_ETYPE_PRINTABLE_STRING 31
-#define ASN1_ETYPE_UNIVERSAL_STRING 32
-#define ASN1_ETYPE_BMP_STRING 33
-#define ASN1_ETYPE_UTF8_STRING 34
-#define ASN1_ETYPE_VISIBLE_STRING 35
-#define ASN1_ETYPE_UTC_TIME 36
-#define ASN1_ETYPE_GENERALIZED_TIME 37
-
-/* Flags used by asn1_delete_structure2() */
-
-/* makes sure the values are zeroized prior to deinitialization */
-#define ASN1_DELETE_FLAG_ZEROIZE 1
-
-/* Flags used by asn1_der_decoding2(). */
-
-/* This flag would allow arbitrary data past the DER data */
-#define ASN1_DECODE_FLAG_ALLOW_PADDING 1
-/* This flag would ensure that no BER decoding takes place */
-#define ASN1_DECODE_FLAG_STRICT_DER (1<<1)
-/* This flag will tolerate Time encoding errors when in strict DER */
-#define ASN1_DECODE_FLAG_ALLOW_INCORRECT_TIME (1<<2)
-
-
- struct asn1_data_node_st
- {
- const char *name; /* Node name */
- const void *value; /* Node value */
- unsigned int value_len; /* Node value size */
- unsigned int type; /* Node value type (ASN1_ETYPE_*) */
- };
- typedef struct asn1_data_node_st asn1_data_node_st;
-
- /***********************************/
- /* Fixed constants */
- /***********************************/
-
-
- /* maximum number of characters */
- /* of a description message */
- /* (null character included) */
-#define ASN1_MAX_ERROR_DESCRIPTION_SIZE 128
-
- /***********************************/
- /* Functions definitions */
- /***********************************/
-
- extern ASN1_API int
- asn1_parser2tree (const char *file,
- asn1_node * definitions, char *error_desc);
-
- extern ASN1_API int
- asn1_parser2array (const char *inputFileName,
- const char *outputFileName,
- const char *vectorName, char *error_desc);
-
- extern ASN1_API int
- asn1_array2tree (const asn1_static_node * array,
- asn1_node * definitions, char *errorDescription);
-
- extern ASN1_API void
- asn1_print_structure (FILE * out, asn1_node structure,
- const char *name, int mode);
-
- extern ASN1_API int
- asn1_create_element (asn1_node definitions,
- const char *source_name, asn1_node * element);
-
- extern ASN1_API int asn1_delete_structure (asn1_node * structure);
-
- extern ASN1_API int asn1_delete_structure2 (asn1_node * structure, unsigned int flags);
-
- extern ASN1_API int
- asn1_delete_element (asn1_node structure, const char *element_name);
-
- extern ASN1_API int
- asn1_write_value (asn1_node node_root, const char *name,
- const void *ivalue, int len);
-
- extern ASN1_API int
- asn1_read_value (asn1_node root, const char *name,
- void *ivalue, int *len);
-
- extern ASN1_API int
- asn1_read_value_type (asn1_node root, const char *name,
- void *ivalue, int *len, unsigned int *etype);
-
- extern ASN1_API int
- asn1_read_node_value (asn1_node node, asn1_data_node_st * data);
-
- extern ASN1_API int
- asn1_number_of_elements (asn1_node element, const char *name, int *num);
-
- extern ASN1_API int
- asn1_der_coding (asn1_node element, const char *name,
- void *ider, int *len, char *ErrorDescription);
-
- extern ASN1_API int
- asn1_der_decoding2 (asn1_node *element, const void *ider,
- int *max_ider_len, unsigned int flags,
- char *errorDescription);
-
- extern ASN1_API int
- asn1_der_decoding (asn1_node * element, const void *ider,
- int len, char *errorDescription);
-
- /* Do not use. Use asn1_der_decoding() instead. */
- extern ASN1_API int
- asn1_der_decoding_element (asn1_node * structure,
- const char *elementName,
- const void *ider, int len,
- char *errorDescription) _ASN1_GCC_ATTR_DEPRECATED;
-
- extern ASN1_API int
- asn1_der_decoding_startEnd (asn1_node element,
- const void *ider, int len,
- const char *name_element,
- int *start, int *end);
-
- extern ASN1_API int
- asn1_expand_any_defined_by (asn1_node definitions, asn1_node * element);
-
- extern ASN1_API int
- asn1_expand_octet_string (asn1_node definitions,
- asn1_node * element,
- const char *octetName, const char *objectName);
-
- extern ASN1_API int
- asn1_read_tag (asn1_node root, const char *name,
- int *tagValue, int *classValue);
-
- extern ASN1_API const char *asn1_find_structure_from_oid (asn1_node
- definitions,
- const char
- *oidValue);
-
- extern ASN1_API const char *asn1_check_version (const char *req_version);
-
- extern ASN1_API const char *asn1_strerror (int error);
-
- extern ASN1_API void asn1_perror (int error);
-
-#define ASN1_MAX_TAG_SIZE 4
-#define ASN1_MAX_LENGTH_SIZE 9
-#define ASN1_MAX_TL_SIZE (ASN1_MAX_TAG_SIZE+ASN1_MAX_LENGTH_SIZE)
- extern ASN1_API long
- asn1_get_length_der (const unsigned char *der, int der_len, int *len);
-
- extern ASN1_API long
- asn1_get_length_ber (const unsigned char *ber, int ber_len, int *len);
-
- extern ASN1_API void
- asn1_length_der (unsigned long int len, unsigned char *der, int *der_len);
-
- /* Other utility functions. */
-
- extern ASN1_API
- int asn1_decode_simple_der (unsigned int etype, const unsigned char *der,
- unsigned int der_len,
- const unsigned char **str,
- unsigned int *str_len);
-
- extern ASN1_API
- int asn1_decode_simple_ber (unsigned int etype, const unsigned char *der,
- unsigned int der_len,
- unsigned char **str,
- unsigned int *str_len,
- unsigned int *ber_len);
-
- extern ASN1_API int
- asn1_encode_simple_der (unsigned int etype, const unsigned char *str,
- unsigned int str_len, unsigned char *tl,
- unsigned int *tl_len);
-
- extern ASN1_API asn1_node
- asn1_find_node (asn1_node pointer, const char *name);
-
- extern ASN1_API int
- asn1_copy_node (asn1_node dst, const char *dst_name,
- asn1_node src, const char *src_name);
- extern ASN1_API asn1_node
- asn1_dup_node (asn1_node src, const char *src_name);
-
- /* Internal and low-level DER utility functions. */
-
- extern ASN1_API int
- asn1_get_tag_der (const unsigned char *der, int der_len,
- unsigned char *cls, int *len, unsigned long *tag);
-
- extern ASN1_API void
- asn1_octet_der (const unsigned char *str, int str_len,
- unsigned char *der, int *der_len);
-
- extern ASN1_API int
- asn1_get_octet_der (const unsigned char *der, int der_len,
- int *ret_len, unsigned char *str,
- int str_size, int *str_len);
-
- extern ASN1_API void asn1_bit_der (const unsigned char *str, int bit_len,
- unsigned char *der, int *der_len);
-
- extern ASN1_API int
- asn1_get_bit_der (const unsigned char *der, int der_len,
- int *ret_len, unsigned char *str,
- int str_size, int *bit_len);
-
- extern ASN1_API int
- asn1_get_object_id_der (const unsigned char *der,
- int der_len, int *ret_len,
- char *str, int str_size);
-
-/* Compatibility types */
-
- typedef int asn1_retCode; /* type returned by libtasn1 functions */
-
-#define node_asn_struct asn1_node_st
-#define node_asn asn1_node_st
-#define ASN1_TYPE asn1_node
-#define ASN1_TYPE_EMPTY NULL
-
-#define static_struct_asn asn1_static_node_st
-#define ASN1_ARRAY_TYPE asn1_static_node
-#define asn1_static_node_t asn1_static_node
-
-#define node_data_struct asn1_data_node_st
-#define ASN1_DATA_NODE asn1_data_node_st
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LIBTASN1_H */
diff --git a/lib/libtasn1.map b/lib/libtasn1.map
deleted file mode 100644
index 007925c..0000000
--- a/lib/libtasn1.map
+++ /dev/null
@@ -1,63 +0,0 @@
-# Copyright (C) 2009-2014 Free Software Foundation, Inc.
-#
-# This file is part of LIBTASN1.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program 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 General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-LIBTASN1_0_3
-{
- global:
- asn1_array2tree;
- asn1_bit_der;
- asn1_check_version;
- asn1_copy_node;
- asn1_create_element;
- asn1_delete_element;
- asn1_delete_structure;
- asn1_der_coding;
- asn1_der_decoding2;
- asn1_der_decoding;
- asn1_der_decoding_element;
- asn1_der_decoding_startEnd;
- asn1_expand_any_defined_by;
- asn1_expand_octet_string;
- asn1_find_node;
- asn1_find_structure_from_oid;
- asn1_get_bit_der;
- asn1_get_length_ber;
- asn1_get_length_der;
- asn1_get_octet_der;
- asn1_get_tag_der;
- asn1_length_der;
- asn1_number_of_elements;
- asn1_octet_der;
- asn1_parser2array;
- asn1_parser2tree;
- asn1_perror;
- asn1_print_structure;
- asn1_read_tag;
- asn1_read_value;
- asn1_strerror;
- asn1_write_value;
- asn1_read_node_value;
- asn1_encode_simple_der;
- asn1_decode_simple_der;
- asn1_read_value_type;
- asn1_delete_structure2;
- asn1_dup_node;
- asn1_decode_simple_ber;
- asn1_get_object_id_der;
- local:
- *;
-};
diff --git a/lib/libtasn1.pc.in b/lib/libtasn1.pc.in
deleted file mode 100644
index 41e7584..0000000
--- a/lib/libtasn1.pc.in
+++ /dev/null
@@ -1,30 +0,0 @@
-# Copyright (C) 2005-2014 Free Software Foundation, Inc.
-#
-# This file is part of LIBTASN1.
-#
-# The LIBTASN1 library 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 library 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 library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301, USA
-
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: libtasn1
-Description: Library for ASN.1 and DER manipulation
-URL: http://www.gnu.org/software/libtasn1/
-Version: @VERSION@
-Libs: -L${libdir} -ltasn1
-Cflags: -I${includedir}
diff --git a/lib/parser_aux.c b/lib/parser_aux.c
deleted file mode 100644
index 786ea64..0000000
--- a/lib/parser_aux.c
+++ /dev/null
@@ -1,1097 +0,0 @@
-/*
- * Copyright (C) 2000-2016 Free Software Foundation, Inc.
- *
- * This file is part of LIBTASN1.
- *
- * The LIBTASN1 library 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 library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- */
-
-#include <int.h>
-#include <hash-pjw-bare.h>
-#include "parser_aux.h"
-#include "gstr.h"
-#include "structure.h"
-#include "element.h"
-
-char _asn1_identifierMissing[ASN1_MAX_NAME_SIZE + 1]; /* identifier name not found */
-
-/***********************************************/
-/* Type: list_type */
-/* Description: type used in the list during */
-/* the structure creation. */
-/***********************************************/
-typedef struct list_struct
-{
- asn1_node node;
- struct list_struct *next;
-} list_type;
-
-
-/* Pointer to the first element of the list */
-list_type *firstElement = NULL;
-
-/******************************************************/
-/* Function : _asn1_add_static_node */
-/* Description: creates a new NODE_ASN element and */
-/* puts it in the list pointed by firstElement. */
-/* Parameters: */
-/* type: type of the new element (see ASN1_ETYPE_ */
-/* and CONST_ constants). */
-/* Return: pointer to the new element. */
-/******************************************************/
-asn1_node
-_asn1_add_static_node (unsigned int type)
-{
- list_type *listElement;
- asn1_node punt;
-
- punt = calloc (1, sizeof (struct asn1_node_st));
- if (punt == NULL)
- return NULL;
-
- listElement = malloc (sizeof (list_type));
- if (listElement == NULL)
- {
- free (punt);
- return NULL;
- }
-
- listElement->node = punt;
- listElement->next = firstElement;
- firstElement = listElement;
-
- punt->type = type;
-
- return punt;
-}
-
-/**
- * asn1_find_node:
- * @pointer: NODE_ASN element pointer.
- * @name: null terminated string with the element's name to find.
- *
- * Searches for an element called @name starting from @pointer. The
- * name is composed by different identifiers separated by dots. When
- * *@pointer has a name, the first identifier must be the name of
- * *@pointer, otherwise it must be the name of one child of *@pointer.
- *
- * Returns: the search result, or %NULL if not found.
- **/
-asn1_node
-asn1_find_node (asn1_node pointer, const char *name)
-{
- asn1_node p;
- char *n_end, n[ASN1_MAX_NAME_SIZE + 1];
- const char *n_start;
- unsigned int nsize;
- unsigned int nhash;
-
- if (pointer == NULL)
- return NULL;
-
- if (name == NULL)
- return NULL;
-
- p = pointer;
- n_start = name;
-
- if (name[0] == '?' && name[1] == 'C' && p->name[0] == '?')
- { /* ?CURRENT */
- n_start = strchr(n_start, '.');
- if (n_start)
- n_start++;
- }
- else if (p->name[0] != 0)
- { /* has *pointer got a name ? */
- n_end = strchr (n_start, '.'); /* search the first dot */
- if (n_end)
- {
- nsize = n_end - n_start;
- if (nsize >= sizeof(n))
- return NULL;
-
- memcpy (n, n_start, nsize);
- n[nsize] = 0;
- n_start = n_end;
- n_start++;
-
- nhash = hash_pjw_bare (n, nsize);
- }
- else
- {
- nsize = _asn1_str_cpy (n, sizeof (n), n_start);
- nhash = hash_pjw_bare (n, nsize);
-
- n_start = NULL;
- }
-
- while (p)
- {
- if (nhash == p->name_hash && (!strcmp (p->name, n)))
- break;
- else
- p = p->right;
- } /* while */
-
- if (p == NULL)
- return NULL;
- }
- else
- { /* *pointer doesn't have a name */
- if (n_start[0] == 0)
- return p;
- }
-
- while (n_start)
- { /* Has the end of NAME been reached? */
- n_end = strchr (n_start, '.'); /* search the next dot */
- if (n_end)
- {
- nsize = n_end - n_start;
- if (nsize >= sizeof(n))
- return NULL;
-
- memcpy (n, n_start, nsize);
- n[nsize] = 0;
- n_start = n_end;
- n_start++;
-
- nhash = hash_pjw_bare (n, nsize);
- }
- else
- {
- nsize = _asn1_str_cpy (n, sizeof (n), n_start);
- nhash = hash_pjw_bare (n, nsize);
- n_start = NULL;
- }
-
- if (p->down == NULL)
- return NULL;
-
- p = p->down;
- if (p == NULL)
- return NULL;
-
- /* The identifier "?LAST" indicates the last element
- in the right chain. */
- if (n[0] == '?' && n[1] == 'L') /* ?LAST */
- {
- while (p->right)
- p = p->right;
- }
- else
- { /* no "?LAST" */
- while (p)
- {
- if (p->name_hash == nhash && !strcmp (p->name, n))
- break;
- else
- p = p->right;
- }
- }
- if (p == NULL)
- return NULL;
- } /* while */
-
- return p;
-}
-
-
-/******************************************************************/
-/* Function : _asn1_set_value */
-/* Description: sets the field VALUE in a NODE_ASN element. The */
-/* previous value (if exist) will be lost */
-/* Parameters: */
-/* node: element pointer. */
-/* value: pointer to the value that you want to set. */
-/* len: character number of value. */
-/* Return: pointer to the NODE_ASN element. */
-/******************************************************************/
-asn1_node
-_asn1_set_value (asn1_node node, const void *value, unsigned int len)
-{
- if (node == NULL)
- return node;
- if (node->value)
- {
- if (node->value != node->small_value)
- free (node->value);
- node->value = NULL;
- node->value_len = 0;
- }
-
- if (!len)
- return node;
-
- if (len < sizeof (node->small_value))
- {
- node->value = node->small_value;
- }
- else
- {
- node->value = malloc (len);
- if (node->value == NULL)
- return NULL;
- }
- node->value_len = len;
-
- memcpy (node->value, value, len);
- return node;
-}
-
-/******************************************************************/
-/* Function : _asn1_set_value_lv */
-/* Description: sets the field VALUE in a NODE_ASN element. The */
-/* previous value (if exist) will be lost. The value */
-/* given is stored as an length-value format (LV */
-/* Parameters: */
-/* node: element pointer. */
-/* value: pointer to the value that you want to set. */
-/* len: character number of value. */
-/* Return: pointer to the NODE_ASN element. */
-/******************************************************************/
-asn1_node
-_asn1_set_value_lv (asn1_node node, const void *value, unsigned int len)
-{
- int len2;
- void *temp;
-
- if (node == NULL)
- return node;
-
- asn1_length_der (len, NULL, &len2);
- temp = malloc (len + len2);
- if (temp == NULL)
- return NULL;
-
- asn1_octet_der (value, len, temp, &len2);
- return _asn1_set_value_m (node, temp, len2);
-}
-
-/* the same as _asn1_set_value except that it sets an already malloc'ed
- * value.
- */
-asn1_node
-_asn1_set_value_m (asn1_node node, void *value, unsigned int len)
-{
- if (node == NULL)
- return node;
-
- if (node->value)
- {
- if (node->value != node->small_value)
- free (node->value);
- node->value = NULL;
- node->value_len = 0;
- }
-
- if (!len)
- return node;
-
- node->value = value;
- node->value_len = len;
-
- return node;
-}
-
-/******************************************************************/
-/* Function : _asn1_append_value */
-/* Description: appends to the field VALUE in a NODE_ASN element. */
-/* */
-/* Parameters: */
-/* node: element pointer. */
-/* value: pointer to the value that you want to be appended. */
-/* len: character number of value. */
-/* Return: pointer to the NODE_ASN element. */
-/******************************************************************/
-asn1_node
-_asn1_append_value (asn1_node node, const void *value, unsigned int len)
-{
- if (node == NULL)
- return node;
-
- if (node->value == NULL)
- return _asn1_set_value (node, value, len);
-
- if (len == 0)
- return node;
-
- if (node->value == node->small_value)
- {
- /* value is in node */
- int prev_len = node->value_len;
- node->value_len += len;
- node->value = malloc (node->value_len);
- if (node->value == NULL)
- {
- node->value_len = 0;
- return NULL;
- }
-
- if (prev_len > 0)
- memcpy (node->value, node->small_value, prev_len);
-
- memcpy (&node->value[prev_len], value, len);
-
- return node;
- }
- else /* if (node->value != NULL && node->value != node->small_value) */
- {
- /* value is allocated */
- int prev_len = node->value_len;
- node->value_len += len;
-
- node->value = _asn1_realloc (node->value, node->value_len);
- if (node->value == NULL)
- {
- node->value_len = 0;
- return NULL;
- }
-
- memcpy (&node->value[prev_len], value, len);
-
- return node;
- }
-}
-
-/******************************************************************/
-/* Function : _asn1_set_name */
-/* Description: sets the field NAME in a NODE_ASN element. The */
-/* previous value (if exist) will be lost */
-/* Parameters: */
-/* node: element pointer. */
-/* name: a null terminated string with the name that you want */
-/* to set. */
-/* Return: pointer to the NODE_ASN element. */
-/******************************************************************/
-asn1_node
-_asn1_set_name (asn1_node node, const char *name)
-{
- unsigned int nsize;
-
- if (node == NULL)
- return node;
-
- if (name == NULL)
- {
- node->name[0] = 0;
- node->name_hash = hash_pjw_bare (node->name, 0);
- return node;
- }
-
- nsize = _asn1_str_cpy (node->name, sizeof (node->name), name);
- node->name_hash = hash_pjw_bare (node->name, nsize);
-
- return node;
-}
-
-/******************************************************************/
-/* Function : _asn1_cpy_name */
-/* Description: copies the field NAME in a NODE_ASN element. */
-/* Parameters: */
-/* dst: a dest element pointer. */
-/* src: a source element pointer. */
-/* Return: pointer to the NODE_ASN element. */
-/******************************************************************/
-asn1_node
-_asn1_cpy_name (asn1_node dst, asn1_node src)
-{
- if (dst == NULL)
- return dst;
-
- if (src == NULL)
- {
- dst->name[0] = 0;
- dst->name_hash = hash_pjw_bare (dst->name, 0);
- return dst;
- }
-
- _asn1_str_cpy (dst->name, sizeof (dst->name), src->name);
- dst->name_hash = src->name_hash;
-
- return dst;
-}
-
-/******************************************************************/
-/* Function : _asn1_set_right */
-/* Description: sets the field RIGHT in a NODE_ASN element. */
-/* Parameters: */
-/* node: element pointer. */
-/* right: pointer to a NODE_ASN element that you want be pointed*/
-/* by NODE. */
-/* Return: pointer to *NODE. */
-/******************************************************************/
-asn1_node
-_asn1_set_right (asn1_node node, asn1_node right)
-{
- if (node == NULL)
- return node;
- node->right = right;
- if (right)
- right->left = node;
- return node;
-}
-
-
-/******************************************************************/
-/* Function : _asn1_get_last_right */
-/* Description: return the last element along the right chain. */
-/* Parameters: */
-/* node: starting element pointer. */
-/* Return: pointer to the last element along the right chain. */
-/******************************************************************/
-asn1_node
-_asn1_get_last_right (asn1_node node)
-{
- asn1_node p;
-
- if (node == NULL)
- return NULL;
- p = node;
- while (p->right)
- p = p->right;
- return p;
-}
-
-/******************************************************************/
-/* Function : _asn1_remove_node */
-/* Description: gets free the memory allocated for an NODE_ASN */
-/* element (not the elements pointed by it). */
-/* Parameters: */
-/* node: NODE_ASN element pointer. */
-/* flags: ASN1_DELETE_FLAG_* */
-/******************************************************************/
-void
-_asn1_remove_node (asn1_node node, unsigned int flags)
-{
- if (node == NULL)
- return;
-
- if (node->value != NULL)
- {
- if (flags & ASN1_DELETE_FLAG_ZEROIZE)
- {
- safe_memset(node->value, 0, node->value_len);
- }
-
- if (node->value != node->small_value)
- free (node->value);
- }
- free (node);
-}
-
-/******************************************************************/
-/* Function : _asn1_find_up */
-/* Description: return the father of the NODE_ASN element. */
-/* Parameters: */
-/* node: NODE_ASN element pointer. */
-/* Return: Null if not found. */
-/******************************************************************/
-asn1_node
-_asn1_find_up (asn1_node node)
-{
- asn1_node p;
-
- if (node == NULL)
- return NULL;
-
- p = node;
-
- while ((p->left != NULL) && (p->left->right == p))
- p = p->left;
-
- return p->left;
-}
-
-/******************************************************************/
-/* Function : _asn1_delete_list */
-/* Description: deletes the list elements (not the elements */
-/* pointed by them). */
-/******************************************************************/
-void
-_asn1_delete_list (void)
-{
- list_type *listElement;
-
- while (firstElement)
- {
- listElement = firstElement;
- firstElement = firstElement->next;
- free (listElement);
- }
-}
-
-/******************************************************************/
-/* Function : _asn1_delete_list_and nodes */
-/* Description: deletes the list elements and the elements */
-/* pointed by them. */
-/******************************************************************/
-void
-_asn1_delete_list_and_nodes (void)
-{
- list_type *listElement;
-
- while (firstElement)
- {
- listElement = firstElement;
- firstElement = firstElement->next;
- _asn1_remove_node (listElement->node, 0);
- free (listElement);
- }
-}
-
-
-char *
-_asn1_ltostr (int64_t v, char str[LTOSTR_MAX_SIZE])
-{
- uint64_t d, r;
- char temp[LTOSTR_MAX_SIZE];
- int count, k, start;
- uint64_t val;
-
- if (v < 0)
- {
- str[0] = '-';
- start = 1;
- val = -((uint64_t)v);
- }
- else
- {
- val = v;
- start = 0;
- }
-
- count = 0;
- do
- {
- d = val / 10;
- r = val - d * 10;
- temp[start + count] = '0' + (char) r;
- count++;
- val = d;
- }
- while (val && ((start+count) < LTOSTR_MAX_SIZE-1));
-
- for (k = 0; k < count; k++)
- str[k + start] = temp[start + count - k - 1];
- str[count + start] = 0;
- return str;
-}
-
-
-/******************************************************************/
-/* Function : _asn1_change_integer_value */
-/* Description: converts into DER coding the value assign to an */
-/* INTEGER constant. */
-/* Parameters: */
-/* node: root of an ASN1element. */
-/* Return: */
-/* ASN1_ELEMENT_NOT_FOUND if NODE is NULL, */
-/* otherwise ASN1_SUCCESS */
-/******************************************************************/
-int
-_asn1_change_integer_value (asn1_node node)
-{
- asn1_node p;
- unsigned char val[SIZEOF_UNSIGNED_LONG_INT];
- unsigned char val2[SIZEOF_UNSIGNED_LONG_INT + 1];
- int len;
-
- if (node == NULL)
- return ASN1_ELEMENT_NOT_FOUND;
-
- p = node;
- while (p)
- {
- if ((type_field (p->type) == ASN1_ETYPE_INTEGER)
- && (p->type & CONST_ASSIGN))
- {
- if (p->value)
- {
- _asn1_convert_integer (p->value, val, sizeof (val), &len);
- asn1_octet_der (val, len, val2, &len);
- _asn1_set_value (p, val2, len);
- }
- }
-
- if (p->down)
- {
- p = p->down;
- }
- else
- {
- if (p == node)
- p = NULL;
- else if (p->right)
- p = p->right;
- else
- {
- while (1)
- {
- p = _asn1_find_up (p);
- if (p == node)
- {
- p = NULL;
- break;
- }
- if (p && p->right)
- {
- p = p->right;
- break;
- }
- }
- }
- }
- }
-
- return ASN1_SUCCESS;
-}
-
-
-/******************************************************************/
-/* Function : _asn1_expand_object_id */
-/* Description: expand the IDs of an OBJECT IDENTIFIER constant. */
-/* Parameters: */
-/* node: root of an ASN1 element. */
-/* Return: */
-/* ASN1_ELEMENT_NOT_FOUND if NODE is NULL, */
-/* otherwise ASN1_SUCCESS */
-/******************************************************************/
-int
-_asn1_expand_object_id (asn1_node node)
-{
- asn1_node p, p2, p3, p4, p5;
- char name_root[ASN1_MAX_NAME_SIZE], name2[2 * ASN1_MAX_NAME_SIZE + 1];
- int move, tlen;
-
- if (node == NULL)
- return ASN1_ELEMENT_NOT_FOUND;
-
- _asn1_str_cpy (name_root, sizeof (name_root), node->name);
-
- p = node;
- move = DOWN;
-
- while (!((p == node) && (move == UP)))
- {
- if (move != UP)
- {
- if ((type_field (p->type) == ASN1_ETYPE_OBJECT_ID)
- && (p->type & CONST_ASSIGN))
- {
- p2 = p->down;
- if (p2 && (type_field (p2->type) == ASN1_ETYPE_CONSTANT))
- {
- if (p2->value && !isdigit (p2->value[0]))
- {
- _asn1_str_cpy (name2, sizeof (name2), name_root);
- _asn1_str_cat (name2, sizeof (name2), ".");
- _asn1_str_cat (name2, sizeof (name2),
- (char *) p2->value);
- p3 = asn1_find_node (node, name2);
- if (!p3
- || (type_field (p3->type) != ASN1_ETYPE_OBJECT_ID)
- || !(p3->type & CONST_ASSIGN))
- return ASN1_ELEMENT_NOT_FOUND;
- _asn1_set_down (p, p2->right);
- _asn1_remove_node (p2, 0);
- p2 = p;
- p4 = p3->down;
- while (p4)
- {
- if (type_field (p4->type) == ASN1_ETYPE_CONSTANT)
- {
- p5 =
- _asn1_add_single_node (ASN1_ETYPE_CONSTANT);
- _asn1_set_name (p5, p4->name);
- if (p4->value)
- {
- tlen = _asn1_strlen (p4->value);
- if (tlen > 0)
- _asn1_set_value (p5, p4->value, tlen + 1);
- }
- if (p2 == p)
- {
- _asn1_set_right (p5, p->down);
- _asn1_set_down (p, p5);
- }
- else
- {
- _asn1_set_right (p5, p2->right);
- _asn1_set_right (p2, p5);
- }
- p2 = p5;
- }
- p4 = p4->right;
- }
- move = DOWN;
- continue;
- }
- }
- }
- move = DOWN;
- }
- else
- move = RIGHT;
-
- if (move == DOWN)
- {
- if (p->down)
- p = p->down;
- else
- move = RIGHT;
- }
-
- if (p == node)
- {
- move = UP;
- continue;
- }
-
- if (move == RIGHT)
- {
- if (p && p->right)
- p = p->right;
- else
- move = UP;
- }
- if (move == UP)
- p = _asn1_find_up (p);
- }
-
-
- /*******************************/
- /* expand DEFAULT */
- /*******************************/
- p = node;
- move = DOWN;
-
- while (!((p == node) && (move == UP)))
- {
- if (move != UP)
- {
- if ((type_field (p->type) == ASN1_ETYPE_OBJECT_ID) &&
- (p->type & CONST_DEFAULT))
- {
- p2 = p->down;
- if (p2 && (type_field (p2->type) == ASN1_ETYPE_DEFAULT))
- {
- _asn1_str_cpy (name2, sizeof (name2), name_root);
- _asn1_str_cat (name2, sizeof (name2), ".");
- _asn1_str_cat (name2, sizeof (name2), (char *) p2->value);
- p3 = asn1_find_node (node, name2);
- if (!p3 || (type_field (p3->type) != ASN1_ETYPE_OBJECT_ID)
- || !(p3->type & CONST_ASSIGN))
- return ASN1_ELEMENT_NOT_FOUND;
- p4 = p3->down;
- name2[0] = 0;
- while (p4)
- {
- if (type_field (p4->type) == ASN1_ETYPE_CONSTANT)
- {
- if (p4->value == NULL)
- return ASN1_VALUE_NOT_FOUND;
-
- if (name2[0])
- _asn1_str_cat (name2, sizeof (name2), ".");
- _asn1_str_cat (name2, sizeof (name2),
- (char *) p4->value);
- }
- p4 = p4->right;
- }
- tlen = strlen (name2);
- if (tlen > 0)
- _asn1_set_value (p2, name2, tlen + 1);
- }
- }
- move = DOWN;
- }
- else
- move = RIGHT;
-
- if (move == DOWN)
- {
- if (p->down)
- p = p->down;
- else
- move = RIGHT;
- }
-
- if (p == node)
- {
- move = UP;
- continue;
- }
-
- if (move == RIGHT)
- {
- if (p && p->right)
- p = p->right;
- else
- move = UP;
- }
- if (move == UP)
- p = _asn1_find_up (p);
- }
-
- return ASN1_SUCCESS;
-}
-
-
-/******************************************************************/
-/* Function : _asn1_type_set_config */
-/* Description: sets the CONST_SET and CONST_NOT_USED properties */
-/* in the fields of the SET elements. */
-/* Parameters: */
-/* node: root of an ASN1 element. */
-/* Return: */
-/* ASN1_ELEMENT_NOT_FOUND if NODE is NULL, */
-/* otherwise ASN1_SUCCESS */
-/******************************************************************/
-int
-_asn1_type_set_config (asn1_node node)
-{
- asn1_node p, p2;
- int move;
-
- if (node == NULL)
- return ASN1_ELEMENT_NOT_FOUND;
-
- p = node;
- move = DOWN;
-
- while (!((p == node) && (move == UP)))
- {
- if (move != UP)
- {
- if (type_field (p->type) == ASN1_ETYPE_SET)
- {
- p2 = p->down;
- while (p2)
- {
- if (type_field (p2->type) != ASN1_ETYPE_TAG)
- p2->type |= CONST_SET | CONST_NOT_USED;
- p2 = p2->right;
- }
- }
- move = DOWN;
- }
- else
- move = RIGHT;
-
- if (move == DOWN)
- {
- if (p->down)
- p = p->down;
- else
- move = RIGHT;
- }
-
- if (p == node)
- {
- move = UP;
- continue;
- }
-
- if (move == RIGHT)
- {
- if (p && p->right)
- p = p->right;
- else
- move = UP;
- }
- if (move == UP)
- p = _asn1_find_up (p);
- }
-
- return ASN1_SUCCESS;
-}
-
-
-/******************************************************************/
-/* Function : _asn1_check_identifier */
-/* Description: checks the definitions of all the identifiers */
-/* and the first element of an OBJECT_ID (e.g. {pkix 0 4}). */
-/* The _asn1_identifierMissing global variable is filled if */
-/* necessary. */
-/* Parameters: */
-/* node: root of an ASN1 element. */
-/* Return: */
-/* ASN1_ELEMENT_NOT_FOUND if NODE is NULL, */
-/* ASN1_IDENTIFIER_NOT_FOUND if an identifier is not defined, */
-/* otherwise ASN1_SUCCESS */
-/******************************************************************/
-int
-_asn1_check_identifier (asn1_node node)
-{
- asn1_node p, p2;
- char name2[ASN1_MAX_NAME_SIZE * 2 + 2];
-
- if (node == NULL)
- return ASN1_ELEMENT_NOT_FOUND;
-
- p = node;
- while (p)
- {
- if (p->value && type_field (p->type) == ASN1_ETYPE_IDENTIFIER)
- {
- _asn1_str_cpy (name2, sizeof (name2), node->name);
- _asn1_str_cat (name2, sizeof (name2), ".");
- _asn1_str_cat (name2, sizeof (name2), (char *) p->value);
- p2 = asn1_find_node (node, name2);
- if (p2 == NULL)
- {
- if (p->value)
- _asn1_str_cpy (_asn1_identifierMissing, sizeof(_asn1_identifierMissing), (char*)p->value);
- else
- _asn1_strcpy (_asn1_identifierMissing, "(null)");
- return ASN1_IDENTIFIER_NOT_FOUND;
- }
- }
- else if ((type_field (p->type) == ASN1_ETYPE_OBJECT_ID) &&
- (p->type & CONST_DEFAULT))
- {
- p2 = p->down;
- if (p2 && (type_field (p2->type) == ASN1_ETYPE_DEFAULT))
- {
- _asn1_str_cpy (name2, sizeof (name2), node->name);
- if (p2->value)
- {
- _asn1_str_cat (name2, sizeof (name2), ".");
- _asn1_str_cat (name2, sizeof (name2), (char *) p2->value);
- _asn1_str_cpy (_asn1_identifierMissing, sizeof(_asn1_identifierMissing), (char*)p2->value);
- }
- else
- _asn1_strcpy (_asn1_identifierMissing, "(null)");
-
- p2 = asn1_find_node (node, name2);
- if (!p2 || (type_field (p2->type) != ASN1_ETYPE_OBJECT_ID) ||
- !(p2->type & CONST_ASSIGN))
- return ASN1_IDENTIFIER_NOT_FOUND;
- else
- _asn1_identifierMissing[0] = 0;
- }
- }
- else if ((type_field (p->type) == ASN1_ETYPE_OBJECT_ID) &&
- (p->type & CONST_ASSIGN))
- {
- p2 = p->down;
- if (p2 && (type_field (p2->type) == ASN1_ETYPE_CONSTANT))
- {
- if (p2->value && !isdigit (p2->value[0]))
- {
- _asn1_str_cpy (name2, sizeof (name2), node->name);
- _asn1_str_cat (name2, sizeof (name2), ".");
- _asn1_str_cat (name2, sizeof (name2), (char *) p2->value);
- _asn1_str_cpy (_asn1_identifierMissing, sizeof(_asn1_identifierMissing), (char*)p2->value);
-
- p2 = asn1_find_node (node, name2);
- if (!p2 || (type_field (p2->type) != ASN1_ETYPE_OBJECT_ID)
- || !(p2->type & CONST_ASSIGN))
- return ASN1_IDENTIFIER_NOT_FOUND;
- else
- _asn1_identifierMissing[0] = 0;
- }
- }
- }
-
- if (p->down)
- {
- p = p->down;
- }
- else if (p->right)
- p = p->right;
- else
- {
- while (1)
- {
- p = _asn1_find_up (p);
- if (p == node)
- {
- p = NULL;
- break;
- }
- if (p && p->right)
- {
- p = p->right;
- break;
- }
- }
- }
- }
-
- return ASN1_SUCCESS;
-}
-
-
-/******************************************************************/
-/* Function : _asn1_set_default_tag */
-/* Description: sets the default IMPLICIT or EXPLICIT property in */
-/* the tagged elements that don't have this declaration. */
-/* Parameters: */
-/* node: pointer to a DEFINITIONS element. */
-/* Return: */
-/* ASN1_ELEMENT_NOT_FOUND if NODE is NULL or not a pointer to */
-/* a DEFINITIONS element, */
-/* otherwise ASN1_SUCCESS */
-/******************************************************************/
-int
-_asn1_set_default_tag (asn1_node node)
-{
- asn1_node p;
-
- if ((node == NULL) || (type_field (node->type) != ASN1_ETYPE_DEFINITIONS))
- return ASN1_ELEMENT_NOT_FOUND;
-
- p = node;
- while (p)
- {
- if ((type_field (p->type) == ASN1_ETYPE_TAG) &&
- !(p->type & CONST_EXPLICIT) && !(p->type & CONST_IMPLICIT))
- {
- if (node->type & CONST_EXPLICIT)
- p->type |= CONST_EXPLICIT;
- else
- p->type |= CONST_IMPLICIT;
- }
-
- if (p->down)
- {
- p = p->down;
- }
- else if (p->right)
- p = p->right;
- else
- {
- while (1)
- {
- p = _asn1_find_up (p);
- if (p == node)
- {
- p = NULL;
- break;
- }
- if (p && p->right)
- {
- p = p->right;
- break;
- }
- }
- }
- }
-
- return ASN1_SUCCESS;
-}
diff --git a/lib/parser_aux.h b/lib/parser_aux.h
deleted file mode 100644
index 9f91833..0000000
--- a/lib/parser_aux.h
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Copyright (C) 2000-2014 Free Software Foundation, Inc.
- *
- * This file is part of LIBTASN1.
- *
- * The LIBTASN1 library 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 library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- */
-
-#ifndef _PARSER_AUX_H
-#define _PARSER_AUX_H
-
-/***************************************/
-/* Functions used by ASN.1 parser */
-/***************************************/
-asn1_node _asn1_add_static_node (unsigned int type);
-
-asn1_node
-_asn1_set_value (asn1_node node, const void *value, unsigned int len);
-
-asn1_node _asn1_set_value_m (asn1_node node, void *value, unsigned int len);
-
-asn1_node
-_asn1_set_value_lv (asn1_node node, const void *value, unsigned int len);
-
-asn1_node
-_asn1_append_value (asn1_node node, const void *value, unsigned int len);
-
-asn1_node _asn1_set_name (asn1_node node, const char *name);
-
-asn1_node _asn1_cpy_name (asn1_node dst, asn1_node src);
-
-asn1_node _asn1_set_right (asn1_node node, asn1_node right);
-
-asn1_node _asn1_get_last_right (asn1_node node);
-
-void _asn1_remove_node (asn1_node node, unsigned int flags);
-
-void _asn1_delete_list (void);
-
-void _asn1_delete_list_and_nodes (void);
-
-/* Max 64-bit integer length is 20 chars + 1 for sign + 1 for null termination */
-#define LTOSTR_MAX_SIZE 22
-char *_asn1_ltostr (int64_t v, char str[LTOSTR_MAX_SIZE]);
-
-asn1_node _asn1_find_up (asn1_node node);
-
-int _asn1_change_integer_value (asn1_node node);
-
-int _asn1_expand_object_id (asn1_node node);
-
-int _asn1_type_set_config (asn1_node node);
-
-int _asn1_check_identifier (asn1_node node);
-
-int _asn1_set_default_tag (asn1_node node);
-
-/******************************************************************/
-/* Function : _asn1_get_right */
-/* Description: returns the element pointed by the RIGHT field of */
-/* a NODE_ASN element. */
-/* Parameters: */
-/* node: NODE_ASN element pointer. */
-/* Return: field RIGHT of NODE. */
-/******************************************************************/
-inline static asn1_node
-_asn1_get_right (asn1_node node)
-{
- if (node == NULL)
- return NULL;
- return node->right;
-}
-
-/******************************************************************/
-/* Function : _asn1_set_down */
-/* Description: sets the field DOWN in a NODE_ASN element. */
-/* Parameters: */
-/* node: element pointer. */
-/* down: pointer to a NODE_ASN element that you want be pointed */
-/* by NODE. */
-/* Return: pointer to *NODE. */
-/******************************************************************/
-inline static asn1_node
-_asn1_set_down (asn1_node node, asn1_node down)
-{
- if (node == NULL)
- return node;
- node->down = down;
- if (down)
- down->left = node;
- return node;
-}
-
-/******************************************************************/
-/* Function : _asn1_get_down */
-/* Description: returns the element pointed by the DOWN field of */
-/* a NODE_ASN element. */
-/* Parameters: */
-/* node: NODE_ASN element pointer. */
-/* Return: field DOWN of NODE. */
-/******************************************************************/
-inline static asn1_node
-_asn1_get_down (asn1_node node)
-{
- if (node == NULL)
- return NULL;
- return node->down;
-}
-
-/******************************************************************/
-/* Function : _asn1_get_name */
-/* Description: returns the name of a NODE_ASN element. */
-/* Parameters: */
-/* node: NODE_ASN element pointer. */
-/* Return: a null terminated string. */
-/******************************************************************/
-inline static char *
-_asn1_get_name (asn1_node node)
-{
- if (node == NULL)
- return NULL;
- return node->name;
-}
-
-/******************************************************************/
-/* Function : _asn1_mod_type */
-/* Description: change the field TYPE of an NODE_ASN element. */
-/* The new value is the old one | (bitwise or) the */
-/* paramener VALUE. */
-/* Parameters: */
-/* node: NODE_ASN element pointer. */
-/* value: the integer value that must be or-ed with the current */
-/* value of field TYPE. */
-/* Return: NODE pointer. */
-/******************************************************************/
-inline static asn1_node
-_asn1_mod_type (asn1_node node, unsigned int value)
-{
- if (node == NULL)
- return node;
- node->type |= value;
- return node;
-}
-
-#endif
diff --git a/lib/structure.c b/lib/structure.c
deleted file mode 100644
index 01715b1..0000000
--- a/lib/structure.c
+++ /dev/null
@@ -1,1197 +0,0 @@
-/*
- * Copyright (C) 2002-2014 Free Software Foundation, Inc.
- *
- * This file is part of LIBTASN1.
- *
- * The LIBTASN1 library 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 library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- */
-
-
-/*****************************************************/
-/* File: structure.c */
-/* Description: Functions to create and delete an */
-/* ASN1 tree. */
-/*****************************************************/
-
-
-#include <int.h>
-#include <structure.h>
-#include "parser_aux.h"
-#include <gstr.h>
-
-
-extern char _asn1_identifierMissing[];
-
-
-/******************************************************/
-/* Function : _asn1_add_single_node */
-/* Description: creates a new NODE_ASN element. */
-/* Parameters: */
-/* type: type of the new element (see ASN1_ETYPE_ */
-/* and CONST_ constants). */
-/* Return: pointer to the new element. */
-/******************************************************/
-asn1_node
-_asn1_add_single_node (unsigned int type)
-{
- asn1_node punt;
-
- punt = calloc (1, sizeof (struct asn1_node_st));
- if (punt == NULL)
- return NULL;
-
- punt->type = type;
-
- return punt;
-}
-
-
-/******************************************************************/
-/* Function : _asn1_find_left */
-/* Description: returns the NODE_ASN element with RIGHT field that*/
-/* points the element NODE. */
-/* Parameters: */
-/* node: NODE_ASN element pointer. */
-/* Return: NULL if not found. */
-/******************************************************************/
-asn1_node
-_asn1_find_left (asn1_node node)
-{
- if ((node == NULL) || (node->left == NULL) || (node->left->down == node))
- return NULL;
-
- return node->left;
-}
-
-
-int
-_asn1_create_static_structure (asn1_node pointer, char *output_file_name,
- char *vector_name)
-{
- FILE *file;
- asn1_node p;
- unsigned long t;
-
- file = fopen (output_file_name, "w");
-
- if (file == NULL)
- return ASN1_FILE_NOT_FOUND;
-
- fprintf (file, "#if HAVE_CONFIG_H\n");
- fprintf (file, "# include \"config.h\"\n");
- fprintf (file, "#endif\n\n");
-
- fprintf (file, "#include <libtasn1.h>\n\n");
-
- fprintf (file, "const asn1_static_node %s[] = {\n", vector_name);
-
- p = pointer;
-
- while (p)
- {
- fprintf (file, " { ");
-
- if (p->name[0] != 0)
- fprintf (file, "\"%s\", ", p->name);
- else
- fprintf (file, "NULL, ");
-
- t = p->type;
- if (p->down)
- t |= CONST_DOWN;
- if (p->right)
- t |= CONST_RIGHT;
-
- fprintf (file, "%lu, ", t);
-
- if (p->value)
- fprintf (file, "\"%s\"},\n", p->value);
- else
- fprintf (file, "NULL },\n");
-
- if (p->down)
- {
- p = p->down;
- }
- else if (p->right)
- {
- p = p->right;
- }
- else
- {
- while (1)
- {
- p = _asn1_find_up (p);
- if (p == pointer)
- {
- p = NULL;
- break;
- }
- if (p->right)
- {
- p = p->right;
- break;
- }
- }
- }
- }
-
- fprintf (file, " { NULL, 0, NULL }\n};\n");
-
- fclose (file);
-
- return ASN1_SUCCESS;
-}
-
-
-/**
- * asn1_array2tree:
- * @array: specify the array that contains ASN.1 declarations
- * @definitions: return the pointer to the structure created by
- * *ARRAY ASN.1 declarations
- * @errorDescription: return the error description.
- *
- * Creates the structures needed to manage the ASN.1 definitions.
- * @array is a vector created by asn1_parser2array().
- *
- * Returns: %ASN1_SUCCESS if structure was created correctly,
- * %ASN1_ELEMENT_NOT_EMPTY if *@definitions not NULL,
- * %ASN1_IDENTIFIER_NOT_FOUND if in the file there is an identifier
- * that is not defined (see @errorDescription for more information),
- * %ASN1_ARRAY_ERROR if the array pointed by @array is wrong.
- **/
-int
-asn1_array2tree (const asn1_static_node * array, asn1_node * definitions,
- char *errorDescription)
-{
- asn1_node p, p_last = NULL;
- unsigned long k;
- int move;
- int result;
- unsigned int type;
-
- if (errorDescription)
- errorDescription[0] = 0;
-
- if (*definitions != NULL)
- return ASN1_ELEMENT_NOT_EMPTY;
-
- move = UP;
-
- k = 0;
- while (array[k].value || array[k].type || array[k].name)
- {
- type = convert_old_type (array[k].type);
-
- p = _asn1_add_static_node (type & (~CONST_DOWN));
- if (array[k].name)
- _asn1_set_name (p, array[k].name);
- if (array[k].value)
- _asn1_set_value (p, array[k].value, strlen (array[k].value) + 1);
-
- if (*definitions == NULL)
- *definitions = p;
-
- if (move == DOWN)
- _asn1_set_down (p_last, p);
- else if (move == RIGHT)
- _asn1_set_right (p_last, p);
-
- p_last = p;
-
- if (type & CONST_DOWN)
- move = DOWN;
- else if (type & CONST_RIGHT)
- move = RIGHT;
- else
- {
- while (1)
- {
- if (p_last == *definitions)
- break;
-
- p_last = _asn1_find_up (p_last);
-
- if (p_last == NULL)
- break;
-
- if (p_last->type & CONST_RIGHT)
- {
- p_last->type &= ~CONST_RIGHT;
- move = RIGHT;
- break;
- }
- } /* while */
- }
- k++;
- } /* while */
-
- if (p_last == *definitions)
- {
- result = _asn1_check_identifier (*definitions);
- if (result == ASN1_SUCCESS)
- {
- _asn1_change_integer_value (*definitions);
- _asn1_expand_object_id (*definitions);
- }
- }
- else
- {
- result = ASN1_ARRAY_ERROR;
- }
-
- if (errorDescription != NULL)
- {
- if (result == ASN1_IDENTIFIER_NOT_FOUND)
- {
- Estrcpy (errorDescription, ":: identifier '");
- Estrcat (errorDescription, _asn1_identifierMissing);
- Estrcat (errorDescription, "' not found");
- }
- else
- errorDescription[0] = 0;
- }
-
- if (result != ASN1_SUCCESS)
- {
- _asn1_delete_list_and_nodes ();
- *definitions = NULL;
- }
- else
- _asn1_delete_list ();
-
- return result;
-}
-
-/**
- * asn1_delete_structure:
- * @structure: pointer to the structure that you want to delete.
- *
- * Deletes the structure *@structure. At the end, *@structure is set
- * to NULL.
- *
- * Returns: %ASN1_SUCCESS if successful, %ASN1_ELEMENT_NOT_FOUND if
- * *@structure was NULL.
- **/
-int
-asn1_delete_structure (asn1_node * structure)
-{
- return asn1_delete_structure2(structure, 0);
-}
-
-/**
- * asn1_delete_structure2:
- * @structure: pointer to the structure that you want to delete.
- * @flags: additional flags (see %ASN1_DELETE_FLAG)
- *
- * Deletes the structure *@structure. At the end, *@structure is set
- * to NULL.
- *
- * Returns: %ASN1_SUCCESS if successful, %ASN1_ELEMENT_NOT_FOUND if
- * *@structure was NULL.
- **/
-int
-asn1_delete_structure2 (asn1_node * structure, unsigned int flags)
-{
- asn1_node p, p2, p3;
-
- if (*structure == NULL)
- return ASN1_ELEMENT_NOT_FOUND;
-
- p = *structure;
- while (p)
- {
- if (p->down)
- {
- p = p->down;
- }
- else
- { /* no down */
- p2 = p->right;
- if (p != *structure)
- {
- p3 = _asn1_find_up (p);
- _asn1_set_down (p3, p2);
- _asn1_remove_node (p, flags);
- p = p3;
- }
- else
- { /* p==root */
- p3 = _asn1_find_left (p);
- if (!p3)
- {
- p3 = _asn1_find_up (p);
- if (p3)
- _asn1_set_down (p3, p2);
- else
- {
- if (p->right)
- p->right->left = NULL;
- }
- }
- else
- _asn1_set_right (p3, p2);
- _asn1_remove_node (p, flags);
- p = NULL;
- }
- }
- }
-
- *structure = NULL;
- return ASN1_SUCCESS;
-}
-
-
-
-/**
- * asn1_delete_element:
- * @structure: pointer to the structure that contains the element you
- * want to delete.
- * @element_name: element's name you want to delete.
- *
- * Deletes the element named *@element_name inside *@structure.
- *
- * Returns: %ASN1_SUCCESS if successful, %ASN1_ELEMENT_NOT_FOUND if
- * the @element_name was not found.
- **/
-int
-asn1_delete_element (asn1_node structure, const char *element_name)
-{
- asn1_node p2, p3, source_node;
-
- source_node = asn1_find_node (structure, element_name);
-
- if (source_node == NULL)
- return ASN1_ELEMENT_NOT_FOUND;
-
- p2 = source_node->right;
- p3 = _asn1_find_left (source_node);
- if (!p3)
- {
- p3 = _asn1_find_up (source_node);
- if (p3)
- _asn1_set_down (p3, p2);
- else if (source_node->right)
- source_node->right->left = NULL;
- }
- else
- _asn1_set_right (p3, p2);
-
- return asn1_delete_structure (&source_node);
-}
-
-asn1_node
-_asn1_copy_structure3 (asn1_node source_node)
-{
- asn1_node dest_node, p_s, p_d, p_d_prev;
- int move;
-
- if (source_node == NULL)
- return NULL;
-
- dest_node = _asn1_add_single_node (source_node->type);
-
- p_s = source_node;
- p_d = dest_node;
-
- move = DOWN;
-
- do
- {
- if (move != UP)
- {
- if (p_s->name[0] != 0)
- _asn1_cpy_name (p_d, p_s);
- if (p_s->value)
- _asn1_set_value (p_d, p_s->value, p_s->value_len);
- if (p_s->down)
- {
- p_s = p_s->down;
- p_d_prev = p_d;
- p_d = _asn1_add_single_node (p_s->type);
- _asn1_set_down (p_d_prev, p_d);
- continue;
- }
- p_d->start = p_s->start;
- p_d->end = p_s->end;
- }
-
- if (p_s == source_node)
- break;
-
- if (p_s->right)
- {
- move = RIGHT;
- p_s = p_s->right;
- p_d_prev = p_d;
- p_d = _asn1_add_single_node (p_s->type);
- _asn1_set_right (p_d_prev, p_d);
- }
- else
- {
- move = UP;
- p_s = _asn1_find_up (p_s);
- p_d = _asn1_find_up (p_d);
- }
- }
- while (p_s != source_node);
-
- return dest_node;
-}
-
-
-static asn1_node
-_asn1_copy_structure2 (asn1_node root, const char *source_name)
-{
- asn1_node source_node;
-
- source_node = asn1_find_node (root, source_name);
-
- return _asn1_copy_structure3 (source_node);
-
-}
-
-
-static int
-_asn1_type_choice_config (asn1_node node)
-{
- asn1_node p, p2, p3, p4;
- int move, tlen;
-
- if (node == NULL)
- return ASN1_ELEMENT_NOT_FOUND;
-
- p = node;
- move = DOWN;
-
- while (!((p == node) && (move == UP)))
- {
- if (move != UP)
- {
- if ((type_field (p->type) == ASN1_ETYPE_CHOICE)
- && (p->type & CONST_TAG))
- {
- p2 = p->down;
- while (p2)
- {
- if (type_field (p2->type) != ASN1_ETYPE_TAG)
- {
- p2->type |= CONST_TAG;
- p3 = _asn1_find_left (p2);
- while (p3)
- {
- if (type_field (p3->type) == ASN1_ETYPE_TAG)
- {
- p4 = _asn1_add_single_node (p3->type);
- tlen = _asn1_strlen (p3->value);
- if (tlen > 0)
- _asn1_set_value (p4, p3->value, tlen + 1);
- _asn1_set_right (p4, p2->down);
- _asn1_set_down (p2, p4);
- }
- p3 = _asn1_find_left (p3);
- }
- }
- p2 = p2->right;
- }
- p->type &= ~(CONST_TAG);
- p2 = p->down;
- while (p2)
- {
- p3 = p2->right;
- if (type_field (p2->type) == ASN1_ETYPE_TAG)
- asn1_delete_structure (&p2);
- p2 = p3;
- }
- }
- move = DOWN;
- }
- else
- move = RIGHT;
-
- if (move == DOWN)
- {
- if (p->down)
- p = p->down;
- else
- move = RIGHT;
- }
-
- if (p == node)
- {
- move = UP;
- continue;
- }
-
- if (move == RIGHT)
- {
- if (p->right)
- p = p->right;
- else
- move = UP;
- }
- if (move == UP)
- p = _asn1_find_up (p);
- }
-
- return ASN1_SUCCESS;
-}
-
-
-static int
-_asn1_expand_identifier (asn1_node * node, asn1_node root)
-{
- asn1_node p, p2, p3;
- char name2[ASN1_MAX_NAME_SIZE + 2];
- int move;
-
- if (node == NULL)
- return ASN1_ELEMENT_NOT_FOUND;
-
- p = *node;
- move = DOWN;
-
- while (!((p == *node) && (move == UP)))
- {
- if (move != UP)
- {
- if (type_field (p->type) == ASN1_ETYPE_IDENTIFIER)
- {
- snprintf (name2, sizeof (name2), "%s.%s", root->name, p->value);
- p2 = _asn1_copy_structure2 (root, name2);
- if (p2 == NULL)
- {
- return ASN1_IDENTIFIER_NOT_FOUND;
- }
- _asn1_cpy_name (p2, p);
- p2->right = p->right;
- p2->left = p->left;
- if (p->right)
- p->right->left = p2;
- p3 = p->down;
- if (p3)
- {
- while (p3->right)
- p3 = p3->right;
- _asn1_set_right (p3, p2->down);
- _asn1_set_down (p2, p->down);
- }
-
- p3 = _asn1_find_left (p);
- if (p3)
- _asn1_set_right (p3, p2);
- else
- {
- p3 = _asn1_find_up (p);
- if (p3)
- _asn1_set_down (p3, p2);
- else
- {
- p2->left = NULL;
- }
- }
-
- if (p->type & CONST_SIZE)
- p2->type |= CONST_SIZE;
- if (p->type & CONST_TAG)
- p2->type |= CONST_TAG;
- if (p->type & CONST_OPTION)
- p2->type |= CONST_OPTION;
- if (p->type & CONST_DEFAULT)
- p2->type |= CONST_DEFAULT;
- if (p->type & CONST_SET)
- p2->type |= CONST_SET;
- if (p->type & CONST_NOT_USED)
- p2->type |= CONST_NOT_USED;
-
- if (p == *node)
- *node = p2;
- _asn1_remove_node (p, 0);
- p = p2;
- move = DOWN;
- continue;
- }
- move = DOWN;
- }
- else
- move = RIGHT;
-
- if (move == DOWN)
- {
- if (p->down)
- p = p->down;
- else
- move = RIGHT;
- }
-
- if (p == *node)
- {
- move = UP;
- continue;
- }
-
- if (move == RIGHT)
- {
- if (p->right)
- p = p->right;
- else
- move = UP;
- }
- if (move == UP)
- p = _asn1_find_up (p);
- }
-
- return ASN1_SUCCESS;
-}
-
-
-/**
- * asn1_create_element:
- * @definitions: pointer to the structure returned by "parser_asn1" function
- * @source_name: the name of the type of the new structure (must be
- * inside p_structure).
- * @element: pointer to the structure created.
- *
- * Creates a structure of type @source_name. Example using
- * "pkix.asn":
- *
- * rc = asn1_create_element(cert_def, "PKIX1.Certificate", certptr);
- *
- * Returns: %ASN1_SUCCESS if creation OK, %ASN1_ELEMENT_NOT_FOUND if
- * @source_name is not known.
- **/
-int
-asn1_create_element (asn1_node definitions, const char *source_name,
- asn1_node * element)
-{
- asn1_node dest_node;
- int res;
-
- dest_node = _asn1_copy_structure2 (definitions, source_name);
-
- if (dest_node == NULL)
- return ASN1_ELEMENT_NOT_FOUND;
-
- _asn1_set_name (dest_node, "");
-
- res = _asn1_expand_identifier (&dest_node, definitions);
- _asn1_type_choice_config (dest_node);
-
- *element = dest_node;
-
- return res;
-}
-
-
-/**
- * asn1_print_structure:
- * @out: pointer to the output file (e.g. stdout).
- * @structure: pointer to the structure that you want to visit.
- * @name: an element of the structure
- * @mode: specify how much of the structure to print, can be
- * %ASN1_PRINT_NAME, %ASN1_PRINT_NAME_TYPE,
- * %ASN1_PRINT_NAME_TYPE_VALUE, or %ASN1_PRINT_ALL.
- *
- * Prints on the @out file descriptor the structure's tree starting
- * from the @name element inside the structure @structure.
- **/
-void
-asn1_print_structure (FILE * out, asn1_node structure, const char *name,
- int mode)
-{
- asn1_node p, root;
- int k, indent = 0, len, len2, len3;
-
- if (out == NULL)
- return;
-
- root = asn1_find_node (structure, name);
-
- if (root == NULL)
- return;
-
- p = root;
- while (p)
- {
- if (mode == ASN1_PRINT_ALL)
- {
- for (k = 0; k < indent; k++)
- fprintf (out, " ");
- fprintf (out, "name:");
- if (p->name[0] != 0)
- fprintf (out, "%s ", p->name);
- else
- fprintf (out, "NULL ");
- }
- else
- {
- switch (type_field (p->type))
- {
- case ASN1_ETYPE_CONSTANT:
- case ASN1_ETYPE_TAG:
- case ASN1_ETYPE_SIZE:
- break;
- default:
- for (k = 0; k < indent; k++)
- fprintf (out, " ");
- fprintf (out, "name:");
- if (p->name[0] != 0)
- fprintf (out, "%s ", p->name);
- else
- fprintf (out, "NULL ");
- }
- }
-
- if (mode != ASN1_PRINT_NAME)
- {
- unsigned type = type_field (p->type);
- switch (type)
- {
- case ASN1_ETYPE_CONSTANT:
- if (mode == ASN1_PRINT_ALL)
- fprintf (out, "type:CONST");
- break;
- case ASN1_ETYPE_TAG:
- if (mode == ASN1_PRINT_ALL)
- fprintf (out, "type:TAG");
- break;
- case ASN1_ETYPE_SIZE:
- if (mode == ASN1_PRINT_ALL)
- fprintf (out, "type:SIZE");
- break;
- case ASN1_ETYPE_DEFAULT:
- fprintf (out, "type:DEFAULT");
- break;
- case ASN1_ETYPE_IDENTIFIER:
- fprintf (out, "type:IDENTIFIER");
- break;
- case ASN1_ETYPE_ANY:
- fprintf (out, "type:ANY");
- break;
- case ASN1_ETYPE_CHOICE:
- fprintf (out, "type:CHOICE");
- break;
- case ASN1_ETYPE_DEFINITIONS:
- fprintf (out, "type:DEFINITIONS");
- break;
- CASE_HANDLED_ETYPES:
- fprintf (out, "%s", _asn1_tags[type].desc);
- break;
- default:
- break;
- }
- }
-
- if ((mode == ASN1_PRINT_NAME_TYPE_VALUE) || (mode == ASN1_PRINT_ALL))
- {
- switch (type_field (p->type))
- {
- case ASN1_ETYPE_CONSTANT:
- if (mode == ASN1_PRINT_ALL)
- if (p->value)
- fprintf (out, " value:%s", p->value);
- break;
- case ASN1_ETYPE_TAG:
- if (mode == ASN1_PRINT_ALL)
- if (p->value)
- fprintf (out, " value:%s", p->value);
- break;
- case ASN1_ETYPE_SIZE:
- if (mode == ASN1_PRINT_ALL)
- if (p->value)
- fprintf (out, " value:%s", p->value);
- break;
- case ASN1_ETYPE_DEFAULT:
- if (p->value)
- fprintf (out, " value:%s", p->value);
- else if (p->type & CONST_TRUE)
- fprintf (out, " value:TRUE");
- else if (p->type & CONST_FALSE)
- fprintf (out, " value:FALSE");
- break;
- case ASN1_ETYPE_IDENTIFIER:
- if (p->value)
- fprintf (out, " value:%s", p->value);
- break;
- case ASN1_ETYPE_INTEGER:
- if (p->value)
- {
- len2 = -1;
- len = asn1_get_length_der (p->value, p->value_len, &len2);
- fprintf (out, " value:0x");
- if (len > 0)
- for (k = 0; k < len; k++)
- fprintf (out, "%02x", (unsigned) (p->value)[k + len2]);
- }
- break;
- case ASN1_ETYPE_ENUMERATED:
- if (p->value)
- {
- len2 = -1;
- len = asn1_get_length_der (p->value, p->value_len, &len2);
- fprintf (out, " value:0x");
- if (len > 0)
- for (k = 0; k < len; k++)
- fprintf (out, "%02x", (unsigned) (p->value)[k + len2]);
- }
- break;
- case ASN1_ETYPE_BOOLEAN:
- if (p->value)
- {
- if (p->value[0] == 'T')
- fprintf (out, " value:TRUE");
- else if (p->value[0] == 'F')
- fprintf (out, " value:FALSE");
- }
- break;
- case ASN1_ETYPE_BIT_STRING:
- if (p->value)
- {
- len2 = -1;
- len = asn1_get_length_der (p->value, p->value_len, &len2);
- if (len > 0)
- {
- fprintf (out, " value(%i):",
- (len - 1) * 8 - (p->value[len2]));
- for (k = 1; k < len; k++)
- fprintf (out, "%02x", (unsigned) (p->value)[k + len2]);
- }
- }
- break;
- case ASN1_ETYPE_GENERALIZED_TIME:
- case ASN1_ETYPE_UTC_TIME:
- if (p->value)
- {
- fprintf (out, " value:");
- for (k = 0; k < p->value_len; k++)
- fprintf (out, "%c", (p->value)[k]);
- }
- break;
- case ASN1_ETYPE_GENERALSTRING:
- case ASN1_ETYPE_NUMERIC_STRING:
- case ASN1_ETYPE_IA5_STRING:
- case ASN1_ETYPE_TELETEX_STRING:
- case ASN1_ETYPE_PRINTABLE_STRING:
- case ASN1_ETYPE_UNIVERSAL_STRING:
- case ASN1_ETYPE_UTF8_STRING:
- case ASN1_ETYPE_VISIBLE_STRING:
- if (p->value)
- {
- len2 = -1;
- len = asn1_get_length_der (p->value, p->value_len, &len2);
- fprintf (out, " value:");
- if (len > 0)
- for (k = 0; k < len; k++)
- fprintf (out, "%c", (p->value)[k + len2]);
- }
- break;
- case ASN1_ETYPE_BMP_STRING:
- case ASN1_ETYPE_OCTET_STRING:
- if (p->value)
- {
- len2 = -1;
- len = asn1_get_length_der (p->value, p->value_len, &len2);
- fprintf (out, " value:");
- if (len > 0)
- for (k = 0; k < len; k++)
- fprintf (out, "%02x", (unsigned) (p->value)[k + len2]);
- }
- break;
- case ASN1_ETYPE_OBJECT_ID:
- if (p->value)
- fprintf (out, " value:%s", p->value);
- break;
- case ASN1_ETYPE_ANY:
- if (p->value)
- {
- len3 = -1;
- len2 = asn1_get_length_der (p->value, p->value_len, &len3);
- fprintf (out, " value:");
- if (len2 > 0)
- for (k = 0; k < len2; k++)
- fprintf (out, "%02x", (unsigned) (p->value)[k + len3]);
- }
- break;
- case ASN1_ETYPE_SET:
- case ASN1_ETYPE_SET_OF:
- case ASN1_ETYPE_CHOICE:
- case ASN1_ETYPE_DEFINITIONS:
- case ASN1_ETYPE_SEQUENCE_OF:
- case ASN1_ETYPE_SEQUENCE:
- case ASN1_ETYPE_NULL:
- break;
- default:
- break;
- }
- }
-
- if (mode == ASN1_PRINT_ALL)
- {
- if (p->type & 0x1FFFFF00)
- {
- fprintf (out, " attr:");
- if (p->type & CONST_UNIVERSAL)
- fprintf (out, "UNIVERSAL,");
- if (p->type & CONST_PRIVATE)
- fprintf (out, "PRIVATE,");
- if (p->type & CONST_APPLICATION)
- fprintf (out, "APPLICATION,");
- if (p->type & CONST_EXPLICIT)
- fprintf (out, "EXPLICIT,");
- if (p->type & CONST_IMPLICIT)
- fprintf (out, "IMPLICIT,");
- if (p->type & CONST_TAG)
- fprintf (out, "TAG,");
- if (p->type & CONST_DEFAULT)
- fprintf (out, "DEFAULT,");
- if (p->type & CONST_TRUE)
- fprintf (out, "TRUE,");
- if (p->type & CONST_FALSE)
- fprintf (out, "FALSE,");
- if (p->type & CONST_LIST)
- fprintf (out, "LIST,");
- if (p->type & CONST_MIN_MAX)
- fprintf (out, "MIN_MAX,");
- if (p->type & CONST_OPTION)
- fprintf (out, "OPTION,");
- if (p->type & CONST_1_PARAM)
- fprintf (out, "1_PARAM,");
- if (p->type & CONST_SIZE)
- fprintf (out, "SIZE,");
- if (p->type & CONST_DEFINED_BY)
- fprintf (out, "DEF_BY,");
- if (p->type & CONST_GENERALIZED)
- fprintf (out, "GENERALIZED,");
- if (p->type & CONST_UTC)
- fprintf (out, "UTC,");
- if (p->type & CONST_SET)
- fprintf (out, "SET,");
- if (p->type & CONST_NOT_USED)
- fprintf (out, "NOT_USED,");
- if (p->type & CONST_ASSIGN)
- fprintf (out, "ASSIGNMENT,");
- }
- }
-
- if (mode == ASN1_PRINT_ALL)
- {
- fprintf (out, "\n");
- }
- else
- {
- switch (type_field (p->type))
- {
- case ASN1_ETYPE_CONSTANT:
- case ASN1_ETYPE_TAG:
- case ASN1_ETYPE_SIZE:
- break;
- default:
- fprintf (out, "\n");
- }
- }
-
- if (p->down)
- {
- p = p->down;
- indent += 2;
- }
- else if (p == root)
- {
- p = NULL;
- break;
- }
- else if (p->right)
- p = p->right;
- else
- {
- while (1)
- {
- p = _asn1_find_up (p);
- if (p == root)
- {
- p = NULL;
- break;
- }
- indent -= 2;
- if (p->right)
- {
- p = p->right;
- break;
- }
- }
- }
- }
-}
-
-
-
-/**
- * asn1_number_of_elements:
- * @element: pointer to the root of an ASN1 structure.
- * @name: the name of a sub-structure of ROOT.
- * @num: pointer to an integer where the result will be stored
- *
- * Counts the number of elements of a sub-structure called NAME with
- * names equal to "?1","?2", ...
- *
- * Returns: %ASN1_SUCCESS if successful, %ASN1_ELEMENT_NOT_FOUND if
- * @name is not known, %ASN1_GENERIC_ERROR if pointer @num is %NULL.
- **/
-int
-asn1_number_of_elements (asn1_node element, const char *name, int *num)
-{
- asn1_node node, p;
-
- if (num == NULL)
- return ASN1_GENERIC_ERROR;
-
- *num = 0;
-
- node = asn1_find_node (element, name);
- if (node == NULL)
- return ASN1_ELEMENT_NOT_FOUND;
-
- p = node->down;
-
- while (p)
- {
- if (p->name[0] == '?')
- (*num)++;
- p = p->right;
- }
-
- return ASN1_SUCCESS;
-}
-
-
-/**
- * asn1_find_structure_from_oid:
- * @definitions: ASN1 definitions
- * @oidValue: value of the OID to search (e.g. "1.2.3.4").
- *
- * Search the structure that is defined just after an OID definition.
- *
- * Returns: %NULL when @oidValue not found, otherwise the pointer to a
- * constant string that contains the element name defined just after
- * the OID.
- **/
-const char *
-asn1_find_structure_from_oid (asn1_node definitions, const char *oidValue)
-{
- char name[2 * ASN1_MAX_NAME_SIZE + 1];
- char value[ASN1_MAX_NAME_SIZE];
- asn1_node p;
- int len;
- int result;
- const char *definitionsName;
-
- if ((definitions == NULL) || (oidValue == NULL))
- return NULL; /* ASN1_ELEMENT_NOT_FOUND; */
-
- definitionsName = definitions->name;
-
- /* search the OBJECT_ID into definitions */
- p = definitions->down;
- while (p)
- {
- if ((type_field (p->type) == ASN1_ETYPE_OBJECT_ID) &&
- (p->type & CONST_ASSIGN))
- {
- snprintf(name, sizeof(name), "%s.%s", definitionsName, p->name);
-
- len = ASN1_MAX_NAME_SIZE;
- result = asn1_read_value (definitions, name, value, &len);
-
- if ((result == ASN1_SUCCESS) && (!strcmp (oidValue, value)))
- {
- p = p->right;
- if (p == NULL) /* reach the end of ASN1 definitions */
- return NULL; /* ASN1_ELEMENT_NOT_FOUND; */
-
- return p->name;
- }
- }
- p = p->right;
- }
-
- return NULL; /* ASN1_ELEMENT_NOT_FOUND; */
-}
-
-/**
- * asn1_copy_node:
- * @dst: Destination asn1 node.
- * @dst_name: Field name in destination node.
- * @src: Source asn1 node.
- * @src_name: Field name in source node.
- *
- * Create a deep copy of a asn1_node variable. That
- * function requires @dst to be expanded using asn1_create_element().
- *
- * Returns: Return %ASN1_SUCCESS on success.
- **/
-int
-asn1_copy_node (asn1_node dst, const char *dst_name,
- asn1_node src, const char *src_name)
-{
- int result;
- asn1_node dst_node;
- void *data = NULL;
- int size = 0;
-
- result = asn1_der_coding (src, src_name, NULL, &size, NULL);
- if (result != ASN1_MEM_ERROR)
- return result;
-
- data = malloc (size);
- if (data == NULL)
- return ASN1_MEM_ERROR;
-
- result = asn1_der_coding (src, src_name, data, &size, NULL);
- if (result != ASN1_SUCCESS)
- {
- free (data);
- return result;
- }
-
- dst_node = asn1_find_node (dst, dst_name);
- if (dst_node == NULL)
- {
- free (data);
- return ASN1_ELEMENT_NOT_FOUND;
- }
-
- result = asn1_der_decoding (&dst_node, data, size, NULL);
-
- free (data);
-
- return result;
-}
-
-/**
- * asn1_dup_node:
- * @src: Source asn1 node.
- * @src_name: Field name in source node.
- *
- * Create a deep copy of a asn1_node variable. This function
- * will return an exact copy of the provided structure.
- *
- * Returns: Return %NULL on failure.
- **/
-asn1_node
-asn1_dup_node (asn1_node src, const char *src_name)
-{
- return _asn1_copy_structure2(src, src_name);
-}
diff --git a/lib/structure.h b/lib/structure.h
deleted file mode 100644
index bb6e7a9..0000000
--- a/lib/structure.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2002-2014 Free Software Foundation, Inc.
- *
- * This file is part of LIBTASN1.
- *
- * The LIBTASN1 library 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 library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- */
-
-/*************************************************/
-/* File: structure.h */
-/* Description: list of exported object by */
-/* "structure.c" */
-/*************************************************/
-
-#ifndef _STRUCTURE_H
-#define _STRUCTURE_H
-
-int _asn1_create_static_structure (asn1_node pointer,
- char *output_file_name, char *vector_name);
-
-asn1_node _asn1_copy_structure3 (asn1_node source_node);
-
-asn1_node _asn1_add_single_node (unsigned int type);
-
-asn1_node _asn1_find_left (asn1_node node);
-
-#endif
diff --git a/lib/version.c b/lib/version.c
deleted file mode 100644
index 25f8a8f..0000000
--- a/lib/version.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2000-2014 Free Software Foundation, Inc.
- *
- * This file is part of LIBTASN1.
- *
- * The LIBTASN1 library 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 library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h> /* for strverscmp */
-
-#include "libtasn1.h"
-
-/**
- * asn1_check_version:
- * @req_version: Required version number, or %NULL.
- *
- * Check that the version of the library is at minimum the
- * requested one and return the version string; return %NULL if the
- * condition is not satisfied. If a %NULL is passed to this function,
- * no check is done, but the version string is simply returned.
- *
- * See %ASN1_VERSION for a suitable @req_version string.
- *
- * Returns: Version string of run-time library, or %NULL if the
- * run-time library does not meet the required version number.
- */
-const char *
-asn1_check_version (const char *req_version)
-{
- if (!req_version || strverscmp (req_version, ASN1_VERSION) <= 0)
- return ASN1_VERSION;
-
- return NULL;
-}