[project @ 2001-01-16 14:06:14 by simonmar]
[ghc-hetmet.git] / ghc / lib / std / cbits / stgio.h
1 /* -----------------------------------------------------------------------------
2  * $Id: stgio.h,v 1.25 2001/01/16 14:06:14 simonmar 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
21 /* closeFile.c */
22 StgAddr allocMemory__ (StgInt);
23
24 /* closeFile.c */
25 StgInt closeFile (StgForeignPtr,StgInt);
26
27 /* echoAux.c */
28 StgInt setTerminalEcho (StgForeignPtr, StgInt);
29 StgInt getTerminalEcho (StgForeignPtr);
30 StgInt isTerminalDevice (StgForeignPtr);
31
32 /* env.c */
33 char *  strDup          (const char *);
34 int     setenviron      (char **);
35 int     copyenv         (void);
36 int     _setenv         (char *);
37 int     delenv          (char *);
38
39 /* errno.c */
40 DLL_IMPORT_STDLIB extern        int ghc_errno;
41 DLL_IMPORT_STDLIB extern        int ghc_errtype;
42 DLL_IMPORT_STDLIB extern        char* ghc_errstr;
43
44 void    cvtErrno(void);
45 void    stdErrno(void);
46 void    convertErrno(void);
47 StgAddr getErrStr__(void);
48 StgInt  getErrNo__(void);
49 StgInt  getErrType__(void);
50
51 /* execvpe.c */
52 int     execvpe (char *, char **, char **);
53
54 /* fileEOF.c */
55 StgInt  fileEOF (StgForeignPtr);
56 /* fileGetc.c */
57 StgInt  fileGetc (StgForeignPtr);
58
59 /* fileLookAhead.c */
60 StgInt  fileLookAhead (StgForeignPtr);
61 StgInt  ungetChar (StgForeignPtr,StgChar);
62
63 /* fileObject.c */
64 void    setBufFlags (StgForeignPtr, StgInt);
65 void    setBufWPtr  (StgForeignPtr, StgInt);
66 StgInt  getBufWPtr  (StgForeignPtr);
67 void    setBuf      (StgForeignPtr, StgAddr, StgInt);
68 StgAddr getBuf      (StgForeignPtr);
69 StgAddr getWriteableBuf (StgForeignPtr);
70 StgAddr getBufStart (StgForeignPtr,StgInt);
71 StgInt  getBufSize  (StgForeignPtr);
72 void    setFilePtr  (StgForeignPtr, StgAddr);
73 StgAddr getFilePtr  (StgForeignPtr);
74 void    setConnectedTo  (StgForeignPtr, StgForeignPtr, StgInt);
75 void    setPushbackBufSize (StgInt);
76 StgInt  getPushbackBufSize (void);
77 void    setNonBlockingIOFlag__ (StgForeignPtr);
78 void    clearNonBlockingIOFlag__ (StgForeignPtr);
79 void    setConnNonBlockingIOFlag__ (StgForeignPtr);
80 void    clearConnNonBlockingIOFlag__ (StgForeignPtr);
81 StgInt  getFileFd  (StgForeignPtr);
82 StgInt  getConnFileFd  (StgForeignPtr);
83 StgInt  fill_up_line_buffer(IOFileObject*);
84
85 /* filePosn.c */
86 StgInt  getFilePosn (StgForeignPtr);
87 StgInt  setFilePosn (StgForeignPtr, StgInt, StgByteArray);
88
89 /* filePutc.c */
90 StgInt  filePutc    (StgForeignPtr, StgChar);
91
92 /* fileSize.c */
93 StgInt  fileSize    (StgForeignPtr, StgByteArray);
94 StgInt  fileSize_int64 (StgForeignPtr, StgByteArray);
95
96 /* flushFile.c */
97 StgInt  flushFile   (StgForeignPtr);
98 StgInt  flushBuffer (StgForeignPtr);
99 StgInt  flushReadBuffer (StgForeignPtr);
100 void    flushConnectedBuf (StgForeignPtr);
101
102 /* freeFile.c */
103 void freeStdFile (StgAddr);
104 void freeStdFileObject (StgAddr);
105 void freeFileObject (StgAddr);
106
107 StgAddr ref_freeStdFileObject (void);
108 StgAddr ref_freeFileObject    (void);
109
110 /* getBufferMode.c */
111 StgInt  getBufferMode (StgForeignPtr);
112
113 /* getCPUTime.c */
114 StgInt getCPUTime (StgByteArray);
115 StgInt clockTicks(void);
116
117 /* getLock.c */
118 int     lockFile    (int, int, int);
119 int     unlockFile  (int);
120 StgInt  getLock     (StgInt, StgInt);
121
122 /* inputReady.c */
123 StgInt  inputReady  (StgForeignPtr, StgInt);
124
125 /* openFile.c */
126 IOFileObject* openFile    (StgByteArray, StgInt, StgInt);
127 IOFileObject* openFd      (StgInt, StgInt, StgInt);
128 IOFileObject* openStdFile (StgInt, StgInt);
129
130 /* progargs.c */
131 StgAddr get_prog_argv(void);
132 StgInt  get_prog_argc(void);
133
134 /* readFile.c */
135 StgInt  readBlock (StgForeignPtr);
136 StgInt  readChunk (StgForeignPtr,StgAddr,StgInt,StgInt);
137 StgInt  readLine  (StgForeignPtr);
138 StgInt  readChar  (StgForeignPtr);
139
140 /* seekFile.c */
141 StgInt  seekFile  (StgForeignPtr, StgInt, StgInt, StgByteArray);
142 StgInt  seekFile_int64 (StgForeignPtr, StgInt, StgInt64);
143 StgInt  seekFileP (StgForeignPtr);
144
145 /* setBinaryMode.c */
146 StgInt  setBinaryMode__ (StgForeignPtr, StgInt);
147
148 /* setBuffering.c */
149 StgInt  setBuffering (StgForeignPtr, StgInt);
150 StgInt  const_BUFSIZ (void);
151
152 /* setCurrentDirectory.c */
153 StgInt setCurrentDirectory (StgByteArray);
154
155 /* showTime.c */
156 StgInt showTime (StgInt, StgByteArray, StgInt, StgByteArray);
157
158 /* system.c */
159 StgInt  systemCmd (StgByteArray);
160
161 /* writeError.c */
162 StgAddr addrOf_ErrorHdrHook(void);
163 void    writeErrString__ (StgAddr, StgByteArray, StgInt);
164
165 /* writeFile.c */
166 StgInt  writeBuf  (StgForeignPtr, StgAddr, StgInt, StgInt);
167 StgInt  writeBufBA  (StgForeignPtr, StgByteArray, StgInt, StgInt);
168 StgInt  writeFileObject (StgForeignPtr, StgInt);
169 StgInt  writeBuffer (StgForeignPtr, StgInt);
170 StgInt  write_ (StgForeignPtr ptr, StgAddr buf, StgInt len);
171
172 /* tcSetAttr.c */
173 #ifdef HAVE_TERMIOS_H
174 #include <termios.h>
175 #endif
176 int tcSetAttr (int fd, int options, const struct termios *tp);
177
178 #endif /* ! STGIO_H */
179
180