1
0
mirror of https://github.com/adtools/clib2.git synced 2025-12-08 14:59:05 +00:00
Files
amiga-clib2/library/include/stdio.h
Olaf Barthel 984c6729c1 - Updated the copyright information.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14789 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2005-01-02 09:07:21 +00:00

346 lines
12 KiB
C

/*
* $Id: stdio.h,v 1.5 2005-01-02 09:07:21 obarthel Exp $
*
* :ts=4
*
* Portable ISO 'C' (1994) runtime library for the Amiga computer
* Copyright (c) 2002-2005 by Olaf Barthel <olsen@sourcery.han.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Neither the name of Olaf Barthel nor the names of contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _STDIO_H
#define _STDIO_H
/****************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/****************************************************************************/
#ifndef _STDDEF_H
#include <stddef.h>
#endif /* _STDDEF_H */
#ifndef _STDARG_H
#include <stdarg.h>
#endif /* _STDARG_H */
/****************************************************************************/
/* 'End of file' indicator returned by, for example, fgetc() */
#define EOF (-1)
/****************************************************************************/
/*
* Maximum number of files that can be open at a time. This number does not
* correspond to a real limitation for this 'C' runtime library and is
* included solely for ISO 'C' (1994) compliance.
*/
#define FOPEN_MAX 64
/****************************************************************************/
/* Maximum size of a file/path name. */
#define FILENAME_MAX 256
/****************************************************************************/
/* Default size for all standard I/O file buffers. */
#define BUFSIZ 8192
/****************************************************************************/
/* File buffering modes for use with setvbuf() */
#define _IOFBF 0 /* Full buffering (flush when buffer is full) */
#define _IOLBF 1 /* Line buffering (flush when buffer is full or when
a line feed character is written) */
#define _IONBF 2 /* Perform no buffering at all */
/****************************************************************************/
/* Positioning modes for use with fseek() */
#define SEEK_SET 0 /* New position is absolute */
#define SEEK_CUR 1 /* New position is relative to current file position */
#define SEEK_END 2 /* New position is relative to end of file */
/****************************************************************************/
/* Used by fgetpos() and fsetpos() */
#if defined(__GNUC__)
typedef long long fpos_t;
#else
typedef long fpos_t;
#endif /* __GNUC__ */
/****************************************************************************/
/*
* This is part of the internal 'FILE' structure; this is guaranteed not to
* change in future library releases. However, the private portion of this
* data structure may change.
*/
typedef struct
{
unsigned long flags; /* See below for some of the public
flag bits defined; this is by no
means a complete list, though! */
unsigned char * buffer; /* Points to the first byte of the
buffer; this could be NULL! */
long size; /* How many bytes will fit into the
buffer; this could be 0! */
long position; /* Current buffer position, which is
usually a number between 0 and
size-1 */
long num_read_bytes; /* How many bytes can be read from
the buffer; this can be 0! */
long num_write_bytes; /* How many bytes have been copied
to the buffer which have not been
written back yet; this can be 0! */
/* Private fields follow... */
} FILE;
/****************************************************************************/
/* Field and flag definitions for the getc/putc macros below. */
#define __FILE_BUFFER_MASK 3 /* Masks off the buffering mode */
#define __FILE_EOF (1<<2) /* EOF reached */
#define __FILE_READABLE (1<<3) /* File is readable */
#define __FILE_WRITABLE (1<<4) /* File is writable */
#define __FILE_IN_USE (1<<5) /* File is in use */
#define __FILE_ERROR (1<<6) /* Error detected */
/****************************************************************************/
/*
* Maximum file name buffer size for use with tmpfile() and tmpnam();
* note that the maximum file name length is shorter by one character
*/
#define L_tmpnam 10
/* Maximum number of unique file names tmpnam() can generate */
#define TMP_MAX 0x3ffff
/****************************************************************************/
/* Anchor for the buffered standard I/O streams */
extern struct iob ** __iob;
/****************************************************************************/
/* The three standard I/O streams */
#define stdin ((FILE *)__iob[0])
#define stdout ((FILE *)__iob[1])
#define stderr ((FILE *)__iob[2])
/****************************************************************************/
extern void perror(const char * s);
/****************************************************************************/
extern FILE *fopen(const char *filename, const char *mode);
extern int fclose(FILE *stream);
extern int fflush(FILE *stream);
extern FILE *freopen(const char *filename, const char *mode, FILE *stream);
extern int setvbuf(FILE *stream,char *buf,int bufmode,size_t size);
extern void setbuf(FILE *stream, char *buf);
/****************************************************************************/
extern int fseek(FILE *stream, long int offset, int wherefrom);
extern long int ftell(FILE *stream);
extern void rewind(FILE *stream);
extern int fgetpos(FILE *stream, fpos_t *pos);
extern int fsetpos(FILE *stream, fpos_t *pos);
/****************************************************************************/
extern int fgetc(FILE *stream);
extern int getc(FILE *stream);
extern int getchar(void);
extern int ungetc(int c,FILE *stream);
/****************************************************************************/
extern int fputc(int c,FILE *stream);
extern int putc(int c,FILE *stream);
extern int putchar(int c);
/****************************************************************************/
extern char *fgets(char *s,int n,FILE *stream);
extern char *gets(char *s);
/****************************************************************************/