Main Page   Class Hierarchy   Compound List   File List   Compound Members  

CAVERNnet_http_c.hxx

00001 /******************************************************************
00002  * CAVERNsoft
00003  * Copyright (C) 1994-2000 Electronic Visualization Laboratory,
00004  * all rights reserved
00005  * By Jason Leigh, Yong-joo Cho, Naveen Krishnaprasad, Chris Scharver,
00006  * Stuart Bailey, Atul Nayak, Shalini Venkataraman
00007  * University of Illinois at Chicago
00008  * 
00009  * This publication and its text and code may not be copied for commercial 
00010  * use without the express written permission of the University of Illinois
00011  * at Chicago.
00012  * The contributors disclaim any representation of warranty: use this
00013  * code at your own risk.
00014  * Direct questions, comments etc to cavern@evl.uic.edu
00015  ******************************************************************/
00016 
00017 #ifndef _CAVERNPLUS_HTTP
00018 #define _CAVERNPLUS_HTTP
00019 
00020 #include "CAVERNnet_tcp_c.hxx"
00021 
00022 #include <sys/types.h>
00023 #include <sys/stat.h>
00024 #include <stdio.h>
00025 
00026 #define INBUFFER_CONST 2048
00027 #define BUFFER_CONST 1024
00028 
00047 class CAVERNnet_perfMonitor_c;
00048 
00049 class CAVERNnet_http_c {
00050 
00051 public:
00052 
00054 
00055 
00056         static const int AUTO_LOAD/* = 0*/;
00058         static const int CHECK_BUT_DONT_LOAD/* = 3*/;
00060         static const int FORCED_LOAD/* = 1*/;
00062 
00064         static const int NO_TIME_OUT/* = -1*/;
00065 
00066         CAVERNnet_http_c(){
00067                 itsMode = AUTO_LOAD;
00068                 timeOutPeriod =NO_TIME_OUT;
00069         }
00070 
00072         void setTimeOut(int timep) {timeOutPeriod = timep;}
00073 
00075 
00076 
00077         void setRemoteSite(char *site) {strcpy(remoteSite, site);}
00079         void setRemotePath(char *path) {strcpy(remotePath, path);}
00081         void setRemoteFile(char *file) {strcpy(remoteFile, file);}
00082 
00084         void setLocalPath(char *path) {strcpy(localPath, path);}
00086         void setLocalFile(char *file) {strcpy(localFile, file);}
00087 
00093         void setMode(int mode) {itsMode = mode;}
00094 
00096         int getTimeOut() {return timeOutPeriod;}
00097 
00099         char* getRemoteSite() {return remoteSite;}
00101         char* getRemotePath() {return remotePath;}
00103         char* getRemoteFile() {return remoteFile;}
00104 
00106         char* getLocalPath() {return localPath;}
00107 
00109         char* getLocalFile() {return localFile;}
00110 
00112         int getMode() { return itsMode;}
00114         
00115         // site = WEB IP address
00116         // path = path to where to grab the file (no leading or trailing / needed)
00117         // filename = name of file to grab.
00118         // localPath = local path to store the file (no trailing / needed)
00119         // localFile = local filename
00120         // Set timeout to -1 for no timeout else timeout is in seconds
00121 
00136         int grabWEBFile();
00137 
00138     //Functions added for performance monitoring interface
00139 
00152     void showStats(char* streamInfo, char* comment);
00153     
00171     int logStats(char* streamInfo, char* comment, FILE* filePtr);
00172 
00186     int sendStats(char* streamInfo, char* comment);
00187 
00201     int initSendStats(char* monitorClientIP, int port = PERF_DAEMON_DEFAULT_PORT);
00202     
00206     void exitSendStats();
00207 
00208 
00209 
00210 private:
00211         //      static const int OUTBUFFER = 512;
00212         static const int INBUFFER/* = 2048*/;
00213 #ifndef WIN32
00214         // Windows provides a macro function min already...
00215         int min(int a, int b) {
00216                 if (a < b) return a; else return b;
00217         }
00218 #endif
00219         int timeDateOfFile(char* filename, char *out, 
00220                  int *date,
00221                  int *month,
00222                  int *year,
00223                  int *hour,
00224                  int *minute,
00225                  int *second);
00226 
00227         char sendBuffer[INBUFFER_CONST];
00228         char receiveBuffer[INBUFFER_CONST];
00229 
00230         static const int BUFFER/* = 1024*/;
00231 
00232         char remoteSite[BUFFER_CONST];
00233         char remotePath[BUFFER_CONST];
00234         char remoteFile[BUFFER_CONST];
00235         char localPath[BUFFER_CONST];
00236         char localFile[BUFFER_CONST];
00237         int timeOutPeriod;
00238         int itsMode;
00239 
00240     //For performance monitoring calculations
00241     CAVERNnet_perfMonitor_c pmonitor;
00242     
00243         // Search for a string in an array of strings and return the index count.
00244         // Return -1 if not found.
00245         int indexIntoString(char **strlist, int len, char *searchstr);
00246 
00247         // If date 1 < date 2 return -1.
00248         // If date 1 > date 2 return 1.
00249         // If date 1 == date 2 return 0.
00250         int compareDate(int date1, int month1, int year1,
00251                         int hour1, int minute1, int second1,
00252                         int date2, int month2, int year2,
00253                         int hour2, int minute2, int second2);
00254 
00255         // Given a HTTP 1.0 Date string convert it into component values.
00256         int webDateConvert(char *instring,
00257                            int *date,
00258                            int *month,
00259                            int *year,
00260                            int *hour,
00261                            int *minute,
00262                            int *second);
00263 
00264 };
00265 #endif
00266 
00267 
00268 
00269 
00270 
00271 
00272 
00273 
00274 
00275 
00276 
00277 
00278 
00279 

Generated at Mon Jul 2 14:24:42 2001 for CAVERNsoft by doxygen1.2.8-20010617 written by Dimitri van Heesch, © 1997-2001