js_buf_getline(3)

NAME
js_buf_getline - grab a line of text from a file (in a buffered context)

SYNOPSIS
#include JsStr.h

int js_buf_getline(js_file *desc, js_string *js)

DESCRIPTION
js_buf_getline reads, in a buffered context, a single line from the file pointed to by desc, and places the read contents in the js_string object js.

ARGUMENTS
desc is a pointer to a file object we are reading a line from.

js is the js_string object we place the read contents in.

WARNING
This routine should not be combined with non-buffered routines, such as js_read.

The js_string object needs to be set to JS_US_ASCII, or another non-binary encoding, before using this function. This is because there are no newline characters (nor any other special characters) in binary data.

RETURN VALUE
js_buf_getline returns JS_SUCCESS on successful reading of a line, -2 if the line is too long for the destination js string, and JS_ERROR otherwise.

EXAMPLE
The following reads a single line from the file "filename" after reading a single line from the file:

	js_string *foo;
	js_file *bar;
	foo = js_create(256,1);
	js_str2js(foo,"filename",8,1);
	js_open_read(foo,bar);
	js_set_encode(foo,JS_US_ASCII);
	js_buf_getline(bar,foo);

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