SAPGetServerByName(3sapd)


SAPGetServerByName -- get server information by name

Synopsis

#include <sap_app.h> 

int SAPGetServerByName(char *ServerName, uint16 ServerType, int *ServerEntry, SAPI *ServerBuf, int MaxEntries);

Description

SAPGetServerByName requests server entries by name and type. If the specified type is ALL_SERVER_TYPE, then all servers by that name are returned. SAP allows servers to have the same name as long as they are of different types. For example, a NetWare® file server and its print server could have the same name.

If your host configuration is set so that the SAP daemon is running, the netInfo_t structure will be filled. If SAPD is not active, SAPGetAllServers retrieves its information from the network and the netInfo_t structure is then set to NULL.

Some limited wildcard capabilities are allowed in this function. If the final character of ServerName is an asterisk (*), the string is matched up only to the asterisk.

Parameters

(IN) ServerName
Pointer to the NULL-terminated name of the requested server.

(IN) ServerType
Specifies either the type of server desired or ALL_SERVER_TYPE to obtain information on all servers with that name.

(IN/OUT) ServerEntry
Pointer to an index value that indicates position in SAP responses from which the next MaxEntries will be returned. Modified on return. Should initially be set to zero (0).

(OUT) ServerBuf
Pointer to the address of a buffer whose size is calculated as follows:
sizeof(SAPI * MaxEntries) 
which will be filled with SAPI entries.

(IN) MaxEntries
Specifies the maximum number of SAPI entries which can be put in ServerBuf.

Usage

The ServerName argument specifies the NULL-terminated name of the requested service. If the name contained in ServerName is not less than SAP_MAX_SERVER_NAME_LENGTH, the service requested will be rejected.

The ServerType argument specifies either the type of server desired or ALL_SERVER_TYPE to obtain information on all servers with that name.

The ServerEntry argument must be set to zero (0) on the first call and is updated by SAPGetServerByName. The updated value should be returned on subsequent calls. You should not modify the contents of ServerEntry except to set the initial value to zero.

The ServerBuf argument specifies the address of a buffer whose size is calculated as follows:

   sizeof(SAPI * MaxEntries) 
which will be filled with SAPI entries.

The MaxEntries argument specifies the maximum number of SAPI entries which can be put in ServerBuf.

If successful, the function returns the number of SAPI entries placed in ServerBuf. The ServerEntry argument is set to index of the next server entry to be read when the next call is made. All server entries have been returned when the function return value is zero or less than the MaxEntries.

Return values

If an error occurs, the function returns a negative number which is the negative of the error code.

>=0
successful

-1
ServerType invalid

-2
ServerName too long/too short

<0
unsuccessful

Examples

   strcpy (ServerName, "TEST_SERVER"); 
   ServerType = FILE_SERVER_TYPE; 
   ServerEntry = 0; 
   MaxEntries = 1; 
   ret=SAPGetServerByName(ServerName,ServerType,&ServerEntry,&ServerBuf, 
       MaxEntries); 

References

SAPGetServerByAddr(3sapd)
30 January 1998
© 1998 The Santa Cruz Operation, Inc. All rights reserved.