txt_db.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. #ifndef HEADER_TXT_DB_H
  10. # define HEADER_TXT_DB_H
  11. # include <openssl/opensslconf.h>
  12. # include <openssl/bio.h>
  13. # include <openssl/safestack.h>
  14. # include <openssl/lhash.h>
  15. # define DB_ERROR_OK 0
  16. # define DB_ERROR_MALLOC 1
  17. # define DB_ERROR_INDEX_CLASH 2
  18. # define DB_ERROR_INDEX_OUT_OF_RANGE 3
  19. # define DB_ERROR_NO_INDEX 4
  20. # define DB_ERROR_INSERT_INDEX_CLASH 5
  21. # define DB_ERROR_WRONG_NUM_FIELDS 6
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. typedef OPENSSL_STRING *OPENSSL_PSTRING;
  26. DEFINE_SPECIAL_STACK_OF(OPENSSL_PSTRING, OPENSSL_STRING)
  27. typedef struct txt_db_st {
  28. int num_fields;
  29. STACK_OF(OPENSSL_PSTRING) *data;
  30. LHASH_OF(OPENSSL_STRING) **index;
  31. int (**qual) (OPENSSL_STRING *);
  32. long error;
  33. long arg1;
  34. long arg2;
  35. OPENSSL_STRING *arg_row;
  36. } TXT_DB;
  37. TXT_DB *TXT_DB_read(BIO *in, int num);
  38. long TXT_DB_write(BIO *out, TXT_DB *db);
  39. int TXT_DB_create_index(TXT_DB *db, int field, int (*qual) (OPENSSL_STRING *),
  40. OPENSSL_LH_HASHFUNC hash, OPENSSL_LH_COMPFUNC cmp);
  41. void TXT_DB_free(TXT_DB *db);
  42. OPENSSL_STRING *TXT_DB_get_by_index(TXT_DB *db, int idx,
  43. OPENSSL_STRING *value);
  44. int TXT_DB_insert(TXT_DB *db, OPENSSL_STRING *value);
  45. #ifdef __cplusplus
  46. }
  47. #endif
  48. #endif