summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Larson <mike@vyatta.com>2010-11-09 17:28:47 -0800
committerMichael Larson <mike@vyatta.com>2010-11-09 17:28:47 -0800
commit1d3fd053d4f76633567e321528b894ed1f727b73 (patch)
tree1eae27bb6c06c4d6ba4121e6648cbb8bef8b192a
parent8d750fc2164ed2db0a7784a7d74ae5644526364b (diff)
downloadvyatta-cfg-1d3fd053d4f76633567e321528b894ed1f727b73.tar.gz
vyatta-cfg-1d3fd053d4f76633567e321528b894ed1f727b73.zip
make commit aware of error location key and allow for passthrough.
-rwxr-xr-xlib/Vyatta/Config.pm8
-rw-r--r--src/commit2.c63
2 files changed, 38 insertions, 33 deletions
diff --git a/lib/Vyatta/Config.pm b/lib/Vyatta/Config.pm
index e8fda29..5283b06 100755
--- a/lib/Vyatta/Config.pm
+++ b/lib/Vyatta/Config.pm
@@ -676,13 +676,13 @@ sub compareValueLists {
return %comp_hash;
}
+
sub outputError {
my ($location, $msg) = @_;
- print STDERR $msg . "\n";
if (defined($ENV{VYATTA_OUTPUT_ERROR_LOCATION})) {
- foreach my $elem (@$location) {
- print STDERR "errloc:[" . $elem . "]\n";
- }
+ foreach my $elem (@$location) {
+ print STDERR "_errloc_:[" . $elem . "]\n" . $msg . "\n";
+ }
}
}
diff --git a/src/commit2.c b/src/commit2.c
index 2f9be94..92f37ed 100644
--- a/src/commit2.c
+++ b/src/commit2.c
@@ -564,36 +564,41 @@ process_func(GNode *node, gpointer data)
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);
+ if (strstr(outbuf,"_errloc_:[") != NULL) {
+ fprintf(out_stream,"%s\n",outbuf);
}
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);
+ //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) {
+ //currently set to format option for GUI client.
+ fprintf(out_stream,"_errloc_:[%s]\n%s\n",p,outbuf);
}
- }
- char *p = clind_unescape(path_buf);
-
- if (strlen(outbuf) > 0) {
- //currently set to format option for GUI client.
- fprintf(out_stream,"_errloc_:[%s]\n%s\n",p,outbuf);
}
}
}
@@ -624,7 +629,7 @@ process_func(GNode *node, gpointer data)
if (!status) { //EXECUTE_LIST RETURNS FALSE ON FAILURE....
syslog(LOG_ERR,"commit error for %s:[%s]\n",ActionNames[result->_action],d->_path);
if (g_display_error_node) {
- fprintf(out_stream,"%s@errloc:[%s]\n",ActionNames[result->_action],d->_path);
+ fprintf(out_stream,"%s@_errloc_:[%s]\n",ActionNames[result->_action],d->_path);
}
result->_err_code = 1;
if (g_debug) {
@@ -1473,7 +1478,7 @@ validate_func(GNode *node, gpointer data)
}
syslog(LOG_ERR,"commit error for %s:[%s]\n",ActionNames[result->_action],d->_path);
if (g_display_error_node) {
- fprintf(out_stream,"%s@errloc:[%s]\n",ActionNames[result->_action],d->_path);
+ fprintf(out_stream,"%s@_errloc_:[%s]\n",ActionNames[result->_action],d->_path);
}
result->_err_code = 1;
if (g_debug) {