/*
 * options.h
 * 
 * Copyright (C) 2006  Josef Kufner <jk@myserver.cz>
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */
#ifndef JK_OPTIONS_H
#define JK_OPTIONS_H

#include <stdio.h>

typedef enum  {
	OPTION_NONE,
	OPTION_INTEGER,
	OPTION_STRING
} OPTION_TYPE;

typedef void (*OPTION_UPDATE_CALLBACK)(void);

extern int option_last_error;

/* init & load defaults */
int option_init(void);
void option_set_update_callback(OPTION_UPDATE_CALLBACK callback);

/* set option */
int option_set_integer(const char *cat, const char *opt, int value);
int option_set_string(const char *cat, const char *opt, const char *value);

/* unset option */
void option_unset_by_id(int id);
int option_unset(const char *cat, const char *opt);

/* read option's value */
int option_get_integer_by_id(int id);
int option_get_integer(const char *cat, const char *opt);
const char *option_get_string_by_id(int id);
const char *option_get_string(const char *cat, const char *opt);

/* read option's type */
OPTION_TYPE option_get_type(const char *cat, const char *opt);
const char *option_get_type_name_by_id(int id);
const char *option_get_type_name(const char *cat, const char *opt);

/* store & load to/from file */
int option_store_to_default(void);
int option_store_file(const char *cat, const char *filename);
int option_store(const char *cat, FILE *file, const char *filename_to_show);
int option_load(FILE *file, const char *filename_to_show);
int option_load_file(const char *filename);

/* get option listing */
const char *option_list_cat(int *iter);
int option_list_opt(const char *cat_query, int *iter, char **cat, char **opt);


#endif

