\n\n");
fprintf(stdout,
"

\n");
fprintf(stdout, "\n\n");
fprintf(stdout, "
%s
\n", _("NAME"));
fprintf(stdout, "
%s ", st->pgm_name);
if (st->module_info.label || st->module_info.description)
fprintf(stdout, " - ");
if (st->module_info.label)
fprintf(stdout, "%s
\n", st->module_info.label);
if (st->module_info.description)
fprintf(stdout, "%s\n", st->module_info.description);
fprintf(stdout, "
%s
\n", _("KEYWORDS"));
if (st->module_info.keywords) {
G__print_keywords(stdout, print_escaped_for_html_keywords);
fprintf(stdout, "\n");
}
fprintf(stdout, "
%s
\n", _("SYNOPSIS"));
fprintf(stdout, "
%s
\n", st->pgm_name);
fprintf(stdout, "
%s --help\n", st->pgm_name);
fprintf(stdout, "
%s", st->pgm_name);
/* print short version first */
if (st->n_flags) {
flag = &st->first_flag;
fprintf(stdout, " [-");
while (flag != NULL) {
fprintf(stdout, "%c", flag->key);
flag = flag->next_flag;
}
fprintf(stdout, "] ");
}
else
fprintf(stdout, " ");
if (st->n_opts) {
opt = &st->first_option;
while (opt != NULL) {
if (opt->key_desc != NULL)
type = opt->key_desc;
else
switch (opt->type) {
case TYPE_INTEGER:
type = "integer";
break;
case TYPE_DOUBLE:
type = "float";
break;
case TYPE_STRING:
type = "string";
break;
default:
type = "string";
break;
}
if (!opt->required)
fprintf(stdout, " [");
fprintf(stdout, "%s=%s", opt->key, type);
if (opt->multiple) {
fprintf(stdout, "[,%s,...]", type);
}
if (!opt->required)
fprintf(stdout, "] ");
opt = opt->next_opt;
fprintf(stdout, " ");
}
}
if (new_prompt)
fprintf(stdout, " [--overwrite] ");
fprintf(stdout, " [--help] ");
fprintf(stdout, " [--verbose] ");
fprintf(stdout, " [--quiet] ");
fprintf(stdout, " [--ui] ");
fprintf(stdout, "\n
\n");
/* now long version */
fprintf(stdout, "\n");
fprintf(stdout, "
\n");
fprintf(stdout, "
%s:
\n", _("Flags"));
fprintf(stdout, "
\n");
if (st->n_flags) {
flag = &st->first_flag;
while (st->n_flags && flag != NULL) {
fprintf(stdout, "- -%c
\n", flag->key);
if (flag->label) {
fprintf(stdout, "- ");
fprintf(stdout, "%s", flag->label);
fprintf(stdout, "
\n");
}
if (flag->description) {
fprintf(stdout, "- ");
fprintf(stdout, "%s", flag->description);
fprintf(stdout, "
\n");
}
flag = flag->next_flag;
fprintf(stdout, "\n");
}
}
if (new_prompt) {
fprintf(stdout, "- --overwrite
\n");
fprintf(stdout, "- %s
\n",
_("Allow output files to overwrite existing files"));
}
/* these flags are always available */
fprintf(stdout, "- --help
\n");
fprintf(stdout, "- %s
\n", _("Print usage summary"));
fprintf(stdout, "- --verbose
\n");
fprintf(stdout, "- %s
\n", _("Verbose module output"));
fprintf(stdout, "- --quiet
\n");
fprintf(stdout, "- %s
\n", _("Quiet module output"));
fprintf(stdout, "- --ui
\n");
fprintf(stdout, "- %s
\n", _("Force launching GUI dialog"));
fprintf(stdout, "
\n");
fprintf(stdout, "
\n");
fprintf(stdout, "\n");
fprintf(stdout, "
\n");
if (st->n_opts) {
opt = &st->first_option;
fprintf(stdout, "
%s:
\n", _("Parameters"));
fprintf(stdout, "
\n");
while (opt != NULL) {
/* TODO: make this a enumeration type? */
if (opt->key_desc != NULL)
type = opt->key_desc;
else
switch (opt->type) {
case TYPE_INTEGER:
type = "integer";
break;
case TYPE_DOUBLE:
type = "float";
break;
case TYPE_STRING:
type = "string";
break;
default:
type = "string";
break;
}
fprintf(stdout, "- %s=%s", opt->key, type);
if (opt->multiple) {
fprintf(stdout, "[,%s,...]", type);
}
fprintf(stdout, "");
if (opt->required) {
fprintf(stdout, " [required]");
}
fprintf(stdout, "
\n");
if (opt->label) {
fprintf(stdout, "- ");
print_escaped_for_html(stdout, opt->label);
fprintf(stdout, "
\n");
}
if (opt->description) {
fprintf(stdout, "- ");
print_escaped_for_html(stdout, opt->description);
fprintf(stdout, "
\n");
}
if (opt->options) {
fprintf(stdout, "- %s: ", _("Options"));
print_escaped_for_html_options(stdout, opt->options);
fprintf(stdout, "
\n");
}
if (opt->def) {
fprintf(stdout, "- %s: ", _("Default"));
print_escaped_for_html(stdout, opt->def);
fprintf(stdout, "
\n");
}
if (opt->descs) {
int i = 0;
while (opt->opts[i]) {
if (opt->descs[i]) {
fprintf(stdout, "- ");
if (opt->gisprompt) {
char *thumbnails = NULL;
if (strcmp(opt->gisprompt,
"old,colortable,colortable") == 0)
thumbnails = "colortables";
else if (strcmp(opt->gisprompt,
"old,barscale,barscale") == 0)
thumbnails = "barscales";
else if (strcmp(opt->gisprompt,
"old,northarrow,northarrow") == 0)
thumbnails = "northarrows";
if (thumbnails)
fprintf(stdout, "
",
thumbnails, opt->opts[i], opt->opts[i]);
}
print_escaped_for_html(stdout, opt->opts[i]);
fprintf(stdout, ": ");
print_escaped_for_html(stdout, opt->descs[i]);
fprintf(stdout, " \n");
}
i++;
}
}
opt = opt->next_opt;
fprintf(stdout, "\n");
}
fprintf(stdout, "
\n");
}
fprintf(stdout, "
\n");
fprintf(stdout, "\n\n");
}
/*!
* \brief Format text for HTML output
*/
#define do_escape(c,escaped) case c: fputs(escaped,f);break
void print_escaped_for_html(FILE * f, const char *str)
{
const char *s;
for (s = str; *s; s++) {
switch (*s) {
do_escape('&', "&");
do_escape('<', "<");
do_escape('>', ">");
do_escape('\n', "
");
do_escape('\t', " ");
default:
fputc(*s, f);
}
}
}
void print_escaped_for_html_options(FILE * f, const char *str)
{
const char *s;
for (s = str; *s; s++) {
switch (*s) {
do_escape('&', "&");
do_escape('<', "<");
do_escape('>', ">");
do_escape('\n', "
");
do_escape('\t', " ");
do_escape(',', ", ");
default:
fputc(*s, f);
}
}
}
void print_escaped_for_html_keywords(FILE * f, const char * str)
{
/* generate HTML links */
/* HTML link only for second keyword */
if (st->n_keys > 1 &&
strcmp(st->module_info.keywords[1], str) == 0) {
const char *s;
/* TODO: fprintf(f, _("topic: ")); */
fprintf(f, "
%s", str);
}
else { /* first and other than second keyword */
if (st->n_keys > 0 &&
strcmp(st->module_info.keywords[0], str) == 0) {
/* command family */
const char *s;
fprintf(f, "
%s", str);
} else {
/* keyword index */
if (st->n_keys > 0 &&
strcmp(st->module_info.keywords[2], str) == 0) {
/* TODO: fprintf(f, _("keywords: ")); */
fprintf(f, "
%s", str, str);
} else {
fprintf(f, "
%s", str, str);
}
}
}
}
#undef do_escape