@@ -144,8 +144,8 @@ WEBCFG_STATUS addNewDocEntry(size_t count)
144144
145145 WebcfgDebug ("DB docs count %ld\n" , (size_t )count );
146146 webcfgdbPackSize = webcfgdb_pack (webcfgdb_data , & data , count );
147- WebcfgInfo ("size of webcfgdbPackSize %ld\n" , webcfgdbPackSize );
148- WebcfgInfo ("writeToDBFile %s\n" , WEBCFG_DB_FILE );
147+ WebcfgDebug ("size of webcfgdbPackSize %ld\n" , webcfgdbPackSize );
148+ WebcfgDebug ("writeToDBFile %s\n" , WEBCFG_DB_FILE );
149149 writeToDBFile (WEBCFG_DB_FILE ,(char * )data ,webcfgdbPackSize );
150150 if (data )
151151 {
@@ -263,6 +263,9 @@ void webcfgdbblob_destroy( blob_struct_t *bd )
263263 if ( NULL != bd -> entries [i ].error_details ) {
264264 free ( bd -> entries [i ].error_details );
265265 }
266+ if ( NULL != bd -> entries [i ].root_string ) {
267+ free ( bd -> entries [i ].root_string );
268+ }
266269 }
267270 if ( NULL != bd -> entries ) {
268271 free ( bd -> entries );
@@ -461,9 +464,9 @@ WEBCFG_STATUS addToTmpList( multipart_t *mp)
461464}
462465
463466
464- void checkDBList (char * docname , uint32_t version )
467+ void checkDBList (char * docname , uint32_t version , char * rootstr )
465468{
466- if (updateDBlist (docname , version ) != WEBCFG_SUCCESS )
469+ if (updateDBlist (docname , version , rootstr ) != WEBCFG_SUCCESS )
467470 {
468471 webconfig_db_data_t * webcfgdb = NULL ;
469472 webcfgdb = (webconfig_db_data_t * ) malloc (sizeof (webconfig_db_data_t ));
@@ -473,10 +476,24 @@ void checkDBList(char *docname, uint32_t version)
473476
474477 webcfgdb -> name = strdup (docname );
475478 webcfgdb -> version = version ;
479+ if ( strcmp ("root" , webcfgdb -> name ) == 0 )
480+ {
481+ if (rootstr != NULL )
482+ {
483+ webcfgdb -> root_string = strdup (rootstr );
484+ }
485+ }
476486 webcfgdb -> next = NULL ;
477487
478488 addToDBList (webcfgdb );
479- WebcfgInfo ("webcfgdb->name added to DB %s webcfgdb->version %lu\n" ,webcfgdb -> name , (long )webcfgdb -> version );
489+ if (webcfgdb -> root_string != NULL )
490+ {
491+ WebcfgInfo ("webcfgdb->name added to DB %s webcfgdb->version %lu webcfgdb->root_string %s\n" ,webcfgdb -> name , (long )webcfgdb -> version , webcfgdb -> root_string );
492+ }
493+ else
494+ {
495+ WebcfgInfo ("webcfgdb->name added to DB %s webcfgdb->version %lu\n" ,webcfgdb -> name , (long )webcfgdb -> version );
496+ }
480497 }
481498 else
482499 {
@@ -485,7 +502,7 @@ void checkDBList(char *docname, uint32_t version)
485502 }
486503}
487504
488- WEBCFG_STATUS updateDBlist (char * docname , uint32_t version )
505+ WEBCFG_STATUS updateDBlist (char * docname , uint32_t version , char * rootstr )
489506{
490507 webconfig_db_data_t * webcfgdb = NULL ;
491508 webcfgdb = get_global_db_node ();
@@ -495,11 +512,23 @@ WEBCFG_STATUS updateDBlist(char *docname, uint32_t version)
495512 {
496513 pthread_mutex_lock (& webconfig_db_mut );
497514 WebcfgDebug ("mutex_lock in updateDBlist\n" );
498- WebcfgDebug ("node is pointing to webcfgdb->name %s, docname %s, dblen %zu, doclen %zu \n" ,webcfgdb -> name , docname , strlen (webcfgdb -> name ), strlen (docname ));
515+ WebcfgDebug ("node is pointing to webcfgdb->name %s, docname %s, dblen %zu, doclen %zu webcfgdb->root_string %s \n" ,webcfgdb -> name , docname , strlen (webcfgdb -> name ), strlen (docname ), webcfgdb -> root_string );
499516 if ( strcmp (docname , webcfgdb -> name ) == 0 )
500517 {
501518 webcfgdb -> version = version ;
502- WebcfgDebug ("webcfgdb %s is updated to version %lu\n" , docname , (long )webcfgdb -> version );
519+ if ( strcmp ("root" , webcfgdb -> name ) == 0 )
520+ {
521+ if (webcfgdb -> root_string != NULL )
522+ {
523+ WEBCFG_FREE (webcfgdb -> root_string );
524+ webcfgdb -> root_string = NULL ;
525+ }
526+ if (rootstr != NULL )
527+ {
528+ webcfgdb -> root_string = strdup (rootstr );
529+ }
530+ }
531+ WebcfgDebug ("webcfgdb %s is updated to version %lu webcfgdb->root_string %s\n" , docname , (long )webcfgdb -> version , webcfgdb -> root_string );
503532 pthread_mutex_unlock (& webconfig_db_mut );
504533 WebcfgDebug ("mutex_unlock if docname is webcfgdb name\n" );
505534 return WEBCFG_SUCCESS ;
@@ -641,7 +670,7 @@ void delete_tmp_doc_list()
641670int process_webcfgdbparams ( webconfig_db_data_t * e , msgpack_object_map * map )
642671{
643672 int left = map -> size ;
644- uint8_t objects_left = 0x02 ;
673+ uint8_t objects_left = 0x03 ;
645674 msgpack_object_kv * p ;
646675
647676 p = map -> ptr ;
@@ -675,16 +704,27 @@ int process_webcfgdbparams( webconfig_db_data_t *e, msgpack_object_map *map )
675704 {
676705 e -> name = strndup ( p -> val .via .str .ptr , p -> val .via .str .size );
677706 //WebcfgDebug("e->name is %s\n", e->name);
678- objects_left &= ~(1 << 0 );
707+ objects_left &= ~(1 << 2 );
679708 //WebcfgDebug("objects_left after name %d\n", objects_left);
680709 }
710+ else if ( 0 == match (p , "root_string" ) )
711+ {
712+ e -> root_string = strndup ( p -> val .via .str .ptr , p -> val .via .str .size );
713+ //WebcfgDebug("e->root_string is %s\n", e->root_string);
714+ objects_left &= ~(1 << 0 );
715+ //WebcfgDebug("objects_left after root_string %d\n", objects_left);
716+ }
681717 }
682718 }
683719 p ++ ;
684720 }
685-
686721 if ( 1 & objects_left )
687722 {
723+ if ( (1 << 0 ) & objects_left )
724+ {
725+ WebcfgDebug ("Skip optional root_string element\n" );
726+ objects_left &= ~(1 << 0 );
727+ }
688728 }
689729 else
690730 {
@@ -815,7 +855,14 @@ char * get_DB_BLOB_base64()
815855 {
816856 for (k = 0 ;k < bd -> entries_count ; k ++ )
817857 {
818- WebcfgInfo ("Blob bd->entries[%zu].name %s, version: %lu, status: %s, error_details: %s, error_code: %d\n" , k , bd -> entries [k ].name , (long )bd -> entries [k ].version , bd -> entries [k ].status , bd -> entries [k ].error_details , bd -> entries [k ].error_code );
858+ if (bd -> entries [k ].root_string != NULL )
859+ {
860+ WebcfgInfo ("Blob bd->entries[%zu].name %s, version: %lu, status: %s, error_details: %s, error_code: %d root_string: %s\n" , k , bd -> entries [k ].name , (long )bd -> entries [k ].version , bd -> entries [k ].status , bd -> entries [k ].error_details , bd -> entries [k ].error_code , bd -> entries [k ].root_string );
861+ }
862+ else
863+ {
864+ WebcfgInfo ("Blob bd->entries[%zu].name %s, version: %lu, status: %s, error_details: %s, error_code: %d\n" , k , bd -> entries [k ].name , (long )bd -> entries [k ].version , bd -> entries [k ].status , bd -> entries [k ].error_details , bd -> entries [k ].error_code );
865+ }
819866 }
820867
821868 }
@@ -874,7 +921,7 @@ int process_webcfgdbblobparams( blob_data_t *e, msgpack_object_map *map )
874921 e -> error_code = (uint16_t ) p -> val .via .u64 ;
875922 //WebcfgDebug("e->version is %d\n", e->error_code);
876923 }
877- objects_left &= ~(1 << 3 );
924+ objects_left &= ~(1 << 4 );
878925
879926 }
880927 }
@@ -898,14 +945,23 @@ int process_webcfgdbblobparams( blob_data_t *e, msgpack_object_map *map )
898945 //WebcfgDebug("e->error_details is %s\n", e->error_details);
899946 objects_left &= ~(1 << 2 );
900947 }
948+ else if (0 == match (p , "root_string" ) )
949+ {
950+ e -> root_string = strndup ( p -> val .via .str .ptr , p -> val .via .str .size );
951+ //WebcfgDebug("e->root_string is %s\n", e->root_string);
952+ objects_left &= ~(1 << 3 );
953+ }
901954 }
902955 }
903956 p ++ ;
904957 }
905-
906958 if ( 1 & objects_left )
907959 {
908960 }
961+ else if ( (1 << 3 ) & objects_left ) {
962+ WebcfgDebug ("Skip optional root_string element\n" );
963+ objects_left &= ~(1 << 3 );
964+ }
909965 else
910966 {
911967 errno = BD_OK ;
0 commit comments