@@ -407,10 +407,12 @@ static int iio_populate_xml_context_helper(struct iio_context *ctx, xmlNode *roo
407407
408408static struct iio_context * iio_create_xml_context_helper (xmlDoc * doc )
409409{
410- const char * description = NULL ;
410+ const char * description = NULL , * git_tag = NULL , * content ;
411411 struct iio_context * ctx ;
412+ long major = 0 , minor = 0 ;
412413 xmlNode * root ;
413414 xmlAttr * attr ;
415+ char * end ;
414416 int err ;
415417
416418 root = xmlDocGetRootElement (doc );
@@ -421,17 +423,42 @@ static struct iio_context * iio_create_xml_context_helper(xmlDoc *doc)
421423 }
422424
423425 for (attr = root -> properties ; attr ; attr = attr -> next ) {
424- if (!strcmp ((char * ) attr -> name , "description" ))
425- description = (const char * )attr -> children -> content ;
426- else if (strcmp ((char * ) attr -> name , "name" ))
426+ content = (const char * ) attr -> children -> content ;
427+
428+ if (!strcmp ((char * ) attr -> name , "description" )) {
429+ description = content ;
430+ } else if (!strcmp ((char * ) attr -> name , "version-major" )) {
431+ major = strtol (content , & end , 10 );
432+ if (* end != '\0' )
433+ IIO_WARNING ("invalid format for major version\n" );
434+ } else if (!strcmp ((char * ) attr -> name , "version-minor" )) {
435+ minor = strtol (content , & end , 10 );
436+ if (* end != '\0' )
437+ IIO_WARNING ("invalid format for minor version\n" );
438+ } else if (!strcmp ((char * ) attr -> name , "version-git" )) {
439+ git_tag = content ;
440+ } else if (strcmp ((char * ) attr -> name , "name" )) {
427441 IIO_WARNING ("Unknown parameter \'%s\' in <context>\n" ,
428- (char * ) attr -> children -> content );
442+ content );
443+ }
429444 }
430445
431446 ctx = iio_context_create_from_backend (& xml_backend , description );
432447 if (!ctx )
433448 return NULL ;
434449
450+ if (git_tag ) {
451+ ctx -> major = major ;
452+ ctx -> minor = minor ;
453+
454+ ctx -> git_tag = iio_strdup (git_tag );
455+ if (!ctx -> git_tag ) {
456+ iio_context_destroy (ctx );
457+ errno = ENOMEM ;
458+ return NULL ;
459+ }
460+ }
461+
435462 err = iio_populate_xml_context_helper (ctx , root );
436463 if (err ) {
437464 iio_context_destroy (ctx );
0 commit comments