Source code of Windows XP (NT5)
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.

1893 lines
47 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. ism.hxx
  5. Abstract:
  6. HTML administrator include file
  7. Author:
  8. Philippe Choquier (phillich) 10-january-1996
  9. Revision History:
  10. --*/
  11. # ifndef _HTMLA_HXX_
  12. # define _HTMLA_HXX_
  13. /************************************************************
  14. * Symbolic Constants
  15. ************************************************************/
  16. //
  17. // HTTP Server response status codes
  18. //
  19. #define HT_OK 200
  20. //#define HT_CREATED 201
  21. //#define HT_ACCEPTED 202
  22. //#define HT_PARTIAL 203
  23. //#define HT_MULT_CHOICE 300
  24. #define HT_MOVED 301
  25. #define HT_REDIRECT 302
  26. #define HT_REDIRECT_METHOD 303
  27. #define HT_NOT_MODIFIED 304
  28. #define HT_REDIRECTH 380
  29. #define HT_BAD_REQUEST 400
  30. #define HT_DENIED 401
  31. //#define HT_PAYMENT_REQ 402
  32. #define HT_FORBIDDEN 403
  33. #define HT_NOT_FOUND 404
  34. //#define HT_METHOD_NOT_ALLOWED 405
  35. #define HT_NONE_ACCEPTABLE 406
  36. #define HT_PROXY_AUTH_REQ 407
  37. //#define HT_REQUEST_TIMEOUT 408
  38. //#define HT_CONFLICT 409
  39. //#define HT_GONE 410
  40. #define HT_SERVER_ERROR 500
  41. #define HT_NOT_SUPPORTED 501
  42. #define HT_BAD_GATEWAY 502
  43. //#define HT_SVC_UNAVAILABLE 503
  44. #define HT_GATEWAY_TIMOUE 504
  45. // some values not conflicting with their respective domain ranges
  46. #define HT_REPROCESS 0x10000000
  47. #define HSE_REPROCESS 0x10000000
  48. #define INET_DIR 0xffff0000
  49. #define INET_LOG_INVALID_TO_FILE 4
  50. //
  51. // script execution status
  52. //
  53. #define HTR_OK 0
  54. #define HTR_OUT_OF_RESOURCE 1000
  55. #define HTR_COM_CONFIG_ACCESS_ERROR 2000
  56. #define HTR_USER_ENUM_ACCESS_ERROR 2010
  57. #define HTR_USER_DISCONNECT_ERROR 2020
  58. #define HTR_CONFIG_ACCESS_ERROR 2100
  59. #define HTR_W3_CONFIG_ACCESS_ERROR 2200
  60. #define HTR_FTP_CONFIG_ACCESS_ERROR 2300
  61. #define HTR_GD_CONFIG_ACCESS_ERROR 2400
  62. #define HTR_CONFIG_WRITE_ERROR 2500
  63. #define HTR_W3_CONFIG_WRITE_ERROR 2600
  64. #define HTR_FTP_CONFIG_WRITE_ERROR 2700
  65. #define HTR_GD_CONFIG_WRITE_ERROR 2800
  66. #define HTR_COM_CONFIG_WRITE_ERROR 2900
  67. #define HTR_REF_NOT_FOUND 4000
  68. #define HTR_BAD_PARAM 5000 // invalid syntax in param
  69. #define HTR_INVALID_VAR_TYPE 6000
  70. #define HTR_INVALID_FORM_PARAM_NAME 7000
  71. #define HTR_INVALID_FORM_PARAM 8000
  72. #define HTR_VAR_NOT_FOUND 9000
  73. #define HTR_TOO_MANY_NESTED_IF 10000
  74. #define HTR_IF_UNDERFLOW 11000
  75. #define HTR_VALIDATION_FAILED 12000 // Update indication rejected
  76. #define HTR_ACCESS_DENIED 13000
  77. #define HTR_DIR_SAME_NAME 14000
  78. #define IP_ADDR_BYTE_SIZE 4
  79. #define MAX_SIZE_OF_DWORD_AS_STRING 32
  80. #define INET_LOG_PERIOD_ON_SIZE 5 // next value in INET_LOG_PERIOD_*
  81. #define HOME_DIR_PATH L"/"
  82. //
  83. // max size DNS name
  84. //
  85. #define MAX_DOMAIN_LENGTH 128
  86. //
  87. // max error code length [when converted to a string]
  88. //
  89. #define MAX_ERROR_CODE_LENGTH 32
  90. //
  91. // HTMLA variables types
  92. //
  93. // Some types are defined to enable specific validation / alteration
  94. // even if their storage convention is the same as already available
  95. // types.
  96. //
  97. enum INET_ELEM_TYPE {
  98. ITYPE_BOOL, // 0 ( FALSE) or 1 ( TRUE ), in a DWORD
  99. ITYPE_LPWSTR, // pointer to UNICODE
  100. ITYPE_LPSTR, // pointer to ASCII
  101. ITYPE_AWCHAR, // array of UNICODE
  102. ITYPE_DWORD, // 32 bits unsigned
  103. ITYPE_SHORT, // 16 bits
  104. ITYPE_IP_ADDR, // array of bytes ( len is IP_ADDR_BYTE_SIZE )
  105. ITYPE_IP_MASK, // array of bytes ( len is IP_ADDR_BYTE_SIZE )
  106. ITYPE_1K, // as DWORD, scaled 1024
  107. ITYPE_TIME, // seconds, in a DWORD
  108. ITYPE_PARAM_LIT_STRING, // as LPSTR
  109. ITYPE_VIRT_DIR_LPWSTR, // virtual root name, as a LPWSTR
  110. ITYPE_SHORTDW, // 16 significant bits in a DWORD
  111. ITYPE_1M, // as DWORD, scaled 1024*1024
  112. ITYPE_PATH_LPWSTR // directory path as LPWSTR
  113. };
  114. #define HEXDIGIT( nDigit ) \
  115. (TCHAR)((nDigit) > 9 ? \
  116. (nDigit) - 10 + 'A' \
  117. : (nDigit) + '0')
  118. //
  119. // Status of HTML script parsing
  120. //
  121. enum HTR_SKIP_STATUS { HSS_NO_SKIP, HSS_SKIP_ITER=1, HSS_SKIP_IF=2,
  122. HSS_SKIP_GOTO=4, HSS_WAIT_ENDIF=8 };
  123. #define MAX_NESTED_IF 16
  124. //
  125. // type of command for the HandleVirtDirRequest() functions
  126. //
  127. #define _VIRT_DIR_REQ_CHECK 0
  128. #define _VIRT_DIR_REQ_ALIAS 1
  129. extern DWORD g_dwZero;
  130. extern DWORD g_dwOne;
  131. extern LPSTR g_pszIPNullAddr;
  132. #if defined(IISv1)
  133. extern OSVERSIONINFO g_OSVersion;
  134. extern DWORD g_dwCap1Flag;
  135. extern DWORD g_dwCap1Mask;
  136. #endif
  137. //
  138. //DLLs to look in for error codes
  139. //
  140. LPSTR g_apszErrorCodeDlls[] =
  141. {
  142. "KERNEL32.DLL",
  143. "NETMSG.DLL",
  144. "NTDLL.DLL"
  145. };
  146. #define NUM_ERROR_CODE_DLLS (sizeof(g_apszErrorCodeDlls)/sizeof(g_apszErrorCodeDlls[0]))
  147. class CInetInfoMap;
  148. //
  149. // Global functions
  150. //
  151. BOOL SortVirtualRoots( LPINET_INFO_VIRTUAL_ROOT_LIST pL );
  152. BOOL SortIpSecList( LPINET_INFO_IP_SEC_LIST pL );
  153. //
  154. // Dynamic string
  155. //
  156. class CDStr {
  157. public:
  158. CDStr();
  159. ~CDStr();
  160. BOOL Init();
  161. // returns pointer to string, always zero-delimited
  162. LPSTR GetString();
  163. // return string length ( excluding delimiter )
  164. DWORD GetLen() { return m_dwLen; }
  165. // add a zero-delimited string
  166. BOOL Add( LPSTR );
  167. // add a byte range
  168. BOOL AddRange( LPSTR, DWORD ); // add a byte range
  169. // reset content to NULL
  170. void Reset();
  171. private:
  172. DWORD m_dwAlloc; // # of alloc'ed bytes
  173. DWORD m_dwLen; // string length
  174. LPSTR m_pStr; // pointer to buffer
  175. } ;
  176. #if defined(GENERATE_AUTH_HEADERS)
  177. //
  178. // Maintains a list of authentication schemes supported
  179. // by the Web server
  180. //
  181. class CAuthenticationReqs {
  182. public:
  183. CAuthenticationReqs();
  184. ~CAuthenticationReqs();
  185. //
  186. BOOL Init();
  187. // Retrieve list of authentication methods as a W3 header
  188. // i.e. each method is prefixed with WWW-Authenticate
  189. // and "\r\n" is appended to the list.
  190. // returns NULL if no supported authentication methods.
  191. LPSTR GetAuthenticationListHeader();
  192. // To be used while accessing the LPSTR returned
  193. // by GetAuthenticationListHeader()
  194. void Lock()
  195. { EnterCriticalSection( &m_csR ); }
  196. void UnLock()
  197. { LeaveCriticalSection( &m_csR ); }
  198. //
  199. BOOL UpdateMethodsIndication();
  200. BOOL UpdateNTAuthenticationProvidersIndication();
  201. // Request termination of this object ( will terminate
  202. // notification thread )
  203. BOOL Terminate();
  204. //
  205. DWORD UpdateIndication();
  206. private:
  207. BOOL BuildListHeader();
  208. private:
  209. HANDLE m_hNotifyEvent;
  210. BOOL m_fRequestTerminate;
  211. HANDLE m_hThread;
  212. CDStr m_dsH; // WWW-Authenticate list
  213. DWORD m_dwMethods; // bitmask from INET_INFO_AUTH_*
  214. LPSTR m_pszProviders;
  215. CRITICAL_SECTION m_csR;
  216. HKEY m_hKey;
  217. } ;
  218. #endif
  219. //
  220. // Memory allocation node, used by CInetInfoConfigInfoMapper to maintain
  221. // a list of all allocations made during a request to allow them to be
  222. // freed at the end of the request.
  223. //
  224. // The memory block is initialized to all 0.
  225. //
  226. class CAllocNode {
  227. public:
  228. // constructor allocates requested memory block
  229. CAllocNode( DWORD dwL )
  230. {
  231. if ( m_pBuff = new BYTE[ dwL ] )
  232. {
  233. memset( m_pBuff, '\0', dwL );
  234. }
  235. m_pNext = NULL;
  236. }
  237. ~CAllocNode()
  238. { delete [] m_pBuff; }
  239. void SetNext( CAllocNode* pN )
  240. { m_pNext = pN; }
  241. CAllocNode* GetNext()
  242. { return m_pNext; }
  243. LPBYTE GetBuff()
  244. { return m_pBuff; }
  245. private:
  246. LPBYTE m_pBuff; // pointer to buffer
  247. CAllocNode* m_pNext; // pointer to next alloc node
  248. } ;
  249. class CInetInfoConfigInfoMapper;
  250. //
  251. // Give access to the list of currently connected users for a given
  252. // servive ( as specified by the CInetInfoConfigInfoMapper given
  253. // at Init() time )
  254. //
  255. class CUserEnum {
  256. public:
  257. CUserEnum();
  258. ~CUserEnum();
  259. //
  260. BOOL Init( CInetInfoConfigInfoMapper* );
  261. void Reset();
  262. // Get count of connected users as a .htr variable
  263. BOOL GetCount( LPVOID* );
  264. // Retrieve info about the current index in the user array
  265. // as a .htr variable
  266. // the index is specified by the bound CInetInfoConfigInfoMapper
  267. // via the GetIter() function. Returns FALSE if invalid/out of range
  268. BOOL GetName( LPVOID* );
  269. BOOL GetAnonymous( LPVOID* );
  270. BOOL GetAddr( LPVOID* );
  271. BOOL GetTime( LPVOID* );
  272. BOOL GetID( LPVOID* );
  273. // same as GetID but as a DWORD
  274. BOOL GetIDAsDWORD( LPDWORD );
  275. // Get count of connected users as a DWORD
  276. BOOL GetCountAsDWORD( LPDWORD );
  277. private:
  278. BOOL InsureLoaded();
  279. private:
  280. CInetInfoConfigInfoMapper* m_pMapper;
  281. DWORD m_dwCount;
  282. W3_USER_INFO *m_pUsers;
  283. } ;
  284. // Directory & drive list management
  285. class CDriveView {
  286. public:
  287. CDriveView();
  288. ~CDriveView();
  289. //
  290. BOOL Init( CInetInfoConfigInfoMapper* );
  291. BOOL Reset();
  292. BOOL Entry( UINT i, UINT cMax, CDStr &dsList, PVOID pRes );
  293. //
  294. BOOL GenerateDirList( LPSTR pDir );
  295. BOOL ValidateDir( LPSTR pDir );
  296. BOOL CreateDir( LPSTR pPath, LPSTR pNewDir );
  297. //
  298. BOOL RootDir( LPSTR *pV )
  299. { *pV = m_achRootDir; return TRUE; }
  300. BOOL BaseDir( LPSTR *pV )
  301. { *pV = m_achBaseDir; return TRUE; }
  302. BOOL DirCount( LPDWORD *pV )
  303. { *pV = &m_cDirs; return TRUE; }
  304. BOOL DirEntry( UINT i, LPVOID pV )
  305. { return Entry( i, m_cDirs, m_dsDirs, pV); }
  306. BOOL DirCompCount( LPDWORD *pV )
  307. { *pV = &m_cComp; return TRUE; }
  308. BOOL DirCompEntry( UINT i, LPVOID pV )
  309. { return Entry( i, m_cComp, m_dsComp, pV); }
  310. BOOL DirFCompEntry( UINT i, LPVOID pV )
  311. { return Entry( i, m_cComp, m_dsFComp, pV); }
  312. BOOL DriveCount( LPDWORD *pV )
  313. { *pV = &m_cDrives; return TRUE; }
  314. BOOL DriveNameEntry( UINT i, LPVOID pV )
  315. { return Entry( i, m_cDrives, m_dsDriveName, pV); }
  316. BOOL DriveLabelEntry( UINT i, LPVOID pV )
  317. { return Entry( i, m_cDrives, m_dsDriveLabel, pV); }
  318. BOOL DriveTypeEntry( UINT i, LPVOID pV )
  319. { if (i < m_cDrives ) { *(LPDWORD*)pV
  320. = (DWORD*)(m_dsDriveType.GetString()+sizeof(DWORD)*i);
  321. return TRUE;} else return FALSE; }
  322. private:
  323. CInetInfoConfigInfoMapper* m_pMapper;
  324. CDStr m_dsDirs;
  325. CDStr m_dsDriveName;
  326. CDStr m_dsDriveLabel;
  327. CDStr m_dsDriveType; // as array of DWORD
  328. CDStr m_dsComp;
  329. CDStr m_dsFComp;
  330. DWORD m_cDirs;
  331. DWORD m_cDrives;
  332. DWORD m_cComp;
  333. char m_achRootDir[MAX_PATH];
  334. char m_achBaseDir[MAX_PATH];
  335. // cache info
  336. DWORD m_dwCachedDrive;
  337. time_t m_tmCacheExpire;
  338. } ;
  339. // expiration time for drive cache ( in second )
  340. #define DRIVE_CACHE_EXPIRE 30
  341. //
  342. // Entry describing a service using its name and type
  343. //
  344. class CServType {
  345. public:
  346. LPSTR GetName() { return pszName; }
  347. DWORD GetType() { return dwType; }
  348. public:
  349. LPSTR pszName;
  350. DWORD dwType;
  351. } ;
  352. //
  353. // Mapper between service names and types
  354. //
  355. class CServTypeEnum {
  356. public:
  357. CServType* GetServByName( LPSTR pName );
  358. CServType* GetServByType( DWORD dwT );
  359. } ;
  360. class CInetInfoRequest;
  361. //
  362. // Provides access to all .htr variables
  363. // Handles RPC access ( get/put )
  364. // and provides set functions for non-RPC variables to make them
  365. // accessible to a .htr script.
  366. // Also handles !Functions
  367. //
  368. class CInetInfoConfigInfoMapper {
  369. public:
  370. CInetInfoConfigInfoMapper();
  371. ~CInetInfoConfigInfoMapper();
  372. BOOL Init( CInetInfoMap*, int, DWORD );
  373. DWORD GetType()
  374. { return m_dwCurrentServerType; }
  375. LPWSTR GetComputerName()
  376. { return m_achComputerName; }
  377. DWORD GetRPCStatus()
  378. { return m_dwRPCStatus; }
  379. VOID SetRPCStatus( DWORD dwS )
  380. { m_dwRPCStatus = dwS; SetRPCStatusString(dwS); }
  381. // return addr of HTMLA script variable
  382. BOOL RequestStatus( LPVOID *pV )
  383. { *pV = (LPVOID)&m_dwRequestStatus; return TRUE; }
  384. BOOL RPCStatus( LPVOID *pV )
  385. { *pV = (LPVOID)&m_dwRPCStatus; return TRUE; }
  386. BOOL RPCStatusString( LPVOID *pV )
  387. { *pV = (LPVOID)&m_pszRPCStatusString; return TRUE; }
  388. BOOL HttpStatus( LPVOID *pV )
  389. { *pV = (LPVOID)&m_dwHttpStatus; return TRUE; }
  390. BOOL FtpStatus( LPVOID *pV )
  391. { *pV = (LPVOID)&m_dwFtpStatus; return TRUE; }
  392. BOOL GopherStatus( LPVOID *pV )
  393. { *pV = (LPVOID)&m_dwGopherStatus; return TRUE; }
  394. BOOL OSMajorVersion( LPVOID *pV )
  395. #if defined(IISv1)
  396. {*pV = (LPVOID)&g_OSVersion.dwMajorVersion; return TRUE;}
  397. #else
  398. { if ( m_pServerCaps != NULL ) { *pV = (LPVOID)
  399. &m_pServerCaps->MajorVersion; return TRUE; }
  400. else {*pV = (LPVOID)&g_dwZero; return FALSE;} }
  401. #endif
  402. BOOL OSMinorVersion( LPVOID *pV )
  403. #if defined(IISv1)
  404. {*pV = (LPVOID)&g_OSVersion.dwMinorVersion; return TRUE;}
  405. #else
  406. { if ( m_pServerCaps != NULL ) { *pV = (LPVOID)
  407. &m_pServerCaps->MinorVersion; return TRUE; }
  408. else {*pV = (LPVOID)&g_dwZero; return FALSE;} }
  409. #endif
  410. BOOL OSBuildNumber( LPVOID *pV )
  411. #if defined(IISv1)
  412. {*pV = (LPVOID)&g_OSVersion.dwBuildNumber; return TRUE;}
  413. #else
  414. { if ( m_pServerCaps != NULL ) { *pV = (LPVOID)
  415. &m_pServerCaps->BuildNumber; return TRUE; }
  416. else {*pV = (LPVOID)&g_dwZero; return FALSE;} }
  417. #endif
  418. BOOL MajorVersion( LPVOID *pV )
  419. { *pV = (LPVOID)&m_dwMajorVersion; return TRUE; }
  420. BOOL MinorVersion( LPVOID *pV )
  421. { *pV = (LPVOID)&m_dwMinorVersion; return TRUE; }
  422. BOOL W3Version( LPVOID *pV )
  423. { *pV = (LPVOID)&m_pszW3Version; return TRUE; }
  424. BOOL Cap1Flag( LPVOID *pV )
  425. #if defined(IISv1)
  426. {*pV = (LPVOID)&g_dwCap1Flag; return TRUE;}
  427. #else
  428. { if ( m_pServerCaps != NULL && m_pServerCaps->NumCapFlags > 0)
  429. { *pV = (LPVOID)&m_pServerCaps->CapFlags[0].Flag; return TRUE; }
  430. else {*pV = (LPVOID)&g_dwZero; return FALSE;} }
  431. #endif
  432. BOOL Cap1Mask( LPVOID *pV )
  433. #if defined(IISv1)
  434. {*pV = (LPVOID)&g_dwCap1Mask; return TRUE;}
  435. #else
  436. { if ( m_pServerCaps != NULL && m_pServerCaps->NumCapFlags > 0)
  437. { *pV = (LPVOID)&m_pServerCaps->CapFlags[0].Mask; return TRUE; }
  438. else {*pV = (LPVOID)&g_dwZero; return FALSE;} }
  439. #endif
  440. BOOL URLParam( LPVOID *pV )
  441. { *pV = (LPVOID)&m_pszURLParam; return TRUE; }
  442. BOOL PlatformType( LPVOID *pV )
  443. #if defined(IISv1)
  444. {*pV = (LPVOID)&g_dwZero; return TRUE;}
  445. #else
  446. { if ( m_pServerCaps != NULL )
  447. { *pV = (LPVOID)&m_pServerCaps->ProductType; return TRUE; }
  448. else {*pV = (LPVOID)&g_dwOne; return TRUE;} }
  449. #endif
  450. BOOL ServName( LPVOID *pV );
  451. BOOL ServIdx( LPVOID *pV )
  452. { *pV = (LPVOID)&m_dwCurrentServerType; return TRUE; }
  453. BOOL Iter( LPVOID *pV )
  454. { *pV = (LPVOID)&m_iIter; return TRUE; }
  455. BOOL ReqParam( LPVOID *pV )
  456. { *pV = (LPVOID)&m_pszReqParam; return TRUE; }
  457. BOOL RemoteAddr( LPVOID *pV )
  458. { *pV = (LPVOID)&m_pszRemoteAddr; return TRUE; }
  459. BOOL IPNullAddr( LPVOID *pV )
  460. { *pV = (LPVOID)&g_pszIPNullAddr; return TRUE; }
  461. BOOL HostName( LPVOID *pV )
  462. { *pV = (LPVOID)&m_pszHostName; return TRUE; }
  463. BOOL HtmlaPath( LPVOID *pV )
  464. { *pV = (LPVOID)&m_pszHtmlaPath; return TRUE; }
  465. BOOL Arg1( LPVOID *pV )
  466. { *pV = (LPVOID)&m_pszArg1; return m_dwCurrentServerType == INET_DIR; }
  467. BOOL Arg2( LPVOID *pV )
  468. { *pV = (LPVOID)&m_pszArg2; return m_dwCurrentServerType == INET_DIR; }
  469. BOOL Arg3( LPVOID *pV )
  470. { *pV = (LPVOID)&m_pszArg3; return m_dwCurrentServerType == INET_DIR; }
  471. BOOL UserFlags( LPVOID *pV )
  472. { *pV = (LPVOID)&m_dwUserFlags; return TRUE; }
  473. //
  474. BOOL CommTimeout( LPVOID *pV )
  475. { if ( m_pConfig!=NULL ) { *pV
  476. = (LPVOID)&m_pConfig->dwConnectionTimeout;
  477. return TRUE;} else return FALSE; }
  478. BOOL MaxConn( LPVOID *pV )
  479. { if ( m_pConfig!=NULL ) { *pV
  480. = (LPVOID)&m_pConfig->dwMaxConnections;
  481. return TRUE;} else return FALSE; }
  482. BOOL AdminName( LPVOID *pV )
  483. { if ( m_pConfig!=NULL ) { *pV
  484. = (LPVOID)&m_pConfig->lpszAdminName;
  485. return TRUE;} else return FALSE; }
  486. BOOL AdminEmail( LPVOID *pV )
  487. { if ( m_pConfig!=NULL ) { *pV
  488. = (LPVOID)&m_pConfig->lpszAdminEmail;
  489. return TRUE;} else return FALSE; }
  490. BOOL ServerComment( LPVOID *pV )
  491. { if ( m_pConfig!=NULL ) { *pV
  492. = (LPVOID)&m_pConfig->lpszServerComment;
  493. return TRUE;} else return FALSE; }
  494. //
  495. BOOL LogSrc( LPVOID *pV )
  496. { if ( m_pConfig!=NULL ) { *pV
  497. = (LPVOID)&m_pConfig->lpLogConfig->rgchDataSource;
  498. return TRUE;} else return FALSE; }
  499. BOOL LogName( LPVOID *pV )
  500. { if ( m_pConfig!=NULL ) { *pV
  501. = (LPVOID)&m_pConfig->lpLogConfig->rgchTableName;
  502. return TRUE;} else return FALSE; }
  503. BOOL LogUser( LPVOID *pV )
  504. { if ( m_pConfig!=NULL ) { *pV
  505. = (LPVOID)&m_pConfig->lpLogConfig->rgchUserName;
  506. return TRUE;} else return FALSE; }
  507. BOOL LogPw( LPVOID *pV )
  508. { if ( m_pConfig!=NULL ) { *pV
  509. = (LPVOID)&m_pConfig->lpLogConfig->rgchPassword;
  510. return TRUE;} else return FALSE; }
  511. BOOL LogDir( LPVOID *pV )
  512. { if ( m_pConfig!=NULL ) { *pV = (LPVOID)
  513. &m_pConfig->lpLogConfig->rgchLogFileDirectory;
  514. return TRUE;} else return FALSE; }
  515. //
  516. BOOL LogAnonymous( LPVOID *pV )
  517. { *pV = (LPVOID)&m_pConfig->fLogAnonymous;
  518. return m_pConfig ? TRUE : FALSE; }
  519. BOOL LogNonAnonymous( LPVOID *pV )
  520. { *pV = (LPVOID)&m_pConfig->fLogNonAnonymous;
  521. return m_pConfig ? TRUE : FALSE; }
  522. BOOL AnonUserName( LPVOID *pV )
  523. { *pV = (LPVOID)&m_pConfig->lpszAnonUserName;
  524. return m_pConfig ? TRUE : FALSE; }
  525. BOOL AnonUserPw( LPVOID *pV )
  526. { *pV = (LPVOID)m_pConfig->szAnonPassword;
  527. return m_pConfig ? TRUE : FALSE; }
  528. BOOL DirBrowseEnab( LPVOID *pV );
  529. BOOL DefFileEnab( LPVOID *pV );
  530. BOOL AuthAnon( LPVOID *pV );
  531. BOOL AuthBasic( LPVOID *pV );
  532. BOOL AuthNT( LPVOID *pV );
  533. BOOL SPort( LPVOID *pV )
  534. { *pV = (LPVOID)&m_pConfig->sPort; return m_pConfig ? TRUE : FALSE; }
  535. //
  536. BOOL DenyIPCount( LPVOID *pV )
  537. { if ( m_pConfig!=NULL ) { *pV = m_pConfig->DenyIPList
  538. ? (LPVOID)&m_pConfig->DenyIPList->cEntries : (LPVOID)&g_dwZero;
  539. return TRUE;} else return FALSE; }
  540. BOOL DenyIsIPSingle( LPVOID *pV );
  541. BOOL DenyIPAddr( LPVOID *pV )
  542. { if ( m_pConfig!=NULL && m_pConfig->DenyIPList
  543. && m_iIter < m_pConfig->DenyIPList->cEntries )
  544. { *pV = (LPVOID)&m_pConfig->DenyIPList->aIPSecEntry[m_iIter].dwNetwork;
  545. return TRUE;} else return FALSE; }
  546. BOOL DenyIPMask( LPVOID *pV )
  547. { if ( m_pConfig!=NULL && m_pConfig->DenyIPList
  548. && m_iIter < m_pConfig->DenyIPList->cEntries )
  549. { *pV = (LPVOID)&m_pConfig->DenyIPList->aIPSecEntry[m_iIter].dwMask;
  550. return TRUE;} else return FALSE; }
  551. BOOL GrantIPCount( LPVOID *pV )
  552. { if ( m_pConfig!=NULL ) { *pV = m_pConfig->GrantIPList
  553. ? (LPVOID)&m_pConfig->GrantIPList->cEntries : (LPVOID)&g_dwZero;
  554. return TRUE;} else return FALSE; }
  555. BOOL GrantIsIPSingle( LPVOID *pV );
  556. BOOL GrantIPAddr( LPVOID *pV )
  557. { if ( m_pConfig!=NULL && m_pConfig->GrantIPList
  558. && m_iIter < m_pConfig->GrantIPList->cEntries ) { *pV
  559. = (LPVOID)&m_pConfig->GrantIPList->aIPSecEntry[m_iIter].dwNetwork;
  560. return TRUE;} else return FALSE; }
  561. BOOL GrantIPMask( LPVOID *pV )
  562. { if ( m_pConfig!=NULL && m_pConfig->GrantIPList
  563. && m_iIter < m_pConfig->GrantIPList->cEntries ) { *pV
  564. = (LPVOID)&m_pConfig->GrantIPList->aIPSecEntry[m_iIter].dwMask;
  565. return TRUE;} else return FALSE; }
  566. BOOL IPDenyRef( LPVOID *pV );
  567. BOOL IPGrantRef( LPVOID *pV );
  568. BOOL IPRef( LPVOID *pV, INET_INFO_IP_SEC_LIST*, LPSTR* );
  569. void AdjustFromIPSingle( LPBYTE );
  570. void AdjustIPSingle( LPBYTE );
  571. void InvalidateIPSingle() { m_dwIsIPSingle = 2; }
  572. //
  573. BOOL RootCount( LPVOID *pV )
  574. { if ( m_pConfig!=NULL ) { *pV = m_pConfig->VirtualRoots
  575. ? (LPVOID)&m_pConfig->VirtualRoots->cEntries : (LPVOID)&g_dwZero;
  576. return TRUE;} else return FALSE; }
  577. BOOL RootName( LPVOID *pV );
  578. BOOL RootAddr( LPVOID *pV )
  579. { if ( m_pConfig!=NULL && m_pConfig->VirtualRoots
  580. && m_iIter < m_pConfig->VirtualRoots->cEntries ) { *pV
  581. = (LPVOID)&m_pConfig->VirtualRoots->aVirtRootEntry[m_iIter].pszAddress;
  582. return TRUE;} else return FALSE; }
  583. BOOL RootDir( LPVOID *pV )
  584. { if ( m_pConfig!=NULL && m_pConfig->VirtualRoots
  585. && m_iIter < m_pConfig->VirtualRoots->cEntries ) { *pV =
  586. (LPVOID)&m_pConfig->VirtualRoots->aVirtRootEntry[m_iIter].pszDirectory;
  587. return TRUE;} else return FALSE; }
  588. BOOL RootAcctName( LPVOID *pV )
  589. { if ( m_pConfig!=NULL && m_pConfig->VirtualRoots
  590. && m_iIter < m_pConfig->VirtualRoots->cEntries ) { *pV = (LPVOID)
  591. &m_pConfig->VirtualRoots->aVirtRootEntry[m_iIter].pszAccountName;
  592. return TRUE;} else return FALSE; }
  593. BOOL RootAcctPw( LPVOID *pV )
  594. { if ( m_pConfig!=NULL && m_pConfig->VirtualRoots
  595. && m_iIter < m_pConfig->VirtualRoots->cEntries ) { *pV = (LPVOID)
  596. m_pConfig->VirtualRoots->aVirtRootEntry[m_iIter].AccountPassword;
  597. return TRUE;} else return FALSE; }
  598. BOOL RootError( LPVOID *pV )
  599. { if ( m_pConfig!=NULL && m_pConfig->VirtualRoots
  600. && m_iIter < m_pConfig->VirtualRoots->cEntries ) { *pV = (LPVOID)
  601. &m_pConfig->VirtualRoots->aVirtRootEntry[m_iIter].dwError;
  602. return TRUE;} else return FALSE; }
  603. BOOL RootIsHome( LPVOID *pV );
  604. BOOL RootIsRead( LPVOID *pV );
  605. BOOL RootIsWrite( LPVOID *pV );
  606. BOOL RootIsExec( LPVOID *pV );
  607. BOOL RootIsSSL( LPVOID *pV );
  608. BOOL RootRef( LPVOID *pV );
  609. BOOL SetRootEntryVars();
  610. //
  611. BOOL DefFile( LPVOID *pV )
  612. { if ( m_pW3Config!=NULL ) { *pV = (LPVOID)
  613. &m_pW3Config->lpszDefaultLoadFile; return TRUE;} else return FALSE; }
  614. BOOL SSIEnabled( LPVOID *pV )
  615. { if ( m_pW3Config!=NULL ) { *pV = (LPVOID)&m_pW3Config->fSSIEnabled;
  616. return TRUE;} else return FALSE; }
  617. BOOL SSIExt( LPVOID *pV )
  618. { if ( m_pW3Config!=NULL ) { *pV = (LPVOID)
  619. &m_pW3Config->lpszSSIExtension; return TRUE;} else return FALSE; }
  620. BOOL CryptCapable( LPVOID *pV );
  621. //
  622. BOOL EnableLog( LPVOID *pV );
  623. BOOL EnableNewLog( LPVOID *pV );
  624. BOOL LogType( LPVOID *pV )
  625. { if ( m_pConfig!= NULL ) {*pV =
  626. &m_pConfig->lpLogConfig->inetLogType; return TRUE;}
  627. else return FALSE; }
  628. BOOL LogSize( LPVOID *pV )
  629. { if ( m_pConfig!= NULL ) {*pV =
  630. &m_pConfig->lpLogConfig->cbSizeForTruncation;
  631. return TRUE;} else return FALSE; }
  632. BOOL LogPeriod( LPVOID *pV );
  633. BOOL LogFormat( LPVOID *pV );
  634. BOOL SetLogEntryVars();
  635. BOOL InvalidLogUpdate( LPVOID *pV );
  636. //
  637. // Gopher variables
  638. //
  639. BOOL GopherSite( LPVOID *pV )
  640. { if ( m_pGdConfig!= NULL ) {*pV = &m_pGdConfig->lpszSite;
  641. return TRUE;} else return FALSE; }
  642. BOOL GopherOrg( LPVOID *pV )
  643. { if ( m_pGdConfig!= NULL ) {*pV = &m_pGdConfig->lpszOrganization;
  644. return TRUE;} else return FALSE; }
  645. BOOL GopherLoc( LPVOID *pV )
  646. { if ( m_pGdConfig!= NULL ) {*pV = &m_pGdConfig->lpszLocation;
  647. return TRUE;} else return FALSE; }
  648. BOOL GopherGeo( LPVOID *pV )
  649. { if ( m_pGdConfig!= NULL ) {*pV = &m_pGdConfig->lpszGeography;
  650. return TRUE;} else return FALSE; }
  651. BOOL GopherLang( LPVOID *pV )
  652. { if ( m_pGdConfig!= NULL ) {*pV = &m_pGdConfig->lpszLanguage;
  653. return TRUE;} else return FALSE; }
  654. //
  655. // FTP variables
  656. //
  657. BOOL FTPIsAnon( LPVOID *pV )
  658. { if ( m_pFtpConfig!= NULL ) {*pV = &m_pFtpConfig->fAllowAnonymous;
  659. return TRUE;} else return FALSE; }
  660. BOOL FTPIsGuest( LPVOID *pV )
  661. { if ( m_pFtpConfig!= NULL ) {*pV = &m_pFtpConfig->fAllowGuestAccess;
  662. return TRUE;} else return FALSE; }
  663. BOOL FTPIsAnotDir( LPVOID *pV )
  664. { if ( m_pFtpConfig!= NULL ) {*pV = &m_pFtpConfig->fAnnotateDirectories;
  665. return TRUE;} else return FALSE; }
  666. BOOL FTPIsAnonOnly( LPVOID *pV )
  667. { if ( m_pFtpConfig!= NULL ) {*pV = &m_pFtpConfig->fAnonymousOnly;
  668. return TRUE;} else return FALSE; }
  669. BOOL FTPExitMsg( LPVOID *pV )
  670. { if ( m_pFtpConfig!= NULL ) {*pV = &m_pFtpConfig->lpszExitMessage;
  671. return TRUE;} else return FALSE; }
  672. BOOL FTPGreetMsg( LPVOID *pV )
  673. { if ( m_pFtpConfig!= NULL ) {*pV = &m_pFtpConfig->lpszGreetingMessage;
  674. return TRUE;} else return FALSE; }
  675. BOOL FTPHomeDir( LPVOID *pV )
  676. { if ( m_pFtpConfig!= NULL ) {*pV = &m_pFtpConfig->lpszHomeDirectory;
  677. return TRUE;} else return FALSE; }
  678. BOOL FTPMaxClMsg( LPVOID *pV )
  679. { if ( m_pFtpConfig!= NULL ) {*pV =
  680. &m_pFtpConfig->lpszMaxClientsMessage; return TRUE;}
  681. else return FALSE; }
  682. BOOL FTPIsMsdos( LPVOID *pV )
  683. { if ( m_pFtpConfig!= NULL ) {*pV = &m_pFtpConfig->fMsdosDirOutput;
  684. return TRUE;} else return FALSE; }
  685. //
  686. // User enumeration ( for all services )
  687. //
  688. BOOL UCount( LPVOID *pV )
  689. { return m_Users.GetCount( pV ); }
  690. BOOL UName( LPVOID *pV )
  691. { return m_Users.GetName( pV ); }
  692. BOOL UAnonymous( LPVOID *pV )
  693. { return m_Users.GetAnonymous( pV ); }
  694. BOOL UAddr( LPVOID *pV )
  695. { return m_Users.GetAddr( pV ); }
  696. BOOL UTime( LPVOID *pV )
  697. { return m_Users.GetTime( pV ); }
  698. BOOL UID( LPVOID *pV )
  699. { return m_Users.GetID( pV ); }
  700. //
  701. // Global information
  702. //
  703. BOOL GlobalBandwidth( LPVOID *pV )
  704. { if ( m_pGlobalConfig!= NULL ) {*pV =
  705. &m_pGlobalConfig->BandwidthLevel; return TRUE;} else return FALSE; }
  706. BOOL GlobalCache( LPVOID *pV )
  707. { if ( m_pGlobalConfig!= NULL ) {*pV =
  708. &m_pGlobalConfig->cbMemoryCacheSize; return TRUE;} else return FALSE; }
  709. BOOL GlobalIsBandwidthLimited( LPVOID *pV );
  710. //
  711. // Directory browsing
  712. //
  713. // these functions are a shell around the m_Drive object
  714. //
  715. BOOL DirRootDir( LPVOID *pV )
  716. { return m_Drive.RootDir( (LPSTR*)(*pV = (LPVOID*)&m_pszRootDir ) ); }
  717. BOOL DirBaseDir( LPVOID *pV )
  718. { return m_Drive.BaseDir( (LPSTR*)(*pV = (LPVOID*)&m_pszBaseDir ) ); }
  719. BOOL DirCount( LPVOID *pV )
  720. { return m_Drive.DirCount( (LPDWORD*)pV ); }
  721. BOOL DirEntry( LPVOID *pV )
  722. { return m_Drive.DirEntry( m_iIter, *pV = (LPVOID*)&m_pszDirEntry ); }
  723. BOOL DirCompCount( LPVOID *pV )
  724. { return m_Drive.DirCompCount( (LPDWORD*)pV ); }
  725. BOOL DirCompEntry( LPVOID *pV )
  726. { return m_Drive.DirCompEntry( m_iIter,
  727. *pV = (LPVOID*)&m_pszDirCompEntry ); }
  728. BOOL DirFCompEntry( LPVOID *pV )
  729. { return m_Drive.DirFCompEntry( m_iIter,
  730. *pV = (LPVOID*)&m_pszDirFCompEntry ); }
  731. BOOL DriveCount( LPVOID *pV )
  732. { return m_Drive.DriveCount( (LPDWORD*)pV ); }
  733. BOOL DriveNameEntry( LPVOID *pV )
  734. { return m_Drive.DriveNameEntry( m_iIter,
  735. *pV = (LPVOID*)&m_pszDriveNameEntry ); }
  736. BOOL DriveLabelEntry( LPVOID *pV )
  737. { return m_Drive.DriveLabelEntry( m_iIter,
  738. *pV = (LPVOID*)&m_pszDriveLabelEntry ); }
  739. BOOL DriveTypeEntry( LPVOID *pV )
  740. { return m_Drive.DriveTypeEntry( m_iIter, pV ); }
  741. //
  742. // Function called to validate a HTMLA variable update.
  743. // if return FALSE then update is invalidated, and a error condition
  744. // will be generated at the HTMLA script level
  745. //
  746. // These functions have to set the relevant bit in the appropriate
  747. // FieldControl of the various RPC structures in order to request
  748. // the server to update its internal state.
  749. //
  750. BOOL UpdateCommTimeout()
  751. { if ( m_pConfig!=NULL ) { SetField( m_pConfig->FieldControl,
  752. FC_INET_INFO_CONNECTION_TIMEOUT); return TRUE;} else return FALSE; }
  753. BOOL UpdateMaxConn()
  754. { if ( m_pConfig!=NULL ) { SetField( m_pConfig->FieldControl,
  755. FC_INET_INFO_MAX_CONNECTIONS); return TRUE;} else return FALSE; }
  756. BOOL UpdateAdminName()
  757. { if ( m_pConfig!=NULL ) { SetField( m_pConfig->FieldControl,
  758. FC_INET_INFO_ADMIN_NAME); return TRUE;} else return FALSE; }
  759. BOOL UpdateAdminEmail()
  760. { if ( m_pConfig!=NULL ) { SetField( m_pConfig->FieldControl,
  761. FC_INET_INFO_ADMIN_EMAIL); return TRUE;} else return FALSE; }
  762. BOOL UpdateServerComment()
  763. { if ( m_pConfig!=NULL ) { SetField( m_pConfig->FieldControl,
  764. FC_INET_INFO_SERVER_COMMENT); return TRUE;} else return FALSE; }
  765. // Triggers error to indicates the associated variable
  766. // should not be updated
  767. BOOL DenyUpdate()
  768. { return FALSE; }
  769. BOOL IgnoreUpdate()
  770. { return TRUE; }
  771. BOOL UpdateLogAnonymous()
  772. { if ( m_pConfig ) {SetField( m_pConfig->FieldControl,
  773. FC_INET_INFO_LOG_ANONYMOUS); return TRUE;} else return FALSE;}
  774. BOOL UpdateLogNonAnonymous()
  775. { if ( m_pConfig ) {SetField( m_pConfig->FieldControl,
  776. FC_INET_INFO_LOG_NONANONYMOUS); return TRUE;} else return FALSE;}
  777. BOOL UpdateAnonUserName()
  778. { if ( m_pConfig ) {SetField( m_pConfig->FieldControl,
  779. FC_INET_INFO_ANON_USER_NAME); return TRUE;} else return FALSE; }
  780. BOOL UpdateAnonUserPw()
  781. { if ( m_pConfig ) {SetField( m_pConfig->FieldControl,
  782. FC_INET_INFO_ANON_PASSWORD); return TRUE;} else return FALSE; }
  783. BOOL UpdateSPort()
  784. { if ( m_pConfig ) {SetField( m_pConfig->FieldControl,
  785. FC_INET_INFO_PORT_NUMBER); return TRUE;} else return FALSE; }
  786. //
  787. BOOL UpdateDenyIsIPSingle();
  788. BOOL UpdateGrantIsIPSingle();
  789. BOOL UpdateIP()
  790. { if ( m_pConfig ) { SetField( m_pConfig->FieldControl,
  791. FC_INET_INFO_SITE_SECURITY); return TRUE;} else return FALSE; }
  792. BOOL UpdateDirControl();
  793. BOOL UpdateRoot()
  794. { if ( m_pConfig ) { SetField( m_pConfig->FieldControl,
  795. FC_INET_INFO_VIRTUAL_ROOTS); return TRUE;} else return FALSE; }
  796. BOOL UpdateRootName();
  797. BOOL UpdateRootMask();
  798. BOOL UpdateAuth();
  799. BOOL UpdateLog();
  800. BOOL UpdateNewLog();
  801. BOOL UpdateLogType();
  802. BOOL UpdateLogPeriod();
  803. BOOL UpdateLogFormat();
  804. BOOL UpdateLogSize();
  805. BOOL UpdateLogInfo()
  806. { if ( m_pConfig!=NULL ) {SetField( m_pConfig->FieldControl,
  807. FC_INET_INFO_ALL ); return TRUE;} else return FALSE; }
  808. BOOL UpdateLogFileInfo();
  809. BOOL UpdateLogODBCInfo();
  810. //
  811. // W3 variables
  812. //
  813. BOOL UpdateDefFile()
  814. { if ( m_pW3Config!=NULL ) { SetField( m_pW3Config->FieldControl,
  815. FC_W3_DEFAULT_LOAD_FILE ); return TRUE;} else return FALSE; }
  816. BOOL UpdateSSIEnabled()
  817. { if ( m_pW3Config!=NULL ) { SetField( m_pW3Config->FieldControl,
  818. FC_W3_SSI_ENABLED ); return TRUE;} else return FALSE; }
  819. BOOL UpdateSSIExt()
  820. { if ( m_pW3Config!=NULL ) { SetField( m_pW3Config->FieldControl,
  821. FC_W3_SSI_EXTENSION ); return TRUE;} else return FALSE; }
  822. //
  823. // Gopher variables
  824. //
  825. BOOL UpdateGopherSite()
  826. { if ( m_pGdConfig!=NULL ) { SetField( m_pGdConfig->FieldControl,
  827. GDA_SITE ); return TRUE;} else return FALSE; }
  828. BOOL UpdateGopherOrg()
  829. { if ( m_pGdConfig!=NULL ) { SetField( m_pGdConfig->FieldControl,
  830. GDA_ORGANIZATION ); return TRUE;} else return FALSE; }
  831. BOOL UpdateGopherLoc()
  832. { if ( m_pGdConfig!=NULL ) { SetField( m_pGdConfig->FieldControl,
  833. GDA_LOCATION ); return TRUE;} else return FALSE; }
  834. BOOL UpdateGopherGeo()
  835. { if ( m_pGdConfig!=NULL ) { SetField( m_pGdConfig->FieldControl,
  836. GDA_GEOGRAPHY ); return TRUE;} else return FALSE; }
  837. BOOL UpdateGopherLang()
  838. { if ( m_pGdConfig!=NULL ) { SetField( m_pGdConfig->FieldControl,
  839. GDA_LANGUAGE ); return TRUE;} else return FALSE; }
  840. //
  841. // FTP variables
  842. //
  843. BOOL UpdateFTPIsAnon()
  844. { if ( m_pFtpConfig!=NULL ) { SetField( m_pFtpConfig->FieldControl,
  845. FC_FTP_ALLOW_ANONYMOUS ); return TRUE;} else return FALSE; }
  846. BOOL UpdateFTPIsGuest()
  847. { if ( m_pFtpConfig!=NULL ) { SetField( m_pFtpConfig->FieldControl,
  848. FC_FTP_ALLOW_GUEST_ACCESS ); return TRUE;} else return FALSE; }
  849. BOOL UpdateFTPIsAnotDir()
  850. { if ( m_pFtpConfig!=NULL ) { SetField( m_pFtpConfig->FieldControl,
  851. FC_FTP_ANNOTATE_DIRECTORIES ); return TRUE;} else return FALSE; }
  852. BOOL UpdateFTPIsAnonOnly()
  853. { if ( m_pFtpConfig!=NULL ) { SetField( m_pFtpConfig->FieldControl,
  854. FC_FTP_ANONYMOUS_ONLY ); return TRUE;} else return FALSE; }
  855. BOOL UpdateFTPExitMsg()
  856. { if ( m_pFtpConfig!=NULL ) { SetField( m_pFtpConfig->FieldControl,
  857. FC_FTP_EXIT_MESSAGE ); return TRUE;} else return FALSE; }
  858. BOOL UpdateFTPGreetMsg()
  859. { if ( m_pFtpConfig!=NULL ) { SetField( m_pFtpConfig->FieldControl,
  860. FC_FTP_GREETING_MESSAGE ); return TRUE;} else return FALSE; }
  861. BOOL UpdateFTPHomeDir()
  862. { if ( m_pFtpConfig!=NULL ) { SetField( m_pFtpConfig->FieldControl,
  863. FC_FTP_HOME_DIRECTORY ); return TRUE;} else return FALSE; }
  864. BOOL UpdateFTPMaxClMsg()
  865. { if ( m_pFtpConfig!=NULL ) { SetField( m_pFtpConfig->FieldControl,
  866. FC_FTP_MAX_CLIENTS_MESSAGE ); return TRUE;} else return FALSE; }
  867. BOOL UpdateFTPIsMsdos()
  868. { if ( m_pFtpConfig!=NULL ) { SetField( m_pFtpConfig->FieldControl,
  869. FC_FTP_MSDOS_DIR_OUTPUT ); return TRUE;} else return FALSE; }
  870. //
  871. // Global configuration variables
  872. //
  873. BOOL UpdateGlobal()
  874. { if ( m_pGlobalConfig != NULL ) { SetField(
  875. m_pGlobalConfig->FieldControl, FC_GINET_INFO_ALL ); return TRUE;}
  876. else return FALSE; }
  877. BOOL UpdateGlobalBandwidth();
  878. BOOL UpdateGlobalIsBandwidthLimited();
  879. //
  880. // variables linked to current client request
  881. //
  882. void SetRequestStatus ( DWORD dwS )
  883. { m_dwRequestStatus = dwS; }
  884. void SetReqParam( LPSTR pszP, CInetInfoRequest* pR, LPSTR pszPRaw )
  885. {
  886. m_pszReqParam = pszP;
  887. m_piiR = pR;
  888. m_pszReqParamRaw = pszPRaw;
  889. }
  890. DWORD GetRequestStatus ()
  891. { return m_dwRequestStatus; }
  892. void SetURLParam( LPSTR pszP )
  893. { m_pszURLParam = pszP; }
  894. BOOL SetRemoteAddr( LPSTR pR );
  895. VOID SetUserFlags( DWORD dw ) { m_dwUserFlags = dw; }
  896. //
  897. // Structure management
  898. //
  899. BOOL GetCurrentConfig();
  900. BOOL Update();
  901. BOOL FreeInfo(); // based on SetField() info
  902. LPVOID Alloc( DWORD );
  903. void Lock( );
  904. void UnLock( );
  905. // Map a variable name to a variable descriptor
  906. BOOL Map( LPBYTE pName, DWORD dwNameLen, CInetInfoMap** );
  907. // return to be deleted depending on fFree
  908. BOOL GetString( CInetInfoMap*, LPSTR *pResult, DWORD *pdwResLen,
  909. BOOL *pfFree );
  910. BOOL EscapeString( LPSTR *pResult, DWORD *pdwResLen,
  911. BOOL fFree );
  912. BOOL GetString( LPBYTE pName, DWORD dwNameLen, LPSTR *pResult,
  913. DWORD *pdwResLen, BOOL *pfFree );
  914. BOOL PutString( CInetInfoMap *pMap, LPSTR pSet );
  915. void ResetIter()
  916. { m_iIter = 0; m_fInvEntry = TRUE; }
  917. void IncIter()
  918. { ++m_iIter; m_fInvEntry = TRUE; }
  919. void SetIter( DWORD dwI )
  920. { ++m_iIter = dwI; m_fInvEntry = TRUE; }
  921. DWORD GetIter() { return m_iIter; }
  922. BOOL GetFromMsgBody( LPSTR pName, DWORD dwNameLen, LPSTR *pResult,
  923. DWORD *pdwResLen );
  924. BOOL GetFromServer( LPSTR pName, DWORD dwNameLen, LPSTR *pResult,
  925. DWORD *pdwResLen );
  926. //
  927. // HTMLA Verbs
  928. //
  929. //
  930. // Directory management
  931. //
  932. BOOL GenerateDirList( LPSTR pV )
  933. { return m_Drive.GenerateDirList( pV ); }
  934. BOOL ValidateDir( LPSTR pV )
  935. { return m_Drive.ValidateDir( pV ); }
  936. BOOL CreateDir( LPSTR pV, LPSTR pV2 )
  937. { return m_Drive.CreateDir( pV, pV2 ); }
  938. //
  939. // IP access list management
  940. //
  941. BOOL AddIPAccess( BOOL );
  942. BOOL DeleteIPAccess( BOOL, LPSTR pID );
  943. BOOL PositionIPAccess( BOOL, LPSTR pID );
  944. BOOL CloneIPAccesses( BOOL, BOOL fExtend, BOOL fDel, DWORD dwToDel );
  945. BOOL SetIPAccessDefault( BOOL fIsDeny );
  946. BOOL BuildIPUniqueID( LPSTR, INET_INFO_IP_SEC_ENTRY* );
  947. //
  948. // Virtual directories list management
  949. //
  950. BOOL AddVirtDir();
  951. BOOL DeleteVirtDir( LPSTR pID );
  952. BOOL PositionVirtDir( LPSTR pID );
  953. BOOL CloneVirtDirs( BOOL fExtend, BOOL fDel, DWORD dwToDel );
  954. BOOL BuildVirtDirUniqueID( LPSTR, INET_INFO_VIRTUAL_ROOT_ENTRY* );
  955. BOOL VirtDirCmp( INET_INFO_VIRTUAL_ROOT_ENTRY* p1,
  956. INET_INFO_VIRTUAL_ROOT_ENTRY* p2, BOOL );
  957. BOOL HandleVirtDirRequest( LPSTR, LPSTR, int );
  958. BOOL AliasVirtDir( INET_INFO_VIRTUAL_ROOT_ENTRY *pU );
  959. //
  960. // Disconnect User management
  961. //
  962. BOOL DisconnectUser( LPSTR );
  963. BOOL DisconnectAll();
  964. //
  965. // Password management
  966. //
  967. BOOL ChangePassword();
  968. //
  969. BOOL GetStatus();
  970. //
  971. LPSTR IPToMultiByte( LPBYTE pB );
  972. BOOL MultiByteToIP( LPSTR *pS, LPBYTE pB );
  973. private:
  974. void SetRPCStatusString(DWORD dwS); //should only be called from SetRPCStatus()
  975. CInetInfoMap *m_pMap; // map name to member
  976. int m_cNbMap;
  977. CInetInfoRequest *m_piiR;
  978. INET_INFO_GLOBAL_CONFIG_INFO *m_pGlobalConfig;
  979. INET_INFO_CONFIG_INFO *m_pConfig; //
  980. W3_CONFIG_INFO *m_pW3Config;
  981. FTP_CONFIG_INFO *m_pFtpConfig;
  982. GOPHERD_CONFIG_INFO *m_pGdConfig;
  983. LPINET_INFO_CAPABILITIES m_pServerCaps;
  984. CUserEnum m_Users;
  985. DWORD m_dwCurrentServerType; // type of bind pConfig
  986. DWORD m_dwUserFlags;
  987. //
  988. DWORD m_iIter; // index in iterated sub-struc
  989. CRITICAL_SECTION m_csLock;
  990. LPSTR m_pszURLParam;
  991. LPSTR m_pszReqParamRaw;
  992. DWORD m_dwRequestStatus;
  993. DWORD m_dwRPCStatus;
  994. LPTSTR m_pszRPCStatusString;
  995. DWORD m_dwHttpStatus;
  996. DWORD m_dwFtpStatus;
  997. DWORD m_dwGopherStatus;
  998. // memory allocation support for RPC structure update
  999. CAllocNode *m_pFirstAlloc;
  1000. CAllocNode *m_pLastAlloc;
  1001. //
  1002. WCHAR m_achComputerName[MAX_COMPUTERNAME_LENGTH+1];
  1003. // virtual vars
  1004. BOOL m_DirBrowseEnab;
  1005. BOOL m_DefFileEnab;
  1006. BOOL m_fRootIsRead;
  1007. BOOL m_fRootIsWrite;
  1008. BOOL m_fRootIsExec;
  1009. BOOL m_fRootIsSSL;
  1010. BOOL m_fRootIsHome;
  1011. BOOL m_fAuthAnon;
  1012. BOOL m_fAuthBasic;
  1013. BOOL m_fAuthNT;
  1014. BOOL m_fEnableLog;
  1015. BOOL m_fEnableNewLog;
  1016. DWORD m_dwLogPeriod;
  1017. DWORD m_dwLogFormat;
  1018. LPSTR m_pDenyRef;
  1019. LPSTR m_pGrantRef;
  1020. LPSTR m_pRootRef;
  1021. LPSTR m_pszVarServName;
  1022. DWORD m_dwIsBandwidthLimited;
  1023. DWORD m_dwIsIPSingle;
  1024. LPSTR m_pszReqParam;
  1025. BOOL m_fInvEntry;
  1026. LPBYTE m_pRemoteAddr;
  1027. LPSTR m_pszRemoteAddr;
  1028. CHAR m_achHostName[MAX_DOMAIN_LENGTH + 1];
  1029. LPSTR m_pszHtmlaPath;
  1030. LPSTR m_pszHostName;
  1031. DWORD m_dwInvalidLogUpdate;
  1032. BOOL m_fLogFileUpdate;
  1033. BOOL m_fLogODBCUpdate;
  1034. DWORD m_dwWasLogPeriod;
  1035. DWORD m_dwWasLogType;
  1036. DWORD m_dwWasSizeForTruncation;
  1037. // directory browsing
  1038. CDriveView m_Drive;
  1039. DWORD m_dwDirCount;
  1040. DWORD m_dwDirCompCount;
  1041. DWORD m_dwDriveCount;
  1042. LPSTR m_pszRootDir;
  1043. LPSTR m_pszBaseDir;
  1044. LPSTR m_pszDirEntry;
  1045. LPSTR m_pszDirCompEntry;
  1046. LPSTR m_pszDirFCompEntry;
  1047. LPSTR m_pszDriveNameEntry;
  1048. LPSTR m_pszDriveLabelEntry;
  1049. LPSTR m_pszArg1;
  1050. LPSTR m_pszArg2;
  1051. LPSTR m_pszArg3;
  1052. //
  1053. DWORD m_dwCryptCapable;
  1054. BOOL m_fGotServerCapsAndVersion;
  1055. DWORD m_dwMajorVersion;
  1056. DWORD m_dwMinorVersion;
  1057. LPSTR m_pszW3Version;
  1058. //For dealing with RPC error strings
  1059. BOOL m_fAllocatedRPCStatusString;
  1060. TCHAR m_achRPCErrorCodeBuffer[MAX_ERROR_CODE_LENGTH];
  1061. } ;
  1062. // Description for an .htr variable
  1063. class CInetInfoMap {
  1064. public:
  1065. LPSTR pName;
  1066. INET_ELEM_TYPE iType;
  1067. BOOL (CInetInfoConfigInfoMapper::*GetAddr)(LPVOID*);
  1068. // called to indicate received update from client
  1069. BOOL (CInetInfoConfigInfoMapper::*UpdateIndication)();
  1070. DWORD dwParam; // type dependant, used as size for AWCHAR
  1071. } ;
  1072. //
  1073. // Dynamic buffer
  1074. //
  1075. class CExtBuff {
  1076. public:
  1077. CExtBuff::CExtBuff();
  1078. CExtBuff::~CExtBuff();
  1079. // Reset buffer : free memory, set length to 0
  1080. void Reset();
  1081. // Add a byte range
  1082. BOOL CopyBuff( LPBYTE pB, UINT cNb );
  1083. // Reserve a byte range, returns ptr to start of range
  1084. LPBYTE ReserveRange( UINT cNb )
  1085. { Extend( cNb ); return m_pB+m_cCurrent; }
  1086. // Declare # of bytes consumed in the previously reserved range
  1087. void SkipRange( UINT cNb )
  1088. { m_cCurrent += cNb; }
  1089. // Declare that a zero-delimited string worth of bytes
  1090. // was consumed in the previously reserved range
  1091. void SkipString() { m_cCurrent += lstrlen((char*)m_pB+m_cCurrent); }
  1092. // returns ptr to the buffer
  1093. LPBYTE GetPtr() { return m_pB; }
  1094. // returns length of the buffer
  1095. UINT GetLen() { return m_cCurrent; }
  1096. private:
  1097. BOOL Extend( UINT );
  1098. LPBYTE m_pB;
  1099. UINT m_cCurrent;
  1100. UINT m_cAlloc;
  1101. } ;
  1102. #define EXTBUFF_INCALLOC 4096
  1103. class CInetInfoVerbMap;
  1104. // Contains !Function execution context ( parameters )
  1105. class CVerbContext {
  1106. public:
  1107. CVerbContext();
  1108. ~CVerbContext();
  1109. CInetInfoMap* GetInfoMap( DWORD dwI );
  1110. DWORD GetNbInfoMap()
  1111. { return m_cNbInfoMap; }
  1112. LPSTR GetVerbName()
  1113. { return m_pszVerbName; }
  1114. DWORD Parse( CInetInfoConfigInfoMapper*, LPBYTE, DWORD );
  1115. private:
  1116. BOOL AddInfoMap( CInetInfoMap* pI );
  1117. private:
  1118. LPSTR m_pszVerbName;
  1119. DWORD m_cNbInfoMap;
  1120. DWORD m_cAllocedInfoMap;
  1121. CInetInfoMap **m_pMaps;
  1122. } ;
  1123. //
  1124. // Information specific to a given HTTP request
  1125. // Handles data writes to the client
  1126. //
  1127. class CInetInfoRequest {
  1128. public:
  1129. CInetInfoRequest( EXTENSION_CONTROL_BLOCK*, CInetInfoConfigInfoMapper*,
  1130. LPSTR, LPSTR );
  1131. ~CInetInfoRequest();
  1132. EXTENSION_CONTROL_BLOCK* GetECB()
  1133. { return m_pECB; }
  1134. CInetInfoConfigInfoMapper* GetMapper()
  1135. { return m_pMapper; }
  1136. LPSTR GetScr()
  1137. { return m_pScr; }
  1138. LPSTR GetParam()
  1139. { return m_pParam; }
  1140. LPSTR GetData()
  1141. { return m_pData; }
  1142. LPSTR GetDataRaw()
  1143. { return m_pDataRaw; }
  1144. CExtBuff* GetBuffer()
  1145. { return &m_eb; }
  1146. BOOL Init( LPSTR, int );
  1147. DWORD Done();
  1148. void SetHTTPStatus( DWORD dwS )
  1149. { m_dwHTTPStatus = dwS; }
  1150. LPSTR HTTPStatusStringFromCode();
  1151. LPWSTR AnsiToUnicode( LPSTR );
  1152. //
  1153. BOOL DoVerb( CVerbContext * );
  1154. LPSTR GetVarAsString( DWORD, BOOL* );
  1155. //
  1156. BOOL AddDenyIPAccess();
  1157. BOOL DeleteDenyIPAccess();
  1158. BOOL PositionDenyIPAccess();
  1159. BOOL DefaultIsDenyIPAccess();
  1160. BOOL AddGrantIPAccess();
  1161. BOOL DeleteGrantIPAccess();
  1162. BOOL PositionGrantIPAccess();
  1163. BOOL DefaultIsGrantIPAccess();
  1164. //
  1165. BOOL AddVirtDir();
  1166. BOOL DeleteVirtDir();
  1167. BOOL PositionVirtDir();
  1168. BOOL ChangePassword();
  1169. BOOL GetUserFlags();
  1170. BOOL SetHttpStatus();
  1171. // Default update function, no validation
  1172. BOOL Update();
  1173. // clear var
  1174. BOOL Clear();
  1175. //
  1176. BOOL DisconnectUser();
  1177. BOOL DisconnectAll();
  1178. //
  1179. BOOL GetStatus();
  1180. //
  1181. BOOL ValidateDir();
  1182. BOOL CreateDir();
  1183. BOOL GenerateDirList();
  1184. //
  1185. BOOL CheckForVirtDir();
  1186. BOOL AliasVirtDir();
  1187. BOOL HandleVirtDirRequest( int );
  1188. //
  1189. private:
  1190. EXTENSION_CONTROL_BLOCK *m_pECB;
  1191. CExtBuff m_eb; // for result
  1192. CInetInfoConfigInfoMapper *m_pMapper;
  1193. LPSTR m_pScr;
  1194. LPSTR m_pParam;
  1195. // request body
  1196. LPSTR m_pData;
  1197. DWORD m_dwDataLen;
  1198. LPSTR m_pDataRaw;
  1199. DWORD m_dwDataRawLen;
  1200. DWORD m_dwHTTPStatus;
  1201. //
  1202. CInetInfoVerbMap *m_apV;
  1203. UINT m_cV;
  1204. CVerbContext *m_pVerbContext;
  1205. LPSTR m_pHeader;
  1206. } ;
  1207. class CInetInfoVerbMap {
  1208. public:
  1209. LPSTR pszName;
  1210. BOOL (CInetInfoRequest::*pHandler)();
  1211. } ;
  1212. class CStatusStringAndCode
  1213. {
  1214. public:
  1215. DWORD dwStatus;
  1216. UINT dwID;
  1217. CHAR achStatus[128];
  1218. } ;
  1219. //
  1220. // Parse a .htr script, using a CInetInfoConfigInfoMapper object
  1221. // to access variables and !Functions
  1222. //
  1223. class CInetInfoMerger {
  1224. public:
  1225. CInetInfoMerger();
  1226. ~CInetInfoMerger();
  1227. //
  1228. BOOL Init();
  1229. BOOL Merge( CInetInfoRequest* );
  1230. private:
  1231. BOOL GetToken( LPBYTE pVS, DWORD dwSize, LPBYTE* pStart, DWORD* dwL );
  1232. LPSTR AllocDup( CInetInfoConfigInfoMapper *pM, LPBYTE pDup, DWORD dwL );
  1233. CInetInfoMap *GetVarMap( CInetInfoConfigInfoMapper *pM,
  1234. LPBYTE pVS, DWORD dwSize );
  1235. } ;
  1236. class CInetInfoRequestMap;
  1237. // Map an incoming request to a CInetInfoConfigInfoMapper, then
  1238. // calls CInetInfoMerger
  1239. class CInetInfoDispatcher {
  1240. public:
  1241. CInetInfoDispatcher();
  1242. ~CInetInfoDispatcher();
  1243. BOOL Init();
  1244. DWORD Invoke( EXTENSION_CONTROL_BLOCK* );
  1245. CInetInfoConfigInfoMapper* GetMapperFromString( LPSTR pszServ );
  1246. UINT GetNbH( VOID )
  1247. { return m_cH; }
  1248. // Handle display for all screens
  1249. BOOL HandleDisplay( CInetInfoRequest* );
  1250. //
  1251. private:
  1252. // maintain mapper, merger
  1253. //
  1254. CInetInfoConfigInfoMapper m_MapperHTTP;
  1255. CInetInfoConfigInfoMapper m_MapperFTP;
  1256. CInetInfoConfigInfoMapper m_MapperGOPHER;
  1257. CInetInfoConfigInfoMapper m_MapperDNS;
  1258. CInetInfoConfigInfoMapper m_MapperDIR;
  1259. CInetInfoMerger m_IFMerger;
  1260. CInetInfoRequestMap *m_apH;
  1261. UINT m_cH;
  1262. } ;
  1263. class CInetInfoRequestMap {
  1264. public:
  1265. LPSTR pszName;
  1266. BOOL (CInetInfoDispatcher::*pHandler)(CInetInfoRequest*);
  1267. BOOL fIsStd;
  1268. } ;
  1269. //
  1270. // .htr expression handling
  1271. //
  1272. class CExpr {
  1273. public:
  1274. CExpr( CInetInfoConfigInfoMapper*pM )
  1275. { m_pMap = pM; m_fMustFree = FALSE; m_pV = NULL; }
  1276. ~CExpr()
  1277. { if ( m_fMustFree ) delete [] m_pV; }
  1278. DWORD Get( LPBYTE, DWORD );
  1279. LPSTR GetAsStr()
  1280. { return m_pV; }
  1281. DWORD GetAsDWORD();
  1282. INET_ELEM_TYPE GetType()
  1283. { return m_iType; }
  1284. private:
  1285. CInetInfoConfigInfoMapper *m_pMap;
  1286. LPSTR m_pV;
  1287. DWORD m_dwV;
  1288. INET_ELEM_TYPE m_iType;
  1289. BOOL m_fMustFree;
  1290. } ;
  1291. //
  1292. // relational operator mapping for the CRelop class
  1293. //
  1294. enum RELOP_TYPE {
  1295. RELOP_INV, // invalid, must be present in front of array
  1296. RELOP_EQ, // equal
  1297. RELOP_NE, // not equal
  1298. RELOP_GT, // greater than
  1299. RELOP_LT, // less than
  1300. RELOP_GE, // greater or equal
  1301. RELOP_LE, // less or equal
  1302. RELOP_RF, // reference
  1303. RELOP_BA // bitwise AND
  1304. };
  1305. //
  1306. // .htr relational operator ( for %if constructs )
  1307. //
  1308. class CRelop {
  1309. public:
  1310. CRelop( )
  1311. { m_iType = RELOP_INV; }
  1312. ~CRelop()
  1313. {}
  1314. DWORD Get( LPBYTE, DWORD );
  1315. BOOL IsTrue( CExpr& v1, CExpr& v2, BOOL * pfValid );
  1316. private:
  1317. RELOP_TYPE m_iType;
  1318. } ;
  1319. BOOL
  1320. InlineFromTransparent(
  1321. LPBYTE pData,
  1322. DWORD *pdwDataLen,
  1323. BOOL
  1324. );
  1325. #endif
  1326.