• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

StatPages.h

Go to the documentation of this file.
00001 /** @file
00002 
00003   A brief file description
00004 
00005   @section license License
00006 
00007   Licensed to the Apache Software Foundation (ASF) under one
00008   or more contributor license agreements.  See the NOTICE file
00009   distributed with this work for additional information
00010   regarding copyright ownership.  The ASF licenses this file
00011   to you under the Apache License, Version 2.0 (the
00012   "License"); you may not use this file except in compliance
00013   with the License.  You may obtain a copy of the License at
00014 
00015       http://www.apache.org/licenses/LICENSE-2.0
00016 
00017   Unless required by applicable law or agreed to in writing, software
00018   distributed under the License is distributed on an "AS IS" BASIS,
00019   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00020   See the License for the specific language governing permissions and
00021   limitations under the License.
00022  */
00023 
00024 /****************************************************************************
00025 
00026   StatPages.h
00027 
00028 
00029  ****************************************************************************/
00030 
00031 #ifndef _StatPages_h_
00032 #define _StatPages_h_
00033 #include "P_EventSystem.h"
00034 
00035 #include "HTTP.h"
00036 
00037 //              SPECIAL URLs
00038 //
00039 //
00040 // 1. Access from Browswers
00041 //
00042 //    By special URLS:
00043 //
00044 //      http://{module}/component/sub-component/request-type?arguments
00045 //
00046 //    Note how the hostname is the module to be queried with "{}" surrounding.
00047 //
00048 //    Running Example:
00049 //
00050 //      http://{http}/groups/dump?comp.compilers
00051 //
00052 // 2. What sort of things should be available?
00053 //
00054 //    A. The type of data should default to HTML or match the
00055 //       extension type e.g.:
00056 //
00057 //         http://{http}/groups/use_graph.gif?august
00058 //
00059 //    B. Each protocol/sybsystem should have their own information.
00060 //       For example
00061 
00062 #define STAT_PAGE_SUCCESS           STAT_PAGES_EVENTS_START+0
00063 #define STAT_PAGE_FAILURE           STAT_PAGES_EVENTS_START+1
00064 
00065 typedef Action *(*StatPagesFunc) (Continuation * cont, HTTPHdr * header);
00066 
00067 struct StatPageData
00068 {
00069   char *data;
00070   char *type;
00071   int length;
00072 
00073     StatPageData():data(NULL), type(NULL), length(0)
00074   {
00075   }
00076   StatPageData(char *adata):data(adata), type(NULL)
00077   {
00078     length = strlen(adata);
00079   }
00080   StatPageData(char *adata, int alength):data(adata), type(NULL), length(alength)
00081   {
00082   }
00083 };
00084 
00085 struct StatPagesManager
00086 {
00087   void init();
00088 
00089   inkcoreapi void register_http(const char *hostname, StatPagesFunc func);
00090 
00091   // Private
00092   Action *handle_http(Continuation * cont, HTTPHdr * header);
00093   bool is_stat_page(URL * url);
00094   bool is_cache_inspector_page(URL * url);
00095   int m_enabled;
00096 };
00097 
00098 inkcoreapi extern StatPagesManager statPagesManager;
00099 
00100 // Stole Pete's code for formatting the page and slapped it here
00101 //   for easy reuse
00102 class BaseStatPagesHandler:public Continuation
00103 {
00104 public:
00105   BaseStatPagesHandler(ProxyMutex * amutex):Continuation(amutex), response(NULL), response_size(0), response_length(0)
00106   {
00107   };
00108   ~BaseStatPagesHandler() {
00109     resp_clear();
00110   };
00111 
00112 protected:
00113 
00114   inkcoreapi void resp_clear(void);
00115   inkcoreapi void resp_add(const char *fmt, ...);
00116   inkcoreapi void resp_add_sep(void);
00117   inkcoreapi void resp_begin(const char *title);
00118   inkcoreapi void resp_end(void);
00119   void resp_begin_numbered(void);
00120   void resp_end_numbered(void);
00121   inkcoreapi void resp_begin_unnumbered(void);
00122   inkcoreapi void resp_end_unnumbered(void);
00123   inkcoreapi void resp_begin_item(void);
00124   void resp_end_item(void);
00125   inkcoreapi void resp_begin_table(int border, int columns, int percent);
00126   inkcoreapi void resp_end_table();
00127   inkcoreapi void resp_begin_row();
00128   inkcoreapi void resp_end_row();
00129   inkcoreapi void resp_begin_column(int percent = -1, const char *align = NULL);
00130   inkcoreapi void resp_end_column();
00131 
00132   char *response;
00133   int response_size;
00134   int response_length;
00135 };
00136 
00137 #endif

Generated by  doxygen 1.7.1