Some menu shuffling.
[grace.git] / src / xfile.h
blob3a2e6e768d3d95b060e22230b41371828cf3b928
1 /*
2 * Grace - GRaphing, Advanced Computation and Exploration of data
3 *
4 * Home page: http://plasma-gate.weizmann.ac.il/Grace/
5 *
6 * Copyright (c) 2000 Grace Development Team
7 *
8 * Maintained by Evgeny Stambulchik
9 *
11 * All Rights Reserved
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 * XML output and related stuff
32 #ifndef __XFILE_H_
33 #define __XFILE_H_
35 typedef struct _XStackEntry {
36 char *name;
37 void *data;
38 } XStackEntry;
40 typedef struct _XStack {
41 int size;
42 int depth;
43 XStackEntry *entries;
44 } XStack;
46 typedef struct _ElementAttribute {
47 char *name;
48 char *value;
49 } ElementAttribute;
51 typedef struct _Attributes {
52 ElementAttribute *args;
53 unsigned int size;
54 unsigned int count;
55 } Attributes;
57 typedef struct _XFile {
58 FILE *fp;
59 XStack *tree;
60 unsigned int indent;
61 char *indstr;
62 int curpos;
63 int convert;
64 char *ns_prefix;
65 char *ns_uri;
66 int ns_force;
67 } XFile;
69 XStack *xstack_new(void);
70 void xstack_free(XStack *xs);
71 int xstack_increment(XStack *xs, const char *name, void *data);
72 int xstack_decrement(XStack *xs, const char *name);
73 int xstack_get_first(XStack *xs, char **name, void **data);
74 int xstack_get_last(XStack *xs, char **name, void **data);
75 int xstack_is_empty(XStack *xs);
77 Attributes *attributes_new(void);
78 void attributes_free(Attributes *attrs);
79 int attributes_reset(Attributes *attrs);
81 int attributes_set_sval(Attributes *attrs, const char *name, const char *value);
82 int attributes_set_bval(Attributes *attrs, const char *name, int bval);
83 int attributes_set_ival(Attributes *attrs, const char *name, int ival);
84 int attributes_set_ival_formatted(Attributes *attrs, const char *name,
85 int ival, char *format);
86 int attributes_set_dval(Attributes *attrs, const char *name, double dval);
87 int attributes_set_dval_formatted(Attributes *attrs, const char *name,
88 double dval, char *format);
90 int attributes_set_ns(Attributes *attrs, const char *ns, const char *uri);
92 XFile *xfile_new(FILE *fp);
93 void xfile_free(XFile *xf);
95 int xfile_set_ns(XFile *xf, const char *ns, const char *uri, int force);
97 int xfile_begin(XFile *xf, int standalone,
98 char *dtd_name, char *dtd_uri, char *root, Attributes *root_attrs);
99 int xfile_end(XFile *xf);
101 int xfile_begin_element(XFile *xf, char *name, Attributes *attrs);
102 int xfile_end_element(XFile *xf, char *name);
103 int xfile_empty_element(XFile *xf, char *name, Attributes *attrs);
104 int xfile_text_element(XFile *xf,
105 char *name, Attributes *attrs, char *text, int cdata);
107 int xfile_comment(XFile *xf, char *comment);
109 int xfile_processing_instruction(XFile *xf, Attributes *attrs);
111 #endif /* __XFILE_H_ */