-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathc_fputc.c
82 lines (53 loc) · 1.51 KB
/
c_fputc.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
////////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
//
// Upon successful completion, c_fputc() shall give ISTAT
// the value it has written.
// Otherwise, it shall give
// EOF,
// the error indicator for the stream shall be set, and ERRNO shall be set
// to indicate the error.
//
void c_fputc_ ( FILE **fp, int *c, int *istat )
{
*istat = fputc ( *c, *fp );
}
//
//
// New version:
// Pass arguments using its reference with value in integer(8), i.e.
// intptr_t defined in /usr/include/stdint.h
//
#include <stdint.h>
void c_fputc_intref_ ( intptr_t *iptr, int *c, int *istat )
{
*istat = fputc ( *c, (FILE *) (*iptr) );
}
/*
DEPRECATED.
Or, consider this procedure:
Use global variable for casting types only one time
because casting types costs time!
We use registry list of pointers.
--> NO IT'S EXTREMELY FAST! I CHECKED. FORGET ABOUT THIS IMPLEMENTATION.
//const int MAX_IPTRLIST = 50 ;
#define MAX_IPTRLIST 50
FILE *IPTRLIST_fputc[MAX_IPTRLIST] = {NULL} ;
// Make sure 0 <= *id <= 49
// pre-processing: do this only only one time for every stream
void c_fputc_intref_pre_ ( int *id, intptr_t *iptr )
{
IPTRLIST_fputc[*id] = (FILE *) (*iptr) ;
}
// processing:
void c_fputc_intref_pro_ ( int *id, int *c, int *istat )
{
*istat = fputc ( *c, IPTRLIST_fputc[*id] );
}
// end-processing:
void c_fputc_intref_end_ ( int *id )
{
IPTRLIST_fputc[*id] = NULL ;
}
*/
//