parser_script.c 3.9 KB

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