1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <glib-2.0/glib.h>
#include "common/common.h"
boolean g_debug = FALSE;
/**
*
*
**/
void
usage()
{
printf("exe_action\n");
printf("-p\t\trelative path to node.def\n");
printf("-a\t\taction (integer value)\n");
printf("-d\t\tdebug mode\n");
printf("-h\t\thelp\n");
}
/**
*
**/
const char* get_tmpp(void) {
const char* tmpp=getenv(ENV_T_DIR);
if(!tmpp)
tmpp="";
return tmpp;
}
/**
*
*
**/
int
main(int argc, char** argv)
{
int ch;
char *path = NULL;
unsigned long act = 0;
/* this is needed before calling certain glib functions */
g_type_init();
//grab inputs
while ((ch = getopt(argc, argv, "dhp:a:")) != -1) {
switch (ch) {
case 'd':
g_debug = TRUE;
break;
case 'h':
usage();
exit(0);
break;
case 'p':
path = optarg;
break;
case 'a':
act = strtoul(optarg,NULL,10);
break;
default:
usage();
exit(0);
}
}
vtw_def def;
struct stat s;
const char *root = get_tmpp();
char buf[2048];
sprintf(buf,"%s/%snode.def",root,path);
printf("%s\n",buf);
initialize_output(NULL);
init_paths(TRUE);
printf("[path: %s][act: %lu]\n",buf,act);
if ((lstat(buf,&s) == 0) && S_ISREG(s.st_mode)) {
if (parse_def(&def,buf,FALSE) == 0) {
//execute
int status;
if (def.actions[act].vtw_list_head) {
set_in_commit(TRUE);
char foo[1024];
sprintf(foo,"b");
set_at_string(foo);
//BROKEN--NEEDS TO BE FIX BELOW FOR DPATH AND CPATH
common_set_context(path,path);
status = execute_list(def.actions[act].vtw_list_head,&def,NULL,FALSE);
if (status == FALSE) {
printf("command failed! status: %d\n", status);
}
else {
printf("SUCCESS!\n");
}
set_in_commit(FALSE);
}
else {
printf("no action for this node\n");
}
}
else {
printf("failure to parse defination file\n");
}
}
else {
printf("node.def not found at: %s\n",buf);
}
return 0;
}
|