types.h 862 B

1234567891011121314151617181920212223242526272829303132333435
  1. /* So we need to define some types to helm us parse an html file.
  2. How about a struct element for html elements?
  3. It'll have fields for child element, older and younger siblings.
  4. Also a pointer to an array of html attributes.
  5. */
  6. #include <stdbool.h>
  7. typedef struct html_attribute * attributeptr;
  8. typedef struct html_attribute {
  9. char * name;
  10. char * contents;
  11. } attribute;
  12. typedef struct element * elementptr;
  13. typedef struct element {
  14. char * name;
  15. /* Some elements like, p or title, may have just
  16. text. So the html element <p>hello</p> will have
  17. contents = "contents".
  18. */
  19. char * contents;
  20. bool done_parsing;
  21. elementptr parent;
  22. elementptr child;
  23. elementptr older_sibling;
  24. elementptr younger_sibling;
  25. attributeptr attribute;
  26. } element;
  27. /* typedef struct html_comment { */
  28. /* char * contents; */
  29. /* } comment; */