mirror of
https://review.haiku-os.org/haiku
synced 2025-01-31 02:35:03 +01:00
000fe088a7
Jef Poskanzer is providing the backend, but had to be adopted in some ways. Other issues in Poorman have been resolved. When testing the license integration, I stumbled over some AboutSystem bugs, basically clicking licenses would not open them. I fixed those in this patch, sorry for mixing that up. Note to Ma Jie: I changed the encoding of the libhttpd files to UTF-8! (This affects only the (C) glyph.) Thanks a lot for your awesome work on Poorman, it's really appreciated! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29906 a95241bf-73f2-0310-859d-f6bbb57e9c96
77 lines
1.7 KiB
C++
77 lines
1.7 KiB
C++
/*
|
|
* Copyright 2009 Haiku Inc. All rights reserved.
|
|
* Distributed under the terms of the MIT License.
|
|
*
|
|
* Author(s):
|
|
* Ma Jie, china.majie at gmail
|
|
*/
|
|
#ifndef POOR_MAN_SERVER_H
|
|
#define POOR_MAN_SERVER_H
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <OS.h>
|
|
#include <SupportDefs.h>
|
|
|
|
#include "libhttpd/libhttpd.h"
|
|
|
|
#define POOR_MAN_BUF_SIZE 1048576ll
|
|
|
|
#ifdef __cplusplus
|
|
class PoorManServer{
|
|
public:
|
|
PoorManServer(const char* webDir, int32 maxConns,
|
|
bool listDir, const char* idxName);
|
|
virtual ~PoorManServer();
|
|
|
|
status_t Run();
|
|
status_t Stop();
|
|
|
|
bool IsRunning()const{return fIsRunning;}
|
|
|
|
status_t SetWebDir(const char* webDir);
|
|
status_t SetMaxConns(int32 count);
|
|
status_t SetListDir(bool listDir);
|
|
status_t SetIndexName(const char* idxName);
|
|
|
|
pthread_rwlock_t* GetWebDirLock(){return &fWebDirLock;}
|
|
pthread_rwlock_t* GetIndexNameLock(){return &fIndexNameLock;}
|
|
private:
|
|
bool fIsRunning;
|
|
int32 fMaxConns;//Max Thread Count
|
|
char* fIndexName;//Index File Name
|
|
|
|
thread_id fListenerTid;
|
|
int32 fCurConns;
|
|
httpd_server* fHttpdServer;
|
|
|
|
pthread_rwlock_t fWebDirLock;
|
|
pthread_rwlock_t fIndexNameLock;
|
|
|
|
PoorManServer(){}
|
|
PoorManServer(PoorManServer& s){}
|
|
PoorManServer& operator=(PoorManServer& s){return *this;}
|
|
|
|
//two thread functions.
|
|
static int32 _Listener(void* data);
|
|
static int32 _Worker(void* data);
|
|
|
|
status_t _HandleGet(httpd_conn* hc);
|
|
status_t _HandleHead(httpd_conn* hc);
|
|
status_t _HandlePost(httpd_conn* hc);
|
|
};
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
pthread_rwlock_t* get_web_dir_lock();
|
|
pthread_rwlock_t* get_index_name_lock();
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif //POOR_MAN_SERVER_H
|