js_js2str(3)

NAME
js_js2str - convert a js_string object in to a NULL-terminated string

SYNOPSIS
#include JsStr.h

js_js2str(js_string *js, char *string, int max)

DESCRIPTION
js_js2str converts the js_string object pointed to by js in to a NULL-terminated string, adding a NULL to the end of the string. The NULL-terminated string in question needs to be be previously allocated, and have at least max + 1 bytes allocated to it, otherwise a buffer overflow may happen. Should the js_string object have NULLs in its string, these NULLs will be copied to the destination string. This may cause routines that use a NULL to terminate a string to inappropriatly terminate the string.

ARGUMENTS
js is a pointer to the js_string object we will convert in to a NULL-terminated string. string is a pointer to where we will place the NULL-terminated string. max is the number of characters allocated to the string - 1. If the string we are pointing to does not have at least max + 1 bytes allocated to it, we may get a buffer overflow. js_js2str returns JS_SUCCESS on successful conversion of the js_string object, JS_ERROR otherwise.

EXAMPLE
The following example creates a js_string object that is given the string "What's up doc?", which is then copied to the string bar, and printed out with printf.
	js_string *foo;
	char bar[256];
	foo = js_create(256,1);
	js_str2js(foo,"What's up doc?",14,1);
	js_js2str(foo,bar,255);
	printf("%s\n",bar);

AUTHOR
Sam Trenholme <kiwi-zttfryb@koala.samiam.org>