Use safestack.h exclusively internally.
[openssl.git] / include / openssl / txt_db.h
1 /*
2  * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the OpenSSL license (the "License").  You may not use
5  * this file except in compliance with the License.  You can obtain a copy
6  * in the file LICENSE in the source distribution or at
7  * https://www.openssl.org/source/license.html
8  */
9
10 #ifndef HEADER_TXT_DB_H
11 # define HEADER_TXT_DB_H
12
13 # include <openssl/opensslconf.h>
14 # include <openssl/bio.h>
15 # include <openssl/lhash.h>
16
17 # define DB_ERROR_OK                     0
18 # define DB_ERROR_MALLOC                 1
19 # define DB_ERROR_INDEX_CLASH            2
20 # define DB_ERROR_INDEX_OUT_OF_RANGE     3
21 # define DB_ERROR_NO_INDEX               4
22 # define DB_ERROR_INSERT_INDEX_CLASH     5
23 # define DB_ERROR_WRONG_NUM_FIELDS       6
24
25 #ifdef  __cplusplus
26 extern "C" {
27 #endif
28
29 typedef OPENSSL_STRING *OPENSSL_PSTRING;
30 DEFINE_SPECIAL_STACK_OF(OPENSSL_PSTRING, OPENSSL_STRING)
31
32 typedef struct txt_db_st {
33     int num_fields;
34     STACK_OF(OPENSSL_PSTRING) *data;
35     LHASH_OF(OPENSSL_STRING) **index;
36     int (**qual) (OPENSSL_STRING *);
37     long error;
38     long arg1;
39     long arg2;
40     OPENSSL_STRING *arg_row;
41 } TXT_DB;
42
43 TXT_DB *TXT_DB_read(BIO *in, int num);
44 long TXT_DB_write(BIO *out, TXT_DB *db);
45 int TXT_DB_create_index(TXT_DB *db, int field, int (*qual) (OPENSSL_STRING *),
46                         OPENSSL_LH_HASHFUNC hash, OPENSSL_LH_COMPFUNC cmp);
47 void TXT_DB_free(TXT_DB *db);
48 OPENSSL_STRING *TXT_DB_get_by_index(TXT_DB *db, int idx,
49                                     OPENSSL_STRING *value);
50 int TXT_DB_insert(TXT_DB *db, OPENSSL_STRING *value);
51
52 #ifdef  __cplusplus
53 }
54 #endif
55
56 #endif