diff options
author | Michael Larson <mike@vyatta.com> | 2010-11-08 17:59:30 -0800 |
---|---|---|
committer | Michael Larson <mike@vyatta.com> | 2010-11-08 17:59:30 -0800 |
commit | 8f11842f7db8e528246a33aaa1085a250efbed1a (patch) | |
tree | 379c774896d42fa3f692a2dc87c58da5db4e9c4b /src | |
parent | efd9dc19a131752a7f1d2922d06e41206bfe38b6 (diff) | |
download | vyatta-cfg-8f11842f7db8e528246a33aaa1085a250efbed1a.tar.gz vyatta-cfg-8f11842f7db8e528246a33aaa1085a250efbed1a.zip |
extend initial error location support to begin,delete,create,update,end--currently only enabled via commit flag.
Diffstat (limited to 'src')
-rw-r--r-- | src/commit2.c | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/src/commit2.c b/src/commit2.c index 6a6a211..b33d6c0 100644 --- a/src/commit2.c +++ b/src/commit2.c @@ -14,6 +14,7 @@ boolean g_display_error_node = FALSE; boolean g_coverage = FALSE; boolean g_dump_trans = FALSE; boolean g_dump_actions = FALSE; +boolean g_print_error_location_all = FALSE; #define g_num_actions 5 @@ -115,7 +116,8 @@ usage(void) printf("\t-o\t\tdisable partial commit\n"); printf("\t-f\t\tfull iteration over configuration on commit check\n"); printf("\t-b\t\tbreak on each priority node (debug mode)\n"); - printf("\t-r [FILE]\trun hook script on finishing commit\n"); + printf("\t-r\t\tdisable run hook script on finishing commit\n"); + printf("\t-x\t\texperimental expand print error location feature\n"); printf("\t-h\t\thelp\n"); } @@ -139,8 +141,11 @@ main(int argc, char** argv) g_type_init(); //grab inputs - while ((ch = getopt(argc, argv, "dpthsecoafbrC:")) != -1) { + while ((ch = getopt(argc, argv, "xdpthsecoafbrC:")) != -1) { switch (ch) { + case 'x': + g_print_error_location_all = TRUE; + break; case 'd': g_debug = TRUE; break; @@ -548,8 +553,48 @@ process_func(GNode *node, gpointer data) setenv(ENV_ACTION_NAME,ENV_ACTION_ACTIVE,1); } + char *outbuf = NULL; if (g_dump_actions == FALSE) { - status = execute_list(c->_def.actions[result->_action].vtw_list_head,&c->_def,NULL); + if (g_print_error_location_all == TRUE) { + outbuf = malloc(8192); + outbuf[0] = '\0'; + status = execute_list(c->_def.actions[result->_action].vtw_list_head,&c->_def,(const char**)&outbuf); + } + else { + status = execute_list(c->_def.actions[result->_action].vtw_list_head,&c->_def,NULL); + } + if (!status && g_print_error_location_all == TRUE) { //EXECUTE_LIST RETURNS FALSE ON FAILURE.... + //just need to convert slashes into spaces here + char path_buf[1024]; + char tmp[1024]; + char *ptr; + path_buf[0] = '\0'; + + strcpy(tmp,d->_path); + ptr = (char*)tmp; + char *slash = strchr(tmp,'/'); + if (slash == NULL) { + strcat(path_buf,d->_path); + } + else { + do { //convert '/' to ' ' + strncat(path_buf,ptr,slash - ptr); + strcat(path_buf," "); + ++slash; + ptr = slash; + } while ((slash = strchr(slash,'/')) != NULL); + } + if (strncmp(ptr,"value:",6) == 0) { + if (strlen(ptr)-6 > 0) { + strncat(path_buf,ptr+6,strlen(ptr)-6); + } + } + char *p = clind_unescape(path_buf); + + if (strlen(outbuf) > 0) { + fprintf(out_stream,"[ %s ] \n %s\n",p,outbuf); + } + } } else { char buf[MAX_LENGTH_DIR_PATH*sizeof(char)]; |