comparison src/procstream.cc @ 1965:01e3ed56c415

[project @ 1996-02-17 02:02:50 by jwe]
author jwe
date Sat, 17 Feb 1996 02:03:11 +0000
parents e62277bf5fe0
children 003570e69c7b
comparison
equal deleted inserted replaced
1964:2ff7b73519db 1965:01e3ed56c415
27 27
28 #ifdef HAVE_CONFIG_H 28 #ifdef HAVE_CONFIG_H
29 #include <config.h> 29 #include <config.h>
30 #endif 30 #endif
31 31
32 #include <fstream.h>
33 #include <procbuf.h>
34
35 #include "procstream.h" 32 #include "procstream.h"
36 33
37 iprocstream::iprocstream (const char *command, int mode) 34 procstreambase::procstreambase (const char *command, int mode)
38 { 35 {
39 pbuf = new procbuf (); 36 pb_init ();
40 37
41 init (pbuf); 38 if (! pb.open (command, mode))
42
43 if (! pbuf->open (command, mode))
44 set (ios::badbit); 39 set (ios::badbit);
45 } 40 }
46 41
47 iprocstream::~iprocstream (void)
48 {
49 delete pbuf;
50 }
51
52 void 42 void
53 iprocstream::open (const char *command, int mode) 43 procstreambase::open (const char *command, int mode)
54 { 44 {
55 clear (); 45 clear ();
56 46
57 if (pbuf) 47 if (! pb.open (command, mode))
58 delete pbuf;
59
60 pbuf = new procbuf ();
61
62 init (pbuf);
63
64 if (! pbuf->open (command, mode))
65 set (ios::badbit); 48 set (ios::badbit);
66 } 49 }
67 50
68 int 51 int
69 iprocstream::is_open (void) 52 procstreambase::close (void)
70 {
71 return pbuf && pbuf->is_open ();
72 }
73
74 int
75 iprocstream::close (void)
76 { 53 {
77 int status = 0; 54 int status = 0;
78 55
79 if (is_open ()) 56 if (is_open ())
80 { 57 {
81 status = pbuf->sys_close (); 58 status = pb.sys_close ();
82 59
83 if (! pbuf->close ()) 60 if (! pb.close ())
84 set (ios::failbit); 61 set (ios::failbit);
85 } 62 }
86 63
87 return status; 64 return status;
88 }
89
90 void
91 cleanup_iprocstream (void *buf)
92 {
93 delete (iprocstream *) buf;
94 }
95
96 oprocstream::oprocstream (const char *command, int mode)
97 {
98 pbuf = new procbuf ();
99
100 init (pbuf);
101
102 if (! pbuf->open (command, mode))
103 set (ios::badbit);
104 }
105
106 oprocstream::~oprocstream (void)
107 {
108 delete pbuf;
109 }
110
111 void
112 oprocstream::open (const char *command, int mode)
113 {
114 clear ();
115
116 if (pbuf)
117 delete pbuf;
118
119 pbuf = new procbuf ();
120
121 init (pbuf);
122
123 if (! pbuf->open (command, mode))
124 set (ios::badbit);
125 }
126
127 int
128 oprocstream::is_open (void)
129 {
130 return pbuf && pbuf->is_open ();
131 }
132
133 int
134 oprocstream::close (void)
135 {
136 int status = 0;
137
138 if (is_open ())
139 {
140 if (! pbuf->close ())
141 set (ios::failbit);
142 }
143
144 return status;
145 }
146
147 void
148 cleanup_oprocstream (void *buf)
149 {
150 delete (oprocstream *) buf;
151 } 65 }
152 66
153 /* 67 /*
154 ;;; Local Variables: *** 68 ;;; Local Variables: ***
155 ;;; mode: C++ *** 69 ;;; mode: C++ ***