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

// This defines only exists to be compatible with the firmware and the used tool
// that creates the staic files...

// get-servlets
#define  SERVLET_SYSLOG             0x0100
#define  SERVLET_XSLT               0x0200
#define  SERVLET_XML                0x0300
#define  SERVLET_STATIC             0x0400
#define  SERVLET_VARS               0x0500
#define  SERVLET_CMD                0x0600
#define  SERVLET_CMD1               0x0700
#define  SERVLET_TABLE              0x0800
#define  SERVLET_FORM               0x0900
#define  SERVLET_MOD_CMD            0x0a00
#define  SERVLET_FORWARD            0x0b00
#define  SERVLET_WEBDAV             0x0c00
#define  SERVLET_LOCALISE           0x0d00
#define  SERVLET_WEBSOCKET          0x0e00
#define  SERVLET_LOCALISE_ENTITY    0x0f00

// POST servlets
#define  SERVLET_POST_MOD		 0x8100
#define  SERVLET_POST_CFGFORM    0x8300
#define  SERVLET_POST_BMC        0x8500
#define  SERVLET_POST_CMD        0x8600
#define  SERVLET_POST_SOAP       0x8700
#define  SERVLET_POST_FILE       0x8800

// flags
#define  HTTP_CACHE      0x01
#define  HTTP_NOPWD      0x02
#define  HTTP_FORCENOPWD 0x04
#define  ALLOW_TFTP      0x08
#define  HTTP_ADMINLOGIN 0x10       // send login to command, not to the destination module
#define  HTTP_CMD_NO_LOG 0x20
#define	 HTTP_CMD_OVERWRITE 0x40    // allow to overwrite CMD with the query string
#define  HTTP_SEND_503   0x80   // used for firmware download
#define  HTTP_LEVEL1     0x100
#define  HTTP_GZIP   	 0x200
#define  HTTP_LOGIN      0x400
#define  HTTP_BUILD_REDIRECT 0x800
#define  HTTP_ALLOW_ORIGIN_ANY 0x1000
#define  HTTP_HIDE       0x2000 // currently used on AP, to hide files needed on the app service only

extern class btree * staticFilesRoot;

class httpfile: public btree, public httpfile_api {
protected:
    word servlet;
    word iposFlags;
    word flags;
    char * fileName;
    char md5str[33];
    const byte * data;
    size_t dataSize;
    word type;

    virtual int btree_compare(void * key);
    virtual int btree_compare(class btree * b);

public:
    httpfile(const char * fileName, word servlet, word theFlags, const byte * data, size_t dataSize);
    ~httpfile();

    const char * GetFileName() { return fileName; }
    const byte * GetData() { return data; }
    size_t GetSize() { return dataSize; }
    word GetResourceType() { return type; }
    word GetServlet() { return servlet; }
    word GetIposFlags() { return iposFlags; }
    word GetFlags() { return flags; }
    void SetFlags(word theFlags) { this->flags = theFlags; }
    const char * GetMD5String() { return md5str; }

    static class httpfile *find(const char * name);
    static class httpfile *find_next_left(const char * name);
};
