/* Parse the configuration file 'fcfg' into the array of configuration elements 'image_cfg', and return the number of configuration elements in 'cfgn'.  */
static int image_create_config_parse(FILE *fcfg)
/* Parse the configuration file 'fcfg' into the array of configuration elements 'image_cfg', and return the number of configuration elements in 'cfgn'.  */
static int image_create_config_parse(FILE *fcfg)
{
	int ret;
	int cfgi = 0;
	while (!feof(fcfg)) {
		char *line;
		char buf[256];
		memset(buf, 0, sizeof(buf));
		line = fgets(buf, sizeof(buf), fcfg);
		if (!line)
			break;
		if (line[0] == '\n' || line[0] == '#')
			continue;
		if (line[strlen(line) - 1] == '\n')
			line[strlen(line) - 1] = 0;
		ret = image_create_config_parse_oneline(line,
							&image_cfg[cfgi]);
		if (ret)
			return ret;
		cfgi++;
		if (cfgi >= IMAGE_CFG_ELEMENT_MAX) {
			fprintf(stderr,
				"Too many configuration elements in .cfg file\n");
			return -1;
		}
	}
	cfgn = cfgi;
	return 0;
}