midgard/pageresolve.h

00001 #ifndef MGD_PAGERESOLVE_H
00002 #define MGD_PAGERESOLVE_H
00003 
00004 #ifdef WIN32
00005 #include <windows.h>
00006 #endif
00007 #include <glib.h>
00008 #include <stdio.h>
00009 #include "midgard/midgard_defs.h"
00010 
00011 typedef struct _midgard_style {
00012         GList *stack;
00013         GHashTable *styles;
00014         GHashTable *page_elements;
00015         GHashTable *style_elements;
00016 }midgard_style;
00017 
00018 typedef enum {
00019    MGD_FOUND_NONE,
00020    MGD_FOUND_PAGE,
00021    MGD_FOUND_BLOB
00022 } mgd_resolve_result_t;
00023 
00024 typedef struct {
00025    int active;
00026    long page;
00027    long style;
00028    int addslash;
00029    int auth_required;
00030    int self_len;
00031    int author;
00032    int owner;
00033    mgd_resolve_result_t found;
00034    int blob;
00035 } mgd_page_t;
00036 
00037 typedef struct {
00038    long host;
00039    long style;
00040    long page;
00041    long sitegroup;
00042    int lang;
00043    int auth_required;
00044    int prefix_length;
00045    int found;
00046 } mgd_host_t;
00047 
00048 typedef void (*mgd_store_style_elt_cb)(const char *name, const char *value, GHashTable * table);
00049 typedef const char* (*mgd_get_style_elt_cb)(const char *name, GHashTable * table);
00050 typedef void (*mgd_pathinfo_cb)(const char *name, void *userdata);
00051 
00052 int mgd_find_host(midgard *mgd,
00053    const char *hostname, int port, const char *uri, int null_prefix,
00054    mgd_host_t *parsed);
00055 
00056 /* EEH: if this returns false, or returns true but active is set, you might still want to test
00057    for pageblobs. The page id will be valid.
00058 */
00059 int mgd_parse_uri(midgard *mgd, mgd_host_t *host, char *uri,
00060    mgd_page_t *result,
00061    mgd_pathinfo_cb pathinfo_cb,
00062    GArray *path,
00063    void *userdata);
00064 
00065 void mgd_load_styles(midgard *mgd, GArray* path, long host, long style,
00066                      mgd_store_style_elt_cb style_elt_cb, void *userdata,
00067                      long cached_page);
00068 
00069 extern void midgard_collect_style_elements(midgard *mgd, long host, long style, 
00070   mgd_store_style_elt_cb style_elt_cb,
00071   void *userdata);
00072 
00073 typedef void (*mgd_parser_output_cb)(char *buffer, int len, void *userdata);
00074 
00075 typedef struct {
00076    struct {
00077       mgd_parser_output_cb func;
00078       void                 *userdata;
00079    } output;
00080 
00081    struct {
00082       mgd_get_style_elt_cb func;
00083       void                 *userdata;
00084    } get_element;
00085 } mgd_parser_itf_t;
00086 
00087 void mgd_preparse_buffer(const char *buffer, mgd_parser_itf_t *itf);
00088 void mgd_preparse_file(FILE *f, mgd_parser_itf_t *itf);
00089 
00090 void mgd_cache_touch(midgard *mgd, long page);
00091 int mgd_cache_is_current(midgard *mgd, long host, long page, long style);
00092 
00093 #define MGD_CACHE_ELT_PAGE    0
00094 #define MGD_CACHE_ELT_STYLE   1
00095 
00096 extern midgard_style *midgard_style_new(void);
00097 
00098 extern gboolean midgard_style_register(midgard *mgd, const gchar *name,
00099                 midgard_style *mgdstyle);
00100 
00101 extern gboolean midgard_style_register_from_dir(midgard *mgd, const gchar *stackname,
00102                                 const gchar *dirname, GHashTable *style_stack);
00103 
00104 extern void midgard_style_get_elements(midgard * mgd, glong style, mgd_store_style_elt_cb style_elt_cb, GHashTable * table);
00105 
00106 void mgd_cache_add(midgard *mgd, long host, long page, long style, int type, long id);
00107 
00108 const gchar * midgard_pc_get_element(const gchar * name, GHashTable * table);
00109 
00110 void  midgard_pc_set_element(const gchar * name, const gchar * value, GHashTable * table);
00111 
00112 void midgard_pc_output(char *buffer, int len, void * userdata);
00113 
00114 extern gboolean midgard_style_get_elements_from_dir(midgard *mgd, const gchar *name,
00115                mgd_store_style_elt_cb style_elt_cb, GHashTable *table);
00116 
00117 #endif

Generated on Thu Feb 22 06:15:14 2007 for midgard-core by  doxygen 1.4.6