National Instruments 320685D-01 Drums User Manual


 
Chapter 4 Windows 3.1 Compiler/Linker Issues
©
National Instruments Corporation 4-17 LabWindows/CVI Programmer Reference Manual
Then assume that a program in LabWindows/CVI uses the function f as follows:
char *bufptr;
bufptr = f();
printf("%s", bufptr);
You would have to modify the glue code as shown here:
char * f(char *ptr)
{
char *retval;
unsigned short cw387;
char *ptr, *tmpPtr, _far *farPtr32, _far *tmpFarPtr32;
int i;
cw387 = Get387CW();
retval = (char *) InvokeIndirectFunction(__static_f, ptr);
Set387CW(cw387);
/* convert the 16 bit far pointer to a 32 bit far pointer*/
farPtr32 = MK_FP32(retval);
tmpFarPtr32 = farPtr32;
/* Calculate the length of the string. Cannot call strlen*/
/* because it does not accept far pointers. */
i = 0
while (*tmpFarPtr32++)
i++;
/* Allocate buffer from CVI memory and copy in data. */
if ((ptr = malloc(i + 1)) != NULL) {
tmpFarPtr32 = farPtr32;
tmpPtr = ptr;
while (*tmpPtr++ = *tmpFarPtr32++);
}
return ptr;
}
00ProRef.book : 06chap04.fm Page 17 Monday, March 9, 1998 3:23 PM