diff options
author | Waldemar Brodkorb <wbx@uclibc-ng.org> | 2018-02-17 18:17:08 +0000 |
---|---|---|
committer | Waldemar Brodkorb <wbx@uclibc-ng.org> | 2018-02-17 18:17:08 +0000 |
commit | 748b5e3d2d70e47ab72ed44a371bd0db9a3a0c20 (patch) | |
tree | a6b903d0656b76e3d879adeb50ad6df63844c0d7 /utils/poparser.h | |
parent | 42ff2bba8eb24626919672f0bc129289cdca6fee (diff) |
add gettext-tiny tools
For libintl stub users tiny gettext tools might be useful.
Tested with x86_64 on Gentoo/uClibc-ng system.
Diffstat (limited to 'utils/poparser.h')
-rw-r--r-- | utils/poparser.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/utils/poparser.h b/utils/poparser.h new file mode 100644 index 000000000..29b7b16e0 --- /dev/null +++ b/utils/poparser.h @@ -0,0 +1,41 @@ +#ifndef POPARSER_H +#define POPARSER_H +#include <unistd.h> + +enum po_entry { + pe_msgid = 0, + pe_plural, + pe_ctxt, + pe_msgstr, + pe_maxstr, + pe_str = pe_maxstr, + pe_invalid, + pe_max, +}; + +struct po_info { + enum po_entry type; + char *text; + char charset[12]; + unsigned int nplurals; + size_t textlen; +}; + +typedef int (*poparser_callback)(struct po_info* info, void* user); + +struct po_parser { + struct po_info info; + char *buf; + size_t bufsize; + enum po_entry prev_type; + enum po_entry prev_rtype; + unsigned curr_len; + poparser_callback cb; + void *cbdata; +}; + +void poparser_init(struct po_parser *p, char* workbuf, size_t bufsize, poparser_callback cb, void* cbdata); +int poparser_feed_line(struct po_parser *p, char* line, size_t buflen); +int poparser_finish(struct po_parser *p); + +#endif |