parse_ctxt.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /**
  2. * @file parse_ctxt.c
  3. */
  4. /*
  5. * This program is free software: you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation, either vers* ion 3 of
  8. * the License, or (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * 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
  17. * <http://www.gnu.org/licenses/>.
  18. */
  19. #include "stdlib.h"
  20. #include "string.h"
  21. #include "config.h"
  22. #include "debug.h"
  23. #include "gl_list.h"
  24. #include "gl_array_list.h"
  25. #include "parse_ctxt.h"
  26. static const size_t default_todo_states_size = 2;
  27. static const char* default_todo_states[] = {"TODO", "DONE"};
  28. gl_list_t parse_ctxt_create_default_todo_states ();
  29. void
  30. parse_ctxt_init (parse_ctxt *ctxt)
  31. {
  32. ctxt->todo_states = NULL;
  33. ctxt->current_level = 0;
  34. return;
  35. }
  36. void
  37. parse_ctxt_set_defaults (parse_ctxt *ctxt)
  38. {
  39. if (ctxt->todo_states == NULL)
  40. {
  41. ctxt->todo_states = parse_ctxt_create_default_todo_states ();
  42. }
  43. ctxt->current_level = 0;
  44. return;
  45. }
  46. gl_list_t
  47. parse_ctxt_create_default_todo_states ()
  48. {
  49. gl_list_t list =
  50. gl_list_nx_create_empty (GL_ARRAY_LIST, NULL, NULL, NULL, true);
  51. int i = 0;
  52. for (i = 0; i < default_todo_states_size; i++)
  53. {
  54. gl_list_nx_add_last (list, default_todo_states[i]);
  55. }
  56. return list;
  57. }