WSPutRawSize()
This feature is not supported on the Wolfram Cloud.

int WSPutRawSize(WSLINK link, int s)
prepares link to receive raw character data or numeric data of length s bytes.

DetailsDetails

  • Use WSPutRawSize() in conjunction with WSPutType() and WSPutRawData() to manually put data to a link rather than using the type-specific API functions such as WSPutInteger32() or WSPutUTF8String().
  • WSPutRawSize() returns a 0 in the event of an error and a nonzero value if the function succeeds.
  • Use WSError() to retrieve the error code if WSPutRawSize() fails.
  • WSPutRawSize() is declared in the WSTP header file wstp.h.

ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

#include "mathlink.h"

/* send a function as raw data to a link */

void f(MLINK lp)
{
    int a = 2, b = 3;

    if(! WSPutType(lp, WSTKFUNC))
        { return; /* unable to put the function type to lp */ }

    if(! WSPutArgCount(lp, 2))
        { return; /* unable to put the number of arguments to lp */ }

    if(! WSPutType(lp, WSTKOLDSYM))
        { return; /* unable to put function head type to lp */ }
    
    if(! WSPutRawSize(lp, 4))
        { return; /* unable to put the size of the symbol to lp */ }

    if(! WSPutRawData(lp, (const unsigned char *)"Plus", 4))
        { return; /* unable to put the raw bytes to lp */ }

    if(! WSPutType(lp, WSTK_CINT))
        { return; /* unable to put the argument type to lp */ }

    if(! WSPutRawSize(lp, sizeof(int)))
        { return; /* unable to put the size of the integer to lp */ }

    if(! WSPutRawData(lp, (const unsigned char *)&a, sizeof(a)))
        { return; /* unable to put the raw bytes of a to lp */ }

    if(! WSPutType(lp, WSTK_CINT))
        { return; /* unable to put the second argument type to lp */ }

    if(! WSPutRawSize(lp, sizeof(int)))
        { return; /* unable to put the size of the integer to lp */ }

    if(! WSPutRawData(lp, (const unsigned char *)&b, sizeof(b)))
        { return; /* unable to put the raw bytes of b to lp */ }
}