Main Page | Class Hierarchy | Class List | File List | Class Members

Http.h

00001 // This is part of tacppd project (extended tacacs++ daemon)
00002 // (c) Copyright in 2000-2004 by tacppd team and contributors
00003 // see http://tacppd.org for more information
00004 //
00005 // file: Http.h
00006 // description: http support
00007 
00008 //  This program is free software; you can redistribute it and/or modify
00009 //  it under the terms of the GNU General Public License as published by
00010 //  the Free Software Foundation; either version 2 of the License, or
00011 //  (at your option) any later version.
00012 //
00013 //  This program is distributed in the hope that it will be useful,
00014 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 //  GNU General Public License for more details.
00017 //
00018 //  You should have received a copy of the GNU General Public License
00019 //  along with this program; if not, write to the Free Software
00020 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 
00022 // modifications:
00023 //
00024 
00025 // all comments which start from /** - this is comments for KDoc
00026 //  for classes
00027 //    @short [short description of the class]
00028 //    @author [class author]
00029 //    @version [class version]
00030 //    @see [references to other classes or methods]
00031 //  for methods
00032 //    @see [references]
00033 //    @return [sentence describing the return value]
00034 //    @exception [list the exeptions that could be thrown]
00035 //    @param [name id] [description]    - can be multiple
00036 
00037 #ifndef __HTTP_H__
00038 #define __HTTP_H__
00039 
00040 #include "global.h"
00041 
00042 namespace tacpp {
00043 
00044 // place for http dir
00045 #define HTTP_DIR        "http"
00046 // connect timeout
00047 #define HTTP_TIMEOUT    2
00048 // default filenames
00049 #define INVALID_AUTH_FILE   "/invalid_auth.html"
00050 #define INVALID_FILE        "/invalid_file.html"
00051 
00052 // types of users and it's directories
00053 #define HTTP_ADMIN_DIR    1
00054 #define HTTP_USER_DIR     2
00055 
00056 // maximum fields in form
00057 #define MAX_FORM_FIELDS   20
00058 
00064 class HttpHeaderData {
00065  public:
00068   HttpHeaderData();
00069 #define HTTP_METHOD_LEN       20
00070 
00072   char method[HTTP_METHOD_LEN];
00073 #define HTTP_REQUEST_LEN      100
00074 
00076   char request[HTTP_REQUEST_LEN];
00077 #define USER_AGENT_LEN        80
00078 
00080   char User_Agent[USER_AGENT_LEN];
00081 #define HTTP_HOST_LEN         30
00082 
00084   char Host[HTTP_HOST_LEN];
00085 #define ACCEPT_LEN            300
00086 
00088   char Accept[ACCEPT_LEN];
00091 #define ACCEPT_ENC_LEN        10
00092   char Accept_Encoding[ACCEPT_ENC_LEN];
00095 #define ACCEPT_LAN_LEN        10
00096   char Accept_Language[ACCEPT_LAN_LEN];
00099 #define ACCEPT_CHR_LEN        20
00100   char Accept_Charset[ACCEPT_CHR_LEN];
00103 #define VIA_LEN               80
00104   char Via[VIA_LEN];
00107 #define X_FORW_LEN            30
00108   char X_Forwarded_For[X_FORW_LEN];
00111 #define CACHE_CONT_LEN        20
00112   char Cache_Control[CACHE_CONT_LEN];
00115 #define CONNECTION_LEN        30
00116   char Connection[CONNECTION_LEN];
00119 #define AUTHOR_LEN            30
00120   char Authorization[AUTHOR_LEN];
00123 #define HTTP_USERNAME_LEN     50
00124   char username[HTTP_USERNAME_LEN];
00127 #define HTTP_PASSWORD_LEN     50
00128   char password[HTTP_PASSWORD_LEN];
00129 #define HTTP_DATA_LEN         200
00130 
00132   char data_string[HTTP_DATA_LEN];
00135   string Cookie;
00136 };
00137 
00143 class HttpPacket : public Packet {
00144  public:
00147   int fid;
00150   HttpPacket(int,struct in_addr);
00153   string hread();
00156   bool hwrite(string);
00157 };
00158 
00164 class HttpHeader : public HttpPacket {
00167   string http_date();
00168  public:
00171   HttpHeader(int fh,struct in_addr addr) : HttpPacket(fh, addr) {}
00174   HttpHeaderData *get_request();
00177   void header_html();
00180   void header_gif();
00183   void header_jpg();
00186   void header_auth();
00189   void header_perl();
00192   void header_class();
00195   void header_css();
00198   void header_js();
00201   void send_stop();
00202 };
00203 
00209 struct formsdata {
00210   char *varname;
00211   char *data;
00212 };
00213 
00219 class HttpFile : public HttpHeader {
00222   std::ifstream htmlf;
00225   bool openfile(char*);
00228   void readwrite();
00231   void closefile();
00234   void send_file_from_file(char*);
00237   void run_perl_file(char*,HttpHeaderData*);
00238  public:
00241   int dir;
00244   HttpFile(int,struct in_addr);
00247   void send_file(char*,HttpHeaderData*);
00250   void send_file_only(char*);
00253   void send_authen();
00256   void send_nofile();
00257 };
00258 
00264 class HttpServer : public HttpFile {
00267   char address[30];
00268  public:
00271   HttpServer(int,struct in_addr);
00274   bool authentication(char*,char*,char*,char*);
00277   void process();
00278 };
00279 
00280 };
00281 
00282 #endif //__HTTP_H__

Generated on Thu Jul 21 23:09:45 2005 for tacppd.kdevelop by doxygen 1.3.5