current version
[opsoft_test.git] / silentbob / src / opts_settings.cxx
blob28adb6ad4aee287630077139d7a55ed77f755094
1 /*
2 * (c) Oleg Puchinin 2006,2007
3 * graycardinalster@gmail.com
5 */
7 #include <head.h>
9 int opts_settings (DArray * d_opts, int & i)
11 int argc;
13 if (! d_opts)
14 return 0;
16 argc = d_opts->get_size ();
18 if (d_opts->get (i)[0] != '-') {
19 ENV->d_files->add (strdup (d_opts->get (i)));
20 return 0;
23 if (EQ (d_opts->get (i), "--verbose")) {
24 SB_FLSET (SB_FLVERBOSE);
25 return 0;
28 if (EQ (d_opts->get (i), "-u")) {
29 SB_FLSET (SB_FLRTREE);
30 return 0;
33 if (EQ (d_opts->get (i), "--linear") ||
34 EQ (d_opts->get (i), "-l")) {
35 SB_FLSET (SB_FLLINEAR);
36 return 0;
39 if (EQ (d_opts->get (i), "-C") && i < argc) {
40 ++i;
41 chdir (d_opts->get (i));
42 return 0;
45 if (EQ (d_opts->get (i), "--linux")) {
46 chdir ("/usr/src/linux");
47 return 0;
50 if (EQ (d_opts->get (i), "--debug")) {
51 SB_FLSET (SB_FLDEBUG);
52 return 0;
55 if (EQ (d_opts->get (i), "--simulate")) {
56 Dtimer ();
57 SB_FLSET (SB_FLSIMULATE);
58 return 0;
61 if (EQ (d_opts->get (i), "--no-links")) {
62 SB_FLSET (SB_FLNOLINKS);
63 return 0;
66 if (EQ (d_opts->get (i), "-a") || EQ (d_opts->get (i), "--all")) {
67 SB_FLSET (SB_FLALL);
68 return 0;
71 if (EQ (d_opts->get (i), "--test") || EQ (d_opts->get (i), "-t")) {
72 SB_FLSET (SB_FLTEST);
73 return 0;
76 if (EQ (d_opts->get (i), "--ctags-append")) {
77 SB_FLSET (SB_FLCTAGSAPPEND);
78 return 0;
81 if (EQ (d_opts->get (i), "-A")) {
82 if (++i >= argc)
83 return 0;
85 ENV->cgrep_A = atoi (d_opts->get (i));
86 return 0;
89 if (EQ (d_opts->get (i), "-B")) {
90 if (++i >= argc)
91 return 0;
93 ENV->cgrep_B = atoi (d_opts->get (i));
94 return 0;
97 if (EQ (d_opts->get (i), "-j")) {
98 if (++i >= argc)
99 return 0;
100 ENV->max_proc = atoi (d_opts->get (i));
101 return 0;
104 if (EQ (d_opts->get (i), "--tag-style") || EQ (d_opts->get (i), "-ts")) {
105 SB_FLSET (SB_FLTAGSTYLE);
106 return 0;
109 if (EQ (d_opts->get (i), "-L") && (i+1) < argc) {
110 ++i;
111 ENV->d_files->from_file (d_opts->get (i));
112 ENV->d_files->foreach ((Dfunc_t) chomp);
113 return 0;
116 if (EQ (d_opts->get (i), "--depth")) {
117 if (++i >= argc)
118 return 0;
120 ENV->d_depth = atoi (d_opts->get (i));
121 return 0;
124 if (EQ (d_opts->get (i), "-fn")) {
125 SB_FLSET (SB_FLFNAMES);
126 return 0;
129 if (EQ (d_opts->get (i), "--lang")) {
130 if (++i >= argc)
131 return 0;
133 ENV->language = strdup (d_opts->get (i));
134 if (EQ (ENV->language, "cpp") ||
135 EQ (ENV->language, "cxx") ||
136 EQ (ENV->language, "c++")) {
137 delete ENV->language;
138 ENV->language = strdup ("C++");
139 SB_FLSET (SB_FLCPP);
141 return 0;
144 if (EQ (d_opts->get (i), "--thread")) {
145 SB_FLSET (SB_FLTHREAD);
146 return 0;
149 return -1;