Request Context: add struct plugin details to the request struct details

Signed-off-by: Eduardo Silva <edsiper@gmail.com>
Package: Export mk_api object to each package

Signed-off-by: Eduardo Silva <edsiper@gmail.com>
Package: init function renamed to duda_package_main()

Signed-off-by: Eduardo Silva <edsiper@gmail.com>
OutQueue: move related functions from duda_event.c to duda_queue.c
Signed-off-by: Eduardo Silva <edsiper@gmail.com>
API: New Event object

This new object expose methods to allow web services to register
file descriptor events with the Monkey Core event loop. Three methods
are implemented:

   event->add()   : register a new event
   event->lookup(): lookup for an event handler
   event->delete(): remove an event handler

This is the one of the initial patch set about event handling, this
functionality still requires to be exported to the package context.

Signed-off-by: Eduardo Silva <edsiper@gmail.com>
API Object: the api object now is available on packages context

This patch makes the web services API object be passed to every package
on load time, so now every package is able to use the same API as the
webservices does. Available objects are:

   - monkey
   - map
   - msg
   - response
   - debug
   - event
   - console
   - param
   - session
   - cookie
   - global
   - xtime

Signed-off-by: Eduardo Silva <edsiper@gmail.com>
API main: workaround about references

Signed-off-by: Eduardo Silva <edsiper@gmail.com>
API: fix reference api object for packages

Signed-off-by: Eduardo Silva <edsiper@gmail.com>
Examples: rename param local variable to params to avoid to mess the param object

Signed-off-by: Eduardo Silva <edsiper@gmail.com>
Clean up

Signed-off-by: Eduardo Silva <edsiper@gmail.com>
Monkey Hooks: adapt to new hooks declaration

Signed-off-by: Eduardo Silva <edsiper@gmail.com>
Package: use MK_EXPORT for package hooks

Signed-off-by: Eduardo Silva <edsiper@gmail.com>
Setup: set right entry method name on exception message

Signed-off-by: Eduardo Silva <edsiper@gmail.com>
API: add internal exception printer

Signed-off-by: Eduardo Silva <edsiper@gmail.com>
API: use printf() instead of mk_err

Signed-off-by: Eduardo Silva <edsiper@gmail.com>
API: New Request object

This new object aims to provide methods to validate/retrieve specific
details from the incoming request given by duda_request_t *dr.

The methods available are the following:

  - is_data()  : check if the request contains a body under a POST or PUT method
  - is_get()   : check if is a GET method request
  - is_post()  : check if is a POST method request
  - is_head()  : check if is a HEAD method request
  - is_put()   : check if is a PUT method request
  - is_delete(): check if is a DELETE method request

Signed-off-by: Eduardo Silva <edsiper@gmail.com>
Request: new is_content_type() method

This new method validate the incoming content type set by the client
in the request headers, usage:

    request->is_content_type(dr, "application/json");

Signed-off-by: Eduardo Silva <edsiper@gmail.com>
Event: improve API to handle different event types

This patch makes the methods of the event object works in a
different way. The new API to register an event is as follows:

int duda_event_add(int sockfd, struct duda_request *dr,
                   int init_mode, int behavior,
                   int (*cb_on_read) (int, struct duda_request *),
                   int (*cb_on_write) (int, struct duda_request *),
                   int (*cb_on_error) (int, struct duda_request *),
                   int (*cb_on_close) (int, struct duda_request *),
                   int (*cb_on_timeout) (int, struct duda_request *));

So it introduce the new parameters init_mode and behavior, where
init_mode takes one of the following values:

    - DUDA_EVENT_READ
    - DUDA_EVENT_WRITE
    - DUDA_EVENT_RW
    - DUDA_EVENT_SLEEP

and behavior can be one of the epoll based modes:

    - DUDA_EVENT_LEVEL_TRIGGERED
    - DUDA_EVENT_EDGE_TRIGGERED

Also a new method to change the mode and behavior of a registered file
descriptor have been added:

    event->mode(int fd, int mode, int behavior);

The modes allowed are the same for the add() method but it adds:

    - DUDA_EVENT_WAKEUP

this one will only work if the file descriptor is in a sleep mode. The
behavior are the same described previously.

Signed-off-by: Eduardo Silva <edsiper@gmail.com>
Response: new methods wait() and cont()

This patch implements two new methods in the response object to
handle different states of the connection.

 - response->wait(): instruct Duda to put in sleep mode the client
                     connection because the response will depend of
                     a third party callback.
 - response->cont(): continue a previous wait() connection, it
                     restore the client events.

Every time a wait() is set, a cont() must be invoked later in some
part of the web service.

On wait mode, no data is flushed until response->cont() and
response->end() are invoked.

Signed-off-by: Eduardo Silva <edsiper@gmail.com>
Events: fix worker list of events

Signed-off-by: Eduardo Silva <edsiper@gmail.com>