1 | /*␊ |
2 | * shell_process.h␊ |
3 | *␊ |
4 | * Created by Rekursor on 1/17/2010.␊ |
5 | *␊ |
6 | */␊ |
7 | #ifndef __CHSHELL_PROCESS_H␊ |
8 | #define __CHSHELL_PROCESS_H␊ |
9 | ␊ |
10 | #include <Security/Authorization.h>␊ |
11 | #include <stdio.h>␊ |
12 | #include <stdlib.h>␊ |
13 | #include <errno.h>␊ |
14 | #include <sys/stat.h>␊ |
15 | #include <vector>␊ |
16 | #include <string>␊ |
17 | #include "file_util.h"␊ |
18 | //----------------------------------------------------------------␊ |
19 | const int MAX_HD = 32;␊ |
20 | ␊ |
21 | //----------------------------------------------------------------␊ |
22 | class ShellProcess ␊ |
23 | {␊ |
24 | public:␊ |
25 | ␉// construction / destruction␊ |
26 | ␉ShellProcess() {_fpt= NULL;}␊ |
27 | ␉~ShellProcess() {if (_fpt) close();}␊ |
28 | ␉␊ |
29 | ␉FILE * open␉(const char *cmd, const char *mode="r");␊ |
30 | ␉int close();␊ |
31 | ␉FILE * desc() const { return _fpt;} // non null if file is open␊ |
32 | ␉char * get_line(char * line, size_t s) const {return _fpt ? fgets(line, s, _fpt) : NULL;}␊ |
33 | ␉␊ |
34 | protected:␊ |
35 | ␉FILE * _fpt;␊ |
36 | };␊ |
37 | ␊ |
38 | #endif␊ |
39 | |