Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

212 lines
5.9 KiB

  1. #if !defined CONVLOG_H
  2. #define CONVLOG_H
  3. #include <windows.h>
  4. #include <stdio.h>
  5. #include <string.h>
  6. #include <stdlib.h>
  7. #include <io.h>
  8. #include <winsock2.h>
  9. #include <strings.h>
  10. #include <mbstring.h> // Bug # 101690
  11. #include <locale.h>
  12. #define CONVLOG_BASE (120)
  13. #define NUM_SERVICES (4)
  14. #define DAILY (CONVLOG_BASE + 0)
  15. #define MONTHLY (CONVLOG_BASE + 1)
  16. #define ONE_BIG_FILE (CONVLOG_BASE + 2)
  17. #define NCSA (CONVLOG_BASE + 3)
  18. #define NOFORMAT (CONVLOG_BASE + 4)
  19. #define ILLEGAL_COMMAND_LINE (CONVLOG_BASE + 5)
  20. #define COMMAND_LINE_OK (CONVLOG_BASE + 6)
  21. #define OUT_DIR_NOT_OK (CONVLOG_BASE + 7)
  22. #define ERROR_BAD_NONE (CONVLOG_BASE + 8)
  23. #define MAXWINSOCKVERSION 2
  24. #define MAXASCIIIPLEN 16
  25. #define ISWHITE( ch ) ((ch) == ' ' || (ch) == '\t' || (ch) == '\r' || (ch) == '\n')
  26. #define MAXMACHINELEN 260
  27. #define GREATEROF(p1,p2) ((p1)>(p2)) ? (p1) : (p2)
  28. typedef enum _DATEFORMATS {
  29. DateFormatUsa = 0, // MM/DD/YY
  30. DateFormatJapan = 1, // YY/MM/DD
  31. DateFormatGermany = 2, // MM.DD.YY
  32. DateFormatMax
  33. } DATEFORMAT;
  34. typedef struct _HASHENTRY {
  35. ULONG uIPAddr;
  36. ULONG NextPtr;
  37. char szMachineName[MAXMACHINELEN];
  38. } HASHENTRY, *PHASHENTRY;
  39. typedef struct _INLOGLINE
  40. {
  41. DWORD dwFieldMask;
  42. LPSTR szClientIP; //client ip address
  43. LPSTR szUserName; //client user name (not put in https log)
  44. LPSTR szDate; //date string in format DD/MM/YY
  45. LPSTR szTime; //time string in format HH:MM:SS 24 hour format
  46. LPSTR szService; //Service name (not put in https log)
  47. LPSTR szServerName; //netbios name of Server
  48. LPSTR szServerIP; //Server ip address
  49. LPSTR szProcTime; //time taken to process request (not put in https log)
  50. LPSTR szBytesRec; //number of bytes received (not put in https log)
  51. LPSTR szBytesSent; //number of bytes sent (not put in https log)
  52. LPSTR szServiceStatus; //HTTP status code (not put in https log)
  53. LPSTR szWin32Status; //win32 status code (not put in https log)
  54. LPSTR szOperation; //one of GET, POST, or HEAD
  55. LPSTR szTargetURL; //URL as requested by the client
  56. LPSTR szUserAgent; //only logged (by W3SVC) if NewLog.dll installed
  57. LPSTR szReferer; //only logged (by W3SVC) if NewLog.dll installed
  58. LPSTR szParameters; //any parameters passed with the URL
  59. LPSTR szVersion; //protocol version
  60. } *LPINLOGLINE, INLOGLINE;
  61. typedef struct _DOSDATE
  62. {
  63. WORD wDOSDate; //holds the DOS Date packed word
  64. WORD wDOSTime; //holds teh DOS Time packed word
  65. } *LPDOSDATE, DOSDATE;
  66. typedef struct _OUTFILESTATUS {
  67. FILE *fpOutFile;
  68. CHAR szLastDate[10];
  69. CHAR szLastTime[10];
  70. CHAR szOutFileName[MAX_PATH];
  71. CHAR szTmpFileName[MAX_PATH];
  72. SYSTEMTIME SystemTime;
  73. FILETIME FileTime;
  74. DOSDATE DosDate;
  75. CHAR szAscTime[25];
  76. } OUTFILESTATUS, *LPOUTFILESTATUS;
  77. enum {
  78. GETLOG_SUCCESS = 0,
  79. GETLOG_ERROR,
  80. GETLOG_ERROR_PARSE_NCSA,
  81. GETLOG_ERROR_PARSE_MSINET,
  82. GETLOG_ERROR_PARSE_EXTENDED
  83. };
  84. char * FindComma (char *);
  85. char * SkipWhite (char *);
  86. DWORD
  87. GetLogLine (
  88. FILE *,
  89. PCHAR szBuf,
  90. DWORD cbBuf,
  91. LPINLOGLINE
  92. );
  93. WORD DateStringToDOSDate(char *);
  94. WORD TimeStringToDOSTime(char *, LPWORD);
  95. char * SystemTimeToAscTime(LPSYSTEMTIME, char *);
  96. char * AscDay (WORD, char *);
  97. char * AscMonth (WORD, char *);
  98. void CombineFiles(LPTSTR, LPTSTR);
  99. void Usage (char*);
  100. int ParseArgs (int, char **);
  101. char * FindChar (char *, char);
  102. VOID
  103. ProcessNoConvertLine(
  104. IN LPINLOGLINE lpLogLine,
  105. IN LPCSTR szInFileName,
  106. IN LPTSTR pszBuf,
  107. IN LPOUTFILESTATUS lpOutFile,
  108. BOOL *lpbNCFileOpen
  109. );
  110. BOOL
  111. ProcessWebLine(
  112. LPINLOGLINE,
  113. LPCSTR,
  114. LPOUTFILESTATUS
  115. );
  116. VOID
  117. printfids(
  118. DWORD ids,
  119. ...
  120. );
  121. VOID InitHashTable (ULONG);
  122. ULONG GetHashEntry();
  123. ULONG GetElementFromCache(ULONG uIPAddr);
  124. VOID AddEntryToCache(ULONG uIPAddr, char *szMachineName);
  125. char *GetMachineName(char *szClientIP);
  126. VOID PrintCacheTotals();
  127. BOOL
  128. InitDateStrings(
  129. VOID
  130. );
  131. VOID
  132. AddLocalMachineToCache(
  133. VOID
  134. );
  135. FILE *
  136. StartNewOutputDumpLog (
  137. IN LPOUTFILESTATUS pOutFile,
  138. IN LPCSTR pszInputFileName,
  139. IN LPCSTR pszExt
  140. );
  141. FILE *
  142. StartNewOutputLog (
  143. IN LPOUTFILESTATUS pOutFile,
  144. IN LPCSTR pszInputFileName,
  145. IN PCHAR szDate
  146. );
  147. //
  148. // defines
  149. //
  150. #define LOGFILE_INVALID 0
  151. #define LOGFILE_NCSA 2
  152. #define LOGFILE_MSINET 3
  153. #define LOGFILE_CUSTOM 4
  154. #define NEW_DATETIME "New"
  155. //
  156. // Globals
  157. //
  158. extern BOOL DoDNSConversion;
  159. extern BOOL SaveFTPEntries;
  160. extern CHAR FTPSaveFile[];
  161. extern CHAR NCSAGMTOffset[];
  162. extern DWORD LogFileFormat;
  163. extern CHAR InputFileName[];
  164. extern CHAR OutputDir[];
  165. extern CHAR TempDir[];
  166. extern DWORD nWebLineCount;
  167. extern BOOL NoFormatConversion;
  168. extern BOOL ExtendedFieldsDefined;
  169. extern CHAR szGlobalDate[];
  170. extern DATEFORMAT dwDateFormat;
  171. extern BOOL bOnErrorContinue;
  172. #endif //CONVLOG_H