| |
| INT WINAPI GopherSelectItem(
|
| |
HCLIENT hClient, |
|
| |
UINT nItemType, |
|
| |
LPCTSTR lpszSelector |
|
| );
|
The GopherSelectItem function sends the specified
selector string to the server. If the item is a directory, a list
of additional items will be returned, otherwise the item itself
will be returned to the client.
Parameters
- hClient
- A handle to the client session.
- nItemType
- The selector item type. The following types are
recognized:
| Value |
Constant |
Description |
| 0 |
GOPHER_ITEM_FILE |
A file, typically a standard text file |
| 1 |
GOPHER_ITEM_DIRECTORY |
A directory which contains a list of Gopher items |
| 2 |
GOPHER_ITEM_PHONEBOOK |
A phonebook server |
| 3 |
GOPHER_ITEM_ERROR |
An error |
| 4 |
GOPHER_ITEM_BINHEX |
A Macintosh file encoded using the BinHex algorithm |
| 5 |
GOPHER_ITEM_DOSFILE |
An MS-DOS binary file |
| 6 |
GOPHER_ITEM_UUENCODE |
A binary file encoded using the uuencode algorithm |
| 7 |
GOPHER_ITEM_INDEX |
An index search server |
| 8 |
GOPHER_ITEM_TELNET |
A Telnet session |
| 9 |
GOPHER_ITEM_BINARY |
A binary file |
| 10 |
GOPHER_ITEM_GIF |
An image stored in the Graphics Interchange Format (GIF) |
| 11 |
GOPHER_ITEM_IMAGE |
A bitmap image stored in an alternate format |
| 12 |
GOPHER_ITEM_TN3270 |
A TN3270 Telnet session |
| 13 |
GOPHER_ITEM_CALENDAR |
A calendar server |
| 14 |
GOPHER_ITEM_SOUND |
An audio file |
| 15 |
GOPHER_ITEM_MIME |
A MIME formatted message |
| 16 |
GOPHER_ITEM_PDF |
A file stored in the Portable Document Format (PDF) |
| 17 |
GOPHER_ITEM_HTML |
An HTML file |
| 18 |
GOPHER_ITEM_MAILBOX |
A mailbox on a mail server |
- lpszSelector
- A pointer to the null-terminated selector string which
identifies the resource to be returned by the server. The selector
may be the name of a file on the server, or it may be an unique
sequence of characters which is used to access the item. This
parameter may be specified as GOPHER_ROOT_SELECTOR, in which case
the root directory will be returned for the Gopher server.
Return Value
If the function succeeds, the return value is zero. If the
function fails, the return value is GOPHER_ERROR. To get extended
error information, call GopherGetLastError.
Remarks
Gopher directories are lists of items that can be accessed by
the client. Setting the nItemType parameter to a value of
GOPHER_ITEM_DIRECTORY and the lpszSelector parameter to
GOPHER_ROOT_SELECTOR will cause the server to return the root
directory. That directory listing will provide additional item
selector strings which can then be used to retrieve specific
resources on the server.
Note that the GOPHER_ITEM_TELNET and GOPHER_ITEM_TN3270 items
are not resources that can be retrieved. Instead, they indicate
that the client should establish a Telnet connection to the
specified server. Attempting to use this item type when calling
GopherSelectItem will result in an error.
Example
HCLIENT hClient;
GOPHERITEM gopherItem;
BOOL bResult;
INT nResult;
// Connect to the Gopher server on the default port
hClient = GopherConnect(lpszHostName,
GOPHER_PORT_DEFAULT,
GOPHER_TIMEOUT,
0);
if (hClient == INVALID_CLIENT)
{
TCHAR szError[ASTRING];
DWORD dwError = GopherGetLastError();
GopherGetErrorString(dwError, szError, ASTRING);
fprintf(stderr, "Error %08x: %s\n", dwError, szError);
return;
}
// Select the default root directory
nResult = GopherSelectItem(hClient,
GOPHER_ITEM_DIRECTORY,
GOPHER_ROOT_SELECTOR);
if (nResult == GOPHER_ERROR)
{
TCHAR szError[ASTRING];
DWORD dwError = GopherGetLastError();
GopherGetErrorString(dwError, szError, ASTRING);
fprintf(stderr, "Error %08x: %s\n", dwError, szError);
return;
}
// Get the items in the selected index, printing the selector
// and a description of the item
bResult = GopherGetNextItem(hClient, &gopherItem);
while (bResult)
{
printf("%s %s\n", gopherItem.szSelector, gopherItem.szDescription);
bResult = GopherGetNextItem(hClient, &gopherItem);
}
GopherDisconnect(hClient);
Requirements
Client: Requires Windows 7, Windows Vista or Windows
XP.
Server: Requires Windows Server 2008 or Windows Server
2003.
Header: Include cstools7.h.
Library: Use csgprav7.lib.
Unicode: Implemented as Unicode and ANSI versions.
See Also
GopherGetFirstItem,
GopherGetItem, GopherGetNextItem, GopherRead, GopherStoreItem
|
|