2 * Copyright 2009 Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Ma Jie, china.majie at gmail
8 #ifndef POOR_MAN_SERVER_H
9 #define POOR_MAN_SERVER_H
14 #include <SupportDefs.h>
16 #include "libhttpd/libhttpd.h"
18 #define POOR_MAN_BUF_SIZE 1048576ll
23 PoorManServer(const char* webDir
, int32 maxConns
,
24 bool listDir
, const char* idxName
);
25 virtual ~PoorManServer();
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
;}
41 int32 fMaxConns
;//Max Thread Count
42 char* fIndexName
;//Index File Name
44 thread_id fListenerTid
;
46 httpd_server
* fHttpdServer
;
48 pthread_rwlock_t fWebDirLock
;
49 pthread_rwlock_t fIndexNameLock
;
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
);
69 pthread_rwlock_t
* get_web_dir_lock();
70 pthread_rwlock_t
* get_index_name_lock();
76 #endif //POOR_MAN_SERVER_H