poparser.h 782 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef POPARSER_H
  2. #define POPARSER_H
  3. #include <unistd.h>
  4. enum po_entry {
  5. pe_msgid = 0,
  6. pe_plural,
  7. pe_ctxt,
  8. pe_msgstr,
  9. pe_maxstr,
  10. pe_str = pe_maxstr,
  11. pe_invalid,
  12. pe_max,
  13. };
  14. struct po_info {
  15. enum po_entry type;
  16. char *text;
  17. char charset[12];
  18. unsigned int nplurals;
  19. size_t textlen;
  20. };
  21. typedef int (*poparser_callback)(struct po_info* info, void* user);
  22. struct po_parser {
  23. struct po_info info;
  24. char *buf;
  25. size_t bufsize;
  26. enum po_entry prev_type;
  27. enum po_entry prev_rtype;
  28. unsigned curr_len;
  29. poparser_callback cb;
  30. void *cbdata;
  31. };
  32. void poparser_init(struct po_parser *p, char* workbuf, size_t bufsize, poparser_callback cb, void* cbdata);
  33. int poparser_feed_line(struct po_parser *p, char* line, size_t buflen);
  34. int poparser_finish(struct po_parser *p);
  35. #endif