parser_script.c 4.0 KB

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