* (c) 2010 Martin Mares <mj@ucw.cz>
*/
-/*
- * TODO:
- * - we probably have to disable NOP
- */
-
/*
* Things that are not implemented:
*
if (!eol)
parse_error("Строка слишком долгая");
*eol = 0;
+ if (eol > line && eol[-1] == '\r')
+ *--eol = 0;
char *c = line;
if (!c[0] || c[0] == ';')
continue;
}
+ if (c[0] == '.')
+ return;
+
if (c[0] == '@')
{
c++;
eat = 1;
break;
case 4: // One Russian symbol
- bit = 6;
- fmt = "r";
+ fmt = "xr";
break;
case 5: // Russian text
fmt = "xrrrrrr";
break;
case 6: // One Latin symbol
- bit = 6;
- fmt = "l";
+ fmt = "xl";
break;
default: // Latin text
fmt = "xllllll";
linebuf[pos] = ch;
pos = (pos+1) & 0177;
}
- assert(!bit);
+ assert(bit >= 0);
}
static void run(void)
#define TBF_MAX 5 // Max number of tokens in the bucket
#define TBF_REFILL_PER_SEC 0.2 // Bucket refill rate (buckets/sec)
-#define PID_FILE "/var/run/minsk.pid"
-#define UID 65534
-#define GID 65534
+#define PID_FILE "/var/run/pd-minsk.pid"
+#define UID 124
+#define GID 125
static void die(char *msg)
{
}
}
+static void init_memory(void)
+{
+ // For the contest, we fill the whole memory with -00 00 0000 0000 (HALT),
+ // not +00 00 0000 0000 (NOP). Otherwise, an empty program would reveal
+ // the location of the password :)
+ for (int i=0; i<4096; i++)
+ mem[i] = 01000000000000ULL;
+
+ // Store the password
+ int pos = 02655;
+ mem[pos++] = 0574060565373;
+ mem[pos++] = 0371741405340;
+ mem[pos++] = 0534051524017;
+}
+
int main(int argc, char **argv)
{
+ init_memory();
+
if (argc > 1)
{
setproctitle_init(argc, argv);
run_as_daemon(1);
else if (!strcmp(argv[1], "--net"))
run_as_daemon(0);
+ else if (!strncmp(argv[1], "--trace=", 8))
+ trace = atoi(argv[1] + 8);
else
die("Usage: minsk [--daemon | --net]");
}
- trace = 3;
parse_in();
run();
return 0;