emb.h

00001 /*
00002  * Copyright (c) 2005-2012 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.18 2010/06/01 20:20:51 tho 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/klone.h>
00021 #include <klone/dypage.h>
00022 
00023 #ifdef __cplusplus
00024 extern "C" {
00025 #endif 
00026 
00027 /* supported embedded resource type */
00028 enum {
00029     ET_FILE,                /* embedded file                */
00030     ET_PAGE                 /* dynamic web page             */
00031 };
00032 
00033 /* define resource list */
00034 LIST_HEAD(emblist_s, embres_s);
00035 
00036 /* common struct for embedded resources */
00037 typedef struct embres_s
00038 {
00039     LIST_ENTRY(embres_s) np;/* next & prev pointers         */
00040     const char *filename;   /* emb resource file name       */
00041     int type;               /* emb resource type (ET_*)     */
00042 } embres_t;
00043 
00044 /* embedded file */
00045 typedef struct embfile_s
00046 {
00047     embres_t res;           /* any emb resource must start with a embres_t    */
00048     size_t size;            /* size of the data block                         */
00049     unsigned char *data;    /* file data                                      */
00050     int comp;               /* if data is compressed                          */
00051     int encrypted;          /* if data is encrypted                           */
00052     time_t mtime;           /* time of last modification                      */
00053     const char *mime_type;  /* guessed mime type                              */
00054     size_t file_size;       /* size of the source file (not compressed)       */
00055 } embfile_t;
00056 
00057 /* embedded dynamic klone page */
00058 typedef struct embpage_s
00059 {
00060     embres_t res;           /* any emb resource must start with a embres_t  */
00061     dypage_fun_t fun;
00062 } embpage_t;
00063 
00064 int emb_init(void);
00065 int emb_term(void);
00066 int emb_register(embres_t *r);
00067 int emb_unregister(embres_t *r);
00068 int emb_lookup(const char *filename, embres_t **pr);
00069 int emb_count(void);
00070 int emb_getn(size_t n, embres_t **pr);
00071 int emb_open(const char *file, io_t **pio);
00072 
00073 int emb_list (char ***plist);
00074 void emb_list_free (char **list);
00075 int emb_to_ubuf(const char *res_name, u_buf_t **pubuf);
00076 
00077 #ifdef __cplusplus
00078 }
00079 #endif 
00080 
00081 #endif

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