get_plugin_list(const char *pltype)
{
	char **	typelist = NULL;
	const char **extPI, **p;
	int numextPI, i;
	Stonith * ext;

	/* let the external plugin return a list */
	if ((ext = stonith_new(pltype)) == NULL) {
		LOG(PIL_CRIT, "Cannot create new external "
			"plugin object");
		return NULL;
	}
	if ((extPI = stonith_get_confignames(ext)) == NULL) {
		LOG(PIL_INFO, "Cannot get %s plugin subplugins", pltype);
		stonith_delete(ext);
		return NULL;
	}

	/* count the external plugins */
	for (numextPI = 0, p = extPI; *p; p++, numextPI++);

	/* sort the external plugins */
	qsort(extPI, numextPI, sizeof(char *), qsort_string_cmp);

	typelist = (char **)
		MALLOC((numextPI+1)*sizeof(char *));
	if (typelist == NULL) {
		LOG(PIL_CRIT, "Out of memory");
		stonith_delete(ext);
		return NULL;
	}

	memset(typelist, 0, (numextPI + 1)*sizeof(char *)); 

	/* copy external plugins */
	for (i = 0; i < numextPI; i++) {
		int len = strlen(pltype) + 
			strlen(extPI[i]) + 2;
		typelist[i] = MALLOC(len);
		if (typelist[i] == NULL) {
			LOG(PIL_CRIT, "Out of memory");
			stonith_delete(ext);
			goto err;
		}
		snprintf(typelist[i], len, "%s/%s"
		,	pltype, extPI[i]);
	}

	stonith_delete(ext);
	return typelist;
err:
	stonith_free_hostlist(typelist);
	return NULL;
}
get_plugin_list(const char *pltype)
{
	char **	typelist = NULL;
	const char **extPI, **p;
	int numextPI, i;
	Stonith * ext;

	 
	if ((ext = stonith_new(pltype)) == NULL) {
		LOG(PIL_CRIT, "Cannot create new external "
			"plugin object");
		return NULL;
	}
	if ((extPI = stonith_get_confignames(ext)) == NULL) {
		LOG(PIL_INFO, "Cannot get %s plugin subplugins", pltype);
		stonith_delete(ext);
		return NULL;
	}

	 
	for (numextPI = 0, p = extPI; *p; p++, numextPI++);

	 
	qsort(extPI, numextPI, sizeof(char *), qsort_string_cmp);

	typelist = (char **)
		MALLOC((numextPI+1)*sizeof(char *));
	if (typelist == NULL) {
		LOG(PIL_CRIT, "Out of memory");
		stonith_delete(ext);
		return NULL;
	}

	memset(typelist, 0, (numextPI + 1)*sizeof(char *)); 

	 
	for (i = 0; i < numextPI; i++) {
		int len = strlen(pltype) + 
			strlen(extPI[i]) + 2;
		typelist[i] = MALLOC(len);
		if (typelist[i] == NULL) {
			LOG(PIL_CRIT, "Out of memory");
			stonith_delete(ext);
			goto err;
		}
		snprintf(typelist[i], len, "%s/%s"
		,	pltype, extPI[i]);
	}

	stonith_delete(ext);
	return typelist;
err:
	stonith_free_hostlist(typelist);
	return NULL;
}