Very old versions for history.
[opsoft_archive.git] / silentbob / silent_bob-1.2 / src / plugins / plugin_aap-program.cpp
blobe28dd044074d09e876f2780d1aec32a443c73324
1 /*
2 * (c) Oleg Puchinin 2006
3 * graycardinalster@gmail.com
5 */
7 #include <gclib/gclib.h>
8 #include <sys/wait.h>
9 #include "../mod.h"
10 #include "../head.h"
11 #include "../dbg.h"
13 extern "C" DArray * plugin_init (struct env_t *env);
14 int __aap_vars;
16 void __do_aap_program (char * pr_name)
18 DArray * d_files;
19 int count;
20 int i = 0;
22 d_files = ENV->d_files;
23 if (! d_files || d_files->get_size () <= 0)
24 return;
26 count = d_files->get_size ();
27 if (__aap_vars) {
28 printf ("CC=gcc\n");
29 printf ("CXX=g++\n");
30 printf ("CFLAGS=-O3 -Wall -pipe\n");
31 printf ("CXXFLAGS=$CFLAGS\n");
33 printf (":program %s : %s\n", pr_name, d_files->get (i));
35 for (i = 1; i < count; ++i)
36 printf ("\t%s\n", d_files->get (i));
38 printf ("\n");
41 char aap_program_opt2 (DArray * d_opts, int * pos)
43 int count;
44 char m_buf[512];
45 char * S;
47 if (! d_opts || ! pos)
48 return 0;
50 count = d_opts->get_size ();
51 S = d_opts->get (*pos);
52 if (EQ (S, "--aap-program")) {
53 if (++(*pos) >= count)
54 return 0;
55 S = d_opts->get (*pos);
56 __do_aap_program (S);
57 exit (0);
58 return 1;
61 if (EQ (S, "--aap-vars")) {
62 __aap_vars = 1;
63 return 1;
66 return 0;
69 char aap_program_opt (DArray * d_opts, int * pos)
71 int count;
72 char *S;
74 if (! d_opts || ! pos)
75 return 0;
77 count = d_opts->get_size ();
78 S = d_opts->get (*pos);
79 if (EQ (S, "--aap-program")) {
80 if (++(*pos) >= count)
81 return 0;
82 return 1;
84 return 0;
87 void aap_program_info ()
89 printf ("AAP file.\n");
90 printf ("Version: 1.0\n");
91 printf ("options: --aap-program --aap-vars\n");
94 DArray * plugin_init (struct env_t *env)
96 struct mod_feature * pm;
97 DArray * Ret;
99 ENV = env;
100 Ret = new DArray (1);
101 pm = CNEW (mod_feature, 1);
102 memset (pm, 0, sizeof (mod_feature));
103 pm->mod.Type = TYPE_FEATURE;
104 pm->mod.Version = strdup ("0.1");
105 pm->mod.info = aap_program_info;
106 pm->opt = aap_program_opt;
107 pm->opt2 = aap_program_opt2;
109 Ret->add (LPCHAR (pm));
110 __aap_vars = 0;
111 return Ret;