| 67 | |
| 68 | |
| 69 | ULONG CAN_encode_decode(burp_rel* relation, lstring* buffer, UCHAR* data, bool direction, bool useMissingOffset) |
| 70 | { |
| 71 | /************************************** |
| 72 | * |
| 73 | * C A N _ e n c o d e _ d e c o d e |
| 74 | * |
| 75 | ************************************** |
| 76 | * |
| 77 | * Functional description |
| 78 | * encode and decode canonical backup. |
| 79 | * |
| 80 | **************************************/ |
| 81 | const burp_fld* field; |
| 82 | SSHORT n; |
| 83 | |
| 84 | BurpXdr xdr; |
| 85 | BurpXdr* xdrs = &xdr; |
| 86 | |
| 87 | xdr_init(xdrs, buffer, direction ? XDR_ENCODE : XDR_DECODE); |
| 88 | |
| 89 | RCRD_OFFSET offset = 0; |
| 90 | for (field = relation->rel_fields; field; field = field->fld_next) |
| 91 | { |
| 92 | if (field->fld_flags & FLD_computed) |
| 93 | continue; |
| 94 | UCHAR* p = data + field->fld_offset; |
| 95 | const bool array_fld = ((field->fld_flags & FLD_array) != 0); |
| 96 | const FLD_LENGTH length = array_fld ? 8 : field->fld_length; |
| 97 | if (field->fld_offset >= offset) |
| 98 | offset = field->fld_offset + length; |
| 99 | if (field->fld_type == blr_varying && !array_fld) |
| 100 | offset += sizeof(SSHORT); |
| 101 | SSHORT dtype; |
| 102 | if (field->fld_type == blr_blob || array_fld) |
| 103 | dtype = dtype_blob; |
| 104 | else |
| 105 | dtype = (SSHORT) gds_cvt_blr_dtype[field->fld_type]; |
| 106 | switch (dtype) |
| 107 | { |
| 108 | case dtype_text: |
| 109 | if (!xdr_opaque(xdrs, reinterpret_cast<char*>(p), length)) |
| 110 | { |
| 111 | return FALSE; |
| 112 | } |
| 113 | break; |
| 114 | |
| 115 | case dtype_varying: |
| 116 | { |
| 117 | vary* pVary = reinterpret_cast<vary*>(p); |
| 118 | if (!xdr_short(xdrs, reinterpret_cast<SSHORT*>(&pVary->vary_length))) |
| 119 | { |
| 120 | return FALSE; |
| 121 | } |
| 122 | if (!xdr_opaque(xdrs, reinterpret_cast<SCHAR*>(pVary->vary_string), |
| 123 | MIN(pVary->vary_length, length))) |
| 124 | { |
| 125 | return FALSE; |
| 126 | } |
nothing calls this directly
no test coverage detected