1 /*
2  * libxlsxwriter
3  *
4  * Copyright 2014-2021, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
5  *
6  * relationships - A libxlsxwriter library for creating Excel XLSX
7  *                 relationships files.
8  *
9  */
10 #ifndef __LXW_RELATIONSHIPS_H__
11 #define __LXW_RELATIONSHIPS_H__
12 
13 #include <stdint.h>
14 
15 #include "common.h"
16 
17 /* Define the queue.h STAILQ structs for the generic data structs. */
18 STAILQ_HEAD(lxw_rel_tuples, lxw_rel_tuple);
19 
20 typedef struct lxw_rel_tuple {
21 
22     char *type;
23     char *target;
24     char *target_mode;
25 
26     STAILQ_ENTRY (lxw_rel_tuple) list_pointers;
27 
28 } lxw_rel_tuple;
29 
30 /*
31  * Struct to represent a relationships.
32  */
33 typedef struct lxw_relationships {
34 
35     FILE *file;
36 
37     uint32_t rel_id;
38     struct lxw_rel_tuples *relationships;
39 
40 } lxw_relationships;
41 
42 
43 
44 /* *INDENT-OFF* */
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 /* *INDENT-ON* */
49 
50 lxw_relationships *lxw_relationships_new(void);
51 void lxw_free_relationships(lxw_relationships *relationships);
52 void lxw_relationships_assemble_xml_file(lxw_relationships *self);
53 
54 void lxw_add_document_relationship(lxw_relationships *self, const char *type,
55                                    const char *target);
56 void lxw_add_package_relationship(lxw_relationships *self, const char *type,
57                                   const char *target);
58 void lxw_add_ms_package_relationship(lxw_relationships *self,
59                                      const char *type, const char *target);
60 void lxw_add_worksheet_relationship(lxw_relationships *self, const char *type,
61                                     const char *target,
62                                     const char *target_mode);
63 
64 /* Declarations required for unit testing. */
65 #ifdef TESTING
66 
67 STATIC void _relationships_xml_declaration(lxw_relationships *self);
68 
69 #endif /* TESTING */
70 
71 /* *INDENT-OFF* */
72 #ifdef __cplusplus
73 }
74 #endif
75 /* *INDENT-ON* */
76 
77 #endif /* __LXW_RELATIONSHIPS_H__ */
78