/* getstats.h */

#ifndef _h_getstats
#define _h_getstats

#include "gs-struct.h"

#define DEFAULTFILE "index.html"

#define GZIPBIN		"/opt/local/bin/gzip"
#define GUNZIPBIN	"/opt/local/bin/gunzip"

#define DTRLEVELS 3
	/* default numbers of dir tree levels saved in memory
	** override with the SET DTRLEVELS command
	*/

#define DOMLEVELS 3
	/* default numbers of domain levels saved in memory
	** override with the SET DOMLEVELS command
	*/

/* convert /~user/file.html to /!/~user/file.html
 * so they can be counted separately
 */
#define PCHAR     '!'

/* pale colors */
#define C_GREEN   "#33FF00"
#define C_BLUE    "#CCFFFF"
#define C_NORM    "#FFFFCC"
#define C_RED     "#FFCCCC"

/* dark colors */
#define D_GREEN   "#006600"

#define BIGDATE  1000000000
#define MAXLINE	       3000
#define CMDLEN	       1000
#define COMMONDATELEN    27
#define SERVERTYPELEN    10
#define REPORTTYPELEN    80
#define DIRLEN           80
#define URLLEN           80
#define MASKLEN         160
#define FLAGLEN           5
#define BREAKLEN         46
#define DATEARGLEN       10
#define SECSPERMIN       60
#define SECSPERHOUR    3600
#define SECSPERDAY    86400
#define BASEYEAR       1990

#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif


#define IS_LEAP(y) (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0))

#ifndef SYSV
	extern int h_errno;
#endif

typedef enum {N_ALPHA, N_REQ, N_BYTES} sortType;
	/* reports can be sorted alphabetically, by the number of requests,
	 * or by the number of bytes transferred.
	 */

/* ======================================== */
/* functions defined in getstats.c */

int main(	int argc,		char **argv);
void readcmdfile(void);
void getwords(	char *buffer,		char *word[],		int *nwords);
char *DoReadCommand(char *word[],	int nwords);
char *DoSetCommand(char *word[],	int nwords);
char *DoWriteCommand(char *word[],	int nwords);
void WriteReportTop(FILE *rpt,		vhost *thisvhost);
void PrintEx(		FILE *rpt,	char *errtext,		int errcount,
			char *suffix,	int *col);
void WriteReportBottom(FILE *rpt);
char *WriteReportDTR(char *rptfilnam,	int lev);
char *WriteReportRED(char *rptfilnam,	int lev);
char *WriteReportERR(char *rptfilnam,	int lev);
int readlogfile(     char *acclogfile,	char *msgfilnam,	char *format);
void AnalyzeInput(	logr *r);
void CountThisRecord(	logr *r,	FILE *err);
void printbreak(	FILE *rpt);
void printstats(	int htmldocnum,	int gifdocnum,		int scriptnum,
			int assetnum,	float bytecount,	int errors);
void printrunning(	FILE *rpt,	time_t starttime,	time_t stoptime);
struct entry *addentry(	struct entry *e,char *address,		long date,
			long filesize);
int numlen(	long num);
void fixslash(	char *string);
char *e_strdup(	char *string);
void *emalloc(	int i);
void progerr(	char *errorstr);
void gigs(	char *dest,		float value,	int width);
void comm(	char *dest,		int value,	int width);
vhost *NewVHost(char *host);
void set_vhost( char *sername);
void set_doroot(char *sername,		char *root);
void set_xtroot(char *sername,		char *root);
char *getlocaltime(void);
int do_args(int argc, char **argv);
int usage(void);


#endif
