[project @ 2001-04-02 16:10:32 by rrt]
[ghc-hetmet.git] / ghc / lib / std / cbits / stgio.h
1 /* -----------------------------------------------------------------------------
2  * $Id: stgio.h,v 1.28 2001/04/02 16:10: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 /* Function prototypes for the I/O subsytem... */
19
20 /* closeFile.c */
21 StgAddr allocMemory__ (StgInt);
22
23 /* closeFile.c */
24 StgInt closeFile (StgForeignPtr,StgInt);
25
26 /* echoAux.c */
27 StgInt setTerminalEcho (StgForeignPtr, StgInt);
28 StgInt getTerminalEcho (StgForeignPtr);
29 StgInt isTerminalDevice (StgForeignPtr);
30
31 /* env.c */
32 char *  strDup          (const char *);
33 int     setenviron      (char **);
34 int     copyenv         (void);
35 int     _setenv         (char *);
36 int     delenv          (char *);
37
38 /* errno.c */
39 DLL_IMPORT_STDLIB extern        int ghc_errno;
40 DLL_IMPORT_STDLIB extern        int ghc_errtype;
41 DLL_IMPORT_STDLIB extern        char* ghc_errstr;
42
43 void    cvtErrno(void);
44 void    stdErrno(void);
45 void    convertErrno(void);
46 StgAddr getErrStr__(void);
47 StgInt  getErrNo__(void);
48 StgInt  getErrType__(void);
49
50 /* execvpe.c */
51 int     execvpe (char *, char **, char **);
52
53 /* fileEOF.c */
54 StgInt  fileEOF (StgForeignPtr);
55 /* fileGetc.c */
56 StgInt  fileGetc (StgForeignPtr);
57
58 /* fileLookAhead.c */
59 StgInt  fileLookAhead (StgForeignPtr);
60 StgInt  ungetChar (StgForeignPtr,StgChar);
61
62 /* fileObject.c */
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*);
83
84 /* filePosn.c */
85 StgInt  getFilePosn (StgForeignPtr);
86 StgInt  setFilePosn (StgForeignPtr, StgInt, StgByteArray);
87
88 /* filePutc.c */
89 StgInt  filePutc    (StgForeignPtr, StgChar);
90
91 /* fileSize.c */
92 StgInt  fileSize    (StgForeignPtr, StgByteArray);
93 StgInt  fileSize_int64 (StgForeignPtr, StgByteArray);
94
95 /* flushFile.c */
96 StgInt  flushFile   (StgForeignPtr);
97 StgInt  flushBuffer (StgForeignPtr);
98 StgInt  flushReadBuffer (StgForeignPtr);
99 void    flushConnectedBuf (StgForeignPtr);
100
101 /* freeFile.c */
102 void freeStdFile (StgAddr);
103 void freeStdFileObject (StgAddr);
104 void freeFileObject (StgAddr);
105
106 StgAddr ref_freeStdFileObject (void);
107 StgAddr ref_freeFileObject    (void);
108
109 /* getBufferMode.c */
110 StgInt  getBufferMode (StgForeignPtr);
111
112 /* getCPUTime.c */
113 StgInt getCPUTime (StgByteArray);
114 StgInt clockTicks(void);
115
116 /* getLock.c */
117 int     lockFile    (int, int, int);
118 int     unlockFile  (int);
119 StgInt  getLock     (StgInt, StgInt);
120
121 /* inputReady.c */
122 StgInt  inputReady  (StgForeignPtr, StgInt);
123
124 /* openFile.c */
125 IOFileObject* openFile    (StgByteArray, StgInt, StgInt);
126 IOFileObject* openFd      (StgInt, StgInt, StgInt);
127 IOFileObject* openStdFile (StgInt, StgInt);
128
129 /* progargs.c */
130 StgAddr get_prog_argv(void);
131 StgInt  get_prog_argc(void);
132
133 /* readFile.c */
134 StgInt  readBlock (StgForeignPtr);
135 StgInt  readChunk (StgForeignPtr,StgAddr,StgInt,StgInt);
136 StgInt  readLine  (StgForeignPtr);
137 StgInt  readChar  (StgForeignPtr);
138
139 /* seekFile.c */
140 StgInt  seekFile  (StgForeignPtr, StgInt, StgInt, StgByteArray);
141 StgInt  seekFile_int64 (StgForeignPtr, StgInt, StgInt64);
142 StgInt  seekFileP (StgForeignPtr);
143
144 /* setBinaryMode.c */
145 StgInt  setBinaryMode__ (StgForeignPtr, StgInt);
146
147 /* setBuffering.c */
148 StgInt  setBuffering (StgForeignPtr, StgInt);
149 StgInt  const_BUFSIZ (void);
150
151 /* setCurrentDirectory.c */
152 StgInt setCurrentDirectory (StgByteArray);
153
154 /* showTime.c */
155 StgInt showTime (StgInt, StgByteArray, StgInt, StgByteArray);
156
157 /* system.c */
158 StgInt  systemCmd (StgByteArray);
159
160 /* writeError.c */
161 StgAddr addrOf_ErrorHdrHook(void);
162 void    writeErrString__ (StgAddr, StgByteArray, StgInt);
163
164 /* writeFile.c */
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);
170
171 /* tcSetAttr.c */
172 #ifdef HAVE_TERMIOS_H
173 #include <termios.h>
174 int tcSetAttr (int fd, int options, const struct termios *tp);
175 #endif
176
177 #endif /* ! STGIO_H */
178
179