/ Make the binary result according to the first argument type. */ /
| 1463 | /* Make the binary result according to the first argument type. */ |
| 1464 | /*********************************************************************************/ |
| 1465 | static PBSON MakeBinResult(PGLOBAL g, UDF_ARGS *args, PJSON top, ulong len, int n = 2) |
| 1466 | { |
| 1467 | PBSON bsnp = JbinAlloc(g, args, len, top); |
| 1468 | |
| 1469 | if (!bsnp) |
| 1470 | return NULL; |
| 1471 | |
| 1472 | if (IsJson(args, 0) == 2) { |
| 1473 | int pretty = 0; |
| 1474 | |
| 1475 | for (uint i = n; i < args->arg_count; i++) |
| 1476 | if (args->arg_type[i] == INT_RESULT) { |
| 1477 | pretty = (int)*(longlong*)args->args[i]; |
| 1478 | break; |
| 1479 | } // endif type |
| 1480 | |
| 1481 | bsnp->Pretty = pretty; |
| 1482 | |
| 1483 | if ((bsnp->Filename = (char*)args->args[0])) { |
| 1484 | bsnp->Filename = MakePSZ(g, args, 0); |
| 1485 | strmake(bsnp->Msg, bsnp->Filename, BMX-1); |
| 1486 | } else |
| 1487 | strmake(bsnp->Msg, "null filename", BMX-1); |
| 1488 | |
| 1489 | } else if (IsJson(args, 0) == 3) { |
| 1490 | PBSON bsp = (PBSON)args->args[0]; |
| 1491 | |
| 1492 | if (bsp->Filename) { |
| 1493 | bsnp->Filename = bsp->Filename; |
| 1494 | strmake(bsnp->Msg, bsp->Filename, BMX-1); |
| 1495 | bsnp->Pretty = bsp->Pretty; |
| 1496 | } else |
| 1497 | strcpy(bsnp->Msg, "Json Binary item"); |
| 1498 | |
| 1499 | } else |
| 1500 | strcpy(bsnp->Msg, "Json Binary item"); |
| 1501 | |
| 1502 | return bsnp; |
| 1503 | } // end of MakeBinResult |
| 1504 | |
| 1505 | /*********************************************************************************/ |
| 1506 | /* Returns a pointer to the first integer argument found from the nth argument. */ |
no test coverage detected