gml_parser.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Copyright 2021
  3. * (C) Universitaet Passau 1986-1991
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. * These are the four essential freedoms with GNU GPL software:
  19. * 1: freedom to run the program, for any purpose
  20. * 2: freedom to study how the program works, and change it to make it do what you wish
  21. * 3: freedom to redistribute copies to help your Free Software friends
  22. * 4: freedom to distribute copies of your modified versions to your Free Software friends
  23. * , ,
  24. * / \
  25. * ((__-^^-,-^^-__))
  26. * `-_---' `---_-'
  27. * `--|o` 'o|--'
  28. * \ ` /
  29. * ): :(
  30. * :o_o:
  31. * "-"
  32. *
  33. * SPDX-License-Identifier: GPL-3.0+
  34. * License-Filename: LICENSE
  35. */
  36. #ifndef GML_PARSER_H
  37. #define GML_PARSER_H 1
  38. union GML_pair_val {
  39. long integer;
  40. double floating;
  41. char *string;
  42. struct GML_pair *list;
  43. };
  44. struct GML_pair {
  45. char *key;
  46. GML_value kind;
  47. union GML_pair_val value;
  48. struct GML_pair *next;
  49. };
  50. struct GML_list_elem {
  51. char *key;
  52. struct GML_list_elem *next;
  53. };
  54. struct GML_stat {
  55. struct GML_error err;
  56. struct GML_list_elem *key_list;
  57. };
  58. /*
  59. * returns list of KEY - VALUE pairs. Errors and a pointer to a list
  60. * of key-names are returned in GML_stat. Previous information contained
  61. * in GML_stat, i.e. the key_list, will be *lost*.
  62. */
  63. extern struct GML_pair *GML_parser(gzFile stream, struct GML_stat *status, int code);
  64. /*
  65. * free memory used in a list of GML_pair
  66. */
  67. extern void GML_free_list(struct GML_pair *pl, struct GML_list_elem *el);
  68. /*
  69. * debugging
  70. */
  71. extern void GML_print_list(struct GML_pair *pl, int code);
  72. /* memory wrapping */
  73. extern void gmlparser_free(void *ptr);
  74. /* */
  75. extern void *gmlparser_calloc(size_t nn, size_t sz);
  76. /* */
  77. extern int gmlparse(struct gml_graph *g, gzFile f, char *fname, char *argv0);
  78. #endif
  79. /* end */