/*

  Copyright (c) 2003,2004 uim Project http://uim.freedesktop.org/

  All rights reserved.

  Redistribution and use in source and binary forms, with or without
  modification, are permitted provided that the following conditions
  are met:

  1. Redistributions of source code must retain the above copyright
     notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in the
     documentation and/or other materials provided with the distribution.
  3. Neither the name of authors nor the names of its contributors
     may be used to endorse or promote products derived from this software
     without specific prior written permission.

  THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  SUCH DAMAGE.

*/

/* API and ABI are unstable */
#ifndef _uim_scm_h_included_
#define _uim_scm_h_included_

#ifdef __cplusplus
extern "C" {
#endif

/* uim companion tools should treat lisp object as opaque */
typedef void * uim_lisp;

/* 'uim_scm' prefix is not appropriate for these functions... any ideas? */
FILE *
uim_scm_get_output(void);
void
uim_scm_set_output(FILE *fp);
  
/* Scheme interpreter interface functions: "uim_scm" prefix is not
 * stable name. More discussion is required.
 *
 * See also bug #481 "Export Scheme interpreter interface as uim API"
 * on freedesktop.org.
 * http://freedesktop.org/cgi-bin/bugzilla/show_bug.cgi?id=481
 */
long
uim_scm_get_verbose_level(void);
void
uim_scm_set_verbose_level(long new_value);
void
uim_scm_load_file(const char *fn);

/* These function names are badly inconsistent. Rename appropriately
 * before becoming proper API.
 */
int
uim_scm_c_int(uim_lisp integer);
int
uim_scm_symbol_value_int(const char *symbol_str);
uim_lisp
uim_scm_int_from_c_int(int integer);
char *
uim_scm_c_str(uim_lisp str);
char *
uim_scm_symbol_value_str(const char *symbol_str);
uim_lisp
uim_scm_str_from_c_str(const char *str);
uim_lisp
uim_scm_c_strs_into_list(int n_strs, const char *const *strs);
uim_lisp
uim_scm_symbol_value(const char *symbol_str);
uim_lisp
uim_scm_intern_c_str(const char *str);
uim_lisp
uim_scm_qintern_c_str(const char *str);
long
uim_scm_repl_c_string(char *str, long want_init, long want_print);

uim_lisp
uim_scm_t(void);
uim_lisp
uim_scm_f(void);
uim_lisp
uim_scm_null_list(void);
int
uim_scm_nullp(uim_lisp obj);
int
uim_scm_eq(uim_lisp a, uim_lisp b);
int
uim_scm_string_equal(uim_lisp a, uim_lisp b);
uim_lisp
uim_scm_eval(uim_lisp obj);
uim_lisp
uim_scm_quote(uim_lisp obj);
uim_lisp
uim_scm_car(uim_lisp cell);
uim_lisp
uim_scm_cdr(uim_lisp cell);
uim_lisp
uim_scm_cadr(uim_lisp cell);
uim_lisp
uim_scm_caar(uim_lisp cell);
uim_lisp
uim_scm_cdar(uim_lisp cell);
uim_lisp
uim_scm_cddr(uim_lisp cell);
uim_lisp
uim_scm_cons(uim_lisp car, uim_lisp cdr);
uim_lisp
uim_scm_nth(uim_lisp n, uim_lisp lst);
uim_lisp
uim_scm_list1(uim_lisp elm1);
uim_lisp
uim_scm_list2(uim_lisp elm1, uim_lisp elm2);
uim_lisp
uim_scm_list3(uim_lisp elm1, uim_lisp elm2, uim_lisp elm3);
uim_lisp
uim_scm_list4(uim_lisp elm1, uim_lisp elm2, uim_lisp elm3, uim_lisp elm4);
uim_lisp
uim_scm_list5(uim_lisp elm1, uim_lisp elm2, uim_lisp elm3, uim_lisp elm4,
              uim_lisp elm5);

/* Customize interface functions: They are not appropriate to be
 * here. More discussion is required.
 *
 * See also bug #538 "Add customization interface to uim" on
 * freedesktop.org.
 * http://freedesktop.org/cgi-bin/bugzilla/show_bug.cgi?id=538
 */

enum UCustomType {
  UCustom_Bool,
  UCustom_Int,
  UCustom_Str,
  UCustom_Path,
  UCustom_Symbol,
  UCustom_Key
};

uim_lisp
uim_custom_value(uim_lisp custom_sym);
int
uim_custom_value_as_bool(uim_lisp custom_sym);
int
uim_custom_value_as_int(uim_lisp custom_sym);
char *
uim_custom_value_as_str(uim_lisp custom_sym);
char *
uim_custom_value_as_path(uim_lisp custom_sym);
uim_lisp
uim_custom_value_as_symbol(uim_lisp custom_sym);
/* char **uim_custom_value_as_key(uim_lisp custom_sym); */
void
uim_custom_set(uim_lisp custom_sym, uim_lisp custom_val);
char *
uim_custom_symbol_label(uim_lisp custom_sym, uim_lisp val_sym);
char *
uim_custom_symbol_desc(uim_lisp custom_sym, uim_lisp val_sym);
uim_lisp
uim_custom_type(uim_lisp custom_sym);
int
uim_custom_ctype(uim_lisp custom_sym);
uim_lisp
uim_custom_range(uim_lisp custom_sym);
char *
uim_custom_group_label(uim_lisp group_sym);
char *
uim_custom_group_desc(uim_lisp group_sym);
uim_lisp
uim_custom_group_subgroups(uim_lisp group_sym);
uim_lisp
uim_custom_list_groups(void);
uim_lisp
uim_custom_list_primary_groups(void);
uim_lisp
uim_custom_collect_by_group(uim_lisp group_sym);
char *
uim_custom_value_as_string(uim_lisp sym);
char *
uim_custom_definition_as_string(uim_lisp sym);

/* function table for dynamic loading */
struct uim_api_tbl {
  int       (*uim_init)(void);
  void      (*uim_quit)(void);

  FILE     *(*uim_scm_get_output)(void);
  void      (*uim_scm_set_output)(FILE *fp);
  long      (*uim_scm_get_verbose_level)(void);
  void      (*uim_scm_set_verbose_level)(long new_value);
  void      (*uim_scm_load_file)(const char *fn);

  int       (*uim_scm_c_int)(uim_lisp integer);
  int       (*uim_scm_symbol_value_int)(const char *symbol_str);
  uim_lisp  (*uim_scm_int_from_c_int)(int integer);
  char     *(*uim_scm_c_str)(uim_lisp str);
  char     *(*uim_scm_symbol_value_str)(const char *symbol_str);
  uim_lisp  (*uim_scm_str_from_c_str)(const char *str);
  uim_lisp  (*uim_scm_c_strs_into_list)(int n_strs, const char *const *strs);
  uim_lisp  (*uim_scm_symbol_value)(const char *symbol_str);
  uim_lisp  (*uim_scm_intern_c_str)(const char *str);
  uim_lisp  (*uim_scm_qintern_c_str)(const char *str);
  long      (*uim_scm_repl_c_string)(char *str,
				     long want_init, long want_print);

  uim_lisp  (*uim_scm_t)(void);
  uim_lisp  (*uim_scm_f)(void);
  uim_lisp  (*uim_scm_null_list)(void);
  int       (*uim_scm_nullp)(uim_lisp obj);
  int       (*uim_scm_eq)(uim_lisp a, uim_lisp b);
  int       (*uim_scm_string_equal)(uim_lisp a, uim_lisp b);
  uim_lisp  (*uim_scm_eval)(uim_lisp obj);
  uim_lisp  (*uim_scm_quote)(uim_lisp obj);
  uim_lisp  (*uim_scm_car)(uim_lisp cell);
  uim_lisp  (*uim_scm_cdr)(uim_lisp cell);
  uim_lisp  (*uim_scm_cadr)(uim_lisp cell);
  uim_lisp  (*uim_scm_caar)(uim_lisp cell);
  uim_lisp  (*uim_scm_cdar)(uim_lisp cell);
  uim_lisp  (*uim_scm_cddr)(uim_lisp cell);
  uim_lisp  (*uim_scm_cons)(uim_lisp car, uim_lisp cdr);
  uim_lisp  (*uim_scm_nth)(uim_lisp n, uim_lisp lst);
  uim_lisp  (*uim_scm_list1)(uim_lisp elm1);
  uim_lisp  (*uim_scm_list2)(uim_lisp elm1, uim_lisp elm2);
  uim_lisp  (*uim_scm_list3)(uim_lisp elm1, uim_lisp elm2, uim_lisp elm3);
  uim_lisp  (*uim_scm_list4)(uim_lisp elm1, uim_lisp elm2, uim_lisp elm3,
			     uim_lisp elm4);
  uim_lisp  (*uim_scm_list5)(uim_lisp elm1, uim_lisp elm2, uim_lisp elm3,
			     uim_lisp elm4, uim_lisp elm5);

  uim_lisp  (*uim_custom_value)(uim_lisp custom_sym);
  int       (*uim_custom_value_as_bool)(uim_lisp custom_sym);
  int       (*uim_custom_value_as_int)(uim_lisp custom_sym);
  char     *(*uim_custom_value_as_str)(uim_lisp custom_sym);
  char     *(*uim_custom_value_as_path)(uim_lisp custom_sym);
  uim_lisp  (*uim_custom_value_as_symbol)(uim_lisp custom_sym);
  void      (*uim_custom_set)(uim_lisp custom_sym, uim_lisp custom_val);
  char     *(*uim_custom_symbol_label)(uim_lisp custom_sym, uim_lisp val_sym);
  char     *(*uim_custom_symbol_desc)(uim_lisp custom_sym, uim_lisp val_sym);
  uim_lisp  (*uim_custom_type)(uim_lisp custom_sym);
  int       (*uim_custom_ctype)(uim_lisp custom_sym);
  uim_lisp  (*uim_custom_range)(uim_lisp custom_sym);
  char     *(*uim_custom_group_label)(uim_lisp group_sym);
  char     *(*uim_custom_group_desc)(uim_lisp group_sym);
  uim_lisp  (*uim_custom_group_subgroups)(uim_lisp group_sym);
  uim_lisp  (*uim_custom_list_groups)(void);
  uim_lisp  (*uim_custom_list_primary_groups)(void);
  uim_lisp  (*uim_custom_collect_by_group)(uim_lisp group_sym);
  char     *(*uim_custom_value_as_string)(uim_lisp sym);
  char     *(*uim_custom_definition_as_string)(uim_lisp sym);
};

#ifdef __cplusplus
}
#endif
#endif
