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.
If an error occurs with this function, -1 is returned and rsp_error is set appropriately. Possible error values are:
RSP_NEED_MORE_DATA
RSP_INVALID_ARGS
RSP_SOCK_CREATE_FAILED
RSP_CONNECT_FAILED
RSP_LOW_MEM
RSP_LOST_CONNECTION
RSP_NO_SSL
RSP_SSL_SETUP_CONN
RSP_SSL_INVALID_CERT
RSP_MYSQL_INVALID