current version
[opsoft_test.git] / silentbob / plugins / plugin_xml_project.cxx
blobe9606025e96c40f81f88a06c8ea575a79c45d0f6
1 /*
2 * (c) Oleg Puchinin 2007
3 * graycardinalster@gmail.com
5 */
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <unistd.h>
10 #include <fcntl.h>
11 #include <gclib/gclib.h>
12 #include <gclib/gclib_c.h>
13 #include <mod.h>
14 #include <head.h>
15 #include <dbg.h>
17 extern "C" DArray * plugin_init (struct env_t *env);
18 struct env_t *ENV;
19 char * __xml_project_name;
20 char * __xml_type;
21 EHash * __compile_env;
23 char xml_project_opt (DArray * d_opts, int * pos)
25 int count;
26 char * S;
28 if (! d_opts || ! pos)
29 return 0;
31 count = d_opts->get_size ();
32 S = d_opts->get (*pos);
34 if (EQ (S, "--xml-bin") ||
35 EQ (S, "--xml-program")) {
36 if (++(*pos) >= count)
37 return 1;
38 __xml_type = "программа";
39 __xml_project_name = d_opts->get (*pos);
40 return 1;
43 if (EQ (S, "--xml-shared")) {
44 if (++(*pos) >= count)
45 return 1;
46 __xml_type = "шаровая_лайба";
47 __xml_project_name = d_opts->get (*pos);
48 return 1;
51 return 0;
54 void xmlDump ()
56 printf ("\t<модуль имя=\"%s\" тип=\"%s\">\n", __xml_project_name, __xml_type);
57 printf ("\t<свойство CC=\"%s\" />\n", (*__compile_env)["CC"]);
58 printf ("\t<свойство CXX=\"%s\" />\n", (*__compile_env)["CXX"]);
59 printf ("\t<свойство OPTS=\"%s\" />\n", (*__compile_env)["OPTS"]);
60 printf ("\t<свойство INCLUDE=\"%s\" />\n", (*__compile_env)["INCLUDE"]);
61 printf ("\t<свойство LIBS=\"%s\" />\n", (*__compile_env)["LIBS"]);
62 printf ("\t<свойство LDFLAGS=\"%s\" />\n", (*__compile_env)["LDFLAGS"]);
64 printf ("\t<исходники>\n");
65 for (int i = 0; i < ENV->d_files->get_size (); ++i)
66 printf ("\t\t<файл имя=\"%s\" />\n", ENV->d_files->get (i));
67 printf ("\t</исходники>\n");
68 printf ("\t</модуль>\n");
71 char xml_project_opt2 (DArray * d_opts, int * pos)
73 char * S;
75 if (! d_opts || ! pos)
76 return 0;
78 S = d_opts->get (*pos);
79 if (EQ (S, "--xml-bin") ||
80 EQ (S, "--xml-program") ||
81 EQ (S, "--xml-shared")) {
82 __compile_env = bob_init_compile_env ();
83 xmlDump ();
84 exit (0);
87 return 0;
90 void xml_project_info ()
92 printf ("XML Project.\n");
93 printf ("Version: 1.0\n");
94 printf ("options: --xml-project --xml-bin --xml-shared\n");
97 DArray * plugin_init (struct env_t *env)
99 DArray * Ret;
100 struct mod_feature * pm;
102 ENV = env;
103 Ret = new DArray (1);
104 pm = CNEW (mod_feature, 1);
105 memset (pm, 0, sizeof (mod_feature));
106 pm->mod.Type = TYPE_FEATURE;
107 pm->mod.Version = strdup ("1.0");
108 pm->mod.short_info = xml_project_info;
109 pm->opt = xml_project_opt;
110 pm->opt2 = xml_project_opt2;
112 Ret->add (LPCHAR (pm));
113 return Ret;