Fixes
[opsoft.git] / silentbob / src / init.cxx
blob6265b5bb2a28e45d0b46382f12ec782c3c0896b9
1 /*
2 * (c) Oleg Puchinin 2006
3 * graycardinalster@gmail.com
4 *
5 */
7 #include <head.h>
8 #include <mod.h>
9 #include <temp_names.h>
11 #define SB_IMMUNE_FILE ".silent_bob/silent_bob_immune"
12 const char * c_ops [] = { "if", "else", "do", "while",
13 "switch", "case", "for", "return", NULL };
15 void mk_dirs ()
17 char m_buf[4096];
18 sprintf (m_buf, "%s/.silent_bob", ENV->home_dir);
19 mkdir (m_buf, 0700);
20 sprintf (m_buf, "%s/.silent_bob/plugins", ENV->home_dir);
21 mkdir (m_buf, 0700);
22 ENV->home_plugins = strdup (m_buf);
23 ENV->shared_plugins = strdup ("/usr/lib/silent_bob/");
26 int sb_init ()
28 char * sb_immune_path = CNEW (char, 256);
29 char * stdout_vbuf;
31 stdout_vbuf = CNEW (char, 4096 * 100);
32 setvbuf (stdout, stdout_vbuf, _IOFBF, 4096*100);
34 ENV = CNEW(env_t, 1);
35 memset (ENV, 0, sizeof (env_t));
37 ENV->d_cops = new EArray(10);
38 ENV->d_cops->push ((char **) c_ops);
39 ENV->d_depth = 6;
40 ENV->sb_flags = 0;
42 ENV->d_tags_file = NULL;
43 ENV->immune_list = NULL;
44 ENV->cgrep_A = 0;
45 ENV->cgrep_B = 0;
47 ENV->home_dir = getenv ("HOME");
48 ENV->tmp_files = CNEW (char, strlen (ENV->home_dir) + strlen (TMPNAME_FILES) + 20);
49 sprintf (ENV->tmp_files, "%s/.silent_bob/%s", ENV->home_dir, TMPNAME_FILES);
50 ENV->tmp_tags = CNEW (char, strlen (ENV->home_dir) + strlen (TMPNAME_TAGS) + 20);
51 sprintf (ENV->tmp_tags, "%s/.silent_bob/%s", ENV->home_dir, TMPNAME_TAGS);
52 ENV->debug_file = (char *) "/tmp/silent_bob.log";
54 mk_dirs ();
55 sprintf (sb_immune_path, "%s/.silent_bob/%s", getenv ("HOME"), SB_IMMUNE_FILE);
57 ENV->immune_list = new EArray;
58 ENV->immune_list->from_file (sb_immune_path);
59 ENV->immune_list->foreach ((Dfunc_t) chomp);
60 ENV->full_list = new EArray;
61 ENV->settings = new EHash;
63 ENV->d_stream_dbg = fopen ("/dev/null", "w");
64 ENV->max_proc = 1;
65 ENV->nproc = 1;
66 ENV->proc_list = new DJobs;
67 ENV->listOptions = new EList;
68 ENV->language = strdup ("C");
70 modding_init ();
71 return 0;