MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / CvtCobolToInt

Function CvtCobolToInt

src/gpre/languages/fbrmclib.cpp:319–349  ·  view source on GitHub ↗

Convert a Cobol BINARY(n) to a C integer.

Source from the content-addressed store, hash-verified

317}
318// Convert a Cobol BINARY(n) to a C integer.
319static ISC_UINT64 CvtCobolToInt(const ISC_UCHAR *s, ISC_USHORT len, char type)
320{
321 ISC_UINT64 temp;
322
323 switch (len)
324 {
325 case 2:
326 temp = (*(s) << 8) + *(s + 1);
327 // If source is negative and signed, extend sign to dest
328 if ((*(s + 1) & 0x80) && (type == 11))
329 temp |= 0xffffffffffff0000;
330 break;
331 case 4:
332 temp = (*(s) << 24) + (*(s + 1) << 16) + (*(s + 2) << 8) + *(s + 3);
333 // If source is negative and signed, extend sign to dest
334 if ((*(s + 1) & 0x80) && (type == 11))
335 temp |= 0xffffffff00000000;
336 break;
337 case 8:
338 temp = ((ISC_UINT64)*(s) << 56) + ((ISC_UINT64)*(s + 1) << 48) +
339 ((ISC_UINT64)*(s + 2) << 40) + ((ISC_UINT64)*(s + 3) << 32) +
340 ((ISC_UINT64)*(s+ 4) << 24) + ((ISC_UINT64)*(s + 5) << 16) +
341 ((ISC_UINT64)*(s + 6) << 8) + (ISC_UINT64)*(s + 7);
342 break;
343 default:
344 temp = 0;
345 break;
346 }
347
348 return (temp);
349}
350
351// Convert a cobol argument to a C integer. Make allowances for different
352// data types, since constants get passed as DISPLAY (NSU or NTS) and fields

Callers 2

CvtArgToIntFunction · 0.85
RM_ENTRYFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected