vfs: check userland buffers before reading them.
[haiku.git] / src / apps / poorman / PoorManServer.h
blob9a5d0b2a0a15cf3c61f8b89af0a83c7636f7f272
1 /*
2 * Copyright 2009 Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Author(s):
6 * Ma Jie, china.majie at gmail
7 */
8 #ifndef POOR_MAN_SERVER_H
9 #define POOR_MAN_SERVER_H
11 #include <pthread.h>
13 #include <OS.h>
14 #include <SupportDefs.h>
16 #include "libhttpd/libhttpd.h"
18 #define POOR_MAN_BUF_SIZE 1048576ll
20 #ifdef __cplusplus
21 class PoorManServer{
22 public:
23 PoorManServer(const char* webDir, int32 maxConns,
24 bool listDir, const char* idxName);
25 virtual ~PoorManServer();
27 status_t Run();
28 status_t Stop();
30 bool IsRunning()const{return fIsRunning;}
32 status_t SetWebDir(const char* webDir);
33 status_t SetMaxConns(int32 count);
34 status_t SetListDir(bool listDir);
35 status_t SetIndexName(const char* idxName);
37 pthread_rwlock_t* GetWebDirLock(){return &fWebDirLock;}
38 pthread_rwlock_t* GetIndexNameLock(){return &fIndexNameLock;}
39 private:
40 bool fIsRunning;
41 int32 fMaxConns;//Max Thread Count
42 char* fIndexName;//Index File Name
44 thread_id fListenerTid;
45 int32 fCurConns;
46 httpd_server* fHttpdServer;
48 pthread_rwlock_t fWebDirLock;
49 pthread_rwlock_t fIndexNameLock;
51 PoorManServer(){}
52 PoorManServer(PoorManServer& s){}
53 PoorManServer& operator=(PoorManServer& s){return *this;}
55 //two thread functions.
56 static int32 _Listener(void* data);
57 static int32 _Worker(void* data);
59 status_t _HandleGet(httpd_conn* hc);
60 status_t _HandleHead(httpd_conn* hc);
61 status_t _HandlePost(httpd_conn* hc);
63 #endif
65 #ifdef __cplusplus
66 extern "C" {
67 #endif
69 pthread_rwlock_t* get_web_dir_lock();
70 pthread_rwlock_t* get_index_name_lock();
72 #ifdef __cplusplus
74 #endif
76 #endif //POOR_MAN_SERVER_H