RSP_getHostsAndModules

Name

RSP_getHostsAndModules -- Retrieves all host and module names.

Synopsis

int RSP_getHostsAndModules(RSP_parseData *pd, char*** pszHosts, char*** pszModules);

Description

This function connects to a History Listener or MySQL database and collects all host and modules names that have data associated with them. The purpose of this function is to give users a list of hosts and modules to choose from when they want to view data. The parameter pd must have been created by a call to either RSP_newParseMySQL or RSP_newParseMySQL.

The remaining parameters pszHosts and pszModules are pointers to arrays into which the function will place the host and module lists. It is up to the user to free any data allocated to store these values. The following is an example of how to use this function:

RSP_parseData* pd;
char **hosts, **modules;
int i = 0;

pd = RSP_newParseRemote("127.0.0.1", 3496, 10);

RSP_getHostsAndModules(pd, &hosts, &modules);

printf("Hosts on server:\n");
i = 0;
while(hosts[i] != NULL)
{
	printf("%s\n", hosts[i]);
	free(hosts[i++]);
}
free(hosts);

printf("\nModules on server:\n");
i = 0;
while(modules[i] != NULL)
{
	printf("%s\n", modules[i]);
	free(modules[i++]);
}
free(modules);
				

As you can see, the end of the array is specified with NULL. Make sure to free all non-NULL array entries as well as the array itself.

Returns

This function returns 0 if no error occurred, and -1 otherwise.

Error Conditions

If an error occurs with this function, -1 is returned and rsp_error is set appropriately. Possible error values are: