32 #include "input.h" |
32 #include "input.h" |
33 #include "colors.h" |
33 #include "colors.h" |
34 #include <string.h> |
34 #include <string.h> |
35 #include <time.h> |
35 #include <time.h> |
36 #include <getopt.h> |
36 #include <getopt.h> |
|
37 #include <locale.h> |
37 |
38 |
38 int get_settings(int argc, char **argv, Settings *settings) { |
39 int get_settings(int argc, char **argv, Settings *settings) { |
39 char *valid; |
40 char *valid; |
40 unsigned long int time, port; |
41 unsigned long int time, port; |
41 uint8_t timeunit = 60; |
42 uint8_t timeunit = 60; |
42 size_t len; |
43 size_t len; |
43 |
44 |
44 for (int opt ; (opt = getopt(argc, argv, "a:bc:hp:rsS:t:v")) != -1 ;) { |
45 for (int opt ; (opt = getopt(argc, argv, "a:bc:hp:rsS:t:Uv")) != -1 ;) { |
45 switch (opt) { |
46 switch (opt) { |
46 case 'c': |
47 case 'c': |
47 settings->continuepgn = optarg; |
48 settings->continuepgn = optarg; |
48 break; |
49 break; |
49 case 'b': |
50 case 'b': |
112 " -a <time> Specifies the time to add after each move\n" |
116 " -a <time> Specifies the time to add after each move\n" |
113 " -b Server plays black pieces (default: white)\n" |
117 " -b Server plays black pieces (default: white)\n" |
114 " -r Distribute color randomly\n" |
118 " -r Distribute color randomly\n" |
115 " -s Single machine mode\n" |
119 " -s Single machine mode\n" |
116 " -t <time> Specifies time limit (default: no limit)\n" |
120 " -t <time> Specifies time limit (default: no limit)\n" |
|
121 " -U Disables unicode pieces\n" |
117 "\nNotes\n" |
122 "\nNotes\n" |
118 "The time unit for -a is seconds and for -t minutes by default. To " |
123 "The time unit for -a is seconds and for -t minutes by default. To " |
119 "specify\nseconds for the -t option, use the s suffix.\n" |
124 "specify\nseconds for the -t option, use the s suffix.\n" |
120 "Example: -t 150s\n\n" |
125 "Example: -t 150s\n\n" |
121 "Use '-' for PGN files to read PGN data from standard input\n" |
126 "Use '-' for PGN files to read PGN data from standard input\n" |
149 static Settings default_settings() { |
154 static Settings default_settings() { |
150 Settings settings; |
155 Settings settings; |
151 memset(&settings, 0, sizeof(Settings)); |
156 memset(&settings, 0, sizeof(Settings)); |
152 settings.gameinfo.servercolor = WHITE; |
157 settings.gameinfo.servercolor = WHITE; |
153 settings.port = "27015"; |
158 settings.port = "27015"; |
|
159 settings.unicode = !!setlocale(LC_CTYPE, "C.UTF-8"); |
154 return settings; |
160 return settings; |
155 } |
161 } |
156 |
162 |
157 void dump_gameinfo(GameInfo *gameinfo) { |
163 void dump_gameinfo(GameInfo *gameinfo) { |
158 int serverwhite = gameinfo->servercolor == WHITE; |
164 int serverwhite = gameinfo->servercolor == WHITE; |