Correct typos
[shigofumi.git] / src / io.h
blob4b4a82605b82ae8249779ee497ff819e20a8e802
1 #ifndef __IO_H__
2 #define __IO_H__
3 #include <libxml/tree.h> /* For xmlDoc and xmlNodePtr */
4 #include <libxml/xpath.h>
6 /* Open file and return descriptor. Return -1 in case of error. */
7 int open_file_for_writing(const char *file, _Bool truncate);
9 /* Return 0, -1 in case of error */
10 int mmap_file(const char *file, int *fd, void **buffer, size_t *length);
12 /* Return 0, -1 in case of error */
13 int munmap_file(int fd, void *buffer, size_t length);
15 /* Return 0, -1 in case of error.
16 * @length and @mime_type are optional. */
17 int load_data_from_file(const char *file, void **data, size_t *length,
18 char **mime_type);
20 int save_data_to_file(const char *file, const void *data,
21 const size_t length, const char *mime_type);
23 /* Parse @buffer as XML document and return @node_list specified by
24 * @xpath_expression.
25 * @node_list is weak copy that must be non-recursively freed by caller. Caller
26 * must free XML document (accessible through @node_list member) on its own.
27 * In case of error @node_list value will be invalid.
28 * If @node_list is returned empty, function freed parsed document already.
29 * @xpat_expr is UTF-8 encoded XPath expression */
30 int load_xml_subtree_from_memory(const void *buffer, size_t length,
31 xmlNodePtr *node_list, const char *xpath_expr);
33 /* Deallocate struct isds_document with embedded XML recursively and NULL it */
34 void free_document_with_xml_node_list(struct isds_document **document);
36 int save_xml_to_file(const char *file, const xmlNodePtr node_list,
37 const char *mime_type);
39 /* Return 0 if @path is directory, 1 if not, -1 if error occurred */
40 int is_directory(const char *path);
41 #endif