| |
| BOOL WINAPI GopherGetFirstItem(
|
| |
HCLIENT hClient, |
|
| |
LPGOPHERITEM lpItem |
|
| );
|
The GopherGetFirstItem function returns the first item in
the currently selected directory.
Parameters
- hClient
- Handle to the client session.
- lpItem
- A pointer to a GOPHERITEM
structure which will contain information about the first item in
the currently selected directory.
Return Value
If the function succeeds, the return value is non-zero. If there
is no currently selected directory, or the function fails, the
return value is zero. To get extended error information, call
GopherGetLastError.
Remarks
The GopherGetFirstItem function returns the first item in
the currently selected directory. This function is used in
conjunction with the GopherGetNextItem function to enumerate
all of the items in the directory returned by the server. Typically
this is used to provide the user with a list of resources or
services to access, or to select subdirectories which list
additional items.
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 = GopherGetFirstItem(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
GopherGetNextItem, GopherSelectItem
|
|