diff options
author | slioch <slioch@eng-140.vyatta.com> | 2009-06-26 23:18:33 -0700 |
---|---|---|
committer | slioch <slioch@eng-140.vyatta.com> | 2009-07-06 13:37:44 -0700 |
commit | c3b23a060d2c949580873dc100469be9ad05734c (patch) | |
tree | e2af7f9bb2bfa6e5c5fefbf17d7edd99dad55939 | |
parent | 8f040d65de91b2d4ff08764d9408a21b5c145735 (diff) | |
download | vyatta-cfg-c3b23a060d2c949580873dc100469be9ad05734c.tar.gz vyatta-cfg-c3b23a060d2c949580873dc100469be9ad05734c.zip |
updated perl api for new cli to support working node representation. not yet functional without additional testing.
-rwxr-xr-x | lib/Vyatta/Config.pm | 60 | ||||
-rw-r--r-- | src/commit2.c | 24 | ||||
-rw-r--r-- | src/common/unionfs.c | 2 |
3 files changed, 83 insertions, 3 deletions
diff --git a/lib/Vyatta/Config.pm b/lib/Vyatta/Config.pm index f80ff86..ba3cd6c 100755 --- a/lib/Vyatta/Config.pm +++ b/lib/Vyatta/Config.pm @@ -98,6 +98,66 @@ sub listNodes { return @nodes_modified; } +## listNodes("level") +# return array of all nodes (active plus currently committed) at "level" +# level is relative +sub listOrigPlusComNodes { + my ($self, $path) = @_; + my @nodes = (); + + my @nodes_modified = $self->listNodes(); + + #convert array to hash + my %coll; + my $coll; + @coll{@nodes_modified} = @nodes_modified; + + my $level = $self->{_level}; + + #now test against the inprocess file in the system +# my $com_file = "/tmp/.changes_$$"; + my $com_file = "/tmp/.changes"; + open FILE, "<", $com_file; + if (-e $com_file) { + foreach my $line (<FILE>) { + my @node = split " ", $line; #split on space + #$node[1] is of the form: system/login/blah + #$coll is of the form: blah + + #first only consider $path matches against $node[1] + if (!defined $level || $node[1] =~ m/^$level/) { + #or does $node[1] match the beginning of the line for $path + + #if yes, then split the right side and find against the hash for the value... + my $tmp; + if (defined $level) { + $tmp = substr($node[1],length($level)+1); + } + else { + $tmp = $node[1]; + } + + #now can we find this entry in the hash? + #if '-' this is a delete and need to remove from hash + if ($node[0] eq "-") { + delete($coll{$tmp}); + } + #if '+' this is a set and need to add to hash + elsif ($node[0] eq "+") { + $coll{$tmp} = '1'; + } + } + } + } + +#print "coll count: ".keys(%coll); + + #now convert hash to array and return + @nodes_modified = (); + @nodes_modified = keys(%coll); + return @nodes_modified; +} + ## listOrigNodes("level") # return array of all original nodes (i.e., before any current change; i.e., # in "working") at "level" diff --git a/src/commit2.c b/src/commit2.c index daea436..5f70aa4 100644 --- a/src/commit2.c +++ b/src/commit2.c @@ -436,7 +436,13 @@ process_func(GNode *node, gpointer data) status = execute_list(c->_def.actions[result->_action].vtw_list_head,&c->_def); } else { - fprintf(out_stream,"%s\t:\t%s\n",ActionNames[result->_action],d->_path); + char buf[MAX_LENGTH_DIR_PATH*sizeof(char)]; + sprintf(buf,"%s\t:\t%s",ActionNames[result->_action],d->_path); + if (c->_def.multi) { //need to handle the embedded multinode as a special case--should be fixed! + char *val = (char*)clind_unescape(d->_name); + strcat(buf,val); + } + fprintf(out_stream,"%s\n",buf); status = 1; } if (result->_action == delete_act) { @@ -985,11 +991,19 @@ validate_func(GNode *node, gpointer data) char *buf = malloc(MAX_LENGTH_DIR_PATH*sizeof(char)); if (IS_DELETE(d->_operation)) { sprintf(buf,"- %s",d->_path); + if (c->_def.multi) { //need to handle the embedded multinode as a special case--should be fixed! + char *val = (char*)clind_unescape(d->_name); + strcat(buf,val); + } coll = g_slist_append(coll,buf); result->_data = (void*)&coll; } else if (IS_SET_OR_CREATE(d->_operation)) { sprintf(buf,"+ %s",d->_path); + if (c->_def.multi) { //need to handle the embedded multinode as a special case--should be fixed! + char *val = (char*)clind_unescape(d->_name); + strcat(buf,val); + } coll = g_slist_append(coll,buf); result->_data = (void*)&coll; } @@ -1052,7 +1066,13 @@ validate_func(GNode *node, gpointer data) status = execute_list(c->_def.actions[result->_action].vtw_list_head,&c->_def); } else { - fprintf(out_stream,"%s\t:\t%s\n",ActionNames[result->_action],d->_path); + char buf[MAX_LENGTH_DIR_PATH*sizeof(char)]; + sprintf(buf,"%s\t:\t%s",ActionNames[result->_action],d->_path); + if (c->_def.multi) { //need to handle the embedded multinode as a special case--should be fixed! + char *val = (char*)clind_unescape(d->_name); + strcat(buf,val); + } + fprintf(out_stream,"%s\n",buf); status = 1; } diff --git a/src/common/unionfs.c b/src/common/unionfs.c index 80a9ba7..1c39cf8 100644 --- a/src/common/unionfs.c +++ b/src/common/unionfs.c @@ -1038,7 +1038,7 @@ dlist_test_func(GQuark key_id,gpointer data,gpointer user_data) } else { new_vn = vn; - strcat(new_vn->_data._path,"/value"); + strcat(new_vn->_data._path,"/"); } new_vn->_data._value = TRUE; strcpy(new_vn->_data._name,(char*)g_quark_to_string(key_id)); |