home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1999 February / DPPCPRO0299.ISO / February / Delphi / Install / DATA.Z / WININET.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-06-09  |  46.2 KB  |  1,068 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Delphi Run-time Library                         }
  5. {       Windows 32bit API Interface Unit                }
  6. {                                                       }
  7. {       Copyright (c) 1996 Borland International        }
  8. {                                                       }
  9. {*******************************************************}
  10.  
  11. unit WinInet;
  12.  
  13. interface
  14.  
  15. uses Windows;
  16.  
  17. { Contains manifests, functions, types and prototypes for 
  18.   Microsoft Windows Internet Extensions }
  19.  
  20.  
  21. { internet types }
  22.  
  23. type
  24.   HINTERNET = Pointer; 
  25.   PHINTERNET = ^HINTERNET; 
  26.  
  27.   INTERNET_PORT = Word; 
  28.   PINTERNET_PORT = ^INTERNET_PORT; 
  29.  
  30.  
  31. { Internet APIs }
  32.  
  33.  
  34. { manifests }
  35.  
  36.  
  37. const
  38.   INTERNET_INVALID_PORT_NUMBER = 0;                 { use the protocol-specific default }
  39.  
  40.   INTERNET_DEFAULT_FTP_PORT = 21;                   { default for FTP servers }
  41.   INTERNET_DEFAULT_GOPHER_PORT = 70;                {    "     "  gopher " }
  42.   INTERNET_DEFAULT_HTTP_PORT = 80;                  {    "     "  HTTP   " }
  43.  
  44.  
  45. { maximum field lengths (arbitrary) }
  46.  
  47.   INTERNET_MAX_HOST_NAME_LENGTH = 256; 
  48.   INTERNET_MAX_USER_NAME_LENGTH = 128; 
  49.   INTERNET_MAX_PASSWORD_LENGTH = 128; 
  50.   INTERNET_MAX_PORT_NUMBER_LENGTH = 5;              { INTERNET_PORT is unsigned short }
  51.   INTERNET_MAX_PORT_NUMBER_VALUE = 65535;           { maximum unsigned short value }
  52.   INTERNET_MAX_PATH_LENGTH = 1024; 
  53.   INTERNET_MAX_PROTOCOL_NAME = 'gopher';            { longest protocol name }
  54.   INTERNET_MAX_URL_LENGTH = ((SizeOf(INTERNET_MAX_PROTOCOL_NAME) - 1) 
  55.                             + SizeOf('://')
  56.                             + INTERNET_MAX_PATH_LENGTH);
  57.  
  58.  
  59. { values returned by InternetQueryOption() with INTERNET_OPTION_KEEP_CONNECTION: }
  60.  
  61.   INTERNET_KEEP_ALIVE_UNKNOWN = -1; 
  62.   INTERNET_KEEP_ALIVE_ENABLED = 1; 
  63.   INTERNET_KEEP_ALIVE_DISABLED = 0; 
  64.  
  65. { flags returned by InternetQueryOption() with INTERNET_OPTION_REQUEST_FLAGS }
  66.  
  67.   INTERNET_REQFLAG_FROM_CACHE = $00000001; 
  68.   INTERNET_REQFLAG_ASYNC = $00000002; 
  69.  
  70. { flags common to open functions (not InternetOpen()): }
  71.  
  72.   INTERNET_FLAG_RELOAD = $80000000;                 { retrieve the original item }
  73.  
  74. { flags for InternetOpenUrl(): }
  75.  
  76.   INTERNET_FLAG_RAW_DATA = $40000000;               { receive the item as raw data }
  77.   INTERNET_FLAG_EXISTING_CONNECT = $20000000;       { do not create new connection object }
  78.  
  79. { flags for InternetOpen(): }
  80.  
  81.   INTERNET_FLAG_ASYNC = $10000000;                  { this request is asynchronous (where supported) }
  82.  
  83. { protocol-specific flags: }
  84.  
  85.   INTERNET_FLAG_PASSIVE = $08000000;                { used for FTP connections }
  86.  
  87. { additional cache flags }
  88.  
  89.   INTERNET_FLAG_DONT_CACHE = $04000000;             { don't add this item to the cache }
  90.   INTERNET_FLAG_MAKE_PERSISTENT = $02000000;        { make this item persistent in cache }
  91.  
  92. { flags field masks }
  93.  
  94.   INTERNET_FLAGS_MASK = INTERNET_FLAG_RELOAD 
  95.                                         or INTERNET_FLAG_RAW_DATA 
  96.                                         or INTERNET_FLAG_EXISTING_CONNECT 
  97.                                         or INTERNET_FLAG_ASYNC 
  98.                                         or INTERNET_FLAG_PASSIVE 
  99.                                         or INTERNET_FLAG_DONT_CACHE 
  100.                                         or INTERNET_FLAG_MAKE_PERSISTENT 
  101.                                         ; 
  102.  
  103.   INTERNET_OPTIONS_MASK =  not INTERNET_FLAGS_MASK; 
  104.  
  105. { INTERNET_NO_CALLBACK - if this value is presented as the dwContext parameter }
  106. { then no call-backs will be made for that API }
  107.  
  108.   INTERNET_NO_CALLBACK = 0; 
  109.  
  110. { structures/types }
  111.  
  112. { INTERNET_ASYNC_RESULT - this structure is returned to the application via }
  113. { the callback with INTERNET_STATUS_REQUEST_COMPLETE. It is not sufficient to }
  114. { just return the result of the async operation. If the API failed then the }
  115. { app cannot call GetLastError() because the thread context will be incorrect. }
  116. { Both the value returned by the async API and any resultant error code are }
  117. { made available. The app need not check dwError if dwResult indicates that }
  118. { the API succeeded (it will be ERROR_SUCCESS) }
  119.  
  120. type
  121.   PInternetAsyncResult = ^TInternetAsyncResult;
  122.   TInternetAsyncResult = packed record
  123.     dwResult: DWORD; { the HINTERNET, DWORD or BOOL return code from an async API }
  124.     dwError: DWORD; { dwError - the error code if the API failed }
  125.   end;
  126.  
  127.  
  128. { prototypes }
  129.  
  130. function InternetOpenA(lpszCallerName: PAnsiChar; dwAccessType: DWORD; 
  131.   lpszServerName: PAnsiChar; nServerPort: INTERNET_PORT; 
  132.   dwFlags: DWORD): HINTERNET; stdcall;
  133. function InternetOpenW(lpszCallerName: PWideChar; dwAccessType: DWORD; 
  134.   lpszServerName: PWideChar; nServerPort: INTERNET_PORT; 
  135.   dwFlags: DWORD): HINTERNET; stdcall;
  136. function InternetOpen(lpszCallerName: PChar; dwAccessType: DWORD; 
  137.   lpszServerName: PChar; nServerPort: INTERNET_PORT; 
  138.   dwFlags: DWORD): HINTERNET; stdcall;
  139.  
  140.  
  141. { access types for InternetOpen() }
  142. const
  143.   PRE_CONFIG_INTERNET_ACCESS = 0;       { use default }
  144.   LOCAL_INTERNET_ACCESS = 1;            { direct to Internet }
  145.   GATEWAY_INTERNET_ACCESS = 2;          { Internet via gateway }
  146.   CERN_PROXY_INTERNET_ACCESS = 3;       { Internet via CERN proxy }
  147.  
  148.  
  149. function InternetCloseHandle(hInet: HINTERNET): BOOL; stdcall;
  150.  
  151. function InternetConnectA(hInet: HINTERNET; lpszServerName: PAnsiChar; 
  152.   nServerPort: INTERNET_PORT; lpszUsername: PAnsiChar; lpszPassword: PAnsiChar; 
  153.   dwService: DWORD; dwFlags: DWORD; dwContext: DWORD): HINTERNET; stdcall;
  154. function InternetConnectW(hInet: HINTERNET; lpszServerName: PWideChar; 
  155.   nServerPort: INTERNET_PORT; lpszUsername: PWideChar; lpszPassword: PWideChar; 
  156.   dwService: DWORD; dwFlags: DWORD; dwContext: DWORD): HINTERNET; stdcall;
  157. function InternetConnect(hInet: HINTERNET; lpszServerName: PChar; 
  158.   nServerPort: INTERNET_PORT; lpszUsername: PChar; lpszPassword: PChar; 
  159.   dwService: DWORD; dwFlags: DWORD; dwContext: DWORD): HINTERNET; stdcall;
  160.  
  161.  
  162. { service types for InternetConnect() }
  163. const
  164.   INTERNET_SERVICE_FTP = 1; 
  165.   INTERNET_SERVICE_GOPHER = 2; 
  166.   INTERNET_SERVICE_HTTP = 3; 
  167.  
  168.  
  169. function InternetOpenUrlA(hInet: HINTERNET; lpszUrl: PAnsiChar; 
  170.   lpszHeaders: PAnsiChar; dwHeadersLength: DWORD; dwFlags: DWORD; 
  171.   dwContext: DWORD): HINTERNET; stdcall;
  172. function InternetOpenUrlW(hInet: HINTERNET; lpszUrl: PWideChar; 
  173.   lpszHeaders: PWideChar; dwHeadersLength: DWORD; dwFlags: DWORD; 
  174.   dwContext: DWORD): HINTERNET; stdcall;
  175. function InternetOpenUrl(hInet: HINTERNET; lpszUrl: PChar; 
  176.   lpszHeaders: PChar; dwHeadersLength: DWORD; dwFlags: DWORD; 
  177.   dwContext: DWORD): HINTERNET; stdcall;
  178.  
  179. function InternetReadFile(hFile: HINTERNET; lpBuffer: Pointer; 
  180.   dwNumberOfBytesToRead: DWORD; var lpdwNumberOfBytesRead: DWORD): BOOL; stdcall;
  181.  
  182. function InternetWriteFile(hFile: HINTERNET; lpBuffer: Pointer; 
  183.   dwNumberOfBytesToWrite: DWORD; 
  184.   var lpdwNumberOfBytesWritten: DWORD): BOOL; stdcall;
  185.  
  186. function InternetFindNextFileA(hFind: HINTERNET; lpvFindData: Pointer): BOOL; stdcall;
  187. function InternetFindNextFileW(hFind: HINTERNET; lpvFindData: Pointer): BOOL; stdcall;
  188. function InternetFindNextFile(hFind: HINTERNET; lpvFindData: Pointer): BOOL; stdcall;
  189.  
  190. function InternetQueryOption(hInet: HINTERNET; dwOption: DWORD; 
  191.   lpBuffer: Pointer; var lpdwBufferLength: DWORD): BOOL; stdcall;
  192.  
  193. function InternetSetOption(hInet: HINTERNET; dwOption: DWORD; 
  194.   lpBuffer: Pointer; dwBufferLength: DWORD): BOOL; stdcall;
  195.  
  196.  
  197. { options manifests for Internet(Query or Set)Option }
  198. const
  199.   INTERNET_OPTION_CALLBACK = 1; 
  200.   INTERNET_OPTION_CONNECT_TIMEOUT = 2; 
  201.   INTERNET_OPTION_CONNECT_RETRIES = 3; 
  202.   INTERNET_OPTION_CONNECT_BACKOFF = 4; 
  203.   INTERNET_OPTION_SEND_TIMEOUT = 5; 
  204.   INTERNET_OPTION_CONTROL_SEND_TIMEOUT       = INTERNET_OPTION_SEND_TIMEOUT; 
  205.   INTERNET_OPTION_RECEIVE_TIMEOUT = 6; 
  206.   INTERNET_OPTION_CONTROL_RECEIVE_TIMEOUT    = INTERNET_OPTION_RECEIVE_TIMEOUT; 
  207.   INTERNET_OPTION_DATA_SEND_TIMEOUT = 7; 
  208.   INTERNET_OPTION_DATA_RECEIVE_TIMEOUT = 8; 
  209.   INTERNET_OPTION_HANDLE_TYPE = 9; 
  210.   INTERNET_OPTION_CONTEXT_VALUE = 10; 
  211.   INTERNET_OPTION_NAME_RES_THREAD = 11; 
  212.   INTERNET_OPTION_READ_BUFFER_SIZE = 12; 
  213.   INTERNET_OPTION_WRITE_BUFFER_SIZE = 13; 
  214.   INTERNET_OPTION_GATEWAY_NAME = 14; 
  215.   INTERNET_OPTION_ASYNC_ID = 15; 
  216.   INTERNET_OPTION_ASYNC_PRIORITY = 16; 
  217.   INTERNET_OPTION_ASYNC_REQUEST_COUNT = 17; 
  218.   INTERNET_OPTION_MAXIMUM_WORKER_THREADS = 18; 
  219.   INTERNET_OPTION_ASYNC_QUEUE_DEPTH = 19; 
  220.   INTERNET_OPTION_WORKER_THREAD_TIMEOUT = 20; 
  221.   INTERNET_OPTION_PARENT_HANDLE = 21; 
  222.   INTERNET_OPTION_KEEP_CONNECTION = 22; 
  223.   INTERNET_OPTION_REQUEST_FLAGS = 23; 
  224.  
  225.   INTERNET_FIRST_OPTION                      = INTERNET_OPTION_CALLBACK; 
  226.   INTERNET_LAST_OPTION                       = INTERNET_OPTION_KEEP_CONNECTION; 
  227.  
  228.  
  229. { values for INTERNET_OPTION_PRIORITY }
  230.  
  231.   INTERNET_PRIORITY_FOREGROUND = 1000; 
  232.  
  233. { handle types }
  234.  
  235.   INTERNET_HANDLE_TYPE_INTERNET = 1; 
  236.   INTERNET_HANDLE_TYPE_CONNECT_FTP = 2; 
  237.   INTERNET_HANDLE_TYPE_CONNECT_GOPHER = 3; 
  238.   INTERNET_HANDLE_TYPE_CONNECT_HTTP = 4; 
  239.   INTERNET_HANDLE_TYPE_FTP_FIND = 5; 
  240.   INTERNET_HANDLE_TYPE_FTP_FIND_HTML = 6; 
  241.   INTERNET_HANDLE_TYPE_FTP_FILE = 7; 
  242.   INTERNET_HANDLE_TYPE_FTP_FILE_HTML = 8; 
  243.   INTERNET_HANDLE_TYPE_GOPHER_FIND = 9; 
  244.   INTERNET_HANDLE_TYPE_GOPHER_FIND_HTML = 10; 
  245.   INTERNET_HANDLE_TYPE_GOPHER_FILE = 11; 
  246.   INTERNET_HANDLE_TYPE_GOPHER_FILE_HTML = 12; 
  247.   INTERNET_HANDLE_TYPE_HTTP_REQUEST = 13; 
  248.  
  249.  
  250. function InternetGetLastResponseInfoA(var lpdwError: DWORD; lpszBuffer: PAnsiChar; 
  251.   var lpdwBufferLength: DWORD): BOOL; stdcall;
  252. function InternetGetLastResponseInfoW(var lpdwError: DWORD; lpszBuffer: PWideChar; 
  253.   var lpdwBufferLength: DWORD): BOOL; stdcall;
  254. function InternetGetLastResponseInfo(var lpdwError: DWORD; lpszBuffer: PChar; 
  255.   var lpdwBufferLength: DWORD): BOOL; stdcall;
  256.  
  257. { callback function for InternetSetStatusCallback }
  258. type
  259.   TFNInternetStatusCallback = TFarProc;
  260.   PFNInternetStatusCallback = ^TFNInternetStatusCallback;
  261.  
  262.  
  263. function InternetSetStatusCallback(hInet: HINTERNET; 
  264.   lpfnInternetCallback: PFNInternetStatusCallback): PFNInternetStatusCallback; stdcall;
  265.  
  266.  
  267. { status manifests for Internet status callback }
  268. const
  269.   INTERNET_STATUS_RESOLVING_NAME = 10; 
  270.   INTERNET_STATUS_NAME_RESOLVED = 11; 
  271.   INTERNET_STATUS_CONNECTING_TO_SERVER = 20; 
  272.   INTERNET_STATUS_CONNECTED_TO_SERVER = 21; 
  273.   INTERNET_STATUS_SENDING_REQUEST = 30; 
  274.   INTERNET_STATUS_REQUEST_SENT = 31; 
  275.   INTERNET_STATUS_RECEIVING_RESPONSE = 40; 
  276.   INTERNET_STATUS_RESPONSE_RECEIVED = 41; 
  277.   INTERNET_STATUS_CTL_RESPONSE_RECEIVED = 42;       { FTP-only: response on control channel }
  278.   INTERNET_STATUS_CLOSING_CONNECTION = 50; 
  279.   INTERNET_STATUS_CONNECTION_CLOSED = 51; 
  280.   INTERNET_STATUS_HANDLE_CREATED = 60; 
  281.   INTERNET_STATUS_REQUEST_COMPLETE = 100; 
  282.  
  283.  
  284. { if the following value is returned by InternetSetStatusCallback, then }
  285. { probably an invalid (non-code) address was supplied for the callback }
  286.  
  287.   INTERNET_INVALID_STATUS_CALLBACK = (-1); 
  288.  
  289. function InternetCancelAsyncRequest(dwAsyncId: DWORD): BOOL; stdcall;
  290.  
  291. { FTP }
  292.  
  293. { manifests }
  294. const
  295.   FTP_TRANSFER_TYPE_UNKNOWN = $00000000; 
  296.   FTP_TRANSFER_TYPE_ASCII = $00000001; 
  297.   FTP_TRANSFER_TYPE_BINARY = $00000002; 
  298.  
  299.   FTP_TRANSFER_TYPE_MASK = $00000003; 
  300.  
  301.  
  302. { prototypes }
  303.  
  304. function FtpFindFirstFileA(hFtpSession: HINTERNET; lpszSearchFile: PAnsiChar; 
  305.   var lpFindFileData: TWin32FindDataA; dwFlags: DWORD; 
  306.   dwContext: DWORD): HINTERNET; stdcall;
  307. function FtpFindFirstFileW(hFtpSession: HINTERNET; lpszSearchFile: PWideChar; 
  308.   var lpFindFileData: TWin32FindDataW; dwFlags: DWORD; 
  309.   dwContext: DWORD): HINTERNET; stdcall;
  310. function FtpFindFirstFile(hFtpSession: HINTERNET; lpszSearchFile: PChar; 
  311.   var lpFindFileData: TWin32FindData; dwFlags: DWORD; 
  312.   dwContext: DWORD): HINTERNET; stdcall;
  313.  
  314. function FtpGetFileA(hFtpSession: HINTERNET; lpszRemoteFile: PAnsiChar; 
  315.   lpszNewFile: PAnsiChar; fFailIfExists: BOOL; dwFlagsAndAttributes: DWORD; 
  316.   dwFlags: DWORD; dwContext: DWORD): BOOL stdcall;
  317. function FtpGetFileW(hFtpSession: HINTERNET; lpszRemoteFile: PWideChar; 
  318.   lpszNewFile: PWideChar; fFailIfExists: BOOL; dwFlagsAndAttributes: DWORD; 
  319.   dwFlags: DWORD; dwContext: DWORD): BOOL stdcall;
  320. function FtpGetFile(hFtpSession: HINTERNET; lpszRemoteFile: PChar; 
  321.   lpszNewFile: PChar; fFailIfExists: BOOL; dwFlagsAndAttributes: DWORD; 
  322.   dwFlags: DWORD; dwContext: DWORD): BOOL stdcall;
  323.  
  324. function FtpPutFileA(hFtpSession: HINTERNET; lpszLocalFile: PAnsiChar; 
  325.   lpszNewRemoteFile: PAnsiChar; dwFlags: DWORD; dwContext: DWORD): BOOL; stdcall;
  326. function FtpPutFileW(hFtpSession: HINTERNET; lpszLocalFile: PWideChar; 
  327.   lpszNewRemoteFile: PWideChar; dwFlags: DWORD; dwContext: DWORD): BOOL; stdcall;
  328. function FtpPutFile(hFtpSession: HINTERNET; lpszLocalFile: PChar; 
  329.   lpszNewRemoteFile: PChar; dwFlags: DWORD; dwContext: DWORD): BOOL; stdcall;
  330.  
  331. function FtpDeleteFileA(hFtpSession: HINTERNET; lpszFileName: PAnsiChar): BOOL; stdcall;
  332. function FtpDeleteFileW(hFtpSession: HINTERNET; lpszFileName: PWideChar): BOOL; stdcall;
  333. function FtpDeleteFile(hFtpSession: HINTERNET; lpszFileName: PChar): BOOL; stdcall;
  334.  
  335. function FtpRenameFileA(hFtpSession: HINTERNET; lpszExisting: PAnsiChar; 
  336.   lpszNew: PAnsiChar): BOOL; stdcall;
  337. function FtpRenameFileW(hFtpSession: HINTERNET; lpszExisting: PWideChar; 
  338.   lpszNew: PWideChar): BOOL; stdcall;
  339. function FtpRenameFile(hFtpSession: HINTERNET; lpszExisting: PChar; 
  340.   lpszNew: PChar): BOOL; stdcall;
  341.  
  342. function FtpOpenFileA(hFtpSession: HINTERNET; lpszFileName: PAnsiChar; 
  343.   dwAccess: DWORD; dwFlags: DWORD; dwContext: DWORD): HINTERNET; stdcall;
  344. function FtpOpenFileW(hFtpSession: HINTERNET; lpszFileName: PWideChar; 
  345.   dwAccess: DWORD; dwFlags: DWORD; dwContext: DWORD): HINTERNET; stdcall;
  346. function FtpOpenFile(hFtpSession: HINTERNET; lpszFileName: PChar; 
  347.   dwAccess: DWORD; dwFlags: DWORD; dwContext: DWORD): HINTERNET; stdcall;
  348.  
  349. function FtpCreateDirectoryA(hFtpSession: HINTERNET; lpszDirectory: PAnsiChar): BOOL; stdcall;
  350. function FtpCreateDirectoryW(hFtpSession: HINTERNET; lpszDirectory: PWideChar): BOOL; stdcall;
  351. function FtpCreateDirectory(hFtpSession: HINTERNET; lpszDirectory: PChar): BOOL; stdcall;
  352.  
  353. function FtpRemoveDirectoryA(hFtpSession: HINTERNET; lpszDirectory: PAnsiChar): BOOL; stdcall;
  354. function FtpRemoveDirectoryW(hFtpSession: HINTERNET; lpszDirectory: PWideChar): BOOL; stdcall;
  355. function FtpRemoveDirectory(hFtpSession: HINTERNET; lpszDirectory: PChar): BOOL; stdcall;
  356.  
  357. function FtpSetCurrentDirectoryA(hFtpSession: HINTERNET; lpszDirectory: PAnsiChar): BOOL; stdcall;
  358. function FtpSetCurrentDirectoryW(hFtpSession: HINTERNET; lpszDirectory: PWideChar): BOOL; stdcall;
  359. function FtpSetCurrentDirectory(hFtpSession: HINTERNET; lpszDirectory: PChar): BOOL; stdcall;
  360.  
  361. function FtpGetCurrentDirectoryA(hFtpSession: HINTERNET; 
  362.   lpszCurrentDirectory: PAnsiChar; var lpdwCurrentDirectory: DWORD): BOOL; stdcall;
  363. function FtpGetCurrentDirectoryW(hFtpSession: HINTERNET; 
  364.   lpszCurrentDirectory: PWideChar; var lpdwCurrentDirectory: DWORD): BOOL; stdcall;
  365. function FtpGetCurrentDirectory(hFtpSession: HINTERNET; 
  366.   lpszCurrentDirectory: PChar; var lpdwCurrentDirectory: DWORD): BOOL; stdcall;
  367.  
  368. function FtpCommandA(hFtpSession: HINTERNET; fExpectResponse: BOOL; 
  369.   dwFlags: DWORD; lpszCommand: PAnsiChar; dwContext: DWORD): BOOL; stdcall;
  370. function FtpCommandW(hFtpSession: HINTERNET; fExpectResponse: BOOL; 
  371.   dwFlags: DWORD; lpszCommand: PWideChar; dwContext: DWORD): BOOL; stdcall;
  372. function FtpCommand(hFtpSession: HINTERNET; fExpectResponse: BOOL; 
  373.   dwFlags: DWORD; lpszCommand: PChar; dwContext: DWORD): BOOL; stdcall;
  374.  
  375.  
  376. { Gopher }
  377.  
  378. { manifests }
  379.  
  380. { string field lengths (in characters, not bytes) }
  381. const
  382.   MAX_GOPHER_DISPLAY_TEXT   = 128; 
  383.   MAX_GOPHER_SELECTOR_TEXT  = 256; 
  384.   MAX_GOPHER_HOST_NAME      = INTERNET_MAX_HOST_NAME_LENGTH; 
  385.   MAX_GOPHER_LOCATOR_LENGTH = 1                                  
  386.                               + MAX_GOPHER_DISPLAY_TEXT           
  387.                               + 1                                 
  388.                               + MAX_GOPHER_SELECTOR_TEXT          
  389.                               + 1                                 
  390.                               + MAX_GOPHER_HOST_NAME              
  391.                               + 1                                 
  392.                               + INTERNET_MAX_PORT_NUMBER_LENGTH   
  393.                               + 1                                 
  394.                               + 1                                 
  395.                               + 2; 
  396.  
  397.  
  398. { structures/types }
  399.  
  400. { GOPHER_FIND_DATA - returns the results of a GopherFindFirstFile()/ }
  401. { InternetFindNextFile() request }
  402.  
  403. type
  404.   PGopherFindData = ^TGopherFindData;
  405.   TGopherFindData = packed record
  406.  
  407.     { DisplayString - points to the string to be displayed by the client (i.e. }
  408.     { the file or directory name) }
  409.     DisplayString: packed array[0..MAX_GOPHER_DISPLAY_TEXT-1] of WCHAR; //!!!
  410.  
  411.     GopherType: DWORD;  { GopherType - bitmap which describes the item returned. See below }
  412.  
  413.     { SizeLow and SizeHigh - (approximate) size of the item, if the gopher }
  414.     { server reports it }
  415.     SizeLow: DWORD;
  416.     SizeHigh: DWORD;
  417.  
  418.     { LastModificationTime - time in Win32 format that this item was last }
  419.     { modified, if the gopher server reports it }
  420.     LastModificationTime: TFileTime;
  421.  
  422.     { Locator - the gopher locator string returned from the server, or created }
  423.     { via GopherCreateLocator }
  424.     Locator: packed array[0..MAX_GOPHER_LOCATOR_LENGTH-1] of WCHAR;
  425.   end;
  426.  
  427.  
  428. { manifests for GopherType }
  429. const
  430.   GOPHER_TYPE_TEXT_FILE = $00000001; 
  431.   GOPHER_TYPE_DIRECTORY = $00000002; 
  432.   GOPHER_TYPE_CSO = $00000004; 
  433.   GOPHER_TYPE_ERROR = $00000008; 
  434.   GOPHER_TYPE_MAC_BINHEX = $00000010; 
  435.   GOPHER_TYPE_DOS_ARCHIVE = $00000020; 
  436.   GOPHER_TYPE_UNIX_UUENCODED = $00000040; 
  437.   GOPHER_TYPE_INDEX_SERVER = $00000080; 
  438.   GOPHER_TYPE_TELNET = $00000100; 
  439.   GOPHER_TYPE_BINARY = $00000200; 
  440.   GOPHER_TYPE_REDUNDANT = $00000400; 
  441.   GOPHER_TYPE_TN3270 = $00000800; 
  442.   GOPHER_TYPE_GIF = $00001000; 
  443.   GOPHER_TYPE_IMAGE = $00002000; 
  444.   GOPHER_TYPE_BITMAP = $00004000; 
  445.   GOPHER_TYPE_MOVIE = $00008000; 
  446.   GOPHER_TYPE_SOUND = $00010000; 
  447.   GOPHER_TYPE_HTML = $00020000; 
  448.   GOPHER_TYPE_PDF = $00040000; 
  449.   GOPHER_TYPE_CALENDAR = $00080000; 
  450.   GOPHER_TYPE_INLINE = $00100000; 
  451.   GOPHER_TYPE_UNKNOWN = $20000000; 
  452.   GOPHER_TYPE_ASK = $40000000; 
  453.   GOPHER_TYPE_GOPHER_PLUS = $80000000; 
  454.  
  455.  
  456. { Gopher Type functions }
  457.  
  458. function IS_GOPHER_FILE(GopherType: DWORD): BOOL;
  459. function IS_GOPHER_DIRECTORY(GopherType: DWORD): BOOL;
  460. function IS_GOPHER_PHONE_SERVER(GopherType: DWORD): BOOL;
  461. function IS_GOPHER_ERROR(GopherType: DWORD): BOOL;
  462. function IS_GOPHER_INDEX_SERVER(GopherType: DWORD): BOOL;
  463. function IS_GOPHER_TELNET_SESSION(GopherType: DWORD): BOOL;
  464. function IS_GOPHER_BACKUP_SERVER(GopherType: DWORD): BOOL;
  465. function IS_GOPHER_TN3270_SESSION(GopherType: DWORD): BOOL;
  466. function IS_GOPHER_ASK(GopherType: DWORD): BOOL;
  467. function IS_GOPHER_PLUS(GopherType: DWORD): BOOL;
  468. function IS_GOPHER_TYPE_KNOWN(GopherType: DWORD): BOOL;
  469.  
  470.  
  471. { GOPHER_TYPE_FILE_MASK - use this to determine if a locator identifies a }
  472. { (known) file type }
  473. const
  474.   GOPHER_TYPE_FILE_MASK = GOPHER_TYPE_TEXT_FILE          
  475.                           or GOPHER_TYPE_MAC_BINHEX        
  476.                           or GOPHER_TYPE_DOS_ARCHIVE       
  477.                           or GOPHER_TYPE_UNIX_UUENCODED    
  478.                           or GOPHER_TYPE_BINARY            
  479.                           or GOPHER_TYPE_GIF               
  480.                           or GOPHER_TYPE_IMAGE             
  481.                           or GOPHER_TYPE_BITMAP            
  482.                           or GOPHER_TYPE_MOVIE             
  483.                           or GOPHER_TYPE_SOUND             
  484.                           or GOPHER_TYPE_HTML              
  485.                           or GOPHER_TYPE_PDF               
  486.                           or GOPHER_TYPE_CALENDAR          
  487.                           or GOPHER_TYPE_INLINE; 
  488.  
  489.  
  490. { structured gopher attributes (as defined in gopher+ protocol document) }
  491. type
  492.   PGopherAdminAttributeType = ^TGopherAdminAttributeType;
  493.   TGopherAdminAttributeType = packed record 
  494.     Comment: LPCSTR;
  495.     EmailAddress: LPCSTR;
  496.   end;
  497.  
  498.   PGopherModDateAttributeType = ^TGopherModDateAttributeType;
  499.   TGopherModDateAttributeType = packed record 
  500.     DateAndTime: TFileTime;
  501.   end;
  502.  
  503.   PGopherTtlAttributeType = ^TGopherTtlAttributeType;
  504.   TGopherTtlAttributeType = packed record 
  505.     Ttl: DWORD;
  506.   end;
  507.  
  508.   PGopherScoreAttributeType = ^TGopherScoreAttributeType;
  509.   TGopherScoreAttributeType = packed record 
  510.     Score: Integer;
  511.   end;
  512.  
  513.   PGopherScoreRangeAttributeType = ^TGopherScoreRangeAttributeType;
  514.   TGopherScoreRangeAttributeType = packed record 
  515.     LowerBound: Integer;
  516.     UpperBound: Integer;
  517.   end;
  518.  
  519.   PGopherSiteAttributeType = ^TGopherSiteAttributeType;
  520.   TGopherSiteAttributeType = packed record 
  521.     Site: LPCSTR;
  522.   end;
  523.  
  524.   PGopherOrganizationAttributeType = ^TGopherOrganizationAttributeType;
  525.   TGopherOrganizationAttributeType = packed record 
  526.     Organization: LPCSTR;
  527.   end;
  528.  
  529.   PGopherLocationAttributeType = ^TGopherLocationAttributeType;
  530.   TGopherLocationAttributeType = packed record 
  531.     Location: LPCSTR;
  532.   end;
  533.  
  534.   PGopherGeographicalLocationAttributeType = ^TGopherGeographicalLocationAttributeType;
  535.   TGopherGeographicalLocationAttributeType = packed record 
  536.     DegreesNorth: Integer;
  537.     MinutesNorth: Integer;
  538.     SecondsNorth: Integer;
  539.     DegreesEast: Integer;
  540.     MinutesEast: Integer;
  541.     SecondsEast: Integer;
  542.   end;
  543.  
  544.   PGopherTimezoneAttributeType = ^TGopherTimezoneAttributeType;
  545.   TGopherTimezoneAttributeType = packed record 
  546.     Zone: Integer;
  547.   end;
  548.  
  549.   PGopherProviderAttributeType = ^TGopherProviderAttributeType;
  550.   TGopherProviderAttributeType = packed record 
  551.     Provider: LPCSTR;
  552.   end;
  553.  
  554.   PGopherVersionAttributeType = ^TGopherVersionAttributeType;
  555.   TGopherVersionAttributeType = packed record 
  556.     Version: LPCSTR;
  557.   end;
  558.  
  559.   PGopherAbstractAttributeType = ^TGopherAbstractAttributeType;
  560.   TGopherAbstractAttributeType = packed record 
  561.     ShortAbstract: LPCSTR;
  562.     AbstractFile: LPCSTR;
  563.   end;
  564.  
  565.   PGopherViewAttributeType = ^TGopherViewAttributeType;
  566.   TGopherViewAttributeType = packed record 
  567.     ContentType: LPCSTR;
  568.     Language: LPCSTR;
  569.     Size: DWORD;
  570.   end;
  571.  
  572.   PGopherVeronicaAttributeType = ^TGopherVeronicaAttributeType;
  573.   TGopherVeronicaAttributeType = packed record 
  574.     TreeWalk: BOOL;
  575.   end;
  576.  
  577.   PGopherAskAttributeType = ^TGopherAskAttributeType;
  578.   TGopherAskAttributeType = packed record 
  579.     QuestionType: LPCSTR;
  580.     QuestionText: LPCSTR;
  581.   end;
  582.  
  583.  
  584. { GOPHER_UNKNOWN_ATTRIBUTE_TYPE - this is returned if we retrieve an attribute }
  585. { that is not specified in the current gopher/gopher+ documentation. It is up }
  586. { to the application to parse the information }
  587.  
  588.   PGopherUnknownAttributeType = ^TGopherUnknownAttributeType;
  589.   TGopherUnknownAttributeType = packed record 
  590.     Text: LPCSTR;
  591.   end;
  592.  
  593.  
  594. { GOPHER_ATTRIBUTE_TYPE - returned in the user's buffer when an enumerated }
  595. { GopherGetAttribute call is made }
  596.  
  597.   PGopherAttributeType = ^TGopherAttributeType;
  598.   TGopherAttributeType = packed record 
  599.     CategoryId: DWORD;  { e.g. GOPHER_CATEGORY_ID_ADMIN }
  600.     AttributeId: DWORD; { e.g. GOPHER_ATTRIBUTE_ID_ADMIN }
  601.     case Integer of
  602.       0: (Admin: TGopherAdminAttributeType);
  603.       1: (ModDate: TGopherModDateAttributeType);
  604.       2: (Ttl: TGopherTtlAttributeType);
  605.       3: (Score: TGopherScoreAttributeType);
  606.       4: (ScoreRange: TGopherScoreRangeAttributeType);
  607.       5: (Site: TGopherSiteAttributeType);
  608.       6: (Organization: TGopherOrganizationAttributeType);
  609.       7: (Location: TGopherLocationAttributeType);
  610.       8: (GeographicalLocation: TGopherGeographicalLocationAttributeType);
  611.       9: (TimeZone: TGopherTimezoneAttributeType);
  612.       10: (Provider: TGopherProviderAttributeType);
  613.       11: (Version: TGopherVersionAttributeType);
  614.       12: (Abstract: TGopherAbstractAttributeType);
  615.       13: (View: TGopherViewAttributeType);
  616.       14: (Veronica: TGopherVeronicaAttributeType);
  617.       15: (Ask: TGopherAskAttributeType);
  618.       16: (Unknown: TGopherUnknownAttributeType);
  619.   end;
  620.  
  621. const
  622.   MAX_GOPHER_CATEGORY_NAME = 128;           { arbitrary }
  623.   MAX_GOPHER_ATTRIBUTE_NAME = 128;          {     " }
  624.   MIN_GOPHER_ATTRIBUTE_LENGTH = 256;        {     " }
  625.  
  626.  
  627. { known gopher attribute categories. See below for ordinals }
  628.  
  629.   GOPHER_INFO_CATEGORY           = '+INFO'; 
  630.   GOPHER_ADMIN_CATEGORY          = '+ADMIN'; 
  631.   GOPHER_VIEWS_CATEGORY          = '+VIEWS'; 
  632.   GOPHER_ABSTRACT_CATEGORY       = '+ABSTRACT'; 
  633.   GOPHER_VERONICA_CATEGORY       = '+VERONICA'; 
  634.  
  635.  
  636. { known gopher attributes. These are the attribute names as defined in the }
  637. { gopher+ protocol document }
  638.  
  639.   GOPHER_ADMIN_ATTRIBUTE         = 'Admin'; 
  640.   GOPHER_MOD_DATE_ATTRIBUTE      = 'Mod-Date'; 
  641.   GOPHER_TTL_ATTRIBUTE           = 'TTL'; 
  642.   GOPHER_SCORE_ATTRIBUTE         = 'Score'; 
  643.   GOPHER_RANGE_ATTRIBUTE         = 'Score-range'; 
  644.   GOPHER_SITE_ATTRIBUTE          = 'Site'; 
  645.   GOPHER_ORG_ATTRIBUTE           = 'Org'; 
  646.   GOPHER_LOCATION_ATTRIBUTE      = 'Loc'; 
  647.   GOPHER_GEOG_ATTRIBUTE          = 'Geog'; 
  648.   GOPHER_TIMEZONE_ATTRIBUTE      = 'TZ'; 
  649.   GOPHER_PROVIDER_ATTRIBUTE      = 'Provider'; 
  650.   GOPHER_VERSION_ATTRIBUTE       = 'Version'; 
  651.   GOPHER_ABSTRACT_ATTRIBUTE      = 'Abstract'; 
  652.   GOPHER_VIEW_ATTRIBUTE          = 'View'; 
  653.   GOPHER_TREEWALK_ATTRIBUTE      = 'treewalk'; 
  654.  
  655.  
  656. { identifiers for attribute strings }
  657.  
  658.   GOPHER_ATTRIBUTE_ID_BASE = $abcccc00; 
  659.   GOPHER_CATEGORY_ID_ALL = GOPHER_ATTRIBUTE_ID_BASE + 1; 
  660.   GOPHER_CATEGORY_ID_INFO = GOPHER_ATTRIBUTE_ID_BASE + 2; 
  661.   GOPHER_CATEGORY_ID_ADMIN = GOPHER_ATTRIBUTE_ID_BASE + 3; 
  662.   GOPHER_CATEGORY_ID_VIEWS = GOPHER_ATTRIBUTE_ID_BASE + 4; 
  663.   GOPHER_CATEGORY_ID_ABSTRACT = GOPHER_ATTRIBUTE_ID_BASE + 5; 
  664.   GOPHER_CATEGORY_ID_VERONICA = GOPHER_ATTRIBUTE_ID_BASE + 6; 
  665.   GOPHER_CATEGORY_ID_ASK = GOPHER_ATTRIBUTE_ID_BASE + 7; 
  666.   GOPHER_CATEGORY_ID_UNKNOWN = GOPHER_ATTRIBUTE_ID_BASE + 8; 
  667.   GOPHER_ATTRIBUTE_ID_ALL = GOPHER_ATTRIBUTE_ID_BASE + 9; 
  668.   GOPHER_ATTRIBUTE_ID_ADMIN = GOPHER_ATTRIBUTE_ID_BASE + 10; 
  669.   GOPHER_ATTRIBUTE_ID_MOD_DATE = GOPHER_ATTRIBUTE_ID_BASE + 11; 
  670.   GOPHER_ATTRIBUTE_ID_TTL = GOPHER_ATTRIBUTE_ID_BASE + 12; 
  671.   GOPHER_ATTRIBUTE_ID_SCORE = GOPHER_ATTRIBUTE_ID_BASE + 13; 
  672.   GOPHER_ATTRIBUTE_ID_RANGE = GOPHER_ATTRIBUTE_ID_BASE + 14; 
  673.   GOPHER_ATTRIBUTE_ID_SITE = GOPHER_ATTRIBUTE_ID_BASE + 15; 
  674.   GOPHER_ATTRIBUTE_ID_ORG = GOPHER_ATTRIBUTE_ID_BASE + 16; 
  675.   GOPHER_ATTRIBUTE_ID_LOCATION = GOPHER_ATTRIBUTE_ID_BASE + 17; 
  676.   GOPHER_ATTRIBUTE_ID_GEOG = GOPHER_ATTRIBUTE_ID_BASE + 18; 
  677.   GOPHER_ATTRIBUTE_ID_TIMEZONE = GOPHER_ATTRIBUTE_ID_BASE + 19; 
  678.   GOPHER_ATTRIBUTE_ID_PROVIDER = GOPHER_ATTRIBUTE_ID_BASE + 20; 
  679.   GOPHER_ATTRIBUTE_ID_VERSION = GOPHER_ATTRIBUTE_ID_BASE + 21; 
  680.   GOPHER_ATTRIBUTE_ID_ABSTRACT = GOPHER_ATTRIBUTE_ID_BASE + 22; 
  681.   GOPHER_ATTRIBUTE_ID_VIEW = GOPHER_ATTRIBUTE_ID_BASE + 23; 
  682.   GOPHER_ATTRIBUTE_ID_TREEWALK = GOPHER_ATTRIBUTE_ID_BASE + 24; 
  683.   GOPHER_ATTRIBUTE_ID_UNKNOWN = GOPHER_ATTRIBUTE_ID_BASE + 25; 
  684.  
  685.  
  686. { prototypes }
  687.  
  688. function GopherCreateLocatorA(lpszHost: PAnsiChar; nServerPort: INTERNET_PORT; 
  689.   lpszDisplayString: PAnsiChar; lpszSelectorString: PAnsiChar; dwGopherType: DWORD; 
  690.   lpszLocator: PAnsiChar; var lpdwBufferLength: DWORD): BOOL; stdcall;
  691. function GopherCreateLocatorW(lpszHost: PWideChar; nServerPort: INTERNET_PORT; 
  692.   lpszDisplayString: PWideChar; lpszSelectorString: PWideChar; dwGopherType: DWORD; 
  693.   lpszLocator: PWideChar; var lpdwBufferLength: DWORD): BOOL; stdcall;
  694. function GopherCreateLocator(lpszHost: PChar; nServerPort: INTERNET_PORT; 
  695.   lpszDisplayString: PChar; lpszSelectorString: PChar; dwGopherType: DWORD; 
  696.   lpszLocator: PChar; var lpdwBufferLength: DWORD): BOOL; stdcall;
  697.  
  698. function GopherGetLocatorTypeA(lpszLocator: PAnsiChar; 
  699.   var lpdwGopherType: DWORD): BOOL; stdcall;
  700. function GopherGetLocatorTypeW(lpszLocator: PWideChar; 
  701.   var lpdwGopherType: DWORD): BOOL; stdcall;
  702. function GopherGetLocatorType(lpszLocator: PChar; 
  703.   var lpdwGopherType: DWORD): BOOL; stdcall;
  704.  
  705. function GopherFindFirstFileA(hGopherSession: HINTERNET; lpszLocator: PAnsiChar; 
  706.   lpszSearchString: PAnsiChar; var lpFindData: TGopherFindData; dwFlags: DWORD; 
  707.   dwContext: DWORD): HINTERNET; stdcall;
  708. function GopherFindFirstFileW(hGopherSession: HINTERNET; lpszLocator: PWideChar; 
  709.   lpszSearchString: PWideChar; var lpFindData: TGopherFindData; dwFlags: DWORD; 
  710.   dwContext: DWORD): HINTERNET; stdcall;
  711. function GopherFindFirstFile(hGopherSession: HINTERNET; lpszLocator: PChar; 
  712.   lpszSearchString: PChar; var lpFindData: TGopherFindData; dwFlags: DWORD; 
  713.   dwContext: DWORD): HINTERNET; stdcall;
  714.  
  715. function GopherOpenFileA(hGopherSession: HINTERNET; lpszLocator: PAnsiChar; 
  716.   lpszView: PAnsiChar; dwFlags: DWORD; dwContext: DWORD): HINTERNET; stdcall;
  717. function GopherOpenFileW(hGopherSession: HINTERNET; lpszLocator: PWideChar; 
  718.   lpszView: PWideChar; dwFlags: DWORD; dwContext: DWORD): HINTERNET; stdcall;
  719. function GopherOpenFile(hGopherSession: HINTERNET; lpszLocator: PChar; 
  720.   lpszView: PChar; dwFlags: DWORD; dwContext: DWORD): HINTERNET; stdcall;
  721.  
  722. type
  723.   TFNGopherAttributeEnumerator = TFarProc;
  724.   PFNGopherAttributeEnumerator = ^TFNGopherAttributeEnumerator;
  725.  
  726. function GopherGetAttributeA(hGopherSession: HINTERNET; lpszLocator: PAnsiChar; 
  727.   lpszAttributeName: PAnsiChar; lpBuffer: Pointer; dwBufferLength: DWORD; 
  728.   var lpdwCharactersReturned: DWORD; lpfnEnumerator: PFNGopherAttributeEnumerator;
  729.   dwContext: DWORD): BOOL; stdcall;
  730. function GopherGetAttributeW(hGopherSession: HINTERNET; lpszLocator: PWideChar; 
  731.   lpszAttributeName: PWideChar; lpBuffer: Pointer; dwBufferLength: DWORD; 
  732.   var lpdwCharactersReturned: DWORD; lpfnEnumerator: PFNGopherAttributeEnumerator;
  733.   dwContext: DWORD): BOOL; stdcall;
  734. function GopherGetAttribute(hGopherSession: HINTERNET; lpszLocator: PChar; 
  735.   lpszAttributeName: PChar; lpBuffer: Pointer; dwBufferLength: DWORD; 
  736.   var lpdwCharactersReturned: DWORD; lpfnEnumerator: PFNGopherAttributeEnumerator;
  737.   dwContext: DWORD): BOOL; stdcall;
  738.  
  739. function GopherSendDataA(hGopherSession: HINTERNET; lpszLocator: PAnsiChar; 
  740.   lpszBuffer: PAnsiChar; dwNumberOfCharactersToSend: DWORD; 
  741.   var lpdwNumberOfCharactersSent: DWORD; dwContext: DWORD): BOOL; stdcall;
  742. function GopherSendDataW(hGopherSession: HINTERNET; lpszLocator: PWideChar; 
  743.   lpszBuffer: PWideChar; dwNumberOfCharactersToSend: DWORD; 
  744.   var lpdwNumberOfCharactersSent: DWORD; dwContext: DWORD): BOOL; stdcall;
  745. function GopherSendData(hGopherSession: HINTERNET; lpszLocator: PChar; 
  746.   lpszBuffer: PChar; dwNumberOfCharactersToSend: DWORD; 
  747.   var lpdwNumberOfCharactersSent: DWORD; dwContext: DWORD): BOOL; stdcall;
  748.  
  749.  
  750. { HTTP }
  751.  
  752. { manifests }
  753. const
  754.   HTTP_TCPIP_PORT = 80; {  The default HTTP port for TCP/IP connections. }
  755.  
  756.  
  757. { The default major/minor HTTP version numbers. }
  758.  
  759.   HTTP_MAJOR_VERSION = 1; 
  760.   HTTP_MINOR_VERSION = 0; 
  761.   HTTP_VERSION       = 'HTTP/1'; 
  762.  
  763.  
  764. { HttpQueryInfo info levels. Generally, there is one info level }
  765. { for each potential RFC822/HTTP/MIME header that an HTTP server }
  766. { may send as part of a request response. }
  767.  
  768. { The HTTP_QUERY_RAW_HEADERS info level is provided for clients }
  769. { that choose to perform their own header parsing. }
  770.  
  771.   HTTP_QUERY_MIN = $0000; 
  772.   HTTP_QUERY_MIME_VERSION = $0000; 
  773.   HTTP_QUERY_CONTENT_TYPE = $0001; 
  774.   HTTP_QUERY_CONTENT_TRANSFER_ENCODING = $0002; 
  775.   HTTP_QUERY_CONTENT_ID = $0003; 
  776.   HTTP_QUERY_CONTENT_DESCRIPTION = $0004; 
  777.   HTTP_QUERY_CONTENT_LENGTH = $0005; 
  778.   HTTP_QUERY_CONTENT_LANGUAGE = $0006; 
  779.   HTTP_QUERY_ALLOW = $0007; 
  780.   HTTP_QUERY_PUBLIC = $0008; 
  781.   HTTP_QUERY_DATE = $0009; 
  782.   HTTP_QUERY_EXPIRES = $000A; 
  783.   HTTP_QUERY_LAST_MODIFIED = $000B; 
  784.   HTTP_QUERY_MESSAGE_ID = $000C; 
  785.   HTTP_QUERY_URI = $000D; 
  786.   HTTP_QUERY_DERIVED_FROM = $000E; 
  787.   HTTP_QUERY_COST = $000F; 
  788.   HTTP_QUERY_LINK = $0010; 
  789.   HTTP_QUERY_PRAGMA = $0011; 
  790.   HTTP_QUERY_VERSION = $0012; 
  791.   HTTP_QUERY_STATUS_CODE = $0013; 
  792.   HTTP_QUERY_STATUS_TEXT = $0014; 
  793.   HTTP_QUERY_RAW_HEADERS = $0015; 
  794.   HTTP_QUERY_RAW_HEADERS_CRLF = $0016; 
  795.   HTTP_QUERY_CONNECTION = $0017; 
  796.   HTTP_QUERY_MAX = $0017; 
  797.  
  798.  
  799. {  HTTP Response Status Codes: }
  800.  
  801.   HTTP_STATUS_OK = 200;                     { request completed }
  802.   HTTP_STATUS_CREATED = 201;                { object created, reason = new URI }
  803.   HTTP_STATUS_ACCEPTED = 202;               { async completion (TBS) }
  804.   HTTP_STATUS_PARTIAL = 203;                { partial completion }
  805.  
  806.   HTTP_STATUS_MOVED = 301;                  { object permanently moved }
  807.   HTTP_STATUS_REDIRECT = 302;               { object temporarily moved }
  808.   HTTP_STATUS_REDIRECT_METHOD = 303;        { redirection w/ new access method }
  809.  
  810.   HTTP_STATUS_BAD_REQUEST = 400;            { invalid syntax }
  811.   HTTP_STATUS_DENIED = 401;                 { access denied }
  812.   HTTP_STATUS_PAYMENT_REQ = 402;            { payment required }
  813.   HTTP_STATUS_FORBIDDEN = 403;              { request forbidden }
  814.   HTTP_STATUS_NOT_FOUND = 404;              { object not found }
  815.  
  816.   HTTP_STATUS_SERVER_ERROR = 500;           { internal server error }
  817.   HTTP_STATUS_NOT_SUPPORTED = 501;          { required not supported }
  818.  
  819.  
  820. { prototypes }
  821.  
  822. function HttpOpenRequestA(hHttpSession: HINTERNET; lpszVerb: PAnsiChar; 
  823.   lpszObjectName: PAnsiChar; lpszVersion: PAnsiChar; lpszReferrer: PAnsiChar; 
  824.   lplpszAcceptTypes: PAnsiChar; dwFlags: DWORD; 
  825.   dwContext: DWORD): HINTERNET; stdcall;
  826. function HttpOpenRequestW(hHttpSession: HINTERNET; lpszVerb: PWideChar; 
  827.   lpszObjectName: PWideChar; lpszVersion: PWideChar; lpszReferrer: PWideChar; 
  828.   lplpszAcceptTypes: PWideChar; dwFlags: DWORD; 
  829.   dwContext: DWORD): HINTERNET; stdcall;
  830. function HttpOpenRequest(hHttpSession: HINTERNET; lpszVerb: PChar; 
  831.   lpszObjectName: PChar; lpszVersion: PChar; lpszReferrer: PChar; 
  832.   lplpszAcceptTypes: PChar; dwFlags: DWORD; 
  833.   dwContext: DWORD): HINTERNET; stdcall;
  834.  
  835. function HttpAddRequestHeadersA(hHttpRequest: HINTERNET; lpszHeaders: PAnsiChar; 
  836.   dwHeadersLength: DWORD; dwReserved: DWORD): BOOL; stdcall;
  837. function HttpAddRequestHeadersW(hHttpRequest: HINTERNET; lpszHeaders: PWideChar; 
  838.   dwHeadersLength: DWORD; dwReserved: DWORD): BOOL; stdcall;
  839. function HttpAddRequestHeaders(hHttpRequest: HINTERNET; lpszHeaders: PChar; 
  840.   dwHeadersLength: DWORD; dwReserved: DWORD): BOOL; stdcall;
  841.  
  842. function HttpSendRequestA(hHttpRequest: HINTERNET; lpszHeaders: PAnsiChar; 
  843.   dwHeadersLength: DWORD; lpOptional: Pointer; 
  844.   dwOptionalLength: DWORD): BOOL; stdcall;
  845. function HttpSendRequestW(hHttpRequest: HINTERNET; lpszHeaders: PWideChar; 
  846.   dwHeadersLength: DWORD; lpOptional: Pointer; 
  847.   dwOptionalLength: DWORD): BOOL; stdcall;
  848. function HttpSendRequest(hHttpRequest: HINTERNET; lpszHeaders: PChar; 
  849.   dwHeadersLength: DWORD; lpOptional: Pointer; 
  850.   dwOptionalLength: DWORD): BOOL; stdcall;
  851.  
  852. function HttpQueryInfoA(hHttpRequest: HINTERNET; dwInfoLevel: DWORD; 
  853.   lpvBuffer: Pointer; var lpdwBufferLength: DWORD; 
  854.   var lpdwReserved: DWORD): BOOL; stdcall;
  855. function HttpQueryInfoW(hHttpRequest: HINTERNET; dwInfoLevel: DWORD; 
  856.   lpvBuffer: Pointer; var lpdwBufferLength: DWORD; 
  857.   var lpdwReserved: DWORD): BOOL; stdcall;
  858. function HttpQueryInfo(hHttpRequest: HINTERNET; dwInfoLevel: DWORD; 
  859.   lpvBuffer: Pointer; var lpdwBufferLength: DWORD; 
  860.   var lpdwReserved: DWORD): BOOL; stdcall;
  861.  
  862.  
  863. { Internet API error returns }
  864. const
  865.   INTERNET_ERROR_BASE = 12000; 
  866.  
  867.   ERROR_INTERNET_OUT_OF_HANDLES = INTERNET_ERROR_BASE + 1; 
  868.   ERROR_INTERNET_TIMEOUT = INTERNET_ERROR_BASE + 2; 
  869.   ERROR_INTERNET_EXTENDED_ERROR = INTERNET_ERROR_BASE + 3; 
  870.   ERROR_INTERNET_INTERNAL_ERROR = INTERNET_ERROR_BASE + 4; 
  871.   ERROR_INTERNET_INVALID_URL = INTERNET_ERROR_BASE + 5; 
  872.   ERROR_INTERNET_UNRECOGNIZED_SCHEME = INTERNET_ERROR_BASE + 6; 
  873.   ERROR_INTERNET_NAME_NOT_RESOLVED = INTERNET_ERROR_BASE + 7; 
  874.   ERROR_INTERNET_PROTOCOL_NOT_FOUND = INTERNET_ERROR_BASE + 8; 
  875.   ERROR_INTERNET_INVALID_OPTION = INTERNET_ERROR_BASE + 9; 
  876.   ERROR_INTERNET_BAD_OPTION_LENGTH = INTERNET_ERROR_BASE + 10; 
  877.   ERROR_INTERNET_OPTION_NOT_SETTABLE = INTERNET_ERROR_BASE + 11; 
  878.   ERROR_INTERNET_SHUTDOWN = INTERNET_ERROR_BASE + 12; 
  879.   ERROR_INTERNET_INCORRECT_USER_NAME = INTERNET_ERROR_BASE + 13; 
  880.   ERROR_INTERNET_INCORRECT_PASSWORD = INTERNET_ERROR_BASE + 14; 
  881.   ERROR_INTERNET_LOGIN_FAILURE = INTERNET_ERROR_BASE + 15; 
  882.   ERROR_INTERNET_INVALID_OPERATION = INTERNET_ERROR_BASE + 16; 
  883.   ERROR_INTERNET_OPERATION_CANCELLED = INTERNET_ERROR_BASE + 17; 
  884.   ERROR_INTERNET_INCORRECT_HANDLE_TYPE = INTERNET_ERROR_BASE + 18; 
  885.  
  886.   ERROR_INTERNET_NOT_PROXY_REQUEST = INTERNET_ERROR_BASE + 20; 
  887.   ERROR_INTERNET_REGISTRY_VALUE_NOT_FOUND = INTERNET_ERROR_BASE + 21; 
  888.   ERROR_INTERNET_BAD_REGISTRY_PARAMETER = INTERNET_ERROR_BASE + 22; 
  889.   ERROR_INTERNET_NO_DIRECT_ACCESS = INTERNET_ERROR_BASE + 23; 
  890.   ERROR_INTERNET_NO_CONTEXT = INTERNET_ERROR_BASE + 24; 
  891.   ERROR_INTERNET_NO_CALLBACK = INTERNET_ERROR_BASE + 25; 
  892.   ERROR_INTERNET_REQUEST_PENDING = INTERNET_ERROR_BASE + 26; 
  893.  
  894.  
  895. { FTP API errors }
  896.  
  897.   ERROR_FTP_TRANSFER_IN_PROGRESS = INTERNET_ERROR_BASE + 28; 
  898.   ERROR_FTP_DROPPED = INTERNET_ERROR_BASE + 29; 
  899.  
  900.  
  901. { gopher API errors }
  902.  
  903.   ERROR_GOPHER_PROTOCOL_ERROR = INTERNET_ERROR_BASE + 30; 
  904.   ERROR_GOPHER_NOT_FILE = INTERNET_ERROR_BASE + 31; 
  905.   ERROR_GOPHER_DATA_ERROR = INTERNET_ERROR_BASE + 32; 
  906.   ERROR_GOPHER_END_OF_DATA = INTERNET_ERROR_BASE + 33; 
  907.   ERROR_GOPHER_INVALID_LOCATOR = INTERNET_ERROR_BASE + 34; 
  908.   ERROR_GOPHER_INCORRECT_LOCATOR_TYPE = INTERNET_ERROR_BASE + 35; 
  909.   ERROR_GOPHER_NOT_GOPHER_PLUS = INTERNET_ERROR_BASE + 36; 
  910.   ERROR_GOPHER_ATTRIBUTE_NOT_FOUND = INTERNET_ERROR_BASE + 37; 
  911.   ERROR_GOPHER_UNKNOWN_LOCATOR = INTERNET_ERROR_BASE + 38; 
  912.  
  913.  
  914. { HTTP API errors }
  915.  
  916.   ERROR_HTTP_HEADER_NOT_FOUND = INTERNET_ERROR_BASE + 40; 
  917.   ERROR_HTTP_DOWNLEVEL_SERVER = INTERNET_ERROR_BASE + 41; 
  918.   ERROR_HTTP_INVALID_SERVER_RESPONSE = INTERNET_ERROR_BASE + 42; 
  919.  
  920.  
  921. implementation
  922.  
  923. const
  924.   winetdll = 'wininet.dll';
  925.  
  926. function FtpCommandA;                   external winetdll name 'FtpCommandA';
  927. function FtpCommandW;                   external winetdll name 'FtpCommandW';
  928. function FtpCommand;                   external winetdll name 'FtpCommandA';
  929. function FtpCreateDirectoryA;           external winetdll name 'FtpCreateDirectoryA';
  930. function FtpCreateDirectoryW;           external winetdll name 'FtpCreateDirectoryW';
  931. function FtpCreateDirectory;           external winetdll name 'FtpCreateDirectoryA';
  932. function FtpDeleteFileA;                external winetdll name 'FtpDeleteFileA';
  933. function FtpDeleteFileW;                external winetdll name 'FtpDeleteFileW';
  934. function FtpDeleteFile;                external winetdll name 'FtpDeleteFileA';
  935. function FtpFindFirstFileA;             external winetdll name 'FtpFindFirstFileA';
  936. function FtpFindFirstFileW;             external winetdll name 'FtpFindFirstFileW';
  937. function FtpFindFirstFile;             external winetdll name 'FtpFindFirstFileA';
  938. function FtpGetCurrentDirectoryA;       external winetdll name 'FtpGetCurrentDirectoryA';
  939. function FtpGetCurrentDirectoryW;       external winetdll name 'FtpGetCurrentDirectoryW';
  940. function FtpGetCurrentDirectory;       external winetdll name 'FtpGetCurrentDirectoryA';
  941. function FtpGetFileA;                   external winetdll name 'FtpGetFileA';
  942. function FtpGetFileW;                   external winetdll name 'FtpGetFileW';
  943. function FtpGetFile;                   external winetdll name 'FtpGetFileA';
  944. function FtpOpenFileA;                  external winetdll name 'FtpOpenFileA';
  945. function FtpOpenFileW;                  external winetdll name 'FtpOpenFileW';
  946. function FtpOpenFile;                  external winetdll name 'FtpOpenFileA';
  947. function FtpPutFileA;                   external winetdll name 'FtpPutFileA';
  948. function FtpPutFileW;                   external winetdll name 'FtpPutFileW';
  949. function FtpPutFile;                   external winetdll name 'FtpPutFileA';
  950. function FtpRemoveDirectoryA;           external winetdll name 'FtpRemoveDirectoryA';
  951. function FtpRemoveDirectoryW;           external winetdll name 'FtpRemoveDirectoryW';
  952. function FtpRemoveDirectory;           external winetdll name 'FtpRemoveDirectoryA';
  953. function FtpRenameFileA;                external winetdll name 'FtpRenameFileA';
  954. function FtpRenameFileW;                external winetdll name 'FtpRenameFileW';
  955. function FtpRenameFile;                external winetdll name 'FtpRenameFileA';
  956. function FtpSetCurrentDirectoryA;       external winetdll name 'FtpSetCurrentDirectoryA';
  957. function FtpSetCurrentDirectoryW;       external winetdll name 'FtpSetCurrentDirectoryW';
  958. function FtpSetCurrentDirectory;       external winetdll name 'FtpSetCurrentDirectoryA';
  959. function GopherCreateLocatorA;          external winetdll name 'GopherCreateLocatorA';
  960. function GopherCreateLocatorW;          external winetdll name 'GopherCreateLocatorW';
  961. function GopherCreateLocator;          external winetdll name 'GopherCreateLocatorA';
  962. function GopherFindFirstFileA;          external winetdll name 'GopherFindFirstFileA';
  963. function GopherFindFirstFileW;          external winetdll name 'GopherFindFirstFileW';
  964. function GopherFindFirstFile;          external winetdll name 'GopherFindFirstFileA';
  965. function GopherGetAttributeA;           external winetdll name 'GopherGetAttributeA';
  966. function GopherGetAttributeW;           external winetdll name 'GopherGetAttributeW';
  967. function GopherGetAttribute;           external winetdll name 'GopherGetAttributeA';
  968. function GopherGetLocatorTypeA;         external winetdll name 'GopherGetLocatorTypeA';
  969. function GopherGetLocatorTypeW;         external winetdll name 'GopherGetLocatorTypeW';
  970. function GopherGetLocatorType;         external winetdll name 'GopherGetLocatorTypeA';
  971. function GopherOpenFileA;               external winetdll name 'GopherOpenFileA';
  972. function GopherOpenFileW;               external winetdll name 'GopherOpenFileW';
  973. function GopherOpenFile;               external winetdll name 'GopherOpenFileA';
  974. function GopherSendDataA;               external winetdll name 'GopherSendDataA';
  975. function GopherSendDataW;               external winetdll name 'GopherSendDataW';
  976. function GopherSendData;               external winetdll name 'GopherSendDataA';
  977. function HttpAddRequestHeadersA;        external winetdll name 'HttpAddRequestHeadersA';
  978. function HttpAddRequestHeadersW;        external winetdll name 'HttpAddRequestHeadersW';
  979. function HttpAddRequestHeaders;        external winetdll name 'HttpAddRequestHeadersA';
  980. function HttpOpenRequestA;              external winetdll name 'HttpOpenRequestA';
  981. function HttpOpenRequestW;              external winetdll name 'HttpOpenRequestW';
  982. function HttpOpenRequest;              external winetdll name 'HttpOpenRequestA';
  983. function HttpQueryInfoA;                external winetdll name 'HttpQueryInfoA';
  984. function HttpQueryInfoW;                external winetdll name 'HttpQueryInfoW';
  985. function HttpQueryInfo;                external winetdll name 'HttpQueryInfoA';
  986. function HttpSendRequestA;              external winetdll name 'HttpSendRequestA';
  987. function HttpSendRequestW;              external winetdll name 'HttpSendRequestW';
  988. function HttpSendRequest;              external winetdll name 'HttpSendRequestA';
  989. function InternetCancelAsyncRequest;      external winetdll name 'InternetCancelAsyncRequest';
  990. function InternetCloseHandle;             external winetdll name 'InternetCloseHandle';
  991. function InternetConnectA;              external winetdll name 'InternetConnectA';
  992. function InternetConnectW;              external winetdll name 'InternetConnectW';
  993. function InternetConnect;              external winetdll name 'InternetConnectA';
  994. function InternetFindNextFileA;         external winetdll name 'InternetFindNextFileA';
  995. function InternetFindNextFileW;         external winetdll name 'InternetFindNextFileW';
  996. function InternetFindNextFile;         external winetdll name 'InternetFindNextFileA';
  997. function InternetGetLastResponseInfoA;  external winetdll name 'InternetGetLastResponseInfoA';
  998. function InternetGetLastResponseInfoW;  external winetdll name 'InternetGetLastResponseInfoW';
  999. function InternetGetLastResponseInfo;  external winetdll name 'InternetGetLastResponseInfoA';
  1000. function InternetOpenA;                 external winetdll name 'InternetOpenA';
  1001. function InternetOpenW;                 external winetdll name 'InternetOpenW';
  1002. function InternetOpen;                 external winetdll name 'InternetOpenA';
  1003. function InternetOpenUrlA;              external winetdll name 'InternetOpenUrlA';
  1004. function InternetOpenUrlW;              external winetdll name 'InternetOpenUrlW';
  1005. function InternetOpenUrl;              external winetdll name 'InternetOpenUrlA';
  1006. function InternetQueryOption;             external winetdll name 'InternetQueryOption';
  1007. function InternetReadFile;                external winetdll name 'InternetReadFile';
  1008. function InternetSetOption;               external winetdll name 'InternetSetOption';
  1009. function InternetSetStatusCallback;       external winetdll name 'InternetSetStatusCallback';
  1010. function InternetWriteFile;               external winetdll name 'InternetWriteFile';
  1011.  
  1012. function IS_GOPHER_FILE(GopherType: DWORD): BOOL;
  1013. begin
  1014.   Result := GopherType and GOPHER_TYPE_FILE_MASK = 0;
  1015. end;
  1016.  
  1017. function IS_GOPHER_DIRECTORY(GopherType: DWORD): BOOL;
  1018. begin
  1019.   Result := GopherType and GOPHER_TYPE_DIRECTORY = 0;
  1020. end;
  1021.  
  1022. function IS_GOPHER_PHONE_SERVER(GopherType: DWORD): BOOL;
  1023. begin
  1024.   Result := GopherType and GOPHER_TYPE_CSO = 0;
  1025. end;
  1026.  
  1027. function IS_GOPHER_ERROR(GopherType: DWORD): BOOL;
  1028. begin
  1029.   Result := GopherType and GOPHER_TYPE_ERROR = 0;
  1030. end;
  1031.  
  1032. function IS_GOPHER_INDEX_SERVER(GopherType: DWORD): BOOL;
  1033. begin
  1034.   Result := GopherType and GOPHER_TYPE_INDEX_SERVER = 0;
  1035. end;
  1036.  
  1037. function IS_GOPHER_TELNET_SESSION(GopherType: DWORD): BOOL;
  1038. begin
  1039.   Result := GopherType and GOPHER_TYPE_TELNET = 0;
  1040. end;
  1041.  
  1042. function IS_GOPHER_BACKUP_SERVER(GopherType: DWORD): BOOL;
  1043. begin
  1044.   Result := GopherType and GOPHER_TYPE_REDUNDANT = 0;
  1045. end;
  1046.  
  1047. function IS_GOPHER_TN3270_SESSION(GopherType: DWORD): BOOL;
  1048. begin
  1049.   Result := GopherType and GOPHER_TYPE_TN3270 = 0;
  1050. end;
  1051.  
  1052. function IS_GOPHER_ASK(GopherType: DWORD): BOOL;
  1053. begin
  1054.   Result := GopherType and GOPHER_TYPE_ASK = 0;
  1055. end;
  1056.  
  1057. function IS_GOPHER_PLUS(GopherType: DWORD): BOOL;
  1058. begin
  1059.   Result := GopherType and GOPHER_TYPE_GOPHER_PLUS = 0;
  1060. end;
  1061.  
  1062. function IS_GOPHER_TYPE_KNOWN(GopherType: DWORD): BOOL;
  1063. begin
  1064.   Result := GopherType and GOPHER_TYPE_UNKNOWN = 0;
  1065. end;
  1066.  
  1067. end.
  1068.