parser_script.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*!
  2. \file lib/gis/parser_script.c
  3. \brief GIS Library - Argument parsing functions (script)
  4. (C) 2001-2009, 2011 by the GRASS Development Team
  5. This program is free software under the GNU General Public License
  6. (>=v2). Read the file COPYING that comes with GRASS for details.
  7. \author Original author CERL
  8. \author Soeren Gebbert added Dec. 2009 WPS process_description document
  9. */
  10. #include <stdio.h>
  11. #include <grass/gis.h>
  12. #include "parser_local_proto.h"
  13. /*!
  14. \brief Generate script-like output
  15. */
  16. void G__script(void)
  17. {
  18. FILE *fp = stdout;
  19. char *type;
  20. fprintf(fp,
  21. "############################################################################\n");
  22. fprintf(fp, "#\n");
  23. fprintf(fp, "# MODULE: %s_wrapper\n", G_program_name());
  24. fprintf(fp, "# AUTHOR(S): %s\n", G_whoami());
  25. fprintf(fp, "# PURPOSE: \n");
  26. fprintf(fp, "# COPYRIGHT: (C) %s by %s, and The GRASS Development Team\n",
  27. GRASS_VERSION_DATE, G_whoami());
  28. fprintf(fp, "#\n");
  29. fprintf(fp,
  30. "# This program is free software; you can redistribute it and/or modify\n");
  31. fprintf(fp,
  32. "# it under the terms of the GNU General Public License as published by\n");
  33. fprintf(fp,
  34. "# the Free Software Foundation; either version 2 of the License, or\n");
  35. fprintf(fp, "# (at your option) any later version.\n");
  36. fprintf(fp, "#\n");
  37. fprintf(fp,
  38. "# This program is distributed in the hope that it will be useful,\n");
  39. fprintf(fp,
  40. "# but WITHOUT ANY WARRANTY; without even the implied warranty of\n");
  41. fprintf(fp,
  42. "# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n");
  43. fprintf(fp, "# GNU General Public License for more details.\n");
  44. fprintf(fp, "#\n");
  45. fprintf(fp,
  46. "############################################################################\n\n");
  47. fprintf(fp, "#%%module\n");
  48. if (st->module_info.label)
  49. fprintf(fp, "#%% label: %s\n", st->module_info.label);
  50. if (st->module_info.description)
  51. fprintf(fp, "#%% description: %s\n", st->module_info.description);
  52. if (st->module_info.keywords) {
  53. fprintf(fp, "#%% keywords: ");
  54. G__print_keywords(fp, NULL);
  55. fprintf(fp, "\n");
  56. }
  57. fprintf(fp, "#%%end\n");
  58. if (st->n_flags) {
  59. struct Flag *flag;
  60. for (flag = &st->first_flag; flag; flag = flag->next_flag) {
  61. fprintf(fp, "#%%flag\n");
  62. fprintf(fp, "#%% key: %c\n", flag->key);
  63. if (flag->suppress_required)
  64. fprintf(fp, "#%% suppress_required: yes\n");
  65. if (flag->label)
  66. fprintf(fp, "#%% label: %s\n", flag->label);
  67. if (flag->description)
  68. fprintf(fp, "#%% description: %s\n", flag->description);
  69. if (flag->guisection)
  70. fprintf(fp, "#%% guisection: %s\n", flag->guisection);
  71. fprintf(fp, "#%%end\n");
  72. }
  73. }
  74. if (st->n_opts) {
  75. struct Option *opt;
  76. for (opt = &st->first_option; opt; opt = opt->next_opt) {
  77. switch (opt->type) {
  78. case TYPE_INTEGER:
  79. type = "integer";
  80. break;
  81. case TYPE_DOUBLE:
  82. type = "double";
  83. break;
  84. case TYPE_STRING:
  85. type = "string";
  86. break;
  87. default:
  88. type = "string";
  89. break;
  90. }
  91. fprintf(fp, "#%%option\n");
  92. fprintf(fp, "#%% key: %s\n", opt->key);
  93. fprintf(fp, "#%% type: %s\n", type);
  94. fprintf(fp, "#%% required: %s\n", opt->required ? "yes" : "no");
  95. fprintf(fp, "#%% multiple: %s\n", opt->multiple ? "yes" : "no");
  96. if (opt->options)
  97. fprintf(fp, "#%% options: %s\n", opt->options);
  98. if (opt->key_desc)
  99. fprintf(fp, "#%% key_desc: %s\n", opt->key_desc);
  100. if (opt->label)
  101. fprintf(fp, "#%% label: %s\n", opt->label);
  102. if (opt->description)
  103. fprintf(fp, "#%% description: %s\n", opt->description);
  104. if (opt->descriptions)
  105. fprintf(fp, "#%% descriptions: %s\n", opt->descriptions);
  106. if (opt->answer)
  107. fprintf(fp, "#%% answer: %s\n", opt->answer);
  108. if (opt->gisprompt)
  109. fprintf(fp, "#%% gisprompt: %s\n", opt->gisprompt);
  110. if (opt->guisection)
  111. fprintf(fp, "#%% guisection: %s\n", opt->guisection);
  112. if (opt->guidependency)
  113. fprintf(fp, "#%% guidependency: %s\n", opt->guidependency);
  114. fprintf(fp, "#%%end\n");
  115. }
  116. }
  117. }