23 #include <sys/types.h>
25 #if defined(HAVE_LANGINFO_H)
28 #if defined(__MINGW32__) && defined(USE_NLS)
29 #include <localcharset.h>
39 #include "parser_local_proto.h"
42 static const char *src_enc;
51 static void print_escaped_for_xml(FILE *fp,
const char *str)
54 iconv_t conv = iconv_open(
"UTF-8", src_enc);
57 if (conv != (iconv_t)-1) {
58 char *
src = (
char *)str;
59 size_t srclen = strlen(
src);
60 size_t dstlen = srclen * 4 + 1;
66 ret = iconv(conv, (
char **)&
src, &srclen, &
dst, &dstlen);
67 if (ret != (
size_t)-1 && srclen == 0) {
95 if (conv != (iconv_t)-1)
110 const char *encoding =
NULL;
117 #if defined(HAVE_LANGINFO_H)
118 encoding = nl_langinfo(CODESET);
119 #elif defined(__MINGW32__) && defined(USE_NLS)
120 encoding = locale_charset();
123 if (!encoding || strlen(encoding) == 0)
136 fprintf(stdout,
"<?xml version=\"1.0\" encoding=\"%s\"?>\n", encoding);
137 fprintf(stdout,
"<!DOCTYPE task SYSTEM \"grass-interface.dtd\">\n");
139 fprintf(stdout,
"<task name=\"%s\">\n",
st->pgm_name);
141 if (
st->module_info.label) {
142 fprintf(stdout,
"\t<label>\n\t\t");
143 print_escaped_for_xml(stdout,
st->module_info.label);
144 fprintf(stdout,
"\n\t</label>\n");
147 if (
st->module_info.description) {
148 fprintf(stdout,
"\t<description>\n\t\t");
149 print_escaped_for_xml(stdout,
st->module_info.description);
150 fprintf(stdout,
"\n\t</description>\n");
153 if (
st->module_info.keywords) {
154 fprintf(stdout,
"\t<keywords>\n\t\t");
156 fprintf(stdout,
"\n\t</keywords>\n");
169 opt = &
st->first_option;
170 while (opt !=
NULL) {
191 "multiple=\"%s\">\n",
196 fprintf(stdout,
"\t\t<label>\n\t\t\t");
197 print_escaped_for_xml(stdout, opt->
label);
198 fprintf(stdout,
"\n\t\t</label>\n");
202 fprintf(stdout,
"\t\t<description>\n\t\t\t");
204 fprintf(stdout,
"\n\t\t</description>\n");
208 fprintf(stdout,
"\t\t<keydesc>\n");
211 s = strtok(top,
",");
212 for (i = 1; s !=
NULL; i++) {
213 fprintf(stdout,
"\t\t\t<item order=\"%d\">", i);
214 print_escaped_for_xml(stdout, s);
215 fprintf(stdout,
"</item>\n");
216 s = strtok(
NULL,
",");
218 fprintf(stdout,
"\t\t</keydesc>\n");
223 const char *atts[] = {
"age",
"element",
"prompt",
NULL};
226 s = strtok(top,
",");
227 fprintf(stdout,
"\t\t<gisprompt ");
228 for (i = 0; s !=
NULL && atts[i] !=
NULL; i++) {
229 fprintf(stdout,
"%s=\"%s\" ", atts[i], s);
230 s = strtok(
NULL,
",");
232 fprintf(stdout,
"/>\n");
237 fprintf(stdout,
"\t\t<default>\n\t\t\t");
238 print_escaped_for_xml(stdout, opt->
def);
239 fprintf(stdout,
"\n\t\t</default>\n");
248 fprintf(stdout,
"\t\t<values>\n");
249 while (opt->
opts[i]) {
250 fprintf(stdout,
"\t\t\t<value>\n");
251 fprintf(stdout,
"\t\t\t\t<name>");
252 print_escaped_for_xml(stdout, opt->
opts[i]);
253 fprintf(stdout,
"</name>\n");
255 fprintf(stdout,
"\t\t\t\t<description>");
256 print_escaped_for_xml(stdout, opt->
descs[i]);
257 fprintf(stdout,
"</description>\n");
259 fprintf(stdout,
"\t\t\t</value>\n");
262 fprintf(stdout,
"\t\t</values>\n");
265 fprintf(stdout,
"\t\t<guisection>\n\t\t\t");
266 print_escaped_for_xml(stdout, opt->
guisection);
267 fprintf(stdout,
"\n\t\t</guisection>\n");
270 fprintf(stdout,
"\t\t<guidependency>\n\t\t\t");
272 fprintf(stdout,
"\n\t\t</guidependency>\n");
280 fprintf(stdout,
"\t</parameter>\n");
285 flag = &
st->first_flag;
286 while (flag !=
NULL) {
287 fprintf(stdout,
"\t<flag name=\"%c\">\n", flag->
key);
290 fprintf(stdout,
"\t\t<label>\n\t\t\t");
291 print_escaped_for_xml(stdout, flag->
label);
292 fprintf(stdout,
"\n\t\t</label>\n");
296 fprintf(stdout,
"\t\t<suppress_required/>\n");
299 fprintf(stdout,
"\t\t<description>\n\t\t\t");
301 fprintf(stdout,
"\n\t\t</description>\n");
304 fprintf(stdout,
" \t\t<guisection>\n\t\t\t");
305 print_escaped_for_xml(stdout, flag->
guisection);
306 fprintf(stdout,
"\n\t\t</guisection>\n");
309 fprintf(stdout,
"\t</flag>\n");
324 fprintf(stdout,
"\t<flag name=\"%s\">\n",
"overwrite");
325 fprintf(stdout,
"\t\t<description>\n\t\t\t");
326 print_escaped_for_xml(
327 stdout,
_(
"Allow output files to overwrite existing files"));
328 fprintf(stdout,
"\n\t\t</description>\n");
329 fprintf(stdout,
"\t</flag>\n");
333 fprintf(stdout,
"\t<flag name=\"%s\">\n",
"help");
334 fprintf(stdout,
"\t\t<description>\n\t\t\t");
335 print_escaped_for_xml(stdout,
_(
"Print usage summary"));
336 fprintf(stdout,
"\n\t\t</description>\n");
337 fprintf(stdout,
"\t</flag>\n");
340 fprintf(stdout,
"\t<flag name=\"%s\">\n",
"verbose");
341 fprintf(stdout,
"\t\t<description>\n\t\t\t");
342 print_escaped_for_xml(stdout,
_(
"Verbose module output"));
343 fprintf(stdout,
"\n\t\t</description>\n");
344 fprintf(stdout,
"\t</flag>\n");
347 fprintf(stdout,
"\t<flag name=\"%s\">\n",
"quiet");
348 fprintf(stdout,
"\t\t<description>\n\t\t\t");
349 print_escaped_for_xml(stdout,
_(
"Quiet module output"));
350 fprintf(stdout,
"\n\t\t</description>\n");
351 fprintf(stdout,
"\t</flag>\n");
355 fprintf(stdout,
"</task>\n");
void G_free(void *)
Free allocated memory.
const char * G_program_name(void)
Return module name.
void G__print_keywords(FILE *fd, void(*format)(FILE *, const char *), int newline)
Print list of keywords (internal use only)
int G__uses_new_gisprompt(void)
void G__describe_option_rules_xml(FILE *fp)
Describe option rules in XML format (internal use only)
void G__usage_xml(void)
Print module usage description in XML format.
Structure that stores flag info.
Structure that stores option information.
const char * guidependency