1 /* This is part of libio/iostream, providing -*- C++ -*- input/output.
2 Copyright (C) 1993 Free Software Foundation
4 This file is part of the GNU IO Library. This library is free
5 software; you can redistribute it and/or modify it under the
6 terms of the GNU General Public License as published by the
7 Free Software Foundation; either version 2, or (at your option)
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this library; see the file COPYING. If not, write to the Free
17 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 As a special exception, if you link this library with files
20 compiled with a GNU compiler to produce an executable, this does not cause
21 the resulting executable to be covered by the GNU General Public License.
22 This exception does not however invalidate any other reasons why
23 the executable file might be covered by the GNU General Public License. */
25 /* Written by Per Bothner (bothner@cygnus.com). */
28 #pragma implementation
35 ipfstream::ipfstream(const char *name
, int mode
, int prot
)
39 // Look for '| command' (as used by ftp).
40 for (p
= name
; *p
== ' ' || *p
== '\t'; p
++) ;
42 procbuf
*pbuf
= new procbuf();
44 if (!pbuf
->open(p
+1, mode
))
49 // Look for 'command |'
50 while (*p
) p
++; // Point to last
51 while (p
[-1] == ' ' || p
[-1] == '\t' || p
[-1] == '\n') p
--;
53 // Must remove the final '|'.
55 #if !defined (__GNUC__) || defined (__STRICT_ANSI__)
56 char *command
= new char[p
-name
+1];
58 char command
[p
-name
+1];
60 memcpy(command
, name
, p
-name
);
61 command
[p
-name
] = '\0';
63 procbuf
*pbuf
= new procbuf();
64 if (pbuf
->open(command
, mode
))
66 #if !defined (__GNUC__) || defined (__STRICT_ANSI__)
73 if (!rdbuf()->open(name
, mode
, prot
))
77 opfstream::opfstream(const char *name
, int mode
, int prot
)
80 // Look for '| command'.
81 for (p
= name
; *p
== ' ' || *p
== '\t'; p
++) ;
83 procbuf
*pbuf
= new procbuf();
85 if (!pbuf
->open(p
+1, mode
))
90 if (!rdbuf()->open(name
, mode
, prot
))