1 /* -----------------------------------------------------------------------------
2 * $Id: stgio.h,v 1.28 2001/04/02 16:10: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 /* Function prototypes for the I/O subsytem... */
21 StgAddr allocMemory__ (StgInt);
24 StgInt closeFile (StgForeignPtr,StgInt);
27 StgInt setTerminalEcho (StgForeignPtr, StgInt);
28 StgInt getTerminalEcho (StgForeignPtr);
29 StgInt isTerminalDevice (StgForeignPtr);
32 char * strDup (const char *);
33 int setenviron (char **);
39 DLL_IMPORT_STDLIB extern int ghc_errno;
40 DLL_IMPORT_STDLIB extern int ghc_errtype;
41 DLL_IMPORT_STDLIB extern char* ghc_errstr;
45 void convertErrno(void);
46 StgAddr getErrStr__(void);
47 StgInt getErrNo__(void);
48 StgInt getErrType__(void);
51 int execvpe (char *, char **, char **);
54 StgInt fileEOF (StgForeignPtr);
56 StgInt fileGetc (StgForeignPtr);
59 StgInt fileLookAhead (StgForeignPtr);
60 StgInt ungetChar (StgForeignPtr,StgChar);
63 void setBufFlags (StgForeignPtr, StgInt);
64 void setBufWPtr (StgForeignPtr, StgInt);
65 StgInt getBufWPtr (StgForeignPtr);
66 void setBuf (StgForeignPtr, StgAddr, StgInt);
67 StgAddr getBuf (StgForeignPtr);
68 StgAddr getWriteableBuf (StgForeignPtr);
69 StgAddr getBufStart (StgForeignPtr,StgInt);
70 StgInt getBufSize (StgForeignPtr);
71 void setFilePtr (StgForeignPtr, StgAddr);
72 StgAddr getFilePtr (StgForeignPtr);
73 void setConnectedTo (StgForeignPtr, StgForeignPtr, StgInt);
74 void setPushbackBufSize (StgInt);
75 StgInt getPushbackBufSize (void);
76 void setNonBlockingIOFlag__ (StgForeignPtr);
77 void clearNonBlockingIOFlag__ (StgForeignPtr);
78 void setConnNonBlockingIOFlag__ (StgForeignPtr);
79 void clearConnNonBlockingIOFlag__ (StgForeignPtr);
80 StgInt getFileFd (StgForeignPtr);
81 StgInt getConnFileFd (StgForeignPtr);
82 StgInt fill_up_line_buffer(IOFileObject*);
85 StgInt getFilePosn (StgForeignPtr);
86 StgInt setFilePosn (StgForeignPtr, StgInt, StgByteArray);
89 StgInt filePutc (StgForeignPtr, StgChar);
92 StgInt fileSize (StgForeignPtr, StgByteArray);
93 StgInt fileSize_int64 (StgForeignPtr, StgByteArray);
96 StgInt flushFile (StgForeignPtr);
97 StgInt flushBuffer (StgForeignPtr);
98 StgInt flushReadBuffer (StgForeignPtr);
99 void flushConnectedBuf (StgForeignPtr);
102 void freeStdFile (StgAddr);
103 void freeStdFileObject (StgAddr);
104 void freeFileObject (StgAddr);
106 StgAddr ref_freeStdFileObject (void);
107 StgAddr ref_freeFileObject (void);
109 /* getBufferMode.c */
110 StgInt getBufferMode (StgForeignPtr);
113 StgInt getCPUTime (StgByteArray);
114 StgInt clockTicks(void);
117 int lockFile (int, int, int);
118 int unlockFile (int);
119 StgInt getLock (StgInt, StgInt);
122 StgInt inputReady (StgForeignPtr, StgInt);
125 IOFileObject* openFile (StgByteArray, StgInt, StgInt);
126 IOFileObject* openFd (StgInt, StgInt, StgInt);
127 IOFileObject* openStdFile (StgInt, StgInt);
130 StgAddr get_prog_argv(void);
131 StgInt get_prog_argc(void);
134 StgInt readBlock (StgForeignPtr);
135 StgInt readChunk (StgForeignPtr,StgAddr,StgInt,StgInt);
136 StgInt readLine (StgForeignPtr);
137 StgInt readChar (StgForeignPtr);
140 StgInt seekFile (StgForeignPtr, StgInt, StgInt, StgByteArray);
141 StgInt seekFile_int64 (StgForeignPtr, StgInt, StgInt64);
142 StgInt seekFileP (StgForeignPtr);
144 /* setBinaryMode.c */
145 StgInt setBinaryMode__ (StgForeignPtr, StgInt);
148 StgInt setBuffering (StgForeignPtr, StgInt);
149 StgInt const_BUFSIZ (void);
151 /* setCurrentDirectory.c */
152 StgInt setCurrentDirectory (StgByteArray);
155 StgInt showTime (StgInt, StgByteArray, StgInt, StgByteArray);
158 StgInt systemCmd (StgByteArray);
161 StgAddr addrOf_ErrorHdrHook(void);
162 void writeErrString__ (StgAddr, StgByteArray, StgInt);
165 StgInt writeBuf (StgForeignPtr, StgAddr, StgInt, StgInt);
166 StgInt writeBufBA (StgForeignPtr, StgByteArray, StgInt, StgInt);
167 StgInt writeFileObject (StgForeignPtr, StgInt);
168 StgInt writeBuffer (StgForeignPtr, StgInt);
169 StgInt write_ (StgForeignPtr ptr, StgAddr buf, StgInt len);
172 #ifdef HAVE_TERMIOS_H
174 int tcSetAttr (int fd, int options, const struct termios *tp);
177 #endif /* ! STGIO_H */