/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.options.c version 1.0.1 - added HACKOPTIONS */ #include "config.h" #ifdef OPTIONS #include "hack.h" extern char *eos(); initoptions() { register char *opts; extern char *getenv(); flags.time = flags.nonews = flags.notombstone = flags.end_own = flags.no_rest_on_space = FALSE; flags.end_top = 5; flags.end_around = 4; /* flags.oneline is set in hack.tty.c depending on the baudrate */ if(opts = getenv("HACKOPTIONS")) parseoptions(opts,TRUE); } parseoptions(opts, from_env) register char *opts; boolean from_env; { register char *op,*op2; unsigned num; boolean negated; if(op = index(opts, ',')) { *op++ = 0; parseoptions(op, from_env); } if(op = index(opts, ' ')) { op2 = op; while(*op++) if(*op != ' ') *op2++ = *op; } if(!*opts) return; negated = FALSE; while((*opts == '!') || !strncmp(opts, "no", 2)) { if(*opts == '!') opts++; else opts += 2; negated = !negated; } if(!strncmp(opts,"tombstone",4)) { flags.notombstone = negated; return; } if(!strncmp(opts,"news",4)) { flags.nonews = negated; return; } if(!strncmp(opts,"time",4)) { flags.time = !negated; flags.botl = 1; return; } if(!strncmp(opts,"oneline",1)) { flags.oneline = !negated; return; } if(!strncmp(opts,"restonspace",4)) { flags.no_rest_on_space = negated; return; } /* endgame:5t[op] 5a[round] o[wn] */ if(!strncmp(opts,"endgame",3)) { op = index(opts,':'); if(!op) goto bad; op++; while(*op) { num = 1; if(digit(*op)) { num = atoi(op); while(digit(*op)) op++; } else if(*op == '!') { negated = !negated; op++; } switch(*op) { case 't': flags.end_top = num; break; case 'a': flags.end_around = num; break; case 'o': flags.end_own = !negated; break; default: goto bad; } while(letter(*++op)) ; if(*op == '/') op++; } return; } bad: if(!from_env) { if(!strncmp(opts, "help", 4)) { pline("%s%s%s", "To set options use `HACKOPTIONS=\"\"' in your environment, or ", "give the command 'o' followed by the line `' while playing. ", "Here is a list of