OpenCores
URL https://opencores.org/ocsvn/c0or1k/c0or1k/trunk

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [conts/] [libc/] [include/] [stdio.h] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 drasko
/*
2
 * Australian Public Licence B (OZPLB)
3
 *
4
 * Version 1-0
5
 *
6
 * Copyright (c) 2004 National ICT Australia
7
 *
8
 * All rights reserved.
9
 *
10
 * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS)
11
 *               National ICT Australia
12
 *               http://www.ertos.nicta.com.au
13
 *
14
 * Permission is granted by National ICT Australia, free of charge, to
15
 * any person obtaining a copy of this software and any associated
16
 * documentation files (the "Software") to deal with the Software without
17
 * restriction, including (without limitation) the rights to use, copy,
18
 * modify, adapt, merge, publish, distribute, communicate to the public,
19
 * sublicense, and/or sell, lend or rent out copies of the Software, and
20
 * to permit persons to whom the Software is furnished to do so, subject
21
 * to the following conditions:
22
 *
23
 *     * Redistributions of source code must retain the above copyright
24
 *       notice, this list of conditions and the following disclaimers.
25
 *
26
 *     * Redistributions in binary form must reproduce the above
27
 *       copyright notice, this list of conditions and the following
28
 *       disclaimers in the documentation and/or other materials provided
29
 *       with the distribution.
30
 *
31
 *     * Neither the name of National ICT Australia, nor the names of its
32
 *       contributors, may be used to endorse or promote products derived
33
 *       from this Software without specific prior written permission.
34
 *
35
 * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT
36
 * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND
37
 * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS,
38
 * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
39
 * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS
40
 * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE,
41
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT,
42
 * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF
43
 * ERRORS, WHETHER OR NOT DISCOVERABLE.
44
 *
45
 * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL
46
 * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL
47
 * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT,
48
 * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER
49
 * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR
50
 * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS
51
 * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR
52
 * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT,
53
 * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN
54
 * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER
55
 * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS
56
 * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS,
57
 * DAMAGES OR OTHER LIABILITY.
58
 *
59
 * If applicable legislation implies representations, warranties, or
60
 * conditions, or imposes obligations or liability on National ICT
61
 * Australia or one of its contributors in respect of the Software that
62
 * cannot be wholly or partly excluded, restricted or modified, the
63
 * liability of National ICT Australia or the contributor is limited, to
64
 * the full extent permitted by the applicable legislation, at its
65
 * option, to:
66
 * a.  in the case of goods, any one or more of the following:
67
 * i.  the replacement of the goods or the supply of equivalent goods;
68
 * ii.  the repair of the goods;
69
 * iii. the payment of the cost of replacing the goods or of acquiring
70
 *  equivalent goods;
71
 * iv.  the payment of the cost of having the goods repaired; or
72
 * b.  in the case of services:
73
 * i.  the supplying of the services again; or
74
 * ii.  the payment of the cost of having the services supplied again.
75
 *
76
 * The construction, validity and performance of this licence is governed
77
 * by the laws in force in New South Wales, Australia.
78
 */
79
 
80
/*
81
Author: Ben Leslie
82
*/
83
 
84
#ifndef _STDIO_H_
85
#define _STDIO_H_
86
 
87
#include <stddef.h>
88
#include <stdarg.h>
89
 
90
#ifdef THREAD_SAFE
91
#include <mutex/mutex.h>
92
#define lock_stream(s) mutex_count_lock(&(s)->mutex)
93
#define unlock_stream(s) mutex_count_unlock(&(s)->mutex)
94
#else
95
#define lock_stream(s)
96
#define unlock_stream(s)
97
#endif
98
 
99
#define __UNGET_SIZE 10
100
 
101
struct __file {
102
        void *handle;
103
 
104
        size_t (*read_fn)(void *, long int, size_t, void *);
105
        size_t (*write_fn)(void *, long int, size_t, void *);
106
        int (*close_fn)(void *);
107
        long int (*eof_fn)(void *);
108
 
109
        unsigned char buffering_mode;
110
        char *buffer;
111
 
112
        unsigned char unget_pos;
113
        long int current_pos;
114
 
115
#ifdef THREAD_SAFE
116
        struct mutex mutex;
117
#endif
118
 
119
        int eof;
120
        int error;
121
 
122
        char unget_stack[__UNGET_SIZE];
123
};
124
 
125
typedef struct __file FILE; /* This needs to be done correctly */
126
typedef long fpos_t; /* same */
127
 
128
#define _IOFBF 0
129
#define _IOLBF 1
130
#define _IONBF 2
131
 
132
#define BUFSIZ 37
133
#define EOF (-1)
134
 
135
#define FOPEN_MAX 37
136
#define FILENAME_MAX 37
137
#define L_tmpnam 37
138
 
139
#ifndef SEEK_SET
140
#define SEEK_SET 0
141
#endif
142
#ifndef SEEK_CUR
143
#define SEEK_CUR 1
144
#endif
145
#ifndef SEEK_END
146
#define SEEK_END 2
147
#endif
148
 
149
#define TMP_MAX 37
150
 
151
extern FILE *stderr;
152
extern FILE *stdin;
153
extern FILE *stdout;
154
 
155
/* 7.19.4 Operations on files */
156
int remove(const char *);
157
int rename(const char *, const char *);
158
FILE *tmpfile(void);
159
char *tmpnam(char *);
160
int fclose(FILE *);
161
int fflush(FILE *);
162
FILE *fopen(const char *, const char *);
163
FILE *freopen(const char *, const char *, FILE *);
164
void setbuf(FILE *, char *);
165
int setvbuf(FILE *, char *, int, size_t);
166
 
167
/* 7.19.6 Format i/o functions */
168
int fprintf(FILE *, const char *, ...);
169
int fscanf(FILE *, const char *, ...);
170
int printf(const char *format, ...) __attribute__((format (printf, 1, 2)));
171
int scanf(const char *, ...);
172
int snprintf(char *, size_t , const char *, ...);
173
int sprintf(char *, const char *, ...);
174
int sscanf(const char *, const char *, ...);
175
int vfprintf(FILE *, const char *, va_list);
176
int vfscanf(FILE *, const char *, va_list);
177
int vprintf(const char *, va_list);
178
int vscanf(const char *, va_list);
179
int vsnprintf(char *, size_t, const char *, va_list );
180
int vsprintf(char *, const char *format, va_list arg);
181
int vsscanf(const char *s, const char *format, va_list arg);
182
 
183
/* 7.19.7 Character i/o functions */
184
char fgetc(FILE *);
185
char *fgetline(FILE *);
186
char *fgets(char *, int, FILE *);
187
int fputc(int, FILE *);
188
int fputs(const char *, FILE *);
189
 
190
/* getc is specified to be the same as fgetc, so it makes
191
   the most sense to implement as a macro here */
192
#define getc fgetc /*int getc(FILE *); */
193
 
194
int getchar(void);
195
char *gets(char *);
196
 
197
/* putc is specified to be the same as fputc, so it makes
198
   the most sense to implement as a macro here */
199
#define putc fputc /*int fetc(int, FILE *); */
200
 
201
int putchar(int);
202
int puts(const char *);
203
int ungetc(int, FILE *);
204
 
205
/* 7.19.8 Direct I/O functions */
206
size_t fread(void *, size_t, size_t, FILE *);
207
size_t fwrite(const void *, size_t, size_t, FILE *);
208
 
209
/* 7.19.9 File positioning functions */
210
int fgetpos(FILE *, fpos_t *);
211
int fseek(FILE *, long int, int);
212
int fsetpos(FILE *, const fpos_t *);
213
long int ftell(FILE *);
214
void rewind(FILE *);
215
 
216
/* 7.19.10 Error-handling functions */
217
void clearerr(FILE *);
218
int feof(FILE *);
219
int ferror(FILE *);
220
void perror(const char *);
221
 
222
#endif /* _STDIO_H_ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.