hooks.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* vim: set tabstop=8 shiftwidth=4 softtabstop=4 expandtab smarttab colorcolumn=80: */
  2. /*
  3. * Copyright 2016 Red Hat, Inc.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. #include "hooks.h"
  18. #include <string.h>
  19. static const jose_hook_jwk_t *jwks;
  20. static const jose_hook_alg_t *algs;
  21. void
  22. jose_hook_jwk_push(jose_hook_jwk_t *jwk)
  23. {
  24. jwk->next = jwks;
  25. jwks = jwk;
  26. }
  27. const jose_hook_jwk_t *
  28. jose_hook_jwk_list(void)
  29. {
  30. return jwks;
  31. }
  32. void
  33. jose_hook_alg_push(jose_hook_alg_t *alg)
  34. {
  35. alg->next = algs;
  36. algs = alg;
  37. }
  38. const jose_hook_alg_t *
  39. jose_hook_alg_list(void)
  40. {
  41. return algs;
  42. }
  43. const jose_hook_alg_t *
  44. jose_hook_alg_find(jose_hook_alg_kind_t kind, const char *name)
  45. {
  46. for (const jose_hook_alg_t *a = algs; a; a = a->next) {
  47. if (a->kind != kind)
  48. continue;
  49. if (!name || strcmp(a->name, name) == 0)
  50. return a;
  51. }
  52. return NULL;
  53. }