watch_columns { return TYPE_WATCH_COLUMNS; }
commands { return TYPE_CMDQUEUE; }
postcommands { return TYPE_POSTCMDQUEUE; }
+encoding { return TYPE_ENCODING; }
yes { yylval.i = 1; return TYPE_BOOL; }
no { yylval.i = 0; return TYPE_BOOL; }
dglstart { yylval.i = DGLTIME_DGLSTART; return TYPE_CMDQUEUENAME; }
#include <string.h>
#include "dgamelaunch.h"
+#include "ttyrec.h"
extern int yylex(void);
extern void yyerror(const char*);
%token TYPE_CMDQUEUE TYPE_DEFINE_MENU TYPE_BANNER_FILE TYPE_CURSOR
%token TYPE_POSTCMDQUEUE
%token TYPE_MAX_IDLE_TIME TYPE_MENU_MAX_IDLE_TIME TYPE_EXTRA_INFO_FILE
+%token TYPE_ENCODING
%token <s> TYPE_VALUE
%token <i> TYPE_NUMBER TYPE_CMDQUEUENAME
%type <kt> KeyType
myconfig[ncnf]->inprogressdir = strdup($3);
break;
+ case TYPE_ENCODING:
+ if (!strcasecmp($3, "ask"))
+ myconfig[ncnf]->encoding = -1;
+ else if ((myconfig[ncnf]->encoding = encoding_by_name($3)) == -1)
+ {
+ fprintf(stderr, "%s:%d: invalid value for encoding: \"%s\"\n",
+ config, line, $3);
+ exit(1);
+ }
+ break;
+
default:
fprintf(stderr, "%s:%d: token does not belong into game definition, bailing out\n",
config, line);
| TYPE_PATH_PASSWD { $$ = TYPE_PATH_PASSWD; }
| TYPE_PATH_LOCKFILE { $$ = TYPE_PATH_LOCKFILE; }
| TYPE_PATH_INPROGRESS { $$ = TYPE_PATH_INPROGRESS; }
+ | TYPE_ENCODING { $$ = TYPE_ENCODING; }
| TYPE_RC_FMT { $$ = TYPE_RC_FMT; }
| TYPE_WATCH_SORTMODE { $$ = TYPE_WATCH_SORTMODE; }
| TYPE_SERVER_ID { $$ = TYPE_SERVER_ID; }
struct dg_cmdpart *postcmdqueue;
int max_idle_time;
char *extra_info_file;
+ int encoding; // -1 = run --print-charset
};
struct dg_watchcols {
# # We can also define per-game commands executed after the game ends,
# # but before commands[gameend]
# postcommands = chdir "/"
+#
+# # If the game uses an ancient encoding, you may specify "ibm" or "dec".
+# # If set to "ask", the game will be run with --print-charset beforehand,
+# # expected to return one of these values.
+# encoding = "unicode"
#}
# rc_template = "/dgl-default-rcfile.crawl"
# rc_fmt = "%rrcfiles/%n.crawlrc"
# inprogressdir = "%rinprogress-crawlss017/"
+# encoding = ask
#}
#
}
signal(SIGALRM, SIG_IGN);
}
+
+int encoding_by_name(const char *enc)
+{
+ if (!strcasecmp(enc, "UTF-8") || !strcasecmp(enc, "UNICODE"))
+ return 0;
+ if (!strcasecmp(enc, "IBM") || !strcasecmp(enc, "CP437"))
+ return 1;
+ if (!strcasecmp(enc, "DEC"))
+ return 2;
+ if (!strcasecmp(enc, "ASCII"))
+ return 1; // what to do with invalid chars?
+ return -1;
+}
extern struct termios tt;
extern struct winsize win;
+extern int encoding_by_name(const char *enc);
#endif