Modify hello to be an enumration and add a backend#9
Modify hello to be an enumration and add a backend#9cminyard wants to merge 10 commits intoclicon:masterfrom
Conversation
Add a backend, this will print out information about the transaction, but that's it. Signed-off-by: Corey Minyard <cminyard@mvista.com>
Add validation of the data, keep a local state and return the proper state information. Signed-off-by: Corey Minyard <minyard@acm.org>
Use the existence of a file for the status for the hello world backend. Signed-off-by: Corey Minyard <minyard@acm.org>
This lets us demonstrate changing the value. The /tmp/world file contains a "to" value. Signed-off-by: Corey Minyard <minyard@acm.org>
Because it's changed... Signed-off-by: Corey Minyard <minyard@acm.org>
Make the versions match. Signed-off-by: Corey Minyard <minyard@acm.org>
To see what's in them. The standard functions don't print the prefix or flags. Signed-off-by: Corey Minyard <minyard@acm.org>
|
Nice initiative! |
Handle body nodes more cleanly. Signed-off-by: Corey Minyard <minyard@acm.org>
There was a problem hiding this comment.
Thanks for improving the hello application.
Could you please add a README to describe the purpose and usage?
Your additions seem to be a better illustration of the commit/transaction semantics?
I could still see the use of a minimal application just to exercise the config+build system (the previous hello was not that either).
Could you also please have a look at https://github.com/clicon/clixon/blob/master/CONTRIBUTING.md#c-style especially in an example its good to be normative in style.
hello/src/hello_backend_plugin.c
Outdated
| int rv; | ||
|
|
||
| printf("*****hello validate*****\n"); | ||
| printf("src:\n"); |
There was a problem hiding this comment.
This will show up on the backend's stdout. This is limiting to a debug case where you run the backend in the foreground.
I would add that as a log instead so you could steer the prints to syslog/stderr/stdout as described here: https://clixon-docs.readthedocs.io/en/latest/backend.html#command-line-options.
Logging XML can be done with the macro clixon_log_xml(). Or debug with clixon_debug_xml().
hello/src/hello_backend_plugin.c
Outdated
| if (strcmp(xml_name(vec), "hello") != 0) | ||
| return 0; | ||
| /* | ||
| * It would be nice to be able to use nscache_xxx() for this. |
There was a problem hiding this comment.
The cache is built on-demand. Yes, you should be able to use such a function. It is not so nice to have this in the example code.
Maybe we could add such a function in the lib if there is nothing appropriate.
The function I think could be used here is xml2ns()
Add a lot of comments, replace hand-coded xml functions with standard one, use clixon_debug() instead of printf in a lot of places, and comment out the printing of the XML trees by default. Also show an example of both parsing the source and target trees or parsing the add,delete,change vectors. Signed-off-by: Corey Minyard <minyard@acm.org>
|
I updated this to address the comments and to add even more useful information and examples. |
You aren't supposed to delete the old ones, just add new ones. Signed-off-by: Corey Minyard <corey@minyard.net>
This is a set of changes to make the "hello" example a little more useful. It shows a lot more of the things I expect you would be using when using clixon.
I don't think this is perfect, and I have a lot of questions still. But something like this would be extremely helpful for new users.