parser_script.c 3.5 KB

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