This is a package which provides Memo input/output functions,
modelled on the C standard I/O (stdio) functions.
Copyright (C) 2002 Graham R. Cobb. The package is distributed under the GPL (see the copyright notices and the COPYING file).
MEMOIO For Rex 6000 is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
MEMOIO For Rex 6000 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 General Public License for more details.
The MEMOIO distribution contains six main files in the top level directory (as well as sources and some informational files):
memoio.h -- This is the header file for programs using this library.
It must be copied to a suitable "include" directory
(e.g. rexdk/include/rex/).
memoio.lib -- This is the self-contained precompiled library file.
It must be copied to rexdk/lib/clibs/ and can be linked using
-lmemoio on the zcc command line.
memoio-ro.lib -- This is a smaller self-contained precompiled library file
which only supports read operations on Memos.
It must be copied to rexdk/lib/clibs/ and can be linked using
-lmemoio-ro on the zcc command line.
memoio-so.lib -- This is a precompiled library file using the shareable library version
of MEMOIO. It should be copied to rexdk/lib/clibs/ and linked using
-lmemoio-so on the zcc command line.
This library must
be used in conjunction with the Rex addins described below.
memoio-read.rex -- This is a Rex addin which contains the MEMOIO
library routines needed for Memo reading.
It is accessed using the shareable library version of the MEMOIO library.
This addin must be loaded on the Rex before a program which uses the MEMOIO shareable
library can run.
If you know your addin only does read operations you only need to load this library.
memoio-write.rex -- This is a Rex addin which contains the MEMOIO
library routines needed for write access to Memos.
It is also accessed using the shareable library version of the GRCLIB library.
This addin must be loaded on the Rex before a program which
opens a Memo for write access can run.
The addin programmer has a choice of three forms of the library to use:
memoio.lib, any required library routines are included
in the addin and no extra programs are required to run it.
Full read-write access is available.
Note that the GRCLIB library must also be linked in.
memoio-ro.lib, any required library routines are included
in the addin and no extra programs are required to run it.
However, only read access is available -- attempts to open a Memo with any mode which would permit
writing returns an error.
Note that the GRCLIB library must also be linked in.
memoio-so.lib, a minimum amount of code
is included in to the addin and the library routines themselves are accessed from the
memoio-read.rex and memoio-write.rex shareable library addins.
If you do not have the memoio-write.rex addin loaded and you attempt to open a Memo
for write access, your addin will terminate as the stub fails to
find the required write routines.
In this case, the GRCLIB library must also be included
in the link but it does not matter whether the static (-lgrclib) or shareable (-lgrclib-so) versions are used:
in either case the required GRCLIB routines are linked statically and the GRCLIB library addin is not required.
The package also contains the sources for the two forms of the library and the shareable library addins and also for a test addin.
For MEMOIO Version 0.4.
These routines are based on the C stdio.h library but with several important differences:
errno is not used.
Errors are stored in the stream structure and can be retrieved using memo_err.
This header file defines several supported constants and one typedef (which should be considered opaque -- the contents can change in future releases).
The stream data structure is critical -- it is used by all the memo routines
to keep context.
It is defined in memoio.h as the MEMO type and must be allocated by the caller of memo_open:
MEMO stream;
memo_open(&stream, "name", "r");
Note: the memo routines expect the address of the stream.
If you forget the & the current compiler will silently add it and everything will work.
However, your code will break if that compiler bug is ever fixed and the structure ends
up passed by value!
NULL, true, false -- all with conventional defintions, and only defined if they are not defined already.
MEMONAME_MAX -- maximum supported length for a Memo name.
MEMO_EOF -- end of file indicator.
MEMO_SEEK_SET, MEMO_SEEK_CUR, MEMO_SEEK_END -- analogous to SEEK_SET, SEEK_CUR, SEEK_END.
Open a Memo and associate a stream.
int memo_open(MEMO *stream, const unsigned char *memo_name, const unsigned char *mode)
MEMO *stream -- pointer to MEMO stream structure (must be allocated by caller)
unsigned char *memo_name -- pointer to memo title
unsigned char *mode -- mode string (as for fopen). If mode is NULL, "r" is assumed.
memo_err.
Terminate I/O operations on a Memo, flush the stream, free the database handle and disassociate the stream.
int memo_close(MEMO *stream)
MEMO *stream -- pointer to MEMO stream structure
memo_err.
Flush any pending I/O for the stream.
This routine is unlikely to be useful on the Rex as other applications cannot be trying to access the
Memo simultaneously.
The final flush is performed automatically by memo_close.
int memo_flush(MEMO *stream)
MEMO *stream -- pointer to MEMO stream structure
Delete a Memo.
int memo_remove(const unsigned char *memo_name)
const unsigned char *memo_name -- pointer to memo title
Rename a Memo.
int memo_rename(const unsigned char *old_name, const unsigned char *new_name)
const unsigned char *old_name -- pointer to old memo title
const unsigned char *new_name -- pointer to new memo title
Seek to a particular position in the memo.
int memo_seek(MEMO *stream, int offset, int origin)
MEMO *stream -- pointer to MEMO stream structure
int offset -- offset, in bytes, from the origin
int origin -- one of MEMO_SEEK_SET (offset is from beginning of file),
MEMO_SEEK_CUR (offset is from current file position),
MEMO_SEEK_END (offset is from end of file).
memo_err.
int, not a long int.
Read a character from a Memo.
int memo_getc(MEMO *stream)
MEMO *stream -- pointer to MEMO stream structure
MEMO_EOF -- MEMO_EOF indicates an error or end of file
memo_eof.
memo_err.
Read a line from a Memo.
The function reads bytes from stream into the array pointed to by buffer, until length-1 bytes are read, or a newline character is read and transferred to buffer, or an end-of-file condition is encountered. The string is then terminated with a null byte.
char *memo_gets(char *buffer, unsigned short length, MEMO *stream)
char *buffer -- address of buffer to store characters
int length -- maximum size of buffer
MEMO *stream -- pointer to MEMO stream structure
buffer or NULL -- NULL indicates an error or end of file
memo_eof.
memo_err.
Wite a byte to a Memo.
int memo_putc(int c, MEMO *stream)
int c -- single character
MEMO *stream -- pointer to MEMO stream structure
MEMO_EOF -- error
memo_err.
Wite a string to a Memo.
int memo_puts(const char *buffer, MEMO *stream)
char *buffer -- address of NUL-terminated string
MEMO *stream -- pointer to MEMO stream structure
MEMO_EOF -- error
memo_err.
memo_clearerr(MEMO *stream) -- reset the error flag (but not the eof flag).
int memo_eof(MEMO *stream) -- return the end of file indicator.
int memo_err(MEMO *stream) -- return the error code (0 indicates no error, all error codes are negative).
int memo_tell(MEMO *stream) -- return the current Memo offset.
memo_rewind(MEMO *stream) -- seek to start of Memo.
Link with new FindLib from August 2002 RexDk
Remove unintended dependency on GRCLIB.
Use new Rexdk library mechanism.