
/*---------------------------------------------------------------------------*/
/* tools.h                                                                   */
/* copyright (c) innovaphone 2015                                            */
/*                                                                           */
/*---------------------------------------------------------------------------*/

#define ISSPACE(c)    (c == ' ' || c == '\t' || c == '\r' || c == '\f' || c == '\n' || c == '\v')

// The types of datasources...
typedef enum {
    WS_DATA_SOURCE_TYPE_HTML,
    WS_DATA_SOURCE_TYPE_WEBSOCKET
} ws_data_source_type;


typedef enum {
    FT_NONE,
    FT_FRAGMENTED_STREAM,
    FT_FRAGMENTED_CHUNK
} fragmented_type_t;


inline size_t AllignForBlockSize(size_t s, size_t block)
{
    size_t tmp = s / block * block;
    if (tmp < s)
        return tmp + block;
    else
        return tmp;
}


class UWebserverWebsocket : public istd::listElement<UWebserverWebsocket> { // Used to ping each websocket connnection...
public:
    UWebserverWebsocket() {}
    virtual ~UWebserverWebsocket() {}
    virtual void Ping() = 0; // The function also can lead to a shutdown, if the last ping didn't receive a pong.
};