2 * (c) Oleg Puchinin 2006
3 * graycardinalster@gmail.com
13 extern "C" struct env_t
*ENV
;
16 int main (int argc
, char ** argv
)
25 ENV
->sb_cmd
= sb_prname (argv
[0]);
26 if (argc
== 1 && !ENV
->sb_cmd
) {
31 ENV
->d_files
= new EArray (128);
32 d_opts
= new EArray (argc
);
34 for (i
= 0; i
< argc
; i
++)
35 d_opts
->add (argv
[i
]);
37 for (i
= 1; i
< d_opts
->get_size (); i
++) {
38 opt
= d_opts
->get (i
);
39 if (opt
[0] != '-' && index (opt
, '=')) {
45 ENV
->d_files
->add (strdup (d_opts
->get (i
)));
49 if (! opts_funcs (d_opts
, i
))
52 if (! opts_settings (d_opts
, i
))
55 if (! opts_kinds (d_opts
, i
))
58 if (d_opts
->get (i
)[0] == '-' && !validOption (d_opts
->get(i
))) {
59 fprintf (stderr
, "unknown option : %s\n", d_opts
->get (i
));
63 modding_optparse (&i
, 1);
64 } // for (i = 1; i < argc; i++)
66 n_files
= ENV
->d_files
->get_size ();
67 for (i
= 0; i
< argc
; i
++)
68 modding_optparse (&i
, 2);
70 if (NE (ENV
->language
, "C") && NE (ENV
->language
, "C++")) {
71 i
= modding_start (ENV
->sb_cmd
);
75 if (SB_FLGET (SB_FLCPP
))
76 ENV
->d_kinds
&= OT::Class
| OT::Struct
| OT::Function
77 | OT::Namespace
| OT::Define
;
79 switch (ENV
->sb_cmd
) {
81 make_ctags (ENV
->d_files
);
87 cgrep::cgrep (ENV
->d_files
);
90 call_tags (ENV
->d_files
);
93 tags (ENV
->d_files
, NULL
);
97 if (ENV
->sb_cmd
== cmd_makectags
||
98 ENV
->sb_cmd
== cmd_indent
||
99 ENV
->sb_cmd
== cmd_cgrep
) {
100 print_the_time (NULL
);
104 for (i
= 0; i
< n_files
; i
++) {
105 switch (ENV
->sb_cmd
) {
107 flist_main (ENV
->d_files
->get (i
));
110 THE_TT::the_tt_main (ENV
->d_files
->get(i
));
112 case cmd_give_structs
:
113 got_structs (ENV
->d_files
->get (i
));
116 kindsFile (ENV
->d_files
->get(i
), ENV
->d_kinds
);
121 if (ENV
->sb_cmd
== cmd_file
||
122 ENV
->sb_cmd
== cmd_the_tt
||
123 ENV
->sb_cmd
== cmd_give_structs
||
124 ENV
->sb_cmd
== cmd_kinds
)
128 ENV
->sb_cmd
= ENV
->sb_cmd
;
130 if (ENV
->sb_cmd
== cmd_the_tt
&& !n_files
) // THE_TT for stdin
131 THE_TT::the_tt_main ((char *) "-");
132 else if (ENV
->sb_cmd
== cmd_give_structs
&& !n_files
) {
133 got_structs ((char *) "-");
134 print_the_time (NULL
);
138 if ((ENV
->sb_cmd
== cmd_kinds
|| ENV
->sb_cmd
== cmd_file
) && !n_files
) {
141 while (fgets (d_buf
, 1023, stdin
)) {
143 switch (ENV
->sb_cmd
) {
145 kindsFile (d_buf
, ENV
->d_kinds
);
154 if (!SB_FLGET (SB_FLRTREE
))
155 call_tree (ENV
->d_files
->get (0), 0);
157 reverse_calltree (ENV
->d_files
->get (0));
160 print_the_time (NULL
);
162 if (ENV
->immune_list
)
163 delete ENV
->immune_list
;
165 ENV
->d_files
->foreach (free
);