htpasswd.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Copyright (c) 2018 Markus Hennecke <markus-hennecke@markus-hennecke.de>
  3. *
  4. * Permission to use, copy, modify, and distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef __HTPASSWD_H__
  17. #define __HTPASSWD_H__
  18. #include <stdbool.h>
  19. #define MAX_HTPASSWD_ENTRIES 128
  20. struct htpasswd {
  21. size_t filesize;
  22. char *htpasswd;
  23. char *usernames[MAX_HTPASSWD_ENTRIES];
  24. char *hashes[MAX_HTPASSWD_ENTRIES];
  25. };
  26. struct htpasswd *htpasswd_init(const char *);
  27. struct htpasswd *htpasswd_init_at(int, const char *);
  28. void htpasswd_free(struct htpasswd *);
  29. bool htpasswd_check_password(struct htpasswd *, const char *,
  30. const char *);
  31. #endif // __HTPASSWD_H__