WSBytesToGet (C 関数)
int WSBytesToGet(WSLINK link,int *n)
現行データのテキスト表現の中で読み取るのに残されたバイト数を計算し,その結果をn に保存する.
例題
例 (1)
#include <stdlib.h>
#include <string.h>
#include "wstp.h"
/* check the incoming string size to allocate enough memory to store the string */
void f(WSLINK lp)
{
int incoming_bytes;
char *string;
const char *wsstring;
switch(WSGetType(lp))
{
case WSTKSTR:
if(! WSBytesToGet(lp, &incoming_bytes))
{ /* unable to get the size of the string */ }
string = (char *)malloc(incoming_bytes + 1);
if(string == (char *)0)
{ /* memory allocation failed */ }
if(! WSGetString(lp, &wsstring))
{ /* unable to get the string from lp */ }
memcpy(string, wsstring, incoming_bytes);
*(string + incoming_bytes) = '\0';
break;
/* ... */
};
/* ... */
}