[project @ 2001-03-01 12:25:32 by rrt]
[ghc-hetmet.git] / ghc / lib / std / cbits / stgio.h
1 /* -----------------------------------------------------------------------------
2  * $Id: stgio.h,v 1.27 2001/03/01 12:25:33 rrt Exp $
3  *
4  * (c) The GRASP/AQUA Project, Glasgow University, 1994-1999
5  *
6  * Helper code for GHC's IO subsystem.
7  *
8  * ---------------------------------------------------------------------------*/
9
10 #ifndef STGIO_H
11 #define STGIO_H
12
13 #include "StgDLL.h"  /* for DLL_IMPORT_STDLIB */
14
15 #include "stgerror.h"
16 #include "fileObject.h"
17
18 /* Fix for mingwin stat */
19 #ifdef mingw32_TARGET_OS
20 /* Need to #define __MSVCRT__ to get these versions, but in order to do this
21    early enough it's done in Stg.h (included by Rts.h) */
22 #define Stat _stati64
23 #define Fstat _fstati64
24 #else
25 #define Stat stat
26 #define Fstat fstat
27 #endif
28
29 /* Function prototypes for the I/O subsytem...
30  */
31
32 /* closeFile.c */
33 StgAddr allocMemory__ (StgInt);
34
35 /* closeFile.c */
36 StgInt closeFile (StgForeignPtr,StgInt);
37
38 /* echoAux.c */
39 StgInt setTerminalEcho (StgForeignPtr, StgInt);
40 StgInt getTerminalEcho (StgForeignPtr);
41 StgInt isTerminalDevice (StgForeignPtr);
42
43 /* env.c */
44 char *  strDup          (const char *);
45 int     setenviron      (char **);
46 int     copyenv         (void);
47 int     _setenv         (char *);
48 int     delenv          (char *);
49
50 /* errno.c */
51 DLL_IMPORT_STDLIB extern        int ghc_errno;
52 DLL_IMPORT_STDLIB extern        int ghc_errtype;
53 DLL_IMPORT_STDLIB extern        char* ghc_errstr;
54
55 void    cvtErrno(void);
56 void    stdErrno(void);
57 void    convertErrno(void);
58 StgAddr getErrStr__(void);
59 StgInt  getErrNo__(void);
60 StgInt  getErrType__(void);
61
62 /* execvpe.c */
63 int     execvpe (char *, char **, char **);
64
65 /* fileEOF.c */
66 StgInt  fileEOF (StgForeignPtr);
67 /* fileGetc.c */
68 StgInt  fileGetc (StgForeignPtr);
69
70 /* fileLookAhead.c */
71 StgInt  fileLookAhead (StgForeignPtr);
72 StgInt  ungetChar (StgForeignPtr,StgChar);
73
74 /* fileObject.c */
75 void    setBufFlags (StgForeignPtr, StgInt);
76 void    setBufWPtr  (StgForeignPtr, StgInt);
77 StgInt  getBufWPtr  (StgForeignPtr);
78 void    setBuf      (StgForeignPtr, StgAddr, StgInt);
79 StgAddr getBuf      (StgForeignPtr);
80 StgAddr getWriteableBuf (StgForeignPtr);
81 StgAddr getBufStart (StgForeignPtr,StgInt);
82 StgInt  getBufSize  (StgForeignPtr);
83 void    setFilePtr  (StgForeignPtr, StgAddr);
84 StgAddr getFilePtr  (StgForeignPtr);
85 void    setConnectedTo  (StgForeignPtr, StgForeignPtr, StgInt);
86 void    setPushbackBufSize (StgInt);
87 StgInt  getPushbackBufSize (void);
88 void    setNonBlockingIOFlag__ (StgForeignPtr);
89 void    clearNonBlockingIOFlag__ (StgForeignPtr);
90 void    setConnNonBlockingIOFlag__ (StgForeignPtr);
91 void    clearConnNonBlockingIOFlag__ (StgForeignPtr);
92 StgInt  getFileFd  (StgForeignPtr);
93 StgInt  getConnFileFd  (StgForeignPtr);
94 StgInt  fill_up_line_buffer(IOFileObject*);
95
96 /* filePosn.c */
97 StgInt  getFilePosn (StgForeignPtr);
98 StgInt  setFilePosn (StgForeignPtr, StgInt, StgByteArray);
99
100 /* filePutc.c */
101 StgInt  filePutc    (StgForeignPtr, StgChar);
102
103 /* fileSize.c */
104 StgInt  fileSize    (StgForeignPtr, StgByteArray);
105 StgInt  fileSize_int64 (StgForeignPtr, StgByteArray);
106
107 /* flushFile.c */
108 StgInt  flushFile   (StgForeignPtr);
109 StgInt  flushBuffer (StgForeignPtr);
110 StgInt  flushReadBuffer (StgForeignPtr);
111 void    flushConnectedBuf (StgForeignPtr);
112
113 /* freeFile.c */
114 void freeStdFile (StgAddr);
115 void freeStdFileObject (StgAddr);
116 void freeFileObject (StgAddr);
117
118 StgAddr ref_freeStdFileObject (void);
119 StgAddr ref_freeFileObject    (void);
120
121 /* getBufferMode.c */
122 StgInt  getBufferMode (StgForeignPtr);
123
124 /* getCPUTime.c */
125 StgInt getCPUTime (StgByteArray);
126 StgInt clockTicks(void);
127
128 /* getLock.c */
129 int     lockFile    (int, int, int);
130 int     unlockFile  (int);
131 StgInt  getLock     (StgInt, StgInt);
132
133 /* inputReady.c */
134 StgInt  inputReady  (StgForeignPtr, StgInt);
135
136 /* openFile.c */
137 IOFileObject* openFile    (StgByteArray, StgInt, StgInt);
138 IOFileObject* openFd      (StgInt, StgInt, StgInt);
139 IOFileObject* openStdFile (StgInt, StgInt);
140
141 /* progargs.c */
142 StgAddr get_prog_argv(void);
143 StgInt  get_prog_argc(void);
144
145 /* readFile.c */
146 StgInt  readBlock (StgForeignPtr);
147 StgInt  readChunk (StgForeignPtr,StgAddr,StgInt,StgInt);
148 StgInt  readLine  (StgForeignPtr);
149 StgInt  readChar  (StgForeignPtr);
150
151 /* seekFile.c */
152 StgInt  seekFile  (StgForeignPtr, StgInt, StgInt, StgByteArray);
153 StgInt  seekFile_int64 (StgForeignPtr, StgInt, StgInt64);
154 StgInt  seekFileP (StgForeignPtr);
155
156 /* setBinaryMode.c */
157 StgInt  setBinaryMode__ (StgForeignPtr, StgInt);
158
159 /* setBuffering.c */
160 StgInt  setBuffering (StgForeignPtr, StgInt);
161 StgInt  const_BUFSIZ (void);
162
163 /* setCurrentDirectory.c */
164 StgInt setCurrentDirectory (StgByteArray);
165
166 /* showTime.c */
167 StgInt showTime (StgInt, StgByteArray, StgInt, StgByteArray);
168
169 /* system.c */
170 StgInt  systemCmd (StgByteArray);
171
172 /* writeError.c */
173 StgAddr addrOf_ErrorHdrHook(void);
174 void    writeErrString__ (StgAddr, StgByteArray, StgInt);
175
176 /* writeFile.c */
177 StgInt  writeBuf  (StgForeignPtr, StgAddr, StgInt, StgInt);
178 StgInt  writeBufBA  (StgForeignPtr, StgByteArray, StgInt, StgInt);
179 StgInt  writeFileObject (StgForeignPtr, StgInt);
180 StgInt  writeBuffer (StgForeignPtr, StgInt);
181 StgInt  write_ (StgForeignPtr ptr, StgAddr buf, StgInt len);
182
183 /* tcSetAttr.c */
184 #ifdef HAVE_TERMIOS_H
185 #include <termios.h>
186 int tcSetAttr (int fd, int options, const struct termios *tp);
187 #endif
188
189 #endif /* ! STGIO_H */
190
191