This file is indexed.

/usr/share/doc/libucommon-dev/a00204_source.html is in libucommon-doc 3.2.0-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>UCommon: ucommon/shell.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.3 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="examples.html"><span>Examples</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
<h1>ucommon/shell.h</h1><a href="a00204.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Copyright (C) 2006-2010 David Sugar, Tycho Softworks.</span>
<a name="l00002"></a>00002 <span class="comment">//</span>
<a name="l00003"></a>00003 <span class="comment">// This file is part of GNU uCommon C++.</span>
<a name="l00004"></a>00004 <span class="comment">//</span>
<a name="l00005"></a>00005 <span class="comment">// GNU uCommon C++ is free software: you can redistribute it and/or modify</span>
<a name="l00006"></a>00006 <span class="comment">// it under the terms of the GNU Lesser General Public License as published </span>
<a name="l00007"></a>00007 <span class="comment">// by the Free Software Foundation, either version 3 of the License, or</span>
<a name="l00008"></a>00008 <span class="comment">// (at your option) any later version.</span>
<a name="l00009"></a>00009 <span class="comment">//</span>
<a name="l00010"></a>00010 <span class="comment">// GNU uCommon C++ is distributed in the hope that it will be useful,</span>
<a name="l00011"></a>00011 <span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00012"></a>00012 <span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<a name="l00013"></a>00013 <span class="comment">// GNU Lesser General Public License for more details.</span>
<a name="l00014"></a>00014 <span class="comment">//</span>
<a name="l00015"></a>00015 <span class="comment">// You should have received a copy of the GNU Lesser General Public License</span>
<a name="l00016"></a>00016 <span class="comment">// along with GNU uCommon C++.  If not, see &lt;http://www.gnu.org/licenses/&gt;.</span>
<a name="l00017"></a>00017 
<a name="l00028"></a>00028 <span class="preprocessor">#ifndef _UCOMMON_STRING_H_</span>
<a name="l00029"></a>00029 <span class="preprocessor"></span><span class="preprocessor">#include &lt;<a class="code" href="a00207.html" title="A common string class and character string support functions.">ucommon/string.h</a>&gt;</span>
<a name="l00030"></a>00030 <span class="preprocessor">#endif</span>
<a name="l00031"></a>00031 <span class="preprocessor"></span>
<a name="l00032"></a>00032 <span class="preprocessor">#ifndef _UCOMMON_MEMORY_H_</span>
<a name="l00033"></a>00033 <span class="preprocessor"></span><span class="preprocessor">#include &lt;<a class="code" href="a00197.html" title="Private heaps, pools, and associations.">ucommon/memory.h</a>&gt;</span>
<a name="l00034"></a>00034 <span class="preprocessor">#endif</span>
<a name="l00035"></a>00035 <span class="preprocessor"></span>
<a name="l00036"></a>00036 <span class="preprocessor">#ifndef _UCOMMON_BUFFER_H_</span>
<a name="l00037"></a>00037 <span class="preprocessor"></span><span class="preprocessor">#include &lt;<a class="code" href="a00189.html" title="A common buffered I/O class is used to stream character data without need for stdlib...">ucommon/buffer.h</a>&gt;</span>
<a name="l00038"></a>00038 <span class="preprocessor">#endif</span>
<a name="l00039"></a>00039 <span class="preprocessor"></span>
<a name="l00040"></a>00040 <span class="preprocessor">#ifndef _UCOMMON_SHELL_H_</span>
<a name="l00041"></a>00041 <span class="preprocessor"></span><span class="preprocessor">#define _UCOMMON_SHELL_H_</span>
<a name="l00042"></a>00042 <span class="preprocessor"></span>
<a name="l00043"></a>00043 <span class="preprocessor">#ifdef  _MSWINDOWS_</span>
<a name="l00044"></a>00044 <span class="preprocessor"></span><span class="preprocessor">#define INVALID_PID_VALUE   INVALID_HANDLE_VALUE</span>
<a name="l00045"></a>00045 <span class="preprocessor"></span><span class="preprocessor">#else</span>
<a name="l00046"></a>00046 <span class="preprocessor"></span><span class="preprocessor">#define INVALID_PID_VALUE   -1</span>
<a name="l00047"></a>00047 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00048"></a>00048 <span class="preprocessor"></span>
<a name="l00049"></a>00049 NAMESPACE_UCOMMON
<a name="l00050"></a>00050 
<a name="l00058"></a><a class="code" href="a00142.html">00058</a> <span class="keyword">class </span>__EXPORT <a class="code" href="a00142.html" title="A utility class for generic shell operations.">shell</a> : <span class="keyword">public</span> <a class="code" href="a00081.html" title="A managed private heap for small allocations.">mempager</a>
<a name="l00059"></a>00059 {
<a name="l00060"></a>00060 <span class="keyword">private</span>:
<a name="l00061"></a>00061     <span class="keywordtype">char</span> **_argv;
<a name="l00062"></a>00062     <span class="keywordtype">unsigned</span> _argc;
<a name="l00063"></a>00063     <span class="keywordtype">char</span> *_argv0;
<a name="l00064"></a>00064 
<a name="l00065"></a>00065     <span class="keyword">class </span>__LOCAL args : <span class="keyword">public</span> <a class="code" href="a00100.html" title="A linked object base class for ordered objects.">OrderedObject</a>
<a name="l00066"></a>00066     {
<a name="l00067"></a>00067     <span class="keyword">public</span>:
<a name="l00068"></a>00068         <span class="keywordtype">char</span> *item;
<a name="l00069"></a>00069     };
<a name="l00070"></a>00070     
<a name="l00076"></a>00076     <span class="keywordtype">void</span> collapse(<a class="code" href="a00069.html" title="Common base class for all objects that can be formed into a linked list.">LinkedObject</a> *first);
<a name="l00077"></a>00077 
<a name="l00081"></a>00081     <span class="keywordtype">void</span> set0(<span class="keywordtype">char</span> *argv0);
<a name="l00082"></a>00082 
<a name="l00083"></a>00083 <span class="keyword">public</span>:
<a name="l00087"></a><a class="code" href="a00142.html#a6f7ee70144bc45af94f00a08d815b7a3">00087</a>     <span class="keyword">typedef</span> <span class="keyword">enum</span> {NOARGS = 0, NOARGUMENT, INVARGUMENT, BADOPTION, OPTION_USED, BAD_VALUE} errmsg_t;
<a name="l00088"></a>00088 
<a name="l00089"></a>00089 <span class="preprocessor">#ifdef  _MSWINDOWS_</span>
<a name="l00090"></a>00090 <span class="preprocessor"></span>    <span class="keyword">typedef</span> HANDLE pid_t;
<a name="l00091"></a>00091 <span class="preprocessor">#else</span>
<a name="l00092"></a>00092 <span class="preprocessor"></span>
<a name="l00095"></a><a class="code" href="a00142.html#a398f2242af2b40f5f95d2c3b7c46c631">00095</a>     <span class="keyword">typedef</span> <span class="keywordtype">int</span> <a class="code" href="a00142.html#a398f2242af2b40f5f95d2c3b7c46c631" title="Standard type of process id for shell class.">pid_t</a>;
<a name="l00096"></a>00096 <span class="preprocessor">#endif</span>
<a name="l00097"></a>00097 <span class="preprocessor"></span>
<a name="l00101"></a><a class="code" href="a00142.html#af7525d05d6f9ea8f71492a42de9c528c">00101</a>     <span class="keyword">typedef</span> <span class="keyword">enum</span> {RD = IOBuffer::BUF_RD, WR = IOBuffer::BUF_WR, RDWR = IOBuffer::BUF_RDWR} pmode_t;
<a name="l00102"></a>00102 
<a name="l00111"></a><a class="code" href="a00149.html">00111</a>     <span class="keyword">class </span>__EXPORT <a class="code" href="a00149.html" title="A class to control a process that is piped.">pipeio</a>
<a name="l00112"></a>00112     {
<a name="l00113"></a>00113     <span class="keyword">protected</span>:
<a name="l00114"></a>00114         <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="a00142.html" title="A utility class for generic shell operations.">shell</a>;
<a name="l00115"></a>00115 
<a name="l00119"></a>00119         <a class="code" href="a00149.html" title="A class to control a process that is piped.">pipeio</a>();
<a name="l00120"></a>00120 
<a name="l00130"></a>00130         <span class="keywordtype">int</span> spawn(<span class="keyword">const</span> <span class="keywordtype">char</span> *path, <span class="keywordtype">char</span> **argv, <a class="code" href="a00142.html#af7525d05d6f9ea8f71492a42de9c528c" title="Pipe I/O mode.">pmode_t</a> mode, <span class="keywordtype">size_t</span> size = 512, <span class="keywordtype">char</span> **env = NULL);
<a name="l00131"></a>00131         
<a name="l00136"></a>00136         <span class="keywordtype">int</span> <a class="code" href="a00214.html#a2f0fa9cbff7791a5006406a3066d4dc5" title="Convenience function to wait on a barrier.">wait</a>(<span class="keywordtype">void</span>);
<a name="l00137"></a>00137 
<a name="l00143"></a>00143         <span class="keywordtype">int</span> cancel(<span class="keywordtype">void</span>);
<a name="l00144"></a>00144 
<a name="l00153"></a>00153         <span class="keywordtype">size_t</span> read(<span class="keywordtype">void</span> *address, <span class="keywordtype">size_t</span> size);
<a name="l00154"></a>00154 
<a name="l00163"></a>00163         <span class="keywordtype">size_t</span> write(<span class="keyword">const</span> <span class="keywordtype">void</span> *address, <span class="keywordtype">size_t</span> size);
<a name="l00164"></a>00164             
<a name="l00165"></a>00165         <a class="code" href="a00142.html#a398f2242af2b40f5f95d2c3b7c46c631" title="Standard type of process id for shell class.">pid_t</a> pid;
<a name="l00166"></a>00166         fd_t input, output; <span class="comment">// input to and output from child process...</span>
<a name="l00167"></a>00167         <span class="keywordtype">int</span> perror, presult;
<a name="l00168"></a>00168     };
<a name="l00169"></a>00169 
<a name="l00176"></a><a class="code" href="a00146.html">00176</a>     <span class="keyword">class </span>__EXPORT <a class="code" href="a00146.html" title="Process pipe with I/O buffering.">iobuf</a> : <span class="keyword">public</span> <a class="code" href="a00057.html" title="Common buffered I/O class.">IOBuffer</a>, <span class="keyword">protected</span> <a class="code" href="a00149.html" title="A class to control a process that is piped.">pipeio</a>
<a name="l00177"></a>00177     {
<a name="l00178"></a>00178     <span class="keyword">protected</span>:
<a name="l00179"></a>00179         <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="a00142.html" title="A utility class for generic shell operations.">shell</a>;
<a name="l00180"></a>00180 
<a name="l00181"></a>00181         <span class="keyword">virtual</span> <span class="keywordtype">size_t</span> _push(<span class="keyword">const</span> <span class="keywordtype">char</span> *address, <span class="keywordtype">size_t</span> size);
<a name="l00182"></a>00182         <span class="keyword">virtual</span> <span class="keywordtype">size_t</span> _pull(<span class="keywordtype">char</span> *address, <span class="keywordtype">size_t</span> size);
<a name="l00183"></a>00183 
<a name="l00184"></a>00184     <span class="keyword">public</span>:
<a name="l00190"></a>00190         <a class="code" href="a00146.html" title="Process pipe with I/O buffering.">iobuf</a>(<span class="keywordtype">size_t</span> size = 0);
<a name="l00191"></a>00191 
<a name="l00202"></a>00202         <a class="code" href="a00146.html" title="Process pipe with I/O buffering.">iobuf</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *path, <span class="keywordtype">char</span> **argv, <a class="code" href="a00142.html#af7525d05d6f9ea8f71492a42de9c528c" title="Pipe I/O mode.">pmode_t</a> mode, <span class="keywordtype">size_t</span> size = 512, <span class="keywordtype">char</span> **env = NULL);
<a name="l00203"></a>00203 
<a name="l00208"></a>00208         ~<a class="code" href="a00146.html" title="Process pipe with I/O buffering.">iobuf</a>();
<a name="l00209"></a>00209 
<a name="l00218"></a>00218         <span class="keywordtype">void</span> open(<span class="keyword">const</span> <span class="keywordtype">char</span> *path, <span class="keywordtype">char</span> **argv, <a class="code" href="a00142.html#af7525d05d6f9ea8f71492a42de9c528c" title="Pipe I/O mode.">pmode_t</a> mode, <span class="keywordtype">size_t</span> size = 512, <span class="keywordtype">char</span> **env = NULL);
<a name="l00219"></a>00219 
<a name="l00224"></a>00224         <span class="keywordtype">void</span> close(<span class="keywordtype">void</span>);
<a name="l00225"></a>00225 
<a name="l00230"></a>00230         <span class="keywordtype">void</span> cancel(<span class="keywordtype">void</span>);
<a name="l00231"></a>00231     };
<a name="l00232"></a>00232 
<a name="l00236"></a><a class="code" href="a00142.html#a8dc921cc22415fef18aa1f248a8ea5bd">00236</a>     <span class="keyword">typedef</span> <a class="code" href="a00146.html" title="Process pipe with I/O buffering.">iobuf</a> <a class="code" href="a00146.html" title="Process pipe with I/O buffering.">io_t</a>;
<a name="l00237"></a>00237 
<a name="l00241"></a><a class="code" href="a00142.html#a76c5d4fe12e1b17d0709656d7ca3b66d">00241</a>     <span class="keyword">typedef</span> <a class="code" href="a00149.html" title="A class to control a process that is piped.">pipeio</a> *<a class="code" href="a00149.html" title="A class to control a process that is piped.">pipe_t</a>;
<a name="l00242"></a>00242 
<a name="l00249"></a>00249     <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="a00142.html#a2a9f42af136fe3bff7e008f2b9fe230b" title="This can be used to get internationalized error messages.">errmsg</a>(<a class="code" href="a00142.html#a6f7ee70144bc45af94f00a08d815b7a3" title="Error table index.">errmsg_t</a> <span class="keywordtype">id</span>);
<a name="l00250"></a>00250 
<a name="l00257"></a>00257     <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="a00142.html#a2a9f42af136fe3bff7e008f2b9fe230b" title="This can be used to get internationalized error messages.">errmsg</a>(<a class="code" href="a00142.html#a6f7ee70144bc45af94f00a08d815b7a3" title="Error table index.">errmsg_t</a> <span class="keywordtype">id</span>, <span class="keyword">const</span> <span class="keywordtype">char</span> *text);
<a name="l00258"></a>00258 
<a name="l00265"></a><a class="code" href="a00144.html">00265</a>     <span class="keyword">class </span>__EXPORT <a class="code" href="a00144.html" title="A class to redefine error messages.">errormap</a>
<a name="l00266"></a>00266     {
<a name="l00267"></a>00267     <span class="keyword">public</span>:
<a name="l00268"></a>00268         <span class="keyword">inline</span> <a class="code" href="a00144.html" title="A class to redefine error messages.">errormap</a>(<a class="code" href="a00142.html#a6f7ee70144bc45af94f00a08d815b7a3" title="Error table index.">errmsg_t</a> <span class="keywordtype">id</span>, <span class="keyword">const</span> <span class="keywordtype">char</span> *text)
<a name="l00269"></a>00269             {shell::errmsg(<span class="keywordtype">id</span>, text);};
<a name="l00270"></a>00270     };
<a name="l00271"></a>00271 
<a name="l00279"></a><a class="code" href="a00148.html">00279</a>     <span class="keyword">class </span>__EXPORT <a class="code" href="a00148.html" title="A base class used to create parsable shell options.">Option</a> : <span class="keyword">public</span> <a class="code" href="a00100.html" title="A linked object base class for ordered objects.">OrderedObject</a>
<a name="l00280"></a>00280     {
<a name="l00281"></a>00281     <span class="keyword">private</span>:
<a name="l00282"></a>00282         <span class="keyword">static</span> <a class="code" href="a00099.html" title="An index container for maintaining an ordered list of objects.">OrderedIndex</a> index;
<a name="l00283"></a>00283 
<a name="l00284"></a>00284     <span class="keyword">public</span>:
<a name="l00285"></a>00285         <span class="keywordtype">char</span> short_option;
<a name="l00286"></a>00286         <span class="keyword">const</span> <span class="keywordtype">char</span> *long_option;
<a name="l00287"></a>00287         <span class="keyword">const</span> <span class="keywordtype">char</span> *uses_option;
<a name="l00288"></a>00288         <span class="keyword">const</span> <span class="keywordtype">char</span> *help_string;
<a name="l00289"></a>00289 
<a name="l00297"></a>00297         <a class="code" href="a00148.html" title="A base class used to create parsable shell options.">Option</a>(<span class="keywordtype">char</span> short_option = 0, <span class="keyword">const</span> <span class="keywordtype">char</span> *long_option = NULL, <span class="keyword">const</span> <span class="keywordtype">char</span> *value_type = NULL, <span class="keyword">const</span> <span class="keywordtype">char</span> *help = NULL);
<a name="l00298"></a>00298 
<a name="l00299"></a>00299         <span class="keyword">virtual</span> ~<a class="code" href="a00148.html" title="A base class used to create parsable shell options.">Option</a>();
<a name="l00300"></a>00300 
<a name="l00301"></a>00301         <span class="keyword">inline</span> <span class="keyword">static</span> <a class="code" href="a00069.html" title="Common base class for all objects that can be formed into a linked list.">LinkedObject</a> *first(<span class="keywordtype">void</span>)
<a name="l00302"></a>00302             {<span class="keywordflow">return</span> index.begin();};
<a name="l00303"></a>00303 
<a name="l00309"></a>00309         <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *assign(<span class="keyword">const</span> <span class="keywordtype">char</span> *value) = 0;
<a name="l00310"></a>00310     };
<a name="l00311"></a>00311 
<a name="l00319"></a><a class="code" href="a00145.html">00319</a>     <span class="keyword">class </span>__EXPORT <a class="code" href="a00145.html" title="Flag option for shell parsing.">flagopt</a> : <span class="keyword">public</span> <a class="code" href="a00148.html" title="A base class used to create parsable shell options.">Option</a>
<a name="l00320"></a>00320     {
<a name="l00321"></a>00321     <span class="keyword">private</span>:
<a name="l00322"></a>00322         <span class="keywordtype">unsigned</span> <a class="code" href="a00044.html" title="Automatic integer counting class.">counter</a>;
<a name="l00323"></a>00323         <span class="keywordtype">bool</span> single;
<a name="l00324"></a>00324 
<a name="l00325"></a>00325         <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *assign(<span class="keyword">const</span> <span class="keywordtype">char</span> *value);
<a name="l00326"></a>00326 
<a name="l00327"></a>00327     <span class="keyword">public</span>:
<a name="l00328"></a>00328         <a class="code" href="a00145.html" title="Flag option for shell parsing.">flagopt</a>(<span class="keywordtype">char</span> short_option, <span class="keyword">const</span> <span class="keywordtype">char</span> *long_option = NULL, <span class="keyword">const</span> <span class="keywordtype">char</span> *help = NULL, <span class="keywordtype">bool</span> single_use = <span class="keyword">true</span>);
<a name="l00329"></a>00329 
<a name="l00330"></a>00330         <span class="keyword">inline</span> operator bool()
<a name="l00331"></a>00331             {<span class="keywordflow">return</span> <a class="code" href="a00044.html" title="Automatic integer counting class.">counter</a> &gt; 0;};
<a name="l00332"></a>00332 
<a name="l00333"></a>00333         <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator!()
<a name="l00334"></a>00334             {<span class="keywordflow">return</span> <a class="code" href="a00044.html" title="Automatic integer counting class.">counter</a> == 0;};
<a name="l00335"></a>00335 
<a name="l00336"></a>00336         <span class="keyword">inline</span> operator unsigned()
<a name="l00337"></a>00337             {<span class="keywordflow">return</span> <a class="code" href="a00044.html" title="Automatic integer counting class.">counter</a>;};
<a name="l00338"></a>00338 
<a name="l00339"></a>00339         <span class="keyword">inline</span> <span class="keywordtype">unsigned</span> operator*()
<a name="l00340"></a>00340             {<span class="keywordflow">return</span> <a class="code" href="a00044.html" title="Automatic integer counting class.">counter</a>;};
<a name="l00341"></a>00341     };
<a name="l00342"></a>00342 
<a name="l00349"></a><a class="code" href="a00150.html">00349</a>     <span class="keyword">class </span>__EXPORT <a class="code" href="a00150.html" title="Text option for shell parsing.">stringopt</a> : <span class="keyword">public</span> <a class="code" href="a00148.html" title="A base class used to create parsable shell options.">Option</a>
<a name="l00350"></a>00350     {
<a name="l00351"></a>00351     <span class="keyword">private</span>:
<a name="l00352"></a>00352         <span class="keywordtype">bool</span> used;
<a name="l00353"></a>00353 
<a name="l00354"></a>00354     <span class="keyword">protected</span>:
<a name="l00355"></a>00355         <span class="keyword">const</span> <span class="keywordtype">char</span> *text;
<a name="l00356"></a>00356 
<a name="l00357"></a>00357         <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *assign(<span class="keyword">const</span> <span class="keywordtype">char</span> *value);
<a name="l00358"></a>00358 
<a name="l00359"></a>00359     <span class="keyword">public</span>:
<a name="l00360"></a>00360         <a class="code" href="a00150.html" title="Text option for shell parsing.">stringopt</a>(<span class="keywordtype">char</span> short_option, <span class="keyword">const</span> <span class="keywordtype">char</span> *long_option = NULL, <span class="keyword">const</span> <span class="keywordtype">char</span> *help = NULL, <span class="keyword">const</span> <span class="keywordtype">char</span> *type = <span class="stringliteral">&quot;text&quot;</span>, <span class="keyword">const</span> <span class="keywordtype">char</span> *def_text = NULL);
<a name="l00361"></a>00361 
<a name="l00362"></a>00362         <span class="keyword">inline</span> operator bool()
<a name="l00363"></a>00363             {<span class="keywordflow">return</span> used;};
<a name="l00364"></a>00364 
<a name="l00365"></a>00365         <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator!()
<a name="l00366"></a>00366             {<span class="keywordflow">return</span> !used;};
<a name="l00367"></a>00367 
<a name="l00368"></a>00368         <span class="keyword">inline</span> operator const char *()
<a name="l00369"></a>00369             {<span class="keywordflow">return</span> text;};
<a name="l00370"></a>00370 
<a name="l00371"></a>00371         <span class="keyword">inline</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *operator*()
<a name="l00372"></a>00372             {<span class="keywordflow">return</span> text;};
<a name="l00373"></a>00373 
<a name="l00374"></a>00374         <span class="keywordtype">char</span> operator[](<span class="keywordtype">size_t</span> index);
<a name="l00375"></a>00375     };
<a name="l00376"></a>00376 
<a name="l00383"></a><a class="code" href="a00143.html">00383</a>     <span class="keyword">class </span>__EXPORT <a class="code" href="a00143.html" title="Character option for shell parsing.">charopt</a> : <span class="keyword">public</span> <a class="code" href="a00148.html" title="A base class used to create parsable shell options.">Option</a>
<a name="l00384"></a>00384     {
<a name="l00385"></a>00385     <span class="keyword">private</span>:
<a name="l00386"></a>00386         <span class="keywordtype">bool</span> used;
<a name="l00387"></a>00387 
<a name="l00388"></a>00388     <span class="keyword">protected</span>:
<a name="l00389"></a>00389         <span class="keywordtype">char</span> code;
<a name="l00390"></a>00390 
<a name="l00391"></a>00391         <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *assign(<span class="keyword">const</span> <span class="keywordtype">char</span> *value);
<a name="l00392"></a>00392 
<a name="l00393"></a>00393     <span class="keyword">public</span>:
<a name="l00394"></a>00394         <a class="code" href="a00143.html" title="Character option for shell parsing.">charopt</a>(<span class="keywordtype">char</span> short_option, <span class="keyword">const</span> <span class="keywordtype">char</span> *long_option = NULL, <span class="keyword">const</span> <span class="keywordtype">char</span> *help = NULL, <span class="keyword">const</span> <span class="keywordtype">char</span> *type = <span class="stringliteral">&quot;char&quot;</span>, <span class="keywordtype">char</span> default_code = <span class="charliteral">&#39; &#39;</span>);
<a name="l00395"></a>00395 
<a name="l00396"></a>00396         <span class="keyword">inline</span> operator bool()
<a name="l00397"></a>00397             {<span class="keywordflow">return</span> used;};
<a name="l00398"></a>00398 
<a name="l00399"></a>00399         <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator!()
<a name="l00400"></a>00400             {<span class="keywordflow">return</span> !used;};
<a name="l00401"></a>00401 
<a name="l00402"></a>00402         <span class="keyword">inline</span> operator char()
<a name="l00403"></a>00403             {<span class="keywordflow">return</span> code;};
<a name="l00404"></a>00404 
<a name="l00405"></a>00405         <span class="keyword">inline</span> <span class="keywordtype">char</span> operator*()
<a name="l00406"></a>00406             {<span class="keywordflow">return</span> code;};
<a name="l00407"></a>00407     };
<a name="l00408"></a>00408 
<a name="l00415"></a><a class="code" href="a00147.html">00415</a>     <span class="keyword">class </span>__EXPORT <a class="code" href="a00147.html" title="Numeric option for shell parsing.">numericopt</a> : <span class="keyword">public</span> <a class="code" href="a00148.html" title="A base class used to create parsable shell options.">Option</a>
<a name="l00416"></a>00416     {
<a name="l00417"></a>00417     <span class="keyword">private</span>:
<a name="l00418"></a>00418         <span class="keywordtype">bool</span> used;
<a name="l00419"></a>00419 
<a name="l00420"></a>00420     <span class="keyword">protected</span>:
<a name="l00421"></a>00421         <span class="keywordtype">long</span> number;
<a name="l00422"></a>00422 
<a name="l00423"></a>00423         <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *assign(<span class="keyword">const</span> <span class="keywordtype">char</span> *value);
<a name="l00424"></a>00424 
<a name="l00425"></a>00425     <span class="keyword">public</span>:
<a name="l00426"></a>00426         <a class="code" href="a00147.html" title="Numeric option for shell parsing.">numericopt</a>(<span class="keywordtype">char</span> short_option, <span class="keyword">const</span> <span class="keywordtype">char</span> *long_option = NULL, <span class="keyword">const</span> <span class="keywordtype">char</span> *help = NULL, <span class="keyword">const</span> <span class="keywordtype">char</span> *type = <span class="stringliteral">&quot;numeric&quot;</span>, <span class="keywordtype">long</span> def_value = 0);
<a name="l00427"></a>00427 
<a name="l00428"></a>00428         <span class="keyword">inline</span> operator bool()
<a name="l00429"></a>00429             {<span class="keywordflow">return</span> used;};
<a name="l00430"></a>00430 
<a name="l00431"></a>00431         <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator!()
<a name="l00432"></a>00432             {<span class="keywordflow">return</span> !used;};
<a name="l00433"></a>00433 
<a name="l00434"></a>00434         <span class="keyword">inline</span> operator long()
<a name="l00435"></a>00435             {<span class="keywordflow">return</span> number;};
<a name="l00436"></a>00436 
<a name="l00437"></a>00437         <span class="keyword">inline</span> <span class="keywordtype">long</span> operator*()
<a name="l00438"></a>00438             {<span class="keywordflow">return</span> number;};
<a name="l00439"></a>00439     };
<a name="l00440"></a>00440 
<a name="l00448"></a>00448     <a class="code" href="a00142.html#a3e70a2ea8af17c1afeb77fcc6d19005e" title="Construct a shell argument list by parsing a simple command string.">shell</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *<span class="keywordtype">string</span>, <span class="keywordtype">size_t</span> pagesize = 0);
<a name="l00449"></a>00449 
<a name="l00458"></a>00458     <a class="code" href="a00142.html#a3e70a2ea8af17c1afeb77fcc6d19005e" title="Construct a shell argument list by parsing a simple command string.">shell</a>(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv, <span class="keywordtype">size_t</span> pagesize = 0);
<a name="l00459"></a>00459 
<a name="l00464"></a>00464     <a class="code" href="a00142.html#a3e70a2ea8af17c1afeb77fcc6d19005e" title="Construct a shell argument list by parsing a simple command string.">shell</a>(<span class="keywordtype">size_t</span> pagesize = 0);
<a name="l00465"></a>00465 
<a name="l00469"></a>00469     <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="a00142.html#ac0f1f89ae32736d2685f49067bb4c2d0" title="Display shell options.">help</a>(<span class="keywordtype">void</span>);
<a name="l00470"></a>00470 
<a name="l00478"></a>00478     <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="a00142.html#a46eb43e8f4e3ea9cc026261e8d37fb05" title="A shell system call.">system</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *command, <span class="keyword">const</span> <span class="keywordtype">char</span> **env = NULL);
<a name="l00479"></a>00479 
<a name="l00486"></a>00486     <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="a00142.html#afbb7a9f622fcd7784d9dc8a71dc89d8e" title="A shell system call that can be issued using a formatted string.">systemf</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *format, ...) __PRINTF(1,2);
<a name="l00487"></a>00487 
<a name="l00493"></a>00493     <span class="keywordtype">char</span> **parse(const <span class="keywordtype">char</span> *<span class="keywordtype">string</span>);
<a name="l00494"></a>00494 
<a name="l00503"></a>00503     <span class="keywordtype">void</span> parse(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv);
<a name="l00504"></a>00504 
<a name="l00511"></a><a class="code" href="a00142.html#aba697ad85eb581f917b4139b395c33bf">00511</a>     inline static <span class="keywordtype">char</span> **parse(<a class="code" href="a00142.html" title="A utility class for generic shell operations.">shell</a> &amp;args, const <span class="keywordtype">char</span> *<span class="keywordtype">string</span>)
<a name="l00512"></a>00512         {<span class="keywordflow">return</span> args.parse(<span class="keywordtype">string</span>);};
<a name="l00513"></a>00513 
<a name="l00517"></a><a class="code" href="a00142.html#ae21aec71e94d5ca6d73ce6ab69121012">00517</a>     <span class="keyword">inline</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="a00142.html#ae21aec71e94d5ca6d73ce6ab69121012" title="Get program name (argv0).">argv0</a>()<span class="keyword"> const</span>
<a name="l00518"></a>00518 <span class="keyword">        </span>{<span class="keywordflow">return</span> _argv0;};
<a name="l00519"></a>00519 
<a name="l00525"></a>00525     <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="a00142.html#a919730cabf3f701a1e62f3e0cbf2cb81" title="Print error message and exit.">errexit</a>(<span class="keywordtype">int</span> exitcode, <span class="keyword">const</span> <span class="keywordtype">char</span> *format = NULL, ...) __PRINTF(2, 3);
<a name="l00526"></a>00526 
<a name="l00531"></a>00531     static <span class="keywordtype">size_t</span> printf(const <span class="keywordtype">char</span> *format, ...) __PRINTF(1, 2);
<a name="l00532"></a>00532 
<a name="l00533"></a>00533     static <span class="keywordtype">size_t</span> readln(<span class="keywordtype">char</span> *address, <span class="keywordtype">size_t</span> size);
<a name="l00534"></a>00534 
<a name="l00535"></a>00535     static <span class="keywordtype">size_t</span> writes(const <span class="keywordtype">char</span> *<span class="keywordtype">string</span>);
<a name="l00536"></a>00536 
<a name="l00537"></a>00537     static <span class="keywordtype">size_t</span> read(<a class="code" href="a00157.html" title="A copy-on-write string class that operates by reference count.">String</a>&amp; <span class="keywordtype">string</span>);
<a name="l00538"></a>00538 
<a name="l00539"></a>00539     inline static <span class="keywordtype">size_t</span> write(<a class="code" href="a00157.html" title="A copy-on-write string class that operates by reference count.">String</a>&amp; <span class="keywordtype">string</span>)
<a name="l00540"></a>00540         {<span class="keywordflow">return</span> writes(<span class="keywordtype">string</span>.c_str());};
<a name="l00541"></a>00541 
<a name="l00548"></a>00548     <span class="keyword">static</span> <span class="keywordtype">size_t</span> <a class="code" href="a00142.html#abcd397f645252399148b326e891deb0b" title="Print to standard output.">printf</a>(pipe_t pipe, <span class="keyword">const</span> <span class="keywordtype">char</span> *format, ...) __PRINTF(2, 3);
<a name="l00549"></a>00549 
<a name="l00557"></a>00557     static <span class="keywordtype">size_t</span> readln(pipe_t pipe, <span class="keywordtype">char</span> *buffer, <span class="keywordtype">size_t</span> size);
<a name="l00558"></a>00558 
<a name="l00559"></a>00559     static <span class="keywordtype">size_t</span> read(pipe_t pipe, <a class="code" href="a00214.html#ad412a12981fa5ebe1b83ac1fb48585ef" title="A convenience type when mixing std::string in old compilers that are bad with namespaces...">String</a>&amp; <span class="keywordtype">string</span>);
<a name="l00560"></a>00560 
<a name="l00561"></a>00561     static <span class="keywordtype">size_t</span> writes(pipe_t pipe, const <span class="keywordtype">char</span> *<span class="keywordtype">string</span>);
<a name="l00562"></a>00562 
<a name="l00563"></a>00563     inline static <span class="keywordtype">size_t</span> write(pipe_t pipe, <a class="code" href="a00214.html#ad412a12981fa5ebe1b83ac1fb48585ef" title="A convenience type when mixing std::string in old compilers that are bad with namespaces...">String</a>&amp; <span class="keywordtype">string</span>)
<a name="l00564"></a>00564         {<span class="keywordflow">return</span> writes(pipe, <span class="keywordtype">string</span>.c_str());};
<a name="l00565"></a>00565 
<a name="l00571"></a><a class="code" href="a00142.html#a3fc5e8b1af9aa42e4837dc13d13f0d95">00571</a>     <span class="keyword">inline</span> <span class="keywordtype">unsigned</span> <a class="code" href="a00142.html#a3fc5e8b1af9aa42e4837dc13d13f0d95" title="Get saved internal argc count for items.">argc</a>(<span class="keywordtype">void</span>)<span class="keyword"> const</span>
<a name="l00572"></a>00572 <span class="keyword">        </span>{<span class="keywordflow">return</span> _argc;};
<a name="l00573"></a>00573 
<a name="l00580"></a><a class="code" href="a00142.html#a9d2cb2cb34f0790f24c1de29f96de347">00580</a>     <span class="keyword">inline</span> <span class="keywordtype">char</span> **<a class="code" href="a00142.html#a9d2cb2cb34f0790f24c1de29f96de347" title="Get saved internal argv count for items in this shell object.">argv</a>(<span class="keywordtype">void</span>)<span class="keyword"> const</span>
<a name="l00581"></a>00581 <span class="keyword">        </span>{<span class="keywordflow">return</span> _argv;};
<a name="l00582"></a>00582 
<a name="l00588"></a><a class="code" href="a00142.html#a09c61f436014f8867fc1695094bffa56">00588</a>     <span class="keyword">inline</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="a00142.html#a09c61f436014f8867fc1695094bffa56" title="Return parser argv element.">operator[]</a>(<span class="keywordtype">unsigned</span> offset)
<a name="l00589"></a>00589         {<span class="keywordflow">return</span> _argv[offset];};
<a name="l00590"></a>00590 
<a name="l00602"></a>00602     <span class="keyword">static</span> <a class="code" href="a00142.html#a398f2242af2b40f5f95d2c3b7c46c631" title="Standard type of process id for shell class.">shell::pid_t</a> <a class="code" href="a00142.html#ab498bb8bb1cabf815bb44bf8a56b067a" title="Spawn a child process.">spawn</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *path, <span class="keywordtype">char</span> **argv, <span class="keywordtype">char</span> **env = NULL, fd_t *stdio = NULL);
<a name="l00603"></a>00603 
<a name="l00615"></a>00615     <span class="keyword">static</span> <a class="code" href="a00149.html" title="A class to control a process that is piped.">shell::pipe_t</a> <a class="code" href="a00142.html#ab498bb8bb1cabf815bb44bf8a56b067a" title="Spawn a child process.">spawn</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *path, <span class="keywordtype">char</span> **argv, pmode_t mode, <span class="keywordtype">size_t</span> size = 512, <span class="keywordtype">char</span> **env = NULL);
<a name="l00616"></a>00616 
<a name="l00626"></a>00626     <span class="keywordtype">int</span> <a class="code" href="a00142.html#abcb2408ff705e20b96f03a49e6855a7f" title="Create a detached process.">detach</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *path, <span class="keywordtype">char</span> **argv, <span class="keywordtype">char</span> **env = NULL, fd_t *stdio = NULL);
<a name="l00627"></a>00627 
<a name="l00633"></a>00633     <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="a00142.html#a9b2588c1b614e56429183a5b1a2ae79f" title="Wait for a child process to terminate.">wait</a>(<a class="code" href="a00142.html#a398f2242af2b40f5f95d2c3b7c46c631" title="Standard type of process id for shell class.">shell::pid_t</a> pid);
<a name="l00634"></a>00634 
<a name="l00640"></a>00640     <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="a00142.html#ad49336f428e17ee7b8853908b0f2a74d" title="Cancel a child process.">cancel</a>(<a class="code" href="a00142.html#a398f2242af2b40f5f95d2c3b7c46c631" title="Standard type of process id for shell class.">shell::pid_t</a> pid);
<a name="l00641"></a>00641 
<a name="l00648"></a>00648     <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="a00142.html#a9b2588c1b614e56429183a5b1a2ae79f" title="Wait for a child process to terminate.">wait</a>(<a class="code" href="a00149.html" title="A class to control a process that is piped.">shell::pipe_t</a> <a class="code" href="a00015.html" title="Typed smart pointer class.">pointer</a>);
<a name="l00649"></a>00649 
<a name="l00655"></a>00655     <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="a00142.html#ad49336f428e17ee7b8853908b0f2a74d" title="Cancel a child process.">cancel</a>(<a class="code" href="a00149.html" title="A class to control a process that is piped.">shell::pipe_t</a> <a class="code" href="a00015.html" title="Typed smart pointer class.">pointer</a>);
<a name="l00656"></a>00656 
<a name="l00661"></a><a class="code" href="a00142.html#a7cac396b2da5b97fba8d41b3d127cade">00661</a>     <span class="keyword">inline</span> <span class="keywordtype">unsigned</span> <a class="code" href="a00142.html#a7cac396b2da5b97fba8d41b3d127cade" title="Return argc count.">operator()</a>(<span class="keywordtype">void</span>)
<a name="l00662"></a>00662         {<span class="keywordflow">return</span> _argc;};
<a name="l00663"></a>00663 
<a name="l00669"></a>00669     <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <a class="code" href="a00069.html#a76f478125e3a86e3f9ad7effecc8e586" title="Count the number of linked objects in a list.">count</a>(<span class="keywordtype">char</span> **argv);
<a name="l00670"></a>00670 
<a name="l00671"></a>00671 <span class="preprocessor">#ifdef  _MSWINDOWS_</span>
<a name="l00672"></a>00672 <span class="preprocessor"></span>
<a name="l00673"></a>00673     <span class="keyword">static</span> <span class="keyword">inline</span> fd_t input(<span class="keywordtype">void</span>)
<a name="l00674"></a>00674         {<span class="keywordflow">return</span> GetStdHandle(STD_INPUT_HANDLE);}; 
<a name="l00675"></a>00675 
<a name="l00676"></a>00676     <span class="keyword">static</span> <span class="keyword">inline</span> fd_t output(<span class="keywordtype">void</span>)
<a name="l00677"></a>00677         {<span class="keywordflow">return</span> GetStdHandle(STD_OUTPUT_HANDLE);}; 
<a name="l00678"></a>00678 
<a name="l00679"></a>00679     <span class="keyword">static</span> <span class="keyword">inline</span> fd_t error(<span class="keywordtype">void</span>)
<a name="l00680"></a>00680         {<span class="keywordflow">return</span> GetStdHandle(STD_ERROR_HANDLE);};
<a name="l00681"></a>00681 
<a name="l00682"></a>00682 <span class="preprocessor">#else</span>
<a name="l00683"></a>00683 <span class="preprocessor"></span>    <span class="keyword">static</span> <span class="keyword">inline</span> fd_t input(<span class="keywordtype">void</span>)
<a name="l00684"></a>00684         {<span class="keywordflow">return</span> 0;};
<a name="l00685"></a>00685 
<a name="l00686"></a>00686     <span class="keyword">static</span> <span class="keyword">inline</span> fd_t output(<span class="keywordtype">void</span>)
<a name="l00687"></a>00687         {<span class="keywordflow">return</span> 1;};
<a name="l00688"></a>00688 
<a name="l00689"></a>00689     <span class="keyword">static</span> <span class="keyword">inline</span> fd_t error(<span class="keywordtype">void</span>)
<a name="l00690"></a>00690         {<span class="keywordflow">return</span> 2;};
<a name="l00691"></a>00691 <span class="preprocessor">#endif</span>
<a name="l00692"></a>00692 <span class="preprocessor"></span>};
<a name="l00693"></a>00693     
<a name="l00694"></a>00694 END_NAMESPACE
<a name="l00695"></a>00695 
<a name="l00696"></a>00696 <span class="preprocessor">#endif</span>
</pre></div></div>
<hr class="footer"/><address style="text-align: right;"><small>Generated on Tue Jul 6 08:22:01 2010 for UCommon by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
</body>
</html>