示例#1
0
文件: config.c 项目: alhazred/onarm
/*
 * Read all the basic and method properties for instance 'inst', as inetd_prop_t
 * tables, into the spaces referenced by 'bprops' and 'mprops' respectively.
 * Each of the properties in the tables are flagged to indicate if the
 * property was present or not, and if it was the value is stored within it.
 * If an error occurs at any time -1 is returned and 'err' is set to
 * indicate the reason, else 0 is returned.
 */
static int
read_inst_props(const char *fmri, inetd_prop_t **bprops,
    inetd_prop_t **mprops, scf_error_t *err)
{
	size_t		nprops;
	int		i;

	debug_msg("Entering read_inst_props");

	if ((*bprops = read_instance_props(rep_handle, (char *)fmri, &nprops,
	    err)) == NULL)
		return (-1);

	for (i = 0; i < NUM_METHODS; i++) {
		if ((mprops[i] =
		    read_method_props(fmri, (instance_method_t)i, err)) ==
		    NULL) {
			for (i--; i >= 0; i--)
				destroy_method_props(mprops[i]);
			free_instance_props(*bprops);
			return (-1);
		}
	}

	return (0);
}
示例#2
0
文件: config.c 项目: alhazred/onarm
/*
 * Try and read each of the method properties for the method 'method' of
 * instance 'inst', and return a table containing all method properties. If an
 * error occurs, NULL is returned, with 'err' set to indicate the cause.
 * Otherwise, a pointer to an inetd_prop_t table is returned containing all
 * the method properties, and each of the properties is flagged according to
 * whether it was present or not, and if it was present its value is set in
 * the property's entry in the table.
 */
static inetd_prop_t *
read_method_props(const char *inst, instance_method_t method, scf_error_t *err)
{
	inetd_prop_t	*ret;
	int		i;

	debug_msg("Entering read_method_props");

	if ((ret = calloc(1, sizeof (method_props))) == NULL) {
		*err = SCF_ERROR_NO_MEMORY;
		return (NULL);
	}

	(void) memcpy(ret, method_props, sizeof (method_props));
	for (i = 0; ret[i].ip_name != NULL; i++) {
		*err = read_prop(rep_handle, &ret[i], i, inst,
		    methods[method].name);
		if ((*err != 0) && (*err != SCF_ERROR_NOT_FOUND)) {
			destroy_method_props(ret);
			return (NULL);
		}
	}

	return (ret);
}
示例#3
0
/*
 * Destroy the basic and method properties returned by read_inst_props().
 */
static void
destroy_inst_props(inetd_prop_t *bprops, inetd_prop_t **mprops)
{
	int	i;

	free_instance_props(bprops);
	for (i = 0; i < NUM_METHODS; i++)
		destroy_method_props(mprops[i]);
}