parser_script.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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->label)
  65. fprintf(fp, "#%% label: %s\n", flag->label);
  66. if (flag->description)
  67. fprintf(fp, "#%% description: %s\n", flag->description);
  68. if (flag->guisection)
  69. fprintf(fp, "#%% guisection: %s\n", flag->guisection);
  70. fprintf(fp, "#%%end\n");
  71. }
  72. }
  73. if (st->n_opts) {
  74. struct Option *opt;
  75. for (opt = &st->first_option; opt; opt = opt->next_opt) {
  76. switch (opt->type) {
  77. case TYPE_INTEGER:
  78. type = "integer";
  79. break;
  80. case TYPE_DOUBLE:
  81. type = "double";
  82. break;
  83. case TYPE_STRING:
  84. type = "string";
  85. break;
  86. default:
  87. type = "string";
  88. break;
  89. }
  90. fprintf(fp, "#%%option\n");
  91. fprintf(fp, "#%% key: %s\n", opt->key);
  92. fprintf(fp, "#%% type: %s\n", type);
  93. fprintf(fp, "#%% required: %s\n", opt->required ? "yes" : "no");
  94. fprintf(fp, "#%% multiple: %s\n", opt->multiple ? "yes" : "no");
  95. if (opt->options)
  96. fprintf(fp, "#%% options: %s\n", opt->options);
  97. if (opt->key_desc)
  98. fprintf(fp, "#%% key_desc: %s\n", opt->key_desc);
  99. if (opt->label)
  100. fprintf(fp, "#%% label: %s\n", opt->label);
  101. if (opt->description)
  102. fprintf(fp, "#%% description: %s\n", opt->description);
  103. if (opt->descriptions)
  104. fprintf(fp, "#%% descriptions: %s\n", opt->descriptions);
  105. if (opt->answer)
  106. fprintf(fp, "#%% answer: %s\n", opt->answer);
  107. if (opt->gisprompt)
  108. fprintf(fp, "#%% gisprompt: %s\n", opt->gisprompt);
  109. if (opt->guisection)
  110. fprintf(fp, "#%% guisection: %s\n", opt->guisection);
  111. if (opt->guidependency)
  112. fprintf(fp, "#%% guidependency: %s\n", opt->guidependency);
  113. fprintf(fp, "#%%end\n");
  114. }
  115. }
  116. }