-- init_compile_env
[silentbob2.git] / src / init.cxx
blob7cc47a3ac9714c8b3b6684ac674de50aac76179f
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 int ruby_init ();
16 int python_init ();
17 int perl_init ();
18 int grep_init ();
19 int editors_init ();
21 void mk_dirs ()
23 char m_buf[4096];
24 sprintf (m_buf, "%s/.silent_bob", ENV->home_dir);
25 mkdir (m_buf, 0700);
26 sprintf (m_buf, "%s/.silent_bob/plugins", ENV->home_dir);
27 mkdir (m_buf, 0700);
28 ENV->home_plugins = strdup (m_buf);
29 ENV->shared_plugins = strdup ("/usr/lib/silent_bob/");
32 int sb_init ()
34 char * sb_immune_path = CNEW (char, 256);
35 char * stdout_vbuf;
37 stdout_vbuf = CNEW (char, 4096 * 100);
38 setvbuf (stdout, stdout_vbuf, _IOFBF, 4096*100);
40 ENV = CNEW(env_t, 1);
41 memset (ENV, 0, sizeof (env_t));
43 ENV->d_cops = new EArray(10);
44 ENV->d_cops->push ((char **) c_ops);
45 ENV->d_depth = 6;
46 ENV->sb_flags = 0;
48 ENV->d_tags_file = NULL;
49 ENV->immune_list = NULL;
50 ENV->cgrep_A = 0;
51 ENV->cgrep_B = 0;
53 ENV->home_dir = getenv ("HOME");
54 ENV->tmp_files = CNEW (char, strlen (ENV->home_dir) + strlen (TMPNAME_FILES) + 20);
55 sprintf (ENV->tmp_files, "%s/.silent_bob/%s", ENV->home_dir, TMPNAME_FILES);
56 ENV->tmp_tags = CNEW (char, strlen (ENV->home_dir) + strlen (TMPNAME_TAGS) + 20);
57 sprintf (ENV->tmp_tags, "%s/.silent_bob/%s", ENV->home_dir, TMPNAME_TAGS);
58 ENV->debug_file = (char *) "/tmp/silent_bob.log";
60 mk_dirs ();
61 sprintf (sb_immune_path, "%s/.silent_bob/%s", getenv ("HOME"), SB_IMMUNE_FILE);
63 ENV->immune_list = new EArray;
64 ENV->immune_list->from_file (sb_immune_path);
65 ENV->immune_list->foreach ((Dfunc_t) chomp);
66 ENV->full_list = new EArray;
67 ENV->settings = new EHash;
69 ENV->d_stream_dbg = fopen ("/dev/null", "w");
70 ENV->max_proc = 1;
71 ENV->nproc = 1;
72 ENV->proc_list = new DJobs;
73 ENV->listOptions = new EList;
74 ENV->language = strdup ("C");
76 modding_init ();
77 ruby_init ();
78 python_init ();
79 perl_init ();
80 grep_init ();
81 editors_init ();
83 return 0;