lib/apacheLog.c File Reference

#include "common.h"
#include "obscure.h"
#include "apacheLog.h"

Include dependency graph for apacheLog.c:

Go to the source code of this file.

Functions

void apacheAccessLogFree (struct apacheAccessLog **pLl)
static void badFormat (struct apacheAccessLog **pLl, char *line, char *fileName, int lineIx, char *message)
static void unterminatedQuote (struct apacheAccessLog **pLl, char *line, char *fileName, int lineIx)
static void shortLine (struct apacheAccessLog **pLl, char *line, char *fileName, int lineIx)
static void badTimeStamp (struct apacheAccessLog **pLl, char *line, char *fileName, int lineIx)
apacheAccessLogapacheAccessLogParse (char *line, char *fileName, int lineIx)

Variables

static char const rcsid [] = "$Id: apacheLog.c,v 1.1 2005/09/03 02:07:40 kent Exp $"


Function Documentation

void apacheAccessLogFree ( struct apacheAccessLog **  pLl  ) 

Definition at line 10 of file apacheLog.c.

References apacheAccessLog::buf, freeMem(), and freez().

00012 {
00013 struct apacheAccessLog *ll = *pLl;
00014 if (ll != NULL)
00015     {
00016     freeMem(ll->buf);
00017     freez(pLl);
00018     }
00019 }

Here is the call graph for this function:

struct apacheAccessLog* apacheAccessLogParse ( char *  line,
char *  fileName,
int  lineIx 
) [read]

Definition at line 60 of file apacheLog.c.

References AllocVar, badFormat(), badTimeStamp(), apacheAccessLog::buf, cloneString(), apacheAccessLog::dash1, apacheAccessLog::dash2, apacheAccessLog::httpVersion, apacheAccessLog::ip, apacheAccessLog::method, nextWord(), apacheAccessLog::num1, parseQuotedString(), apacheAccessLog::program, apacheAccessLog::referrer, sameString, shortLine(), apacheAccessLog::status, apacheAccessLog::timeStamp, apacheAccessLog::timeZone, unterminatedQuote(), and apacheAccessLog::url.

00064 {
00065 struct apacheAccessLog *ll;
00066 char *buf, *s, *e;
00067 AllocVar(ll);
00068 ll->buf = buf = cloneString(line);
00069 ll->ip = nextWord(&buf);
00070 ll->dash1 = nextWord(&buf);
00071 ll->dash2 = nextWord(&buf);
00072 if (buf == NULL)
00073     {
00074     shortLine(&ll, line, fileName, lineIx);
00075     return NULL;
00076     }
00077 s = strchr(buf, '[');
00078 if (s == NULL)
00079     {
00080     badTimeStamp(&ll, line, fileName, lineIx);
00081     return NULL;
00082     }
00083 s += 1;
00084 e = strchr(s, ']');
00085 if (e == NULL)
00086     {
00087     badTimeStamp(&ll, line, fileName, lineIx);
00088     return NULL;
00089     }
00090 *e = 0;
00091 ll->timeStamp = nextWord(&s);
00092 if (!isdigit(ll->timeStamp[0]))
00093     {
00094     badTimeStamp(&ll, line, fileName, lineIx);
00095     return NULL;
00096     }
00097 ll->timeZone = nextWord(&s);
00098 buf = e+2;
00099 if (buf[0] != '"')
00100     {
00101     badFormat(&ll, line, fileName, lineIx, "Missing quote after time stamp");
00102     return NULL;
00103     }
00104 if (!parseQuotedString(buf, buf, &e))
00105     {
00106     unterminatedQuote(&ll, line, fileName, lineIx);
00107     return NULL;
00108     }
00109 ll->method = nextWord(&buf);
00110 ll->url = nextWord(&buf);
00111 ll->httpVersion = nextWord(&buf);
00112 if (ll->url == NULL)
00113     {
00114     badFormat(&ll, line, fileName, lineIx, "Missing URL");
00115     return NULL;
00116     }
00117 buf = e;
00118 s = nextWord(&buf);
00119 if (!isdigit(s[0]))
00120     {
00121     badFormat(&ll, line, fileName, lineIx, "Non-numerical status code");
00122     return NULL;
00123     }
00124 ll->status = atoi(s);
00125 ll->num1 = nextWord(&buf);
00126 if (buf == NULL)
00127     {
00128     shortLine(&ll, line, fileName, lineIx);
00129     return NULL;
00130     }
00131 if (buf[0] != '"')
00132     {
00133     badFormat(&ll, line, fileName, lineIx, "Missing quote after request");
00134     return NULL;
00135     }
00136 if (!parseQuotedString(buf, buf, &e))
00137     {
00138     unterminatedQuote(&ll, line, fileName, lineIx);
00139     return NULL;
00140     }
00141 if (!sameString(buf, "-"))
00142     ll->referrer = buf;
00143 buf = e + 1;
00144 if (buf[0] != '"')
00145     {
00146     badFormat(&ll, line, fileName, lineIx, "Missing quote after referrer");
00147     return NULL;
00148     }
00149 if (!parseQuotedString(buf, buf, &e))
00150     {
00151     unterminatedQuote(&ll, line, fileName, lineIx);
00152     return NULL;
00153     }
00154 ll->program = buf;
00155 return ll;
00156 }

Here is the call graph for this function:

static void badFormat ( struct apacheAccessLog **  pLl,
char *  line,
char *  fileName,
int  lineIx,
char *  message 
) [static]

Definition at line 22 of file apacheLog.c.

References verboseLevel(), and warn().

Referenced by apacheAccessLogParse(), badTimeStamp(), shortLine(), and unterminatedQuote().

00026 {
00027 if (verboseLevel()  > 1)
00028     {
00029     if (fileName != NULL)
00030         warn("%s line %d: %s", fileName, lineIx, message);
00031     else
00032         warn("%s", message);
00033     }
00034 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void badTimeStamp ( struct apacheAccessLog **  pLl,
char *  line,
char *  fileName,
int  lineIx 
) [static]

Definition at line 52 of file apacheLog.c.

References badFormat().

Referenced by apacheAccessLogParse().

00055 {
00056 badFormat(pLl, line, fileName, lineIx, 
00057         "bad time stamp");
00058 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void shortLine ( struct apacheAccessLog **  pLl,
char *  line,
char *  fileName,
int  lineIx 
) [static]

Definition at line 44 of file apacheLog.c.

References badFormat().

Referenced by apacheAccessLogParse().

00047 {
00048 badFormat(pLl, line, fileName, lineIx, 
00049         "short line");
00050 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void unterminatedQuote ( struct apacheAccessLog **  pLl,
char *  line,
char *  fileName,
int  lineIx 
) [static]

Definition at line 36 of file apacheLog.c.

References badFormat().

Referenced by apacheAccessLogParse().

00039 {
00040 badFormat(pLl, line, fileName, lineIx, 
00041         "missing closing quote");
00042 }

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

char const rcsid[] = "$Id: apacheLog.c,v 1.1 2005/09/03 02:07:40 kent Exp $" [static]

Definition at line 8 of file apacheLog.c.


Generated on Tue Dec 25 19:31:54 2007 for blat by  doxygen 1.5.2