edward6018 / libnetconf

Automatically exported from code.google.com/p/libnetconf
Other
0 stars 0 forks source link

yinmodel_parse fails to update the prefix tag #19

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use two or more individual yin schema;

What is the expected output? What do you see instead?
At initializing stage, the yinmodel_parse fails to update the prefix tag.

What version of the product are you using? On what operating system?
Master branch, one month old. Ubuntu.

Please provide any additional information below.
Fixed(in my code) in yinmodel_parse routine using:
for (i=0; ns_mapping[i] != NULL; i=i+3) {
    if (strcmp(ns_mapping[i+1], yin->ns_uri) == 0) {
        yin->ns_prefix = strdup(ns_mapping[i+2]);
        break;
    }
}

Original issue reported on code.google.com by catalin.olteanu on 8 Oct 2013 at 8:00

GoogleCodeExporter commented 9 years ago

Original comment by david.kupka@gmail.com on 8 Oct 2013 at 8:13

GoogleCodeExporter commented 9 years ago
Hello,
on current master HEAD (master@505eb702ddbc) I'm unable to reproduce the 
problem You are describing. Code similar to Yours is in yinmodel_parse function 
since june (according to git blame src/transapi/yinparser.c) and I see the 
ns_prefix property of structure model_tree is filled in all elements.
Can you please try Your case with library build from current sources?

In addition, It is unlikely that you code will behave correctly since the 
ns_mapping array is structured as {"prefix1", "uri1", "prefix2", "uri2", ..., 
"prefixN", "uriN", NULL, NULL}. Assuming You have 2 namespaces, Your
array will look like this {"prefix1", "uri1", "prefix2", "uri2", NULL, NULL}. 
Your code will assign prefix "prefix2" to elements with namespace uri = "uri1" 
and will crash while trying to assign prefix for namespace uri = "uri2" 
(strdup(NULL)).

Best regards,
David Kupka

Original comment by david.kupka@gmail.com on 8 Oct 2013 at 11:27

GoogleCodeExporter commented 9 years ago
Hi David,
I believed that the ns_mapping is something like 
"module_name1","uri1","prefix1","module_name2","uri2","prefix2",...

I suppose my callbacks are generated in a different way(a wrong way).

Do you have an tutorial(email/readme, etc) related to multiple(individual) 
schema support ?

Thank you,
Catalin

Original comment by catalin.olteanu on 8 Oct 2013 at 1:51

GoogleCodeExporter commented 9 years ago
Hi Catalin,
I'm not sure what is your goal. Do you want to create multiple modules each 
with its own datastore and its own schema? Or do you want to create single 
module with configuration specified in multiple schema documents?

If you need the first case, you can use this guide 
http://libnetconf.googlecode.com/git/doc/doxygen/html/d3/df0/transapi_tutorial.h
tml to create individual modules. Getting state and configuration data can be 
then done using filter statement. When applying changes the namespace 
determines on which datastore (module) will be the changes applied.

If you have model scattered into more files you should specify the main model 
and use functions ncds_add_models_path and ncds_add_model 
(http://libnetconf.googlecode.com/git/doc/doxygen/html/db/d67/group__store.html#
ga93c65facb061f1048674343ac94a993b) to specify location of referenced and 
included models. Then you simply create single module as in previous case.

Hope this helps. If not please let me know.

Best regards,
David

Original comment by david.kupka@gmail.com on 8 Oct 2013 at 2:12

GoogleCodeExporter commented 9 years ago
I have individual modules.

After your last email, I regenerated the stubs according to your details.

I managed to build the server using two individual databases.

Now everything works as it should.

Thank you!
Catalin

Original comment by catalin.olteanu on 21 Oct 2013 at 12:30

GoogleCodeExporter commented 9 years ago

Original comment by rkre...@cesnet.cz on 11 Nov 2013 at 7:48