XCLE



File IO module

Instructions manual


XCLE: eXtensible Concatenative Language Engine
Copyright (C) 2000-2006 Yann LANDRIN-SCHWEITZER a.k.a. Varkhan


This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA


Author: Yann LANDRIN-SCHWEITZER
Contact: varkhan@varkhan.net
Homepage: http://www.varkhan.net/


Objects File-descriptor Printing


Function XCLE_ObjectPrint

unsigned long XCLE_ObjectPrint(XCLE_Object obj, int fd) ;
Prints an XCLE_Object into a file descriptor.

Args:
obj: XCLE_Object to print
fd: output file descriptor output file descriptor


Returns:
-1: if some error occurred
else the total number of characters printed


Errors:
EINVAL: if a NULL XCLE_Object was passed as argument
or any error generated by the 'write' system call on file descriptor 'fd'



Function XCLE_VoidPrint

unsigned long XCLE_VoidPrint(XCLE_Void vd, int fd) ;
Prints an XCLE_Void into a file descriptor.

Args:
vd: XCLE_Void to print
fd: output file descriptor output file descriptor


Returns:
NULL: if no memory was available
else the total number of characters printed


Errors:
EINVAL: if a NULL was passed as argument
or any error generated by the 'write' system call on file descriptor 'fd'



Function XCLE_IntgPrint

unsigned long XCLE_IntgPrint(XCLE_Intg in, int fd) ;
Prints an XCLE_Intg into a file descriptor.

Args:
in: XCLE_Intg to print
fd: output file descriptor output file descriptor


Returns:
NULL: if no memory was available
else the total number of characters printed


Errors:
EINVAL: if a NULL was passed as argument
or any error generated by the 'write' system call on file descriptor 'fd'



Function XCLE_FltpPrint

unsigned long XCLE_FltpPrint(XCLE_Fltp fp, int fd) ;
Prints an XCLE_Fltp into a file descriptor.

Args:
fp: XCLE_Fltp to print
fd: output file descriptor


Returns:
NULL: if no memory was available


Errors:
EINVAL: if a NULL was passed as argument
or any error generated by the 'write' system call on file descriptor 'fd'



Function XCLE_StrgPrint

unsigned long XCLE_StrgPrint(XCLE_Strg str, int fd) ;
Prints an XCLE_Strg into a file descriptor.

Args:
str: XCLE_Strg to print
fd: output file descriptor


Returns:
NULL: if no memory was available


Errors:
EINVAL: if a NULL was passed as argument
or any error generated by the 'write' system call on file descriptor 'fd'



Function XCLE_ListPrint

unsigned long XCLE_ListPrint(XCLE_List lst, int fd) ;
Prints an XCLE_List into a file descriptor.

Args:
lst: XCLE_List to print
fd: output file descriptor


Returns:
NULL: if no memory was available


Errors:
EINVAL: if a NULL was passed as argument
or any error generated by the 'write' system call on file descriptor 'fd'



Function XCLE_CodePrint

unsigned long XCLE_CodePrint(XCLE_Code cod, int fd) ;
Prints an XCLE_Code into a file descriptor.

Args:
cod: XCLE_Code to print
fd: output file descriptor


Returns:
NULL: if no memory was available


Errors:
EINVAL: if a NULL was passed as argument
or any error generated by the 'write' system call on file descriptor 'fd'




Objects Stream Printing


Function XCLE_ObjectFPrint

unsigned long XCLE_ObjectFPrint(XCLE_Object obj, FILE * os) ;
Prints an XCLE_Object into an output stream.

Args:
obj: XCLE_Object to print
os: output stream output file descriptor


Returns:
-1: if some error occurred
else the total number of characters printed


Errors:
EINVAL: if a NULL XCLE_Object was passed as argument
or any error generated by the 'fwrite' system call on stream 'os'



Function XCLE_VoidFPrint

unsigned long XCLE_VoidFPrint(XCLE_Void vd, FILE * os) ;
Prints an XCLE_Void into an output stream.

Args:
vd: XCLE_Void to print
os: output stream output file descriptor


Returns:
NULL: if no memory was available
else the total number of characters printed


Errors:
EINVAL: if a NULL was passed as argument
or any error generated by the 'fwrite' system call on stream 'os'



Function XCLE_IntgFPrint

unsigned long XCLE_IntgFPrint(XCLE_Intg in, FILE * os) ;
Prints an XCLE_Intg into an output stream.

Args:
in: XCLE_Intg to print
os: output stream output file descriptor


Returns:
NULL: if no memory was available
else the total number of characters printed


Errors:
EINVAL: if a NULL was passed as argument
or any error generated by the 'fwrite' system call on stream 'os'



Function XCLE_FltpFPrint

unsigned long XCLE_FltpFPrint(XCLE_Fltp fp, FILE * os) ;
Prints an XCLE_Fltp into an output stream.

Args:
fp: XCLE_Fltp to print
os: output stream


Returns:
NULL: if no memory was available


Errors:
EINVAL: if a NULL was passed as argument
or any error generated by the 'fwrite' system call on stream 'os'



Function XCLE_StrgFPrint

unsigned long XCLE_StrgFPrint(XCLE_Strg str, FILE * os) ;
Prints an XCLE_Strg into an output stream.

Args:
str: XCLE_Strg to print
os: output stream


Returns:
NULL: if no memory was available


Errors:
EINVAL: if a NULL was passed as argument
or any error generated by the 'fwrite' system call on stream 'os'



Function XCLE_ListFPrint

unsigned long XCLE_ListFPrint(XCLE_List lst, FILE * os) ;
Prints an XCLE_List into an output stream.

Args:
lst: XCLE_List to print
os: output stream


Returns:
NULL: if no memory was available


Errors:
EINVAL: if a NULL was passed as argument
or any error generated by the 'fwrite' system call on stream 'os'



Function XCLE_CodeFPrint

unsigned long XCLE_CodeFPrint(XCLE_Code cod, FILE * os) ;
Prints an XCLE_Code into an output stream.

Args:
cod: XCLE_Code to print
os: output stream


Returns:
NULL: if no memory was available


Errors:
EINVAL: if a NULL was passed as argument
or any error generated by the 'fwrite' system call on stream 'os'




Stack and Hash Printing


Function XCLE_StackPrintF

unsigned long XCLE_StackPrintF(XCLE_Stack stk, int fd, char * head, char * rowfmt, char * tail, unsigned long rows) ;
Prints the contents of an XCLE_Stack in a file descriptor, following the given formats.

Args:
stk: XCLE_Stack
fd: file descriptor
head: head string
rowfmt: row printing format
tail: tail string
rows: number of rows (height in chars)


Returns:
-1: if some error occurred
else the number of characters printed.


Errors:
EINVAL: if a NULL XCLE_Stack was passed as argument



Function XCLE_HashPrintF

unsigned long XCLE_HashPrintF(XCLE_Hash hsh, int fd, char * head, char * rowfmt, char * tail) ;
Prints the contents of an XCLE_Hash in a file descriptor, following the given formats.

Args:
hsh: XCLE_Hash
fd: file descriptor
head: head string
rowfmt: row printing format
tail: tail string
rows: number of rows (height in chars)


Returns:
-1: if some error occurred
else the number of characters printed.


Errors:
EINVAL: if a NULL XCLE_Hash was passed as argument



Function XCLE_StackFPrintF

unsigned long XCLE_StackFPrintF(XCLE_Stack stk, FILE * os, char * head, char * rowfmt, char * tail, unsigned long rows) ;
Prints the contents of an XCLE_Stack in an output stream, following the given formats.

Args:
stk: XCLE_Stack
os: output stream
head: head string
rowfmt: row printing format
tail: tail string
rows: number of rows (height in chars)


Returns:
-1: if some error occurred
else the number of characters printed.


Errors:
EINVAL: if a NULL XCLE_Stack was passed as argument



Function XCLE_HashFPrintF

unsigned long XCLE_HashFPrintF(XCLE_Hash hsh, int fd, char * head, char * rowfmt, char * tail) ;
Prints the contents of an XCLE_Hash in an output stream, following the given formats.

Args:
hsh: XCLE_Hash
os: output stream
head: head string
rowfmt: row printing format
tail: tail string
rows: number of rows (height in chars)


Returns:
-1: if some error occurred
else the number of characters printed.


Errors:
EINVAL: if a NULL XCLE_Hash was passed as argument




File-descriptor Parsing


Function XCLE_ObjectScan

XCLE_Object XCLE_ObjectScan(XCLE_ParseCtx contx, int fd, unsigned long * ln) ;
Parses an object from an input stream.

Args:
contx: parsing context
fd: file descriptor to read from
ln: line number


Returns:
NULL: if an IO error or a syntax error occured
else one parsed object from the stream.


Errors:
EBADF: an invalid file descriptor war specified
EIO: a read error occured
ENOMEM: no memory was available
EINVAL: a syntax error occured

Note:
Do not rely on the file descriptor offset to be anywhere usable or in relation
to the data read. The buffering scheme used does not allow this. This is a BUG,
and will be corrected in the future by repositioning the stream offset on file
streams. Pipe streams will remain bugged until FILE* reading is implemented.




Function XCLE_ListScan

XCLE_List XCLE_ListScan(XCLE_ParseCtx contx, int fd, unsigned long * ln) ;
Parses a list from an input flux.

Args:
contx: parsing context
fd: file descriptor to read from
ln: line number


Returns:
NULL: if an IO error or a syntax error occured
else the parsed List.


Errors:
EBADF: an invalid file descriptor war specified
EIO: a read error occured
ENOMEM: no memory was available
EINVAL: a syntax error occured

Note:
Do not rely on the file descriptor offset to be anywhere usable or in relation
to the data read. The buffering scheme used does not allow this. This is a BUG,
and will be corrected in the future by repositioning the stream offset on file
streams. Pipe streams will remain bugged until FILE* reading is implemented.





Generated by textdoc2html - 2006-02-22