Example #1
0
int parse(const char *device)
{
	char *filepath;
	int rc;

	filepath = resolve_path(conf_filename, device);

	cur_opt = NULL;
	dev = malloc(sizeof(*dev));
	memset(dev, 0, sizeof(*dev));
	dev->id = strdup(device);

	rc = pm_process(filepath, section, parameter);
	if (!rc)
		return 0;

	if (cur_opt) {
		add_boot_option(cur_opt);
		free_boot_option(cur_opt);
	}

	cur_opt = NULL;

	free(filepath);

	return 1;
}
static WERROR smbconf_txt_load_file(struct smbconf_ctx *ctx)
{
	WERROR werr;
	uint64_t new_csn;

	if (!file_exist(ctx->path, NULL)) {
		return WERR_BADFILE;
	}

	new_csn = (uint64_t)file_modtime(ctx->path);
	if (new_csn == pd(ctx)->csn) {
		return WERR_OK;
	}

	werr = smbconf_txt_init_cache(ctx);
	if (!W_ERROR_IS_OK(werr)) {
		return werr;
	}

	if (!pm_process(ctx->path, smbconf_txt_do_section,
			smbconf_txt_do_parameter, pd(ctx)))
	{
		return WERR_CAN_NOT_COMPLETE;
	}

	pd(ctx)->csn = new_csn;

	return WERR_OK;
}