+=========1.4.44b================\r
+- "Implementation" of new buttons and controls.\r
+- The "Persist" option is now persistent. That is if you turn of "Persist" then as a special case PG will remember this.\r
+- There is now a "reset" button which restores the default options. The code is commented out since WB does not support it yet.\r
=========1.4.42b================\r
- SaveSettingsOnExit/SaveFile renamed as Persist/PersistFile.\r
- Many bug fixes in the persistence feature.\r
#define PACKAGE_NAME "polyglot"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "polyglot 1.4.42b"
+#define PACKAGE_STRING "polyglot 1.4.44b"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "polyglot"
/* Define to the version of this package. */
-#define PACKAGE_VERSION "1.4.42b"
+#define PACKAGE_VERSION "1.4.44b"
/* Define to 1 if the C compiler supports function prototypes. */
#define PROTOTYPES 1
#define TIME_WITH_SYS_TIME 1
/* Version number of package */
-#define VERSION "1.4.42b"
+#define VERSION "1.4.44b"
/* Define like PROTOTYPES; this can be used by system headers. */
#define __PROTOTYPES 1
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.61 for polyglot 1.4.42b.
+# Generated by GNU Autoconf 2.61 for polyglot 1.4.44b.
#
# Report bugs to <michel.vandenbergh@uhasselt.be>.
#
# Identity of this package.
PACKAGE_NAME='polyglot'
PACKAGE_TARNAME='polyglot'
-PACKAGE_VERSION='1.4.42b'
-PACKAGE_STRING='polyglot 1.4.42b'
+PACKAGE_VERSION='1.4.44b'
+PACKAGE_STRING='polyglot 1.4.44b'
PACKAGE_BUGREPORT='michel.vandenbergh@uhasselt.be'
ac_unique_file="mainloop.c"
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures polyglot 1.4.42b to adapt to many kinds of systems.
+\`configure' configures polyglot 1.4.44b to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of polyglot 1.4.42b:";;
+ short | recursive ) echo "Configuration of polyglot 1.4.44b:";;
esac
cat <<\_ACEOF
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-polyglot configure 1.4.42b
+polyglot configure 1.4.44b
generated by GNU Autoconf 2.61
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by polyglot $as_me 1.4.42b, which was
+It was created by polyglot $as_me 1.4.44b, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@
# Define the identity of the package.
PACKAGE='polyglot'
- VERSION='1.4.42b'
+ VERSION='1.4.44b'
cat >>confdefs.h <<_ACEOF
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by polyglot $as_me 1.4.42b, which was
+This file was extended by polyglot $as_me 1.4.44b, which was
generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
-polyglot config.status 1.4.42b
+polyglot config.status 1.4.44b
configured by $0, generated by GNU Autoconf 2.61,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61)
-AC_INIT([polyglot], [1.4.42b], [michel.vandenbergh@uhasselt.be])
+AC_INIT([polyglot], [1.4.44b], [michel.vandenbergh@uhasselt.be])
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([mainloop.c])
AC_CONFIG_HEADER([config.h])
ini->index=0;
}
+// ini_copy()
+
+void ini_copy(ini_t *dst, ini_t *src){
+ int i;
+ dst->index=src->index;
+ dst->iter=src->iter;
+ for(i=0;i<src->index;i++){
+ my_string_set(&dst->entries[i].section,src->entries[i].section);
+ my_string_set(&dst->entries[i].name,src->entries[i].name);
+ my_string_set(&dst->entries[i].value,src->entries[i].value);
+ }
+}
+
// ini_find()
ini_entry_t *ini_find(ini_t *ini, const char *section, const char* name){
void ini_disp(ini_t *ini){
int i;
- my_log("POLYGLOT Current options\n");
for(i=0;i<ini->index;i++){
my_log("POLYGLOT [%s] %s=\"%s\"\n",
(ini->entries)[i].section,
return &ini->entries[ini->iter++];
}
-// ini_create_pg()
extern void ini_init (ini_t *ini);
extern void ini_clear (ini_t *ini);
+extern void ini_copy (ini_t *dst, ini_t *src);
extern int ini_parse (ini_t *ini, const char *filename);
extern void ini_disp (ini_t *ini);
extern void ini_insert (ini_t *ini, ini_entry_t *entry);
// constants\r
\r
\r
-static const char * const Version = "1.4.42b";\r
+static const char * const Version = "1.4.44b";\r
static const char * const HelpMessage = "\\r
SYNTAX\n\\r
* polyglot [configfile] [-noini] [-ec engine] [-ed enginedirectory] [-en enginename] [-log] [-lf logfile] [-hash value] [-bk book] [-pg <name>=<value>]* [-uci <name>=<value>]*\n\\r
FILE *f;\r
f=fopen(filename,"w");\r
if(!f){\r
- my_fatal("ini_create_pg(): Cannot open %s for writing.\n",filename);\r
+ my_fatal("write_ini(): Cannot open %s for writing.\n",filename);\r
}\r
fprintf(f,"; You may edit this file to set options for the\n"\r
"; UCI engine whose PolyGlot name is %s.\n"\r
option_start_iter(pg_options);\r
while((opt=option_next(pg_options))){\r
if(!my_string_equal(opt->value,opt->default_)&&\r
- !my_string_case_equal(opt->type,"button") &&\r
+ !IS_BUTTON(opt) &&\r
(opt->mode & XBOARD)){\r
snprintf(tmp,sizeof(tmp),"%s=%s\n",opt->name,opt->value);\r
tmp[sizeof(tmp)-1]='\0';\r
option_start_iter(uci_options);\r
while((opt=option_next(uci_options))){\r
if(!my_string_equal(opt->value,opt->default_)&&\r
- !my_string_case_equal(opt->type,"button")){\r
+ !IS_BUTTON(opt)){\r
snprintf(tmp,sizeof(tmp),"%s=%s\n",opt->name,opt->value);\r
tmp[sizeof(tmp)-1]='\0';\r
fprintf(f,"%s",tmp);\r
fclose(f);\r
}\r
\r
+// write_ini_ex()\r
+\r
+static void write_ini_ex(const char *filename,\r
+ ini_t *ini){\r
+ ini_entry_t *entry;\r
+ char tmp[StringSize];\r
+ FILE *f;\r
+ f=fopen(filename,"w");\r
+ if(!f){\r
+ my_fatal("write_ini_ex(): Cannot open %s for writing.\n",filename);\r
+ }\r
+ fprintf(f,"; You may edit this file to set options for the\n"\r
+ "; UCI engine whose PolyGlot name is %s.\n"\r
+ "; You may also safely delete this file\n"\r
+ "; to restore the default options.\n",\r
+ option_get_string(Option,"EngineName"));\r
+ fprintf(f,"[PolyGlot]\n");\r
+ ini_start_iter(ini);\r
+ while((entry=ini_next(ini))){\r
+ if(my_string_case_equal(entry->section,"polyglot")){\r
+ snprintf(tmp,sizeof(tmp),"%s=%s\n",\r
+ entry->name,\r
+ entry->value);\r
+ tmp[sizeof(tmp)-1]='\0';\r
+ fprintf(f,"%s",tmp);\r
+ }\r
+ }\r
+ fprintf(f,"[Engine]\n");\r
+ ini_start_iter(ini);\r
+ while((entry=ini_next(ini))){\r
+ if(my_string_case_equal(entry->section,"engine")){\r
+ snprintf(tmp,sizeof(tmp),"%s=%s\n",\r
+ entry->name,\r
+ entry->value);\r
+ tmp[sizeof(tmp)-1]='\0';\r
+ fprintf(f,"%s",tmp);\r
+ }\r
+ }\r
+ fclose(f);\r
+}\r
+\r
\r
// main()\r
\r
ini_entry_t *entry;\r
char *arg;\r
int arg_index;\r
- bool NoIni;\r
+ bool NoIni, Persist;\r
\r
if(!DEBUG){\r
printf("PolyGlot %s by Fabien Letouzey.\n",Version);\r
my_log("POLYGLOT *** Switching to UCI mode ***\n");\r
}\r
\r
- // initialize uci parsing and send uci command. Parse options and wait\r
- // for uciok\r
+ // initialize uci parsing and send uci command. \r
+ // Parse options and wait for uciok\r
\r
uci_open(Uci,Engine);\r
\r
option_set(Option,"PersistFile",tmp);\r
}\r
\r
- // if "Persist" is true, load the persist file!\r
- \r
- if(option_get_bool(Option,"Persist")){\r
- my_log("POLYGLOT PersistFile=%s\n",option_get_string(Option,"PersistFile"));\r
- if(ini_parse(ini_save,option_get_string(Option,"PersistFile"))){\r
- my_log("POLYGLOT Unable to open PersistFile\n"); \r
- }\r
+ // Load the persist file\r
+\r
+ my_log("POLYGLOT PersistFile=%s\n",option_get_string(Option,"PersistFile")); \r
+ if(ini_parse(ini_save,option_get_string(Option,"PersistFile"))){\r
+ my_log("POLYGLOT Unable to open PersistFile\n"); \r
+ }\r
+\r
+ // Do we want to use the persist file?\r
+\r
+ entry=ini_find(ini_save,"polyglot","Persist");\r
+ if(!entry){\r
+ Persist=option_get_bool(Option,"Persist");\r
+ }else{\r
+ Persist=(my_string_case_equal(entry->value,"false") || \r
+ my_string_equal(entry->value,"0"))?FALSE:TRUE;\r
}\r
- \r
- // parse the command line and merge remaining options\r
+\r
+ // if "Persist" now happens to be false, forget about the\r
+ // persist file \r
+\r
+ if(!Persist){\r
+ my_log("POLYGLOT Ignoring PersistFile");\r
+ ini_clear(ini_save);\r
+ }\r
+\r
+ option_set(Option,"Persist",Persist?"true":"false");\r
+\r
+ // parse the command line and merge remaining options\r
\r
arg_index=1;\r
while((arg=argv[arg_index])){\r
\r
// remind the reader once again about options\r
\r
- my_log("POLYGLOG Options from save file and command line\n");\r
+ my_log("POLYGLOG Options from PersistFile and command line\n");\r
ini_disp(ini_save);\r
\r
// extract PG options; this time do not set the default\r
// polyglot_set_option()\r
\r
void polyglot_set_option(const char *name, const char *value){ // this must be cleaned up!\r
+ option_t *opt;\r
my_log("POLYGLOT Setting PolyGlot option %s=\"%s\"\n",name,value);\r
+ if(my_string_case_equal(name,"Defaults")){\r
+ option_start_iter(Uci->option);\r
+ while((opt=option_next(Uci->option))){\r
+ if(!IS_BUTTON(opt)){\r
+ // also sets opt->value\r
+ uci_send_option(Uci,opt->name,opt->default_);\r
+ }\r
+ }\r
+ option_start_iter(Option);\r
+ while((opt=option_next(Option))){\r
+ if(!IS_BUTTON(opt)){\r
+ polyglot_set_option(opt->name,opt->default_);\r
+ }\r
+ }\r
+ xboard2uci_send_options();\r
+ }\r
option_set(Option,name,value);\r
if(option_get_bool(Option,"Book")&&(my_string_case_equal(name,"BookFile")||my_string_case_equal(name,"Book"))){\r
my_log("POLYGLOT *** SETTING BOOK ***\n");\r
my_log("POLYGLOT Unable to open book \"%s\"\n",option_get_string(Option,"BookFile"));\r
}\r
}else if(option_get_bool(Option,"Log")&&(my_string_case_equal(name,"LogFile") ||my_string_case_equal(name,"Log"))){\r
- my_log("POLYGLOT *** SETTING LOGFILE ***\n");\r
+ my_log("POLYGLOT *** SWITCHING LOGFILE ***\n");\r
my_log("POLYGLOT LOGFILE \"%s\"\n",option_get_string(Option,"LogFile"));\r
my_log_close();\r
my_log_open(option_get_string(Option,"LogFile"));\r
\r
void quit() {\r
\r
+ ini_t empty[1];\r
+\r
+ ini_init(empty);\r
+\r
my_log("POLYGLOT *** QUIT ***\n");\r
\r
if (Init) {\r
engine_close(Engine);\r
\r
}\r
+ // printf("def=%s val=%s\n",option_get_default(Option,"Persist"),option_get_string(Option,"Persist"));\r
if(option_get_bool(Option,"Persist")){\r
write_ini(option_get_string(Option,"PersistFile"),\r
Option,Uci->option);\r
+ }else if(!my_string_case_equal(option_get_default(Option,"Persist"),\r
+ option_get_string(Option,"Persist"))){\r
+ // Hack\r
+ ini_insert_ex(empty,"PolyGlot","Persist","false");\r
+ write_ini_ex(option_get_string(Option,"PersistFile"),empty);\r
+ }else{\r
+ write_ini_ex(option_get_string(Option,"PersistFile"),empty);\r
}\r
my_log("POLYGLOT Calling exit\n");\r
exit(EXIT_SUCCESS);\r
\r
{ "WbWorkArounds", "check","0","0", "true" , NULL,0,NNB, PG|XBOARD}, \r
{ "WbWorkArounds2", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD}, \r
+\r
+ // Buttons\r
+\r
+// { "Defaults", "reset","0","0", "false" , NULL,0,NNB, PG|XBOARD},\r
+\r
{ NULL, NULL,"0","0", NULL , NULL,0,NNB, 0},\r
\r
};\r
opt = option_find(option,name);\r
if (opt == NULL) return FALSE;\r
\r
+ if(my_string_case_equal(opt->type,"check")){\r
+ value=(my_string_equal(value,"1")||\r
+ my_string_case_equal(value,"true"))?"true":"false";\r
+ }\r
+\r
my_string_set(&opt->value,value);\r
\r
if (UseDebug) my_log("POLYGLOT OPTION SET \"%s\" -> \"%s\"\n",opt->name,opt->value);\r
opt = option_find(option,name);\r
if (opt == NULL) return FALSE;\r
\r
+ if(my_string_case_equal(opt->type,"check")){\r
+ value=(my_string_equal(value,"1")||\r
+ my_string_case_equal(value,"true"))?"true":"false";\r
+ }\r
+\r
my_string_set(&opt->default_,value);\r
\r
if (UseDebug) my_log("POLYGLOT OPTION DEFAULT SET \"%s\" -> \"%s\"\n",opt->name,opt->default_);\r
#define PG (1<<2)\r
#define OptionNb 256\r
\r
+#define IS_BUTTON(opt) (my_string_case_equal(opt->type,"button") || \\r
+ my_string_case_equal(opt->type,"save") || \\r
+ my_string_case_equal(opt->type,"reset")) \\r
+\r
+#define IS_SPIN(opt) (my_string_case_equal(opt->type,"spin") || \\r
+ my_string_case_equal(opt->type,"slider")) \\r
+\r
// types\r
\r
typedef struct { // TODO: put back in more logical order\r
Summary: A Winboard protocol to UCI protocol adapter
Name: polyglot
-Version: 1.4.42b
+Version: 1.4.44b
Release: 1
License: GPL
Group: Amusement/Games
opt=option_find(uci->option,option);\r
if(opt){\r
found=TRUE;\r
- if(!my_string_case_equal(opt->type,"button")){\r
+ if(!IS_BUTTON(opt)){\r
if(!my_string_equal(opt->value,value)){\r
engine_send(uci->engine,"setoption name %s value %s",\r
opt->name,value);\r
strcat(option_line,option_string);
sprintf(option_string," type %s",opt->type);
strcat(option_line,option_string);
- if(strcmp(opt->type,"button")){
+ if(!IS_BUTTON(opt)){
sprintf(option_string," default %s",opt->default_);
strcat(option_line,option_string);
}
- if(!strcmp(opt->type,"spin")){
+ if(IS_SPIN(opt)){
sprintf(option_string," min %s",opt->min);
strcat(option_line,option_string);
}
- if(!strcmp(opt->type,"spin")){
+ if(IS_SPIN(opt)){
sprintf(option_string," max %s",opt->max);
strcat(option_line,option_string);
}
} \\r
} \\r
\r
+\r
+\r
// types\r
\r
typedef signed char sint8;\r
#include "uci.h"\r
#include "uci2uci.h"\r
#include "util.h"\r
+#include "xboard2uci.h"\r
\r
// defines\r
\r
}\r
} else if (match(string,"option *")){\r
char *name=Star[0];\r
- start_protected_command();\r
+ if(match(name, "Polyglot *")){\r
+ char *pg_name=Star[0];\r
+ polyglot_set_option(pg_name,"<empty>");\r
+ }else{ \r
+ start_protected_command();\r
// value is ignored\r
- if(!uci_send_option(Uci, name, "%s", "<empty>")){\r
- gui_send(GUI,"Error (unknown option): %s",name); \r
- }; \r
- end_protected_command();\r
+ if(!uci_send_option(Uci, name, "%s", "<empty>")){\r
+ gui_send(GUI,"Error (unknown option): %s",name); \r
+ }; \r
+ end_protected_command();\r
+ }\r
} else if (XB->has_feature_smp && match(string,"cores *")){\r
int cores=atoi(Star[0]);\r
if(cores>=1){\r
strcat(option_line,option_string);\r
sprintf(option_string," -%s",opt->type);\r
strcat(option_line,option_string);\r
- if(strcmp(opt->type,"button") && strcmp(opt->type,"combo")){\r
+ if(!IS_BUTTON(opt) && strcmp(opt->type,"combo")){\r
if(strcmp(opt->type,"check")){\r
sprintf(option_string," %s",opt->value);\r
}else{\r
}\r
strcat(option_line,option_string);\r
}\r
- if(!strcmp(opt->type,"spin")){\r
+ if(IS_SPIN(opt)){\r
sprintf(option_string," %s",opt->min);\r
strcat(option_line,option_string);\r
}\r
- if(!strcmp(opt->type,"spin")){\r
+ if(IS_SPIN(opt)){\r
sprintf(option_string," %s",opt->max);\r
strcat(option_line,option_string);\r
}\r
\r
static void send_xboard_options(){\r
\r
- char option_line[StringSize]="";\r
- const char * name;\r
- option_t *opt;\r
- \r
+ \r
gui_send(GUI,"feature done=0");\r
\r
gui_send(GUI,"feature analyze=1");\r
gui_send(GUI,"feature variants=\"normal\"");\r
}\r
\r
- option_start_iter(Uci->option);\r
- while((opt=option_next(Uci->option))){\r
- if(my_string_case_equal(opt->name,"UCI_AnalyseMode")) continue;\r
- if(my_string_case_equal(opt->name,"UCI_Opponent")) continue;\r
- if(my_string_case_equal(opt->name,"UCI_Chess960")) continue;\r
- if(my_string_case_equal(opt->name,"UCI_ShowCurrLine")) continue;\r
- if(my_string_case_equal(opt->name,"UCI_ShowRefutations")) continue;\r
- if(my_string_case_equal(opt->name,"UCI_ShredderbasesPath")) continue;\r
- if(my_string_case_equal(opt->name,"UCI_SetPositionValue")) continue;\r
- if(my_string_case_equal(opt->name,"UCI_DrawOffers")) continue;\r
- if(my_string_case_equal(opt->name,"Ponder")) continue;\r
- if(my_string_case_equal(opt->name,"Hash")) continue;\r
- if(my_string_case_equal(opt->name,"NalimovPath")) continue;\r
- if((name=uci_thread_option(Uci))!=NULL &&\r
- my_string_case_equal(opt->name,name)) continue;\r
- format_xboard_option_line(option_line,opt);\r
- \r
- gui_send(GUI,"%s",option_line);\r
- }\r
-\r
+ xboard2uci_send_options();\r
+}\r
\r
- option_start_iter(Option);\r
- while((opt=option_next(Option))){\r
- if(opt->mode &XBOARD){\r
- if(my_string_case_equal(opt->name,"Persist") &&\r
- my_string_case_equal(option_get_default(Option,opt->name),\r
- "false")){\r
- continue;\r
- }\r
- format_xboard_option_line(option_line,opt);\r
- gui_send(GUI,"%s",option_line);\r
- }\r
- } \r
- gui_send(GUI,"feature done=1"); \r
+void xboard2uci_send_options(){\r
+ char option_line[StringSize]="";\r
+ const char * name;\r
+ option_t *opt;\r
+ \r
+ option_start_iter(Uci->option);\r
+ while((opt=option_next(Uci->option))){\r
+ if(my_string_case_equal(opt->name,"UCI_AnalyseMode")) continue;\r
+ if(my_string_case_equal(opt->name,"UCI_Opponent")) continue;\r
+ if(my_string_case_equal(opt->name,"UCI_Chess960")) continue;\r
+ if(my_string_case_equal(opt->name,"UCI_ShowCurrLine")) continue;\r
+ if(my_string_case_equal(opt->name,"UCI_ShowRefutations")) continue;\r
+ if(my_string_case_equal(opt->name,"UCI_ShredderbasesPath")) continue;\r
+ if(my_string_case_equal(opt->name,"UCI_SetPositionValue")) continue;\r
+ if(my_string_case_equal(opt->name,"UCI_DrawOffers")) continue;\r
+ if(my_string_case_equal(opt->name,"Ponder")) continue;\r
+ if(my_string_case_equal(opt->name,"Hash")) continue;\r
+ if(my_string_case_equal(opt->name,"NalimovPath")) continue;\r
+ if((name=uci_thread_option(Uci))!=NULL &&\r
+ my_string_case_equal(opt->name,name)) continue;\r
+ format_xboard_option_line(option_line,opt);\r
\r
+ gui_send(GUI,"%s",option_line);\r
+ }\r
+ \r
+ \r
+ option_start_iter(Option);\r
+ while((opt=option_next(Option))){\r
+ if(opt->mode &XBOARD){\r
+ format_xboard_option_line(option_line,opt);\r
+ gui_send(GUI,"%s",option_line);\r
+ }\r
+ } \r
+ gui_send(GUI,"feature done=1"); \r
+ \r
}\r
\r
// report_best_score()\r
extern void xboard2uci_init ();\r
extern void xboard2uci_gui_step (char string[]);\r
extern void xboard2uci_engine_step (char string[]);\r
+extern void xboard2uci_send_options ();\r
+\r
\r
#endif // !defined XBOARD2UCI_H\r
\r