MCPcopy Create free account
hub / github.com/Netis/cloud-probe / print_value

Function print_value

cpworker/src/cJSON/cJSON.c:1380–1451  ·  view source on GitHub ↗

Render a value to text. */

Source from the content-addressed store, hash-verified

1378
1379/* Render a value to text. */
1380static cJSON_bool print_value(const cJSON * const item, printbuffer * const output_buffer)
1381{
1382 unsigned char *output = NULL;
1383
1384 if ((item == NULL) || (output_buffer == NULL))
1385 {
1386 return false;
1387 }
1388
1389 switch ((item->type) & 0xFF)
1390 {
1391 case cJSON_NULL:
1392 output = ensure(output_buffer, 5);
1393 if (output == NULL)
1394 {
1395 return false;
1396 }
1397 strcpy((char*)output, "null");
1398 return true;
1399
1400 case cJSON_False:
1401 output = ensure(output_buffer, 6);
1402 if (output == NULL)
1403 {
1404 return false;
1405 }
1406 strcpy((char*)output, "false");
1407 return true;
1408
1409 case cJSON_True:
1410 output = ensure(output_buffer, 5);
1411 if (output == NULL)
1412 {
1413 return false;
1414 }
1415 strcpy((char*)output, "true");
1416 return true;
1417
1418 case cJSON_Number:
1419 return print_number(item, output_buffer);
1420
1421 case cJSON_Raw:
1422 {
1423 size_t raw_length = 0;
1424 if (item->valuestring == NULL)
1425 {
1426 return false;
1427 }
1428
1429 raw_length = strlen(item->valuestring) + sizeof("");
1430 output = ensure(output_buffer, raw_length);
1431 if (output == NULL)
1432 {
1433 return false;
1434 }
1435 memcpy(output, item->valuestring, raw_length);
1436 return true;
1437 }

Callers 5

printFunction · 0.85
cJSON_PrintBufferedFunction · 0.85
cJSON_PrintPreallocatedFunction · 0.85
print_arrayFunction · 0.85
print_objectFunction · 0.85

Calls 5

ensureFunction · 0.85
print_numberFunction · 0.85
print_stringFunction · 0.85
print_arrayFunction · 0.85
print_objectFunction · 0.85

Tested by

no test coverage detected