Browse Source

cmDspSys.h/c: Completed and tested cmDspRsrcWriteString().

master
kevin 11 years ago
parent
commit
778e95cb1f
2 changed files with 34 additions and 8 deletions
  1. 33
    8
      dsp/cmDspSys.c
  2. 1
    0
      dsp/cmDspSys.h

+ 33
- 8
dsp/cmDspSys.c View File

1870
       break;
1870
       break;
1871
     
1871
     
1872
     if( prevStr != NULL )
1872
     if( prevStr != NULL )
1873
-      path = cmTextAppendSS(path,"/");
1874
-    path = cmTextAppendSS(path,prevStr);    
1873
+    {
1874
+      if( path != NULL )
1875
+        path = cmTextAppendSS(path,"/");
1876
+
1877
+      path = cmTextAppendSS(path,prevStr);    
1878
+    }
1875
 
1879
 
1876
     prevStr = str;    
1880
     prevStr = str;    
1877
   }
1881
   }
2333
   return rc;
2337
   return rc;
2334
 }
2338
 }
2335
 
2339
 
2340
+cmDspRC_t _cmDspWritePathAndParent( cmDspSysH_t h, cmChar_t** pathRef, cmChar_t** varLabelRef, cmJsonNode_t** parentRef, va_list vl )
2341
+{
2342
+  cmDsp_t*      p                = _cmDspHandleToPtr(h);
2343
+  cmJsonH_t     jsH              = cmDspSysPgmRsrcHandle(h);
2344
+  cmDspRC_t     rc;
2345
+
2346
+  if((rc = _cmDspRsrcWritePath(h,pathRef,varLabelRef,vl)) != kOkDspRC )
2347
+    goto errLabel;
2348
+
2349
+  if( *pathRef == NULL )
2350
+    *parentRef = cmJsonRoot(jsH);
2351
+  else
2352
+    *parentRef = cmJsonFindPathValue( jsH, *pathRef, cmJsonRoot(jsH), kPairTId );
2353
+    
2354
+  if( *parentRef == NULL )
2355
+  {
2356
+    rc = cmErrMsg(&p->err,kJsonFailDspRC,"The parent object '%s' for variable '%s' could not be found.",cmStringNullGuard(*pathRef),cmStringNullGuard(*varLabelRef)); 
2357
+    goto errLabel;
2358
+  }
2359
+
2360
+ errLabel:
2361
+  return rc;
2362
+}
2363
+
2336
 cmDspRC_t cmDspRsrcWriteStringV( cmDspSysH_t h, const cmChar_t*  v, va_list vl )
2364
 cmDspRC_t cmDspRsrcWriteStringV( cmDspSysH_t h, const cmChar_t*  v, va_list vl )
2337
 {
2365
 {
2338
   cmDsp_t*      p                = _cmDspHandleToPtr(h);
2366
   cmDsp_t*      p                = _cmDspHandleToPtr(h);
2339
-  cmChar_t*     pathStr          = NULL;
2340
-  cmChar_t*     varStr           = NULL;
2341
   cmJsonH_t     jsH              = cmDspSysPgmRsrcHandle(h);
2367
   cmJsonH_t     jsH              = cmDspSysPgmRsrcHandle(h);
2368
+  cmChar_t*     varStr           = NULL;
2369
+  cmChar_t*     pathStr          = NULL;
2342
   cmJsonNode_t* parentObjNodePtr = NULL;
2370
   cmJsonNode_t* parentObjNodePtr = NULL;
2343
   cmDspRC_t     rc;
2371
   cmDspRC_t     rc;
2344
 
2372
 
2345
-  if((rc = _cmDspRsrcWritePath(h,&pathStr,&varStr,vl)) != kOkDspRC )
2373
+  if((rc = _cmDspWritePathAndParent(h, &pathStr, &varStr, &parentObjNodePtr,  vl )) != kOkDspRC )
2346
     goto errLabel;
2374
     goto errLabel;
2347
 
2375
 
2348
-  if((parentObjNodePtr = cmJsonFindPathValue( jsH, pathStr, cmJsonRoot(jsH), kPairTId )) == NULL )
2349
-    rc = cmErrMsg(&p->err,kJsonFailDspRC,"The parent object '%s' for variable '%s' could not be found.",cmStringNullGuard(pathStr),cmStringNullGuard(varStr)); 
2350
-
2351
   if( cmJsonInsertOrReplacePairString( jsH, parentObjNodePtr, varStr, kStringTId, v ) != kOkJsRC )
2376
   if( cmJsonInsertOrReplacePairString( jsH, parentObjNodePtr, varStr, kStringTId, v ) != kOkJsRC )
2352
     rc = cmErrMsg(&p->err,kJsonFailDspRC,"Write 'string' resource value failed for path '%s' and variable '%s'",cmStringNullGuard(pathStr),cmStringNullGuard(varStr)); 
2377
     rc = cmErrMsg(&p->err,kJsonFailDspRC,"Write 'string' resource value failed for path '%s' and variable '%s'",cmStringNullGuard(pathStr),cmStringNullGuard(varStr)); 
2353
 
2378
 

+ 1
- 0
dsp/cmDspSys.h View File

268
  
268
  
269
 
269
 
270
   cmDspRC_t cmDspRsrcWriteStringV( cmDspSysH_t h, const cmChar_t* v, va_list vl );
270
   cmDspRC_t cmDspRsrcWriteStringV( cmDspSysH_t h, const cmChar_t* v, va_list vl );
271
+
271
   cmDspRC_t cmDspRsrcWriteString(  cmDspSysH_t h, const cmChar_t* v, ... );
272
   cmDspRC_t cmDspRsrcWriteString(  cmDspSysH_t h, const cmChar_t* v, ... );
272
 
273
 
273
 
274
 

Loading…
Cancel
Save