Added cscope_db
[vimicxx.git] / src / main.cc
blobb6607663fc03512c6e09d14b9eb69c56f9507086
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 using namespace std;
23 bool vimicxx_init(string*);
24 void vimicxx_config(configfile*);
25 bool vimicxx_parse_cmd(int argc, char** argv);
27 int main(int argc, char* argv[])
29 string DOTVIMICXX_PATH;
30 if (!vimicxx_init(&DOTVIMICXX_PATH)) {
31 return 1;
33 vimicxx_conf conf(DOTVIMICXX_PATH);
34 vector<string> tmp;
35 conf.add_project("test", "/home/ahmed/data", tmp);
36 conf.add_project("test2", "/home/ahmed/data", tmp);
37 /* vimicxx_config(&vimicxx_conf); */
38 if (!vimicxx_parse_cmd(argc, argv)) {
39 return 1;
41 return 0;
45 * Check for the .vimicxx directory, create it if it
46 * doesn't exist, checks for DOTVIMICXX_PATH
48 bool vimicxx_init(string* vimicxx_path)
50 char* tmp;
51 if ((tmp = getenv("DOTVIMICXX_PATH")) != NULL) {
52 *vimicxx_path = tmp;
53 } else {
54 passwd* tmp2 = getpwuid(geteuid());
55 *vimicxx_path = tmp2->pw_dir;
56 *vimicxx_path += "/.vimicxx";
59 struct stat tmp_stat;
60 if ((stat(vimicxx_path->c_str(), &tmp_stat) == 0) &&
61 (S_ISDIR(tmp_stat.st_mode))) {
62 return true;
63 } else if (mkdir(vimicxx_path->c_str(), S_IRUSR | S_IWUSR | S_IXUSR |
64 S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) == 0) {
65 return true;
66 } else {
67 perror("mkdir error");
68 return false;
73 * Parse the command, figure out what are we being asked for
75 bool vimicxx_parse_cmd(int argc, char** argv)
77 return true;