ffead.server.doc
ScriptHandler.h
1 /*
2  Copyright 2009-2012, Sumeet Chhetri
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 /*
17  * ScriptHandler.h
18  *
19  * Created on: Jun 17, 2012
20  * Author: Sumeet
21  */
22 
23 #ifndef SCRIPTHANDLER_H_
24 #define SCRIPTHANDLER_H_
25 #include <stdlib.h>
26 #include "AfcUtil.h"
27 #include "HttpRequest.h"
28 #include "HttpResponse.h"
29 #include <sys/types.h>
30 #include <sys/wait.h>
31 #include "Timer.h"
32 #include <unistd.h>
33 #include "Logger.h"
34 #include "Constants.h"
35 
37  static Logger logger;
38  static int pcloseRWE(int pid, int *rwepipe);
39  static int popenRWE(int *rwepipe, const char *exe, const char *const argv[],string tmpf);
40  static int popenRWEN(int *rwepipe, const char *exe, const char** argv);
41 public:
42  ScriptHandler();
43  static string execute(string exe, bool retErrs);
44  static string chdirExecute(string exe, string tmpf, bool retErrs);
45  static bool handle(HttpRequest* req, HttpResponse& res, map<string, string> handoffs, void* dlib,
46  string ext, map<string, string> props);
47  virtual ~ScriptHandler();
48 };
49 
50 #endif /* SCRIPTHANDLER_H_ */