1 |
// Smersh |
2 |
// |
3 |
// Douglas Thrift |
4 |
// |
5 |
// $Id$ |
6 |
|
7 |
#ifndef _Smersh_hpp_ |
8 |
#define _Smersh_hpp_ |
9 |
|
10 |
#include <iostream> |
11 |
#include <string> |
12 |
#include <sstream> |
13 |
#include <vector> |
14 |
#include <map> |
15 |
#include <algorithm> |
16 |
#include <cstdlib> |
17 |
#include <cctype> |
18 |
|
19 |
#include <menes-ext/casts.hpp> |
20 |
|
21 |
using namespace std; |
22 |
|
23 |
inline string sgetenv(const string& name) |
24 |
{ |
25 |
char* value = getenv(name.c_str()); |
26 |
|
27 |
return value != NULL ? value : ""; |
28 |
} |
29 |
|
30 |
inline int ssetenv(const string& name, const string& value, bool write = true) |
31 |
{ |
32 |
return setenv(name.c_str(), value.c_str(), write); |
33 |
} |
34 |
|
35 |
inline int sputenv(const string& env) |
36 |
{ |
37 |
istringstream input(env); |
38 |
string name, value; |
39 |
|
40 |
getline(input, name, '='); |
41 |
getline(input, value); |
42 |
|
43 |
return ssetenv(name, value); |
44 |
} |
45 |
|
46 |
inline void sunsetenv(const string& name) { unsetenv(name.c_str()); } |
47 |
|
48 |
class Person; |
49 |
|
50 |
class Smersh |
51 |
{ |
52 |
private: |
53 |
multimap<string, string> cgi; |
54 |
void parse(istream& sin); |
55 |
void smersh(ostream& sout); |
56 |
void output(ostream& sout, const vector<Person>& people); |
57 |
public: |
58 |
Smersh(istream& sin = cin, ostream& sout = cout); |
59 |
~Smersh() {} |
60 |
}; |
61 |
|
62 |
#endif // _Smersh_hpp_ |