home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fish 'n' More 2
/
fishmore-publicdomainlibraryvol.ii1991xetec.iso
/
fish
/
languages
/
northc_384
/
example1.lzh
/
clibs
/
UNIX
/
README
< prev
next >
Wrap
Text File
|
1990-08-30
|
3KB
|
106 lines
(c) 1990 S.Hawtin.
Permission is granted to copy this file provided
1) It is not used for commercial gain
2) This notice is included in all copies
3) Altered copies are marked as such
No liability is accepted for the contents of the file.
README within Public Domain UNIX.lib
This directory contains the source for the "UNIX" library, this
implements a few UNIX type functions that are missing from the standard
'C' library.
This set of functions follows the older style of file interface for 'C',
I have included them because you may find a program that needs to call
these lower level functions to manipulate files.
To use any of these functions you should include the file "unix.h" in
your source and link the program with a command such as
prog1: foo.o bar.o baz.o
blink with $*.blink LIB jim:libs/libUNIX.a
in you Makefile, this tells the linker to look in "jim:libs/libUNIX.a" for
any functions that are used but not defined.
The functions in the library are not quite the same as the UNIX or MSDOS
functions but they are near enough to work. Once you have your program
up and running you should change it over to use the ANSI functions, you will
find it easier to move the program later.
The functions in this library are:
int close(handle)
APTR handle;
Close the file, this will call the AmigaDOS function Close() on the file
handle, the value returned will be from Close().
APTR creat(name,mode)
char *name;
int mode;
Open the named file, this function will create a new file even if one
already existed with the given name. This function calls the AmigaDOS
Open() function.
unsigned int getw(fptr)
FILE *fptr;
Get the next word from the file, this will just treat the next two bytes
in the file as an integer. Beware when reading files that were written on
other machines, for example on the IBM PC, the byte order can make a
difference.
long lseek(handle,offset,whence)
APTR handle;
long offset;
int whence;
Move the current location within a file, this calls the AmigaDOS Seek()
function. Note the value of whence uses the UNIX values of 0 1 and 2 not
the values defined in <stdio.h>.
APTR open(name,mode)
char *name;
int mode;
Open a file, this function will either open a new file or an existing file.
The function of course uses the AmigaDOS Open() function.
int putw(val,fptr)
int val;
FILE *fptr;
Put a short word into the file, if you intend to transfer files to other
machines then beware of the byte order of your processor.
int read(handle,buf,count)
APTR handle;
char *buf;
int count;
Read a block of data from the file into an area of memory. Again the byte
order may mess you up with foreign files. Not this is an unbuffered read.
long tell(handle)
APTR handle;
Return the current location of the pointer in the buffer, this is given
in terms of the number of bytes from the start of the file.
int write(handle,buf,count)
APTR handle;
char *buf;
int count;
Write a block of data from memory to the file, this function uses the
AmigaDOS Write() function.