page.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: page.h,v 1.8 2006/04/22 13:14:46 tat Exp $
00009  */
00010 
00011 #ifndef _KLONE_PAGE_H_
00012 #define _KLONE_PAGE_H_
00013 
00014 #include "klone_conf.h"
00015 #ifdef HAVE_STDINT
00016 #include <stdint.h>
00017 #endif /* HAVE_STDINT */
00018 #include <u/libu.h>
00019 #include <klone/response.h>
00020 #include <klone/request.h>
00021 
00022 #ifdef __cplusplus
00023 extern "C" {
00024 #endif
00025 
00026 typedef void (*page_run_t)(request_t*, response_t*);
00027 
00028 typedef enum page_type_e { 
00029     PAGE_TYPE_UNKNOWN, 
00030     PAGE_TYPE_STATIC, 
00031     PAGE_TYPE_DYNAMIC 
00032 } page_type_t;
00033 
00034 /* static content page */
00035 typedef struct page_static_s
00036 {
00037     size_t size;
00038     unsigned char *data;
00039 } page_static_t;
00040 
00041 /* dyunamic content page */
00042 typedef struct page_dynamic_s
00043 {
00044     page_run_t run; /* run page code func pointer  */
00045 } page_dynamic_t;
00046 
00047 /* define page list */
00048 LIST_HEAD(pages_s, page_s);
00049 
00050 struct page_s
00051 {
00052     const char *uri;        /* *.kl1 file name              */
00053     const char *mime_type;  /* default mime type            */
00054     page_type_t type;       /* page type PAGE_TYPE_XXX      */
00055     void *sd;               /* static or dyn page context   */
00056     LIST_ENTRY(page_s) np;  /* next & prev pointers         */
00057 };
00058 
00059 #define PAGE_STATIC_INIT(uri, mime, type, ptr) \
00060     { uri, mime, type, ptr, LIST_ENTRY_NULL } 
00061 
00062 typedef struct page_s page_t;
00063 typedef struct pages_s pages_t; 
00064 
00065 #ifdef __cplusplus
00066 }
00067 #endif 
00068 
00069 #endif

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