1 /* -----------------------------------------------------------------------------
2 * $Id: stgio.h,v 1.27 2001/03/01 12:25:33 rrt Exp $
4 * (c) The GRASP/AQUA Project, Glasgow University, 1994-1999
6 * Helper code for GHC's IO subsystem.
8 * ---------------------------------------------------------------------------*/
13 #include "StgDLL.h" /* for DLL_IMPORT_STDLIB */
16 #include "fileObject.h"
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) */
23 #define Fstat _fstati64
29 /* Function prototypes for the I/O subsytem...
33 StgAddr allocMemory__ (StgInt);
36 StgInt closeFile (StgForeignPtr,StgInt);
39 StgInt setTerminalEcho (StgForeignPtr, StgInt);
40 StgInt getTerminalEcho (StgForeignPtr);
41 StgInt isTerminalDevice (StgForeignPtr);
44 char * strDup (const char *);
45 int setenviron (char **);
51 DLL_IMPORT_STDLIB extern int ghc_errno;
52 DLL_IMPORT_STDLIB extern int ghc_errtype;
53 DLL_IMPORT_STDLIB extern char* ghc_errstr;
57 void convertErrno(void);
58 StgAddr getErrStr__(void);
59 StgInt getErrNo__(void);
60 StgInt getErrType__(void);
63 int execvpe (char *, char **, char **);
66 StgInt fileEOF (StgForeignPtr);
68 StgInt fileGetc (StgForeignPtr);
71 StgInt fileLookAhead (StgForeignPtr);
72 StgInt ungetChar (StgForeignPtr,StgChar);
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*);
97 StgInt getFilePosn (StgForeignPtr);
98 StgInt setFilePosn (StgForeignPtr, StgInt, StgByteArray);
101 StgInt filePutc (StgForeignPtr, StgChar);
104 StgInt fileSize (StgForeignPtr, StgByteArray);
105 StgInt fileSize_int64 (StgForeignPtr, StgByteArray);
108 StgInt flushFile (StgForeignPtr);
109 StgInt flushBuffer (StgForeignPtr);
110 StgInt flushReadBuffer (StgForeignPtr);
111 void flushConnectedBuf (StgForeignPtr);
114 void freeStdFile (StgAddr);
115 void freeStdFileObject (StgAddr);
116 void freeFileObject (StgAddr);
118 StgAddr ref_freeStdFileObject (void);
119 StgAddr ref_freeFileObject (void);
121 /* getBufferMode.c */
122 StgInt getBufferMode (StgForeignPtr);
125 StgInt getCPUTime (StgByteArray);
126 StgInt clockTicks(void);
129 int lockFile (int, int, int);
130 int unlockFile (int);
131 StgInt getLock (StgInt, StgInt);
134 StgInt inputReady (StgForeignPtr, StgInt);
137 IOFileObject* openFile (StgByteArray, StgInt, StgInt);
138 IOFileObject* openFd (StgInt, StgInt, StgInt);
139 IOFileObject* openStdFile (StgInt, StgInt);
142 StgAddr get_prog_argv(void);
143 StgInt get_prog_argc(void);
146 StgInt readBlock (StgForeignPtr);
147 StgInt readChunk (StgForeignPtr,StgAddr,StgInt,StgInt);
148 StgInt readLine (StgForeignPtr);
149 StgInt readChar (StgForeignPtr);
152 StgInt seekFile (StgForeignPtr, StgInt, StgInt, StgByteArray);
153 StgInt seekFile_int64 (StgForeignPtr, StgInt, StgInt64);
154 StgInt seekFileP (StgForeignPtr);
156 /* setBinaryMode.c */
157 StgInt setBinaryMode__ (StgForeignPtr, StgInt);
160 StgInt setBuffering (StgForeignPtr, StgInt);
161 StgInt const_BUFSIZ (void);
163 /* setCurrentDirectory.c */
164 StgInt setCurrentDirectory (StgByteArray);
167 StgInt showTime (StgInt, StgByteArray, StgInt, StgByteArray);
170 StgInt systemCmd (StgByteArray);
173 StgAddr addrOf_ErrorHdrHook(void);
174 void writeErrString__ (StgAddr, StgByteArray, StgInt);
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);
184 #ifdef HAVE_TERMIOS_H
186 int tcSetAttr (int fd, int options, const struct termios *tp);
189 #endif /* ! STGIO_H */