Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals

emb.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2005, 2006 by KoanLogic s.r.l. <http://www.koanlogic.com>
00003  * All rights reserved.
00004  *
00005  * This file is part of KLone, and as such it is subject to the license stated
00006  * in the LICENSE file which you have received as part of this distribution.
00007  *
00008  * $Id: emb.h,v 1.14 2006/04/22 13:14:46 tat Exp $
00009  */
00010 
00011 #ifndef _KLONE_EMB_H_
00012 #define _KLONE_EMB_H_
00013 
00014 #include "klone_conf.h"
00015 #include <sys/stat.h>
00016 #ifdef HAVE_STDINT
00017 #include <stdint.h>
00018 #endif /* HAVE_STDINT */
00019 #include <u/libu.h>
00020 #include <klone/request.h>
00021 #include <klone/response.h>
00022 #include <klone/session.h>
00023 #include <klone/io.h>
00024 #include <klone/codecs.h>
00025 #include <klone/utils.h>
00026 
00027 #ifdef __cplusplus
00028 extern "C" {
00029 #endif 
00030 
00031 /* supported embedded resource type */
00032 enum {
00033     ET_FILE,                /* embedded file                */
00034     ET_PAGE                 /* dynamic web page             */
00035 };
00036 
00037 /* define resource list */
00038 LIST_HEAD(emblist_s, embres_s);
00039 
00040 /* common struct for embedded resources */
00041 typedef struct embres_s
00042 {
00043     LIST_ENTRY(embres_s) np;/* next & prev pointers         */
00044     const char *filename;   /* emb resource file name       */
00045     int type;               /* emb resource type (ET_*)     */
00046 } embres_t;
00047 
00048 /* embedded file */
00049 typedef struct embfile_s
00050 {
00051     embres_t res;           /* any emb resource must start with a embres_t    */
00052     size_t size;            /* size of the data block                         */
00053     unsigned char *data;    /* file data                                      */
00054     int comp;               /* if data is compressed                          */
00055     int encrypted;          /* if data is encrypted                           */
00056     time_t mtime;           /* time of last modification                      */
00057     const char *mime_type;  /* guessed mime type                              */
00058     size_t file_size;       /* size of the source file (not compressed)       */
00059 } embfile_t;
00060 
00061 /* embedded dynamic klone page */
00062 typedef struct embpage_s
00063 {
00064     embres_t res;           /* any emb resource must start with a embres_t  */
00065     void (*run)(request_t*, response_t*, session_t*);   /* page code        */
00066 } embpage_t;
00067 
00068 int emb_init(void);
00069 int emb_term(void);
00070 int emb_register(embres_t *r);
00071 int emb_unregister(embres_t *r);
00072 int emb_lookup(const char *filename, embres_t **pr);
00073 int emb_count(void);
00074 int emb_getn(size_t n, embres_t **pr);
00075 int emb_open(const char *file, io_t **pio);
00076 
00077 #ifdef __cplusplus
00078 }
00079 #endif 
00080 
00081 #endif

←Products
© 2005-2006 - KoanLogic S.r.l. - All rights reserved