Very old versions for history.
[opsoft_archive.git] / silentbob / silent_bob / flist.cpp
blob3618546f1d608db3b705efe7f8c342bb3f0f8138
1 /*
2 * (c) Oleg Puchinin 2006
3 * graycardinalster@gmail.com
4 *
5 */
7 #include "functions.h"
9 extern char * d_lpsz_operators[]; // from nogui_indent.cpp
11 char * flist_iter (char * d_ptr, char * d_name, bool b_repair)
13 EArray d_operators;
14 int d_len = 0;
15 char *d_out;
16 char ch;
18 d_operators.push (d_lpsz_operators);
20 while (true) {
21 ch = t_op (&d_ptr, &d_out);
22 d_len = strlen (d_out);
24 if (ch == 0)
25 break;
27 if (d_operators.snfind (d_out) != -1)
28 continue;
30 if (what_is_this (d_out, ch) == GLOBAL_TYPE_FUNCTION) {
31 if (b_repair)
32 d_out[d_len] = ch;
33 return d_out;
37 return NULL;
40 // $ silent_bob --file
41 // Get functions list from file.
42 void flist_main (char * d_file)
44 struct tt_state_t * d_tt_state;
45 EArray d_operators;
46 char * d_ptr;
48 if (access (d_file, R_OK) != F_OK) {
49 printf ("/*** %s ***/\n", d_file);
50 perror ("");
51 return;
54 d_tt_state = CNEW (tt_state_t, 1);
55 d_tt_state->d_file_name = d_file;
56 d_ptr = THE_TT::do_tt_file (d_tt_state);
58 d_ptr = do_tt(d_tt_state);
60 printf ("/*** %s ***/\n", d_file);
61 while (true) {
62 d_ptr = flist_iter (d_ptr, NULL, false);
63 if (d_ptr == NULL)
64 break;
66 printf ("%s{\n", d_ptr);
67 d_ptr += strlen (d_ptr);
68 d_ptr++;
71 fputc ('\n', stdout);
72 THE_TT::free_tt_state (d_tt_state);