void write_dictionary(char *name, int len, char *dict, int dictsize, cell *up, int usersize) { FILE *fd; struct header file_hdr; char cstrbuf[512]; if ((fd = fopen(altocstr(name, len, cstrbuf, 512), "wb")) == NULL) fatal("Can't create dictionary file\n", up); file_hdr.magic = MAGIC; file_hdr.serial = 0; file_hdr.dstart = 0; file_hdr.dsize = dictsize; file_hdr.ustart = 0; file_hdr.usize = usersize; file_hdr.entry = 0; file_hdr.res1 = 0; if (fwrite((char *)&file_hdr, 1, sizeof(file_hdr), fd) != sizeof(file_hdr)) fatal("Can't write header\n", up); if (fwrite(dict, 1, dictsize, fd) != dictsize) fatal("Can't write dictionary image\n", up); if (fwrite((char *)up, 1, usersize, fd) != usersize) fatal("Can't write user area image\n", up); (void)fclose(fd); }
/* * This simplified interpreter has no interpret state. * Everything that can be "interpreted" as opposed to "compiled" * is "magic", and is executed directly by this metacompiler. * It doesn't handle numbers either. */ int interpret_word(u_char *adr, cell len, cell *up) { char strbuf[32]; char *cstr = altocstr((char *)adr, len, strbuf, 32); xt_t xt; token_t pct; int immed; int number; if (ismagic(cstr, up)) return(1); if (alfind((char *)adr, len, (xt_t *)&xt, up) != 0) { /* * If the word we found is a primitive, use its primitive number * instead of its cfa */ pct = *(token_t *)xt; compile ( pct < MAXPRIM ? pct : CT_FROM_XT(xt, up) ); return(1); } if (sscanf(cstr,"%d",&number) == 1) { if (V(STATE)) { compile(PAREN_LIT); ncomma(number); } else { stack = number; } return(1); } /* Undefined */ alerror((char *)adr, len, up); FTHERROR(" ?\n"); return(0); }