Administration API (isc_service_query) - Functional Specification

Description

Once a client has attached to the services mananger using isc_service_attach, the client uses this API call to retrieve information about the server, such as the installed licenses. This is accomplished by specifying the correct parameters in the receive buffer specified in the API call.

User interface/Usability

This feature will only be available to the end user via a call into the InterBase API.

ISC_STATUS ISC_EXPORT isc_service_query
  (ISC_STATUS *status_vector,
   isc_svc_handle *svc_handle,
   ISC_USHORT send_spb_length,
   char *send_spb,
   ISC_USHORT recv_spb_length,
   char *recv_spb,
   ISC_USHORT buffer_length,
   char *buffer);
returns:
value of ISC_STATUS[1] :: 0 if no error >0 if there is an error
*status_vector
pointer to a 20 element array of ISC_STATUS
*svc_handle
pointer to a long value used to store the handle of the service structure on the server.This must point to a handle previously allocated in isc_service_attach.
*reserved
this parameter is being reserved for future use
send_spb_length
length in characters of the send buffer
*send_spb
pointer to a buffer containing flags instructing the service manager to process information
recv_spb_length
length in characters of the receive buffer
*recv_spb
pointer to a buffer containing flags instructing the service manager to return information
buffer_length
length in characters of the return buffer
*buffer
pointer to a buffer containing information received from the services manager

example (after isc_service_attach has been completed):

1. ISC_STATUS status [20];
2. char respbuf[SVC_RESPBUF],
3. recvbuf[] = { isc_info_svc_get_licensed_users, isc_info_svc_get_env_msg };
4. char *p = respbuf;
5. ISC_ULONG path_length;
6.
7. /* service attach happens here */
8. if (isc_service_query (status, &svc_handle, NULL, 0, NULL, sizeof (recvbuf),
9. recvbuf, SVC_RESPBUF, respbuf))
10. {
11. isc_print_status (status);
12. isc_service_detach (status, &svc_handle);
13. return;
14. }
15.
16. do {
17. switch (*p++)
18.  {
19.  case isc_info_svc_get_licensed_users:
20.   {
21.   ISC_ULONG nUsers;
22.   nUsers = (ISC_ULONG)isc_vax_integer(p, sizeof (ISC_ULONG));
23.   printf ("Number of licensed users: %dn", nUsers);
24.   p += sizeof(ISC_ULONG);
25.   break;
26.   }
27.
28.    case isc_info_svc_get_env_msg:
29.    {
30.    ISC_USHORT path_length;
31.    char *buffer;
32.    path_length = (ISC_USHORT) isc_vax_integer (p, sizeof(ISC_USHORT));
33.    p += sizeof (ISC_USHORT);
34.    buffer = (char*) malloc (path_length);
35.    strncpy (buffer, p, path_length);
36.    buffer [path_length] = '0';
37.    printf ("Path to INTERBASE.MSG: %sn", buffer);
38.    p += path_length;
39.    break;
40.    }
41.   }
42.  } while (*p);

As with all parameter buffers (i.e. dpb) that get sent to the server for processing information, service buffers can also be used to send multiple parameters to be processed. This can be seen in line 3 where the sendbuf is being initalized to hold parameters. Once the call to isc_service_query is made, the response buffer (respbuf) contains the information that was requested. Lines 15-42 show how to process the response buffer once the call to isc_service_query returns. Some important things to note about this API call are:

  1. isc_service_query will not return unless either the request has completed or the response buffer is full. In the case of the buffer being full, it will return isc_info_truncated. You will need to increase the size of the buffer before calling into the services manager again with your request. If there is no data to return and you have started a service (using isc_service_start), this call will not return until the service has completed. This removes the need for polling to determine if a service has finished.
  2. The format of the response buffer is: <isc_info_svc_xxx><length><data>. All lengths returned by this call will be 2 bytes long (line 32) and all numeric data returned will be 4 bytes long (line 21). This helps keep all formatting consistent so that there is no worry about what is actually being passed around. Parameters that specify numeric values (line 21) do not have a length associated with it.
  3. isc_service_query can only process isc_info_svc requests. Any request that isc_service_query can not process will not produce an error and will not return any information. A complete list of isc_info_svc parameters follows.

List of isc_info_svc parameters
isc_service_query parameter What it does Special notes
isc_info_svc_svr_db_info Returns the number of attachments and databases May also return the actual database names if time permits
isc_info_svc_get_license Returns all license keys and IDs from the license file  
isc_info_svc_get_license_mask Returns a bitmask representing licensed options on the server This is primarilly for internal use as the bitmask returned can only be used with definitions in the source
isc_info_svc_get_config Returns the parameters and values for IB_CONFIG Values returned are specific to the individual platforms
isc_info_svc_version Returns the version of the services manager This is currently set to 2
isc_info_svc_server_version Returns the version of the InterBase server  
isc_info_svc_implementation Returns the implementation string of the InterBase server (i.e. InterBase/Sun4)  
isc_info_svc_capabilities Returns a bitmask representing the server's capabilities This is primarilly here for internal use
isc_info_svc_user_dbpath Returns the path to the security database in use by the server  
isc_info_svc_get_env Returns the setting of $INTERBASE or the Windows NT registry setting for RootDirectory  
isc_info_svc_get_env_lock Returns the setting of $INTERBASE_LCK  
isc_info_svc_get_env_msg Returns the setting of $INTERBASE_MSG  
isc_info_svc_line Returns 1 line of service output per call Used to retrieve information from a service started with isc_service_start
isc_info_svc_to_eof Returns as much of the server output as will fit in the supplied buffer Used to retrieve information from a service started with isc_service_start
isc_info_svc_timeout Sets / signifies a timeout value for reading service information To set a timeout value, send this info request in the send buffer
isc_info_svc_get_licensed_users Returns the number of users licensed for accessing the server  
isc_info_svc_running Returns true if the current attachment has a service running This can be used before isc_service_start to determine if a service is already running. If isc_service_start is called and a service is running, an error is returned
isc_info_svc_get_users Returns user information from a call to isc_action_svc_display_users You MUST have started the service isc_action_svc_display_users before using this service
isc_info_svc_limbo_trans Returns limbo transaction information based on a previous call to isc_action_svc_repar with the bit isc_spb_rpr_list_limbo_trans set You MUST have started the service isc_action_svc_repair before using this service with the option isc_spb_rpr_list_limbo_trans
Additional Parameters
Main Parameter Parameter name Length Data Meaning
isc_info_svc_svr_db_info isc_spb_num_att NA ISC_ULONG Number of attachments on the server
  isc_spb_num_db NA ISC_ULONG Number of databases in use by the server (excl. ISC4)
  isc_spb_dbname det. by dbname database name Name of database in use by the server
  isc_info_flag_end 1 byte   Main parameter is complete
isc_info_svc_get_license isc_spb_lic_key det. by key the license key A license key
  isc_spb_lic_id det by id the license id A license certificate id
  isc_info_flag_end 1 byte   Main parameter is complete
isc_info_svc_get_users isc_spb_username det by username username The user name in isc4
  isc_spb_firstname det by firstname first name The first name in isc4
  isc_spb_middlename det bymiddlename middle name The middle name in isc4
  isc_spb_lastname det by last name last name The last name in isc4
  isc_spb_groupid NA ISC_ULONG The user's group ID
  isc_spb_userid NA ISC_ULONG The user's id
isc_info_svc_limbo_trans isc_spb_single_tra_id NA ISC_ULONG The transaction specified is a single-database transaction
  isc_spb_multi_tra_id NA ISC_ULONG The transaction specified is a multi-database transaction
  isc_spb_tra_host_site det by host site name name of host site for the transaction For a multi database transaction, specifies the name of the site where the transaction was initiated
  isc_spb_tra_state NA NA the next byte to follow signifies the state of the last transaction encountered
  isc_spb_tra_state_limbo NA NA 1 byte specifying that the transaction is in limbo
  isc_spb_tra_state_commit NA NA 1 byte specifying that the transaction has been committed
  isc_spb_tra_state_rollback NA NA 1 byte specifying that the transaction has been rolledback
  isc_spb_tra_state_unknown NA NA 1 byte specifying that the transaction state is unknown
  isc_spb_tra_remote_site det by remote site name of remote site for this transaction For a multi database transaction, specifies the name of the site where the transaction was working against
  isc_spb_tra_db_path det by db path name of the database path on the remote site For a multi database transaction, specifies the path of the database on the remote site
  isc_spb_tra_advise NA NA the next byte to follow is the server's recommendation for processing the limbo transaction
  isc_spb_tra_advise_commit NA NA 1 byte specifying that the transaction should be committed
  isc_spb_tra_advise_rollback NA NA 1 byte specifying that the transaction should be rolledback
  isc_spb_tra_advise_unknown NA NA 1 byte specifying that the server can not make a recommendation about the state of the transaction

Additional Notes

The following is a list of action services which return formatted text to the response buffer when queried by isc_info_svc_line or isc_info_svc_to_eof:

  • isc_action_svc_backup
  • isc_action_svc_restore
  • isc_action_svc_repair
  • isc_action_svc_db_stats
  • isc_action_svc_get_ib_log

Requirements and Constraints

General InterBase Requirements

isc_service_query only accepts isc_info_svc parameters

data lengths in the response buffer are always 2 bytes long (use ISC_USHORT)

numeric data returned in the response buffer is always 4 bytes long (use ISC_ULONG)

Migration Issues

There are no migration issues with this feature as the call was never documented or distributed for public use.