gml_parser.h 2.3 KB

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