/contrib/bind9/lib/isccc/include/isccc/sexpr.h

https://bitbucket.org/freebsd/freebsd-head/ · C Header · 124 lines · 61 code · 29 blank · 34 comment · 0 complexity · 57a5a56d4519dd4909ada93e0912cdb1 MD5 · raw file

  1. /*
  2. * Portions Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
  3. * Portions Copyright (C) 2001 Internet Software Consortium.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND ISC AND NOMINUM DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
  11. * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY
  12. * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. *
  17. * Portions Copyright (C) 2001 Nominum, Inc.
  18. *
  19. * Permission to use, copy, modify, and/or distribute this software for any
  20. * purpose with or without fee is hereby granted, provided that the above
  21. * copyright notice and this permission notice appear in all copies.
  22. *
  23. * THE SOFTWARE IS PROVIDED "AS IS" AND ISC AND NOMINUM DISCLAIMS ALL
  24. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
  25. * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY
  26. * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  27. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  28. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  29. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  30. */
  31. /* $Id: sexpr.h,v 1.11 2007/08/28 07:20:43 tbox Exp $ */
  32. #ifndef ISCCC_SEXPR_H
  33. #define ISCCC_SEXPR_H 1
  34. /*! \file isccc/sexpr.h */
  35. #include <stdio.h>
  36. #include <isc/lang.h>
  37. #include <isccc/types.h>
  38. ISC_LANG_BEGINDECLS
  39. /*% dotted pair structure */
  40. struct isccc_dottedpair {
  41. isccc_sexpr_t *car;
  42. isccc_sexpr_t *cdr;
  43. };
  44. /*% iscc_sexpr structure */
  45. struct isccc_sexpr {
  46. unsigned int type;
  47. union {
  48. char * as_string;
  49. isccc_dottedpair_t as_dottedpair;
  50. isccc_region_t as_region;
  51. } value;
  52. };
  53. #define ISCCC_SEXPRTYPE_NONE 0x00 /*%< Illegal. */
  54. #define ISCCC_SEXPRTYPE_T 0x01
  55. #define ISCCC_SEXPRTYPE_STRING 0x02
  56. #define ISCCC_SEXPRTYPE_DOTTEDPAIR 0x03
  57. #define ISCCC_SEXPRTYPE_BINARY 0x04
  58. #define ISCCC_SEXPR_CAR(s) (s)->value.as_dottedpair.car
  59. #define ISCCC_SEXPR_CDR(s) (s)->value.as_dottedpair.cdr
  60. isccc_sexpr_t *
  61. isccc_sexpr_cons(isccc_sexpr_t *car, isccc_sexpr_t *cdr);
  62. isccc_sexpr_t *
  63. isccc_sexpr_tconst(void);
  64. isccc_sexpr_t *
  65. isccc_sexpr_fromstring(const char *str);
  66. isccc_sexpr_t *
  67. isccc_sexpr_frombinary(const isccc_region_t *region);
  68. void
  69. isccc_sexpr_free(isccc_sexpr_t **sexprp);
  70. void
  71. isccc_sexpr_print(isccc_sexpr_t *sexpr, FILE *stream);
  72. isccc_sexpr_t *
  73. isccc_sexpr_car(isccc_sexpr_t *list);
  74. isccc_sexpr_t *
  75. isccc_sexpr_cdr(isccc_sexpr_t *list);
  76. void
  77. isccc_sexpr_setcar(isccc_sexpr_t *pair, isccc_sexpr_t *car);
  78. void
  79. isccc_sexpr_setcdr(isccc_sexpr_t *pair, isccc_sexpr_t *cdr);
  80. isccc_sexpr_t *
  81. isccc_sexpr_addtolist(isccc_sexpr_t **l1p, isccc_sexpr_t *l2);
  82. isc_boolean_t
  83. isccc_sexpr_listp(isccc_sexpr_t *sexpr);
  84. isc_boolean_t
  85. isccc_sexpr_emptyp(isccc_sexpr_t *sexpr);
  86. isc_boolean_t
  87. isccc_sexpr_stringp(isccc_sexpr_t *sexpr);
  88. isc_boolean_t
  89. isccc_sexpr_binaryp(isccc_sexpr_t *sexpr);
  90. char *
  91. isccc_sexpr_tostring(isccc_sexpr_t *sexpr);
  92. isccc_region_t *
  93. isccc_sexpr_tobinary(isccc_sexpr_t *sexpr);
  94. ISC_LANG_ENDDECLS
  95. #endif /* ISCCC_SEXPR_H */