nss_db.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* Common database open/close routines for nss_db.
  2. Copyright (C) 1999-2019 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #ifndef _NSS_DB_H
  16. #define _NSS_DB_H 1
  17. #include <nss.h>
  18. #include <stdint.h>
  19. #include <libc-lock.h>
  20. /* String table index type. */
  21. typedef uint32_t stridx_t;
  22. /* Database file header. */
  23. struct nss_db_header
  24. {
  25. uint32_t magic;
  26. #define NSS_DB_MAGIC 0xdd110601
  27. uint32_t ndbs;
  28. uint64_t valstroffset;
  29. uint64_t valstrlen;
  30. uint64_t allocate;
  31. struct
  32. {
  33. char id;
  34. char pad[sizeof (uint32_t) - 1];
  35. uint32_t hashsize;
  36. uint64_t hashoffset;
  37. uint64_t keyidxoffset;
  38. uint64_t keystroffset;
  39. } dbs[0];
  40. };
  41. /* Information about mapped database. */
  42. struct nss_db_map
  43. {
  44. struct nss_db_header *header;
  45. size_t len;
  46. };
  47. /* Open the database stored in FILE. If succesful, store the database
  48. handle in *MAPPINGP or a file descriptor for the file in *FDP and
  49. return NSS_STATUS_SUCCESS. On failure, return the appropriate
  50. lookup status. */
  51. enum nss_status internal_setent (const char *file,
  52. struct nss_db_map *mappingp);
  53. /* Close the database FD. */
  54. extern void internal_endent (struct nss_db_map *mapping);
  55. #endif /* nss_db.h */