diff options
-rw-r--r-- | doc/README | 20 | ||||
-rw-r--r-- | lib/Handle.cc | 4 | ||||
-rw-r--r-- | lib/HttpServ.cc | 6 | ||||
-rw-r--r-- | lib/Socket.cc | 8 | ||||
-rw-r--r-- | lib/TaskMan.cc | 26 |
5 files changed, 36 insertions, 28 deletions
@@ -2,12 +2,20 @@ Baltisot 0.1.0 ~~~~~~~~~~~~~~ Hello, this is the library Baltisot. If you are reading this, you probably are -a developper and want to learn to use it. Before that, let's talk a bit about -what exactly Baltisot is. +a developper and want to learn how to use it. Before that, let's talk a bit +about what exactly Baltisot is and why I did developped it. Baltisot is a multiple purpose C++ library. I've written as much low level, -middle level and high level classes as possible. I've classified the classes: +middle level and high level classes as possible. Baltisot is NOT a HTTP server. +If you are looking for a general purpose HTTP server, look at Apache or thttpd. +Some people will say that I tried to rewrite everything from scratch. They are +true. I did wrote it because of school projects. Teachers don't allow us to use +much third party work, and we are obliged to work in C++. Since this work began +to be huge and useful, I decided to spread it. + + +I've classified the classes: o Low level: Base - Override memory allocations routines. @@ -53,9 +61,9 @@ empty & any - Two basic regex. You can now read the API file to know how to use each of the classes. As an example, you can read the source from 'Main.cc' into the 'src' directory. -There is two little helpers functions into the 'src/misc.cc' file to generate HTTP -actions. GeneDeroul can read a handle and returns two String array to be used as -a pull down menu. The input handle can be seen as this: +There is two little helpers functions into the 'src/misc.cc' file to generate +HTTP actions. GeneDeroul can read a handle and returns two String array to be +used as a pull down menu. The input handle can be seen as this: ----- begin ----- value1 diff --git a/lib/Handle.cc b/lib/Handle.cc index 9f6736d..47be433 100644 --- a/lib/Handle.cc +++ b/lib/Handle.cc @@ -46,7 +46,7 @@ ssize_t Handle::write(const void *buf, size_t count) throw (GeneralException) { done = false; full = true; if (nonblock) { - cerr << "write: throwing IOAgain for handle " << GetName() << endl; +// cerr << "write: throwing IOAgain for handle " << GetName() << endl; throw IOAgain(); } else { sleep(1); @@ -77,7 +77,7 @@ ssize_t Handle::read(void *buf, size_t count) throw (GeneralException) { // Avant de déclarer une erreur, on vérifie si ce n'est pas un // problème lié au fait qu'il n'y a plus d'octets. if (nonblock) { - cerr << "read: throwing IOAgain for handle " << GetName() << endl; +// cerr << "read: throwing IOAgain for handle " << GetName() << endl; throw IOAgain(); } } else { diff --git a/lib/HttpServ.cc b/lib/HttpServ.cc index 1dba18b..b4669ad 100644 --- a/lib/HttpServ.cc +++ b/lib/HttpServ.cc @@ -254,7 +254,7 @@ void ProcessRequest::ParseVars(Handle * s, int len) { v += t[pos++]; } } - cerr << "Pushing HTTP variable: " << v << endl; +// cerr << "Pushing HTTP variable: " << v << endl; Vars->Add(v); pos++; } @@ -274,7 +274,7 @@ bool ProcessRequest::ParseUri(String & file, String & domain, String & gvars, Ha ssize_t sppos; *s >> t; - cerr << "Read Request (1): " << t << endl; +// cerr << "Read Request (1): " << t << endl; int IPos = t.strchr('?'); @@ -288,7 +288,7 @@ bool ProcessRequest::ParseUri(String & file, String & domain, String & gvars, Ha free(sdup); } - cerr << "New request: " << t << ", gvars = " << gvars << endl; +// cerr << "New request: " << t << ", gvars = " << gvars << endl; bad = false; diff --git a/lib/Socket.cc b/lib/Socket.cc index 62de4b6..9883898 100644 --- a/lib/Socket.cc +++ b/lib/Socket.cc @@ -96,7 +96,7 @@ bool Socket::Connect(const String & host, int port) { struct sockaddr_in remotesocketaddr; if (!listening && !connected) { - cerr << " - Resolving '" << host << "'..." << endl; +// cerr << " - Resolving '" << host << "'..." << endl; if (!(remotehostent = gethostbyname(host.to_charp()))) { return false; } @@ -104,12 +104,12 @@ bool Socket::Connect(const String & host, int port) { remotesocketaddr.sin_family = AF_INET; remotesocketaddr.sin_port = htons(port); bcopy(remotehostent->h_addr, &remotesocketaddr.sin_addr, remotehostent->h_length); - cerr << " - Connecting to port " << port << " ..." << endl; +// cerr << " - Connecting to port " << port << " ..." << endl; if (!connect(GetHandle(), (struct sockaddr *)&remotesocketaddr, sizeof(remotesocketaddr))) { - cerr << " - Connected." << endl; +// cerr << " - Connected." << endl; connected = true; } else { - cerr << " - Error connecting: " << strerror(errno) << endl; +// cerr << " - Error connecting: " << strerror(errno) << endl; } } return connected; diff --git a/lib/TaskMan.cc b/lib/TaskMan.cc index bf1a6be..a348ab0 100644 --- a/lib/TaskMan.cc +++ b/lib/TaskMan.cc @@ -41,7 +41,7 @@ void taskman_sigchild(int sig) { TaskMan::WaitFor(pid, 0, status); } - cerr << "Got SIGCHILD, pid = " << pid << " and status = " << status << endl; +// cerr << "Got SIGCHILD, pid = " << pid << " and status = " << status << endl; signal(SIGCHLD, taskman_sigchild); } @@ -207,13 +207,13 @@ void TaskMan::MainLoop() throw (GeneralException) { if (stopped) return; - cerr << "-=- TaskMan: begin main loop with " << number << " task to manage.\n"; +// cerr << "-=- TaskMan: begin main loop with " << number << " task to manage.\n"; for (TaskList_t::iterator p = TaskList.begin(); p && (p != TaskList.end()); p++) { Task * t = *p; - cerr << "-=- TaskMan: task " << t->GetName() << endl; +// cerr << "-=- TaskMan: task " << t->GetName() << endl; } - cerr << "-=- TaskMan: processing burning tasks.\n"; +// cerr << "-=- TaskMan: processing burning tasks.\n"; no_burst = 0; while (!no_burst) { @@ -228,7 +228,7 @@ void TaskMan::MainLoop() throw (GeneralException) { } if (t->GetState() == TASK_BURST) { - cerr << "-=- TaskMan: running burning task " << t->GetName() << endl; +// cerr << "-=- TaskMan: running burning task " << t->GetName() << endl; t->Run(); /* if the task added some new tasks, we have to rerun the loop */ no_burst = 0; @@ -247,7 +247,7 @@ void TaskMan::MainLoop() throw (GeneralException) { /* Now is time to check all the handle and enters into a wait state. */ event = E_HANDLE; - cerr << "-=- TaskMan: processing handle-waiting tasks.\n"; +// cerr << "-=- TaskMan: processing handle-waiting tasks.\n"; nfds = w4ha.size(); no_burst = 1; @@ -330,11 +330,11 @@ void TaskMan::MainLoop() throw (GeneralException) { } if (q->revents & POLLERR) { - cerr << _("Error condition with poll, handle ") << q->fd << endl; +// cerr << _("Error condition with poll, handle ") << q->fd << endl; } if (q->revents & POLLHUP) { - cerr << _("Handle ") << q->fd << _(" hung up.\n"); +// cerr << _("Handle ") << q->fd << _(" hung up.\n"); } fd = q->fd; @@ -352,7 +352,7 @@ void TaskMan::MainLoop() throw (GeneralException) { touched = false; if ((p->ha->GetHandle() == fd) && (!p->T->IsStopped()) && (p->T->GetState() != TASK_DONE) && (!p->dirthy)) { // We've got one, launch it. - cerr << "-=- TaskMan: launching task " << p->T->GetName() << " for handle " << p->ha->GetHandle() << endl; +// cerr << "-=- TaskMan: launching task " << p->T->GetName() << " for handle " << p->ha->GetHandle() << endl; w4ha_t w4 = *p; p->dirthy = true; @@ -391,7 +391,7 @@ void TaskMan::MainLoop() throw (GeneralException) { no_zombies = 0; event = E_TASK; - cerr << "-=- TaskMan: processing zombies loop.\n"; +// cerr << "-=- TaskMan: processing zombies loop.\n"; while (!no_zombies) { no_zombies = 1; @@ -404,7 +404,7 @@ void TaskMan::MainLoop() throw (GeneralException) { } if ((o = t->WaitedBy())) { - cerr << "-=- TaskMan: running task " << o->GetName() << " for task " << t->GetName() << endl; +// cerr << "-=- TaskMan: running task " << o->GetName() << " for task " << t->GetName() << endl; etask = t; o->Run(); @@ -428,7 +428,7 @@ void TaskMan::MainLoop() throw (GeneralException) { /* To end up the loop, let's recall task waiting for processes */ event = E_PROCESS; - cerr << "-=- TaskMan: processing child-waiting tasks.\n"; +// cerr << "-=- TaskMan: processing child-waiting tasks.\n"; if (got_sigchild) { for (vector<w4pr_t>::iterator p = w4pr.begin(); p && (p != w4pr.end()); p++) { @@ -439,7 +439,7 @@ void TaskMan::MainLoop() throw (GeneralException) { } eprocess = p->pr; estatus = p->status; - cerr << "-=- TaskMan: running task " << p->T->GetName() << " for process " << p->pr << " (" << p->status << ")\n"; +// cerr << "-=- TaskMan: running task " << p->T->GetName() << " for process " << p->pr << " (" << p->status << ")\n"; t = p->T; w4pr.erase(p); got_sigchild--; |