+ Fixes
[opsoft.git] / silentbob / src / file.cxx
blob57cbeaa9678f2e4caf8d522058d47f2052a2b734
1 /*
2 * (c) Oleg Puchinin 2006
3 * graycardinalster@gmail.com
4 *
5 */
7 #include <head.h>
8 #include <wit.h>
9 #include <the_tt.h>
11 extern char * d_lpsz_operators[]; // from nogui_indent.cpp
13 // $ silent_bob --file
14 // Get functions list from file.
15 void flist_main (char * d_file)
17 struct tt_state_t * d_tt_state;
18 EArray d_operators;
19 int d_len = 0;
20 char *d_out,*d_ptr;
21 char ch;
22 int brace_depth = 0;
24 if (access (d_file, R_OK) != F_OK) {
25 printf ("/*** %s ***/\n", d_file);
26 perror ("");
27 return;
30 d_tt_state = CNEW (tt_state_t, 1);
31 d_tt_state->fileName = strdup (d_file);
32 d_ptr = THE_TT::do_tt_file (d_tt_state);
34 d_ptr = do_tt(d_tt_state);
36 printf ("/*** %s ***/\n", d_file);
37 while (true) {
38 ch = t_op (&d_ptr, &d_out, true);
40 if (ch == 0)
41 break;
43 d_len = strlen (d_out);
45 if (!brace_depth && d_operators.snfind (d_out) == -1) {
46 if (what_is_this (d_out, ch) == OT::Function)
47 printf ("%s;\n", d_out);
50 if (ch == '{')
51 brace_depth ++;
53 if (ch == '}')
54 brace_depth --;
56 if (brace_depth < 0)
57 brace_depth = 0;
60 fputc ('\n', stdout);
61 free_tt_state (d_tt_state);