stonith_types(void)
{
	int i, j, cur=0, rl_size, sub_pl = 0;
	static char **	rl = NULL;
	char **		new_list, **sub_list = NULL;

	if (!init_pluginsys()) {
		return NULL;
	}

	new_list = PILListPlugins(StonithPIsys, STONITH_TYPE_S, NULL);
	if (new_list == NULL) {
		return NULL;
	}
	for (i=0; new_list[i]; ++i)
		; /* count */
	rl_size = i+1;

	rl = (char**)MALLOC(rl_size * sizeof(char *));
	if (rl == NULL) {
		LOG(PIL_CRIT, "Out of memory");
		goto types_exit;
	}

	for (i=0; new_list[i]; ++i) {
		/* look for 'external' and 'rhcs' plugins */
		if (strcmp(new_list[i], EXTPINAME_S) == 0) {
			sub_list = get_plugin_list(EXTPINAME_S);
			sub_pl = 1;
		} else if (strcmp(new_list[i], RHCSPINAME_S) == 0) {
			sub_list = get_plugin_list(RHCSPINAME_S);
			sub_pl = 1;
		}
		if (sub_pl) {
			if (sub_list) {
				for (j=0; sub_list[j]; ++j)
					; /* count */
				rl_size += j;
				rl = (char**)REALLOC(rl, rl_size*sizeof(char *));
				for (j=0; sub_list[j]; ++j) {
					rl[cur++] = sub_list[j];
				}
				FREE(sub_list);
				sub_list = NULL;
			}
			sub_pl = 0;
		} else {
			rl[cur] = STRDUP(new_list[i]);
			if (rl[cur] == NULL) {
				LOG(PIL_CRIT, "Out of memory");
				goto types_exit_mem;
			}
			cur++;
		}
	}

	rl[cur] = NULL;
	goto types_exit;

types_exit_mem:
	stonith_free_hostlist(rl);
	rl = NULL;
types_exit:
	PILFreePluginList(new_list);
	return rl;
}
stonith_types(void)
{
	int i, j, cur=0, rl_size, sub_pl = 0;
	static char **	rl = NULL;
	char **		new_list, **sub_list = NULL;

	if (!init_pluginsys()) {
		return NULL;
	}

	new_list = PILListPlugins(StonithPIsys, STONITH_TYPE_S, NULL);
	if (new_list == NULL) {
		return NULL;
	}
	for (i=0; new_list[i]; ++i)
		;  
	rl_size = i+1;

	rl = (char**)MALLOC(rl_size * sizeof(char *));
	if (rl == NULL) {
		LOG(PIL_CRIT, "Out of memory");
		goto types_exit;
	}

	for (i=0; new_list[i]; ++i) {
		 
		if (strcmp(new_list[i], EXTPINAME_S) == 0) {
			sub_list = get_plugin_list(EXTPINAME_S);
			sub_pl = 1;
		} else if (strcmp(new_list[i], RHCSPINAME_S) == 0) {
			sub_list = get_plugin_list(RHCSPINAME_S);
			sub_pl = 1;
		}
		if (sub_pl) {
			if (sub_list) {
				for (j=0; sub_list[j]; ++j)
					;  
				rl_size += j;
				rl = (char**)REALLOC(rl, rl_size*sizeof(char *));
				for (j=0; sub_list[j]; ++j) {
					rl[cur++] = sub_list[j];
				}
				FREE(sub_list);
				sub_list = NULL;
			}
			sub_pl = 0;
		} else {
			rl[cur] = STRDUP(new_list[i]);
			if (rl[cur] == NULL) {
				LOG(PIL_CRIT, "Out of memory");
				goto types_exit_mem;
			}
			cur++;
		}
	}

	rl[cur] = NULL;
	goto types_exit;

types_exit_mem:
	stonith_free_hostlist(rl);
	rl = NULL;
types_exit:
	PILFreePluginList(new_list);
	return rl;
}