2 * (c) Oleg Puchinin 2006
3 * graycardinalster@gmail.com
13 extern "C" struct env_t
*ENV
;
19 f
= fopen ("./gop.log", "a");
20 fprintf (f
, "Files: %i\n", ENV
->d_files
->get_size ());
25 int main (int argc
, char ** argv
)
34 ENV
->sb_cmd
= sb_prname (argv
[0]);
35 if (argc
== 1 && !ENV
->sb_cmd
) {
40 ENV
->d_files
= new EArray (128);
41 d_opts
= new EArray (argc
);
43 for (i
= 0; i
< argc
; i
++)
44 d_opts
->add (argv
[i
]);
46 for (i
= 1; i
< d_opts
->get_size (); i
++) {
47 opt
= d_opts
->get (i
);
48 if (opt
[0] != '-' && index (opt
, '=')) {
54 ENV
->d_files
->add (strdup (d_opts
->get (i
)));
58 if (! bob_options (d_opts
, i
))
61 if (! opts_kinds (d_opts
, i
))
64 if (d_opts
->get (i
)[0] == '-' && !validOption (d_opts
->get(i
))) {
65 fprintf (stderr
, "unknown option : %s\n", d_opts
->get (i
));
69 modding_optparse (&i
, 1);
70 } // for (i = 1; i < argc; i++)
72 n_files
= ENV
->d_files
->get_size ();
73 for (i
= 0; i
< argc
; i
++)
74 modding_optparse (&i
, 2);
76 if (NE (ENV
->language
, "C") && NE (ENV
->language
, "C++")) {
77 i
= modding_start (ENV
->sb_cmd
);
81 if (SB_FLGET (SB_FLCPP
))
82 ENV
->d_kinds
&= OT::Class
| OT::Struct
| OT::Function
83 | OT::Namespace
| OT::Define
;
85 switch (ENV
->sb_cmd
) {
87 make_ctags (ENV
->d_files
);
93 cgrep::cgrep (ENV
->d_files
);
96 call_tags (ENV
->d_files
);
99 tags (ENV
->d_files
, NULL
);
103 if (ENV
->sb_cmd
== cmd_makectags
||
104 ENV
->sb_cmd
== cmd_indent
||
105 ENV
->sb_cmd
== cmd_cgrep
) {
106 print_the_time (NULL
);
110 for (i
= 0; i
< n_files
; i
++) {
111 switch (ENV
->sb_cmd
) {
113 flist_main (ENV
->d_files
->get (i
));
116 THE_TT::the_tt_main (ENV
->d_files
->get(i
));
118 case cmd_give_structs
:
119 got_structs (ENV
->d_files
->get (i
));
122 kindsFile (ENV
->d_files
->get(i
), ENV
->d_kinds
);
127 if (ENV
->sb_cmd
== cmd_file
||
128 ENV
->sb_cmd
== cmd_the_tt
||
129 ENV
->sb_cmd
== cmd_give_structs
||
130 ENV
->sb_cmd
== cmd_kinds
)
133 ENV
->sb_cmd
= ENV
->sb_cmd
;
135 if (ENV
->sb_cmd
== cmd_the_tt
&& !n_files
) // THE_TT for stdin
136 THE_TT::the_tt_main ((char *) "-");
137 else if (ENV
->sb_cmd
== cmd_give_structs
&& !n_files
) {
138 got_structs ((char *) "-");
139 print_the_time (NULL
);
143 if ((ENV
->sb_cmd
== cmd_kinds
|| ENV
->sb_cmd
== cmd_file
) && !n_files
) {
146 while (fgets (d_buf
, 1023, stdin
)) {
148 switch (ENV
->sb_cmd
) {
150 kindsFile (d_buf
, ENV
->d_kinds
);
159 if (!SB_FLGET (SB_FLRTREE
))
160 call_tree (ENV
->d_files
->get (0), 0);
162 reverse_calltree (ENV
->d_files
->get (0));
165 print_the_time (NULL
);
167 if (ENV
->immune_list
)
168 delete ENV
->immune_list
;
170 ENV
->d_files
->foreach (free
);