txt_db.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (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 OPENSSL_TXT_DB_H
  10. # define OPENSSL_TXT_DB_H
  11. # pragma once
  12. # include <openssl/macros.h>
  13. # ifndef OPENSSL_NO_DEPRECATED_3_0
  14. # define HEADER_TXT_DB_H
  15. # endif
  16. # include <openssl/opensslconf.h>
  17. # include <openssl/bio.h>
  18. # include <openssl/safestack.h>
  19. # include <openssl/lhash.h>
  20. # define DB_ERROR_OK 0
  21. # define DB_ERROR_MALLOC 1
  22. # define DB_ERROR_INDEX_CLASH 2
  23. # define DB_ERROR_INDEX_OUT_OF_RANGE 3
  24. # define DB_ERROR_NO_INDEX 4
  25. # define DB_ERROR_INSERT_INDEX_CLASH 5
  26. # define DB_ERROR_WRONG_NUM_FIELDS 6
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. typedef OPENSSL_STRING *OPENSSL_PSTRING;
  31. DEFINE_SPECIAL_STACK_OF(OPENSSL_PSTRING, OPENSSL_STRING)
  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. TXT_DB *TXT_DB_read(BIO *in, int num);
  43. long TXT_DB_write(BIO *out, TXT_DB *db);
  44. int TXT_DB_create_index(TXT_DB *db, int field, int (*qual) (OPENSSL_STRING *),
  45. OPENSSL_LH_HASHFUNC hash, OPENSSL_LH_COMPFUNC cmp);
  46. void TXT_DB_free(TXT_DB *db);
  47. OPENSSL_STRING *TXT_DB_get_by_index(TXT_DB *db, int idx,
  48. OPENSSL_STRING *value);
  49. int TXT_DB_insert(TXT_DB *db, OPENSSL_STRING *value);
  50. #ifdef __cplusplus
  51. }
  52. #endif
  53. #endif