[patch] ctags_db: Implemented update, add_file and remove_file
[vimicxx.git] / src / main.cc
blobb7a7dcedae80bbbb87a84d81e4f2c150ddbd1b2a
1 /*******************************************************************************
2 ********************************************************************************
4 Copyright (c) 2008 Ahmed S. Badran
6 Licensed under the FreeBSD License (see LICENSE)
8 Filename: main.cc
9 Description: Vimicxx main.
10 Created: 09/01/2008 06:35:01 PM PDT
11 Author: Ahmed S. Badran (Ahmed B.), ahmed.badran@gmail.com
13 ********************************************************************************
14 *******************************************************************************/
15 #include <unistd.h>
16 #include <pwd.h>
17 #include <sys/stat.h>
18 #include <string>
19 #include <cstdlib>
20 #include "vimicxx_conf.h"
21 #include "ctags_db.h"
22 using namespace std;
24 bool vimicxx_init(string*);
25 void vimicxx_config(configfile*);
26 bool vimicxx_parse_cmd(int argc, char** argv);
28 int main(int argc, char* argv[])
30 string DOTVIMICXX_PATH;
31 if (!vimicxx_init(&DOTVIMICXX_PATH)) {
32 return 1;
34 vimicxx_conf conf(DOTVIMICXX_PATH);
35 vector<string> tmp;
36 vector<string> extensions;
37 extensions.push_back(".c");
38 extensions.push_back(".cpp");
39 extensions.push_back(".h");
40 conf.add_project("test", "/home/ahmed/data", tmp);
41 conf.add_project("test3", "/home/ahmed/data/oss/vimicxx", extensions);
42 extensions);
43 /* vimicxx_config(&vimicxx_conf); */
44 if (!vimicxx_parse_cmd(argc, argv)) {
45 return 1;
48 string name, prj_path, prj_cache, prj_flist, prj_tags_db;
49 conf.get_project_path("test4", &prj_path);
50 conf.get_project_cache_dir("test4", &prj_cache);
51 conf.get_project_flist("test4", &prj_flist);
52 conf.get_project_tags_db("test4", &prj_tags_db);
53 ctags_db ctags("test4", prj_path, prj_cache, prj_flist,
54 prj_tags_db, extensions);
55 ctags.create();
57 time_t start = time(0);
58 ctags.update();
59 time_t end = time(0);
60 printf("time : %d\n", end - start);
61 return 0;
65 * Check for the .vimicxx directory, create it if it
66 * doesn't exist, checks for DOTVIMICXX_PATH
68 bool vimicxx_init(string* vimicxx_path)
70 char* tmp;
71 if ((tmp = getenv("DOTVIMICXX_PATH")) != NULL) {
72 *vimicxx_path = tmp;
73 } else {
74 passwd* tmp2 = getpwuid(geteuid());
75 *vimicxx_path = tmp2->pw_dir;
76 *vimicxx_path += "/.vimicxx";
79 struct stat tmp_stat;
80 if ((stat(vimicxx_path->c_str(), &tmp_stat) == 0) &&
81 (S_ISDIR(tmp_stat.st_mode))) {
82 return true;
83 } else if (mkdir(vimicxx_path->c_str(), S_IRUSR | S_IWUSR | S_IXUSR |
84 S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) == 0) {
85 return true;
86 } else {
87 perror("mkdir error");
88 return false;
93 * Parse the command, figure out what are we being asked for
95 bool vimicxx_parse_cmd(int argc, char** argv)
97 return true;