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)
59 char *src = (
char *) str;
60 size_t srclen = strlen(src);
61 size_t dstlen = srclen * 4 + 1;
67 ret = iconv(conv, (
char **)&src, &srclen, &dst, &dstlen);
68 if (ret != (
size_t) -1 && srclen == 0) {
95 if (conv != (iconv_t) -1)
110 const char *encoding;
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) {
186 fprintf(stdout,
"\t<parameter " 190 "multiple=\"%s\">\n",
197 fprintf(stdout,
"\t\t<label>\n\t\t\t");
198 print_escaped_for_xml(stdout, opt->
label);
199 fprintf(stdout,
"\n\t\t</label>\n");
203 fprintf(stdout,
"\t\t<description>\n\t\t\t");
205 fprintf(stdout,
"\n\t\t</description>\n");
209 fprintf(stdout,
"\t\t<keydesc>\n");
212 s = strtok(top,
",");
213 for (i = 1; s !=
NULL; i++) {
214 fprintf(stdout,
"\t\t\t<item order=\"%d\">", i);
215 print_escaped_for_xml(stdout, s);
216 fprintf(stdout,
"</item>\n");
217 s = strtok(
NULL,
",");
219 fprintf(stdout,
"\t\t</keydesc>\n");
224 const char *atts[] = {
"age",
"element",
"prompt",
NULL };
227 s = strtok(top,
",");
228 fprintf(stdout,
"\t\t<gisprompt ");
229 for (i = 0; s !=
NULL && atts[i] !=
NULL; i++) {
230 fprintf(stdout,
"%s=\"%s\" ", atts[i], s);
231 s = strtok(
NULL,
",");
233 fprintf(stdout,
"/>\n");
238 fprintf(stdout,
"\t\t<default>\n\t\t\t");
239 print_escaped_for_xml(stdout, opt->
def);
240 fprintf(stdout,
"\n\t\t</default>\n");
249 fprintf(stdout,
"\t\t<values>\n");
250 while (opt->
opts[i]) {
251 fprintf(stdout,
"\t\t\t<value>\n");
252 fprintf(stdout,
"\t\t\t\t<name>");
253 print_escaped_for_xml(stdout, opt->
opts[i]);
254 fprintf(stdout,
"</name>\n");
256 fprintf(stdout,
"\t\t\t\t<description>");
257 print_escaped_for_xml(stdout, opt->
descs[i]);
258 fprintf(stdout,
"</description>\n");
260 fprintf(stdout,
"\t\t\t</value>\n");
263 fprintf(stdout,
"\t\t</values>\n");
266 fprintf(stdout,
"\t\t<guisection>\n\t\t\t");
267 print_escaped_for_xml(stdout, opt->
guisection);
268 fprintf(stdout,
"\n\t\t</guisection>\n");
271 fprintf(stdout,
"\t\t<guidependency>\n\t\t\t");
273 fprintf(stdout,
"\n\t\t</guidependency>\n");
281 fprintf(stdout,
"\t</parameter>\n");
287 flag = &
st->first_flag;
288 while (flag !=
NULL) {
289 fprintf(stdout,
"\t<flag name=\"%c\">\n", flag->
key);
292 fprintf(stdout,
"\t\t<label>\n\t\t\t");
293 print_escaped_for_xml(stdout, flag->
label);
294 fprintf(stdout,
"\n\t\t</label>\n");
298 fprintf(stdout,
"\t\t<suppress_required/>\n");
301 fprintf(stdout,
"\t\t<description>\n\t\t\t");
303 fprintf(stdout,
"\n\t\t</description>\n");
306 fprintf(stdout,
" \t\t<guisection>\n\t\t\t");
307 print_escaped_for_xml(stdout, flag->
guisection);
308 fprintf(stdout,
"\n\t\t</guisection>\n");
311 fprintf(stdout,
"\t</flag>\n");
326 fprintf(stdout,
"\t<flag name=\"%s\">\n",
"overwrite");
327 fprintf(stdout,
"\t\t<description>\n\t\t\t");
328 print_escaped_for_xml(stdout,
329 _(
"Allow output files to overwrite existing files"));
330 fprintf(stdout,
"\n\t\t</description>\n");
331 fprintf(stdout,
"\t</flag>\n");
335 fprintf(stdout,
"\t<flag name=\"%s\">\n",
"help");
336 fprintf(stdout,
"\t\t<description>\n\t\t\t");
337 print_escaped_for_xml(stdout,
_(
"Print usage summary"));
338 fprintf(stdout,
"\n\t\t</description>\n");
339 fprintf(stdout,
"\t</flag>\n");
342 fprintf(stdout,
"\t<flag name=\"%s\">\n",
"verbose");
343 fprintf(stdout,
"\t\t<description>\n\t\t\t");
344 print_escaped_for_xml(stdout,
_(
"Verbose module output"));
345 fprintf(stdout,
"\n\t\t</description>\n");
346 fprintf(stdout,
"\t</flag>\n");
349 fprintf(stdout,
"\t<flag name=\"%s\">\n",
"quiet");
350 fprintf(stdout,
"\t\t<description>\n\t\t\t");
351 print_escaped_for_xml(stdout,
_(
"Quiet module output"));
352 fprintf(stdout,
"\n\t\t</description>\n");
353 fprintf(stdout,
"\t</flag>\n");
357 fprintf(stdout,
"</task>\n");
int G__uses_new_gisprompt(void)
const char * guidependency
const char * G_program_name(void)
Return module name.
void G__usage_xml(void)
Print module usage description in XML format.
void G_free(void *)
Free allocated memory.
Structure that stores flag info.
void G__describe_option_rules_xml(FILE *fp)
Describe option rules in XML format (internal use only)
Structure that stores option information.
void G__print_keywords(FILE *fd, void(*format)(FILE *, const char *))
Print list of keywords (internal use only)