2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
8 #include <toollib/error.h>
9 #include <toollib/stdiocb.h>
12 StdioGetCB (StdioStream
* ss
, int dummy
, CBD data
)
16 int c
= getc (ss
->in
);
29 StdioUngetCB (StdioStream
* ss
, int c
, CBD data
)
32 return ungetc (c
, ss
->in
);
39 StdioPutCB (StdioStream
* ss
, int c
, CBD data
)
42 return putc (c
, ss
->out
);
49 StdioPutsCB (StdioStream
* ss
, const char * str
, CBD data
)
52 return fputs (str
, ss
->out
);
59 StdStr_New (const char * path
, const char * mode
)
61 StdioStream
* ss
= new (StdioStream
);
64 if (strcmp (path
, "-"))
66 fh
= fopen (path
, mode
);
70 PushStdError ("Can't open \"%s\" with mode \"%s\"\n", path
, mode
);
75 Str_Init (&ss
->stream
, path
);
77 ss
->stream
.get
= (CB
) StdioGetCB
;
78 ss
->stream
.unget
= (CB
) StdioUngetCB
;
79 ss
->stream
.put
= (CB
) StdioPutCB
;
80 ss
->stream
.puts
= (CB
) StdioPutsCB
;
82 if (strchr (mode
, 'r'))
84 if (strcmp (path
, "-"))
101 if (strchr (mode
, 'w') || strchr (mode
, 'a'))
103 if (strcmp (path
, "-"))
120 if (ss
->in
&& ss
->out
)
129 StdStr_Delete (StdioStream
* ss
)
137 Str_Delete (&ss
->stream
);