EntityHandlerType() { name = newstring("mapsound"); }
void newm(const char *name) { gmenu &menu = menus.add(); menu.name = newstring(name); menu.menusel = 0; }
static void handle_options(int argc, char *argv[], Font *fnt) { register int lastext; register int i; size_t l; int arginc; char *temp; char c; char *vpl_name = NULL; Boolean have_capheight = 0; Boolean have_sfd = 0; int sfd_begin, postfix_begin; int base_name; stringlist* sl; /* scan first whether the -q switch is set */ for (i = 1; i < argc; i++) if (argv[i][0] == '-' && argv[i][1] == 'q') quiet = True; if (!quiet) printf("This is %s\n", ident); /* Make VPL file identical to that created under Unix */ fnt->titlebuf = (char *)mymalloc(strlen(progname) + strlen(argv[1]) + 1 + 1); sprintf(fnt->titlebuf, "%s %s", progname, argv[1]); /* * TrueType font name. */ fnt->ttfname = newstring(argv[1]); /* * The other arguments. We delay the final processing of some switches * until the tfm font name has been scanned -- if it contains two `@'s, * many switches are ignored. */ while (argc > 2 && *argv[2] == '-') { arginc = 2; i = argv[2][1]; switch (i) { case 'v': makevpl = 1; if (argc <= 3) oops("Missing parameter for -v option."); if (vpl_name) free(vpl_name); vpl_name = newstring(argv[3]); handle_extension(&vpl_name, ".vpl"); break; case 'V': makevpl = 2; if (argc <= 3) oops("Missing parameter for -V option."); if (vpl_name) free(vpl_name); vpl_name = newstring(argv[3]); handle_extension(&vpl_name, ".vpl"); break; case 'f': if (argc <= 3) oops("Missing parameter for -f option."); if (sscanf(argv[3], "%lu", &(fnt->fontindex)) == 0) oops("Invalid font index."); fnt->fontindexparam = argv[3]; break; case 'E': if (argc <= 3) oops("Missing parameter for -E option."); if (sscanf(argv[3], "%hu", &(fnt->eid)) == 0) oops("Invalid encoding ID."); fnt->eidparam = argv[3]; break; case 'P': if (argc <= 3) oops("Missing parameter for -P option."); if (sscanf(argv[3], "%hu", &(fnt->pid)) == 0) oops("Invalid platform ID."); fnt->pidparam = argv[3]; break; case 'e': if (argc <= 3) oops("Missing parameter for -e option."); if (sscanf(argv[3], "%f", &(fnt->efactor)) == 0 || fnt->efactor < 0.01) oops("Bad extension factor."); fnt->efactorparam = argv[3]; break; case 'c': if (argc <= 3) oops("Missing parameter for -c option."); have_capheight = True; if (sscanf(argv[3], "%f", &(fnt->capheight)) == 0) fnt->capheight = 0; break; case 's': if (argc <= 3) oops("Missing parameter for -s option."); if (sscanf(argv[3], "%f", &(fnt->slant)) == 0) oops("Bad slant parameter."); fnt->slantparam = argv[3]; break; case 'p': if (argc <= 3) oops("Missing parameter for -p option."); if (fnt->inencname) free(fnt->inencname); fnt->inencname = newstring(argv[3]); break; case 'T': if (argc <= 3) oops("Missing parameter for -T option."); if (fnt->inencname) free(fnt->inencname); if (fnt->outencname) free(fnt->outencname); fnt->inencname = newstring(argv[3]); fnt->outencname = newstring(argv[3]); break; case 't': if (argc <= 3) oops("Missing parameter for -T option."); if (fnt->outencname) free(fnt->outencname); fnt->outencname = newstring(argv[3]); break; case 'r': if (argc <= 4) oops("Not enough parameters for -r option."); sl = newstringlist(); sl->old_name = newstring(argv[3]); sl->new_name = newstring(argv[4]); sl->single_replacement = True; sl->next = fnt->replacements; fnt->replacements = sl; arginc = 3; break; case 'R': if (argc <= 3) oops("Missing parameter for -R option."); if (fnt->replacementname) free(fnt->replacementname); fnt->replacementname = newstring(argv[3]); break; case 'y': if (argc <= 3) oops("Missing parameter for -y option."); if (sscanf(argv[3], "%f", &(fnt->y_offset)) == 0) oops("Invalid y-offset."); fnt->y_offsetparam = argv[3]; break; case 'O': forceoctal = True; arginc = 1; break; case 'n': fnt->PSnames = Yes; arginc = 1; break; case 'N': fnt->PSnames = Only; arginc = 1; break; case 'u': pedantic = True; arginc = 1; break; case 'q': quiet = True; arginc = 1; break; case 'L': if (argc <= 3) oops("Missing parameter for -L option."); if (fnt->ligname) free(fnt->ligname); fnt->ligname = newstring(argv[3]); fnt->subfont_ligs = True; break; case 'l': fnt->subfont_ligs = True; arginc = 1; break; case 'w': fnt->write_enc = True; arginc = 1; break; case 'x': fnt->rotate = True; arginc = 1; break; case 'o': if (argc <= 3) oops("Missing parameter for -o option."); if (vpl_name) free(vpl_name); vpl_name = newstring(argv[3]); handle_extension(&vpl_name, ".ovp"); break; default: if (argc <= 3 || argv[3][0] == '-') { warning("Unknown option `%s' will be ignored.\n", argv[2]); arginc = 1; } else warning("Unknown option `%s %s' will be ignored.\n", argv[2], argv[3]); } for (i = 0; i < arginc; i++) { l = strlen(fnt->titlebuf); fnt->titlebuf = (char *)myrealloc((void *)fnt->titlebuf, l + strlen(argv[2]) + 1 + 1); sprintf(fnt->titlebuf + strlen(fnt->titlebuf), " %s", argv[2]); argv++; argc--; } } /* Read replacement glyph name file */ get_replacements(fnt); if (argc > 3 || (argc == 3 && *argv[2] == '-')) oops("Need at most two non-option arguments."); /* * The tfm file name. */ if (argc == 2) temp = newstring(fnt->ttfname); else { temp = newstring(argv[2]); l = strlen(fnt->titlebuf); fnt->titlebuf = (char *)myrealloc((void *)fnt->titlebuf, l + strlen(argv[2]) + 1 + 1); sprintf(fnt->titlebuf + strlen(fnt->titlebuf), " %s", argv[2]); } handle_sfd(temp, &sfd_begin, &postfix_begin); if (sfd_begin > -1) { have_sfd = True; i = sfd_begin - 2; } else i = strlen(temp) - 1; /* * Now we search the beginning of the name without directory. */ for (; i >= 0; i--) if (temp[i] == '/' || temp[i] == ':' || temp[i] == '\\') break; base_name = i + 1; /* * We store the path (with the final directory separator). */ if (base_name > 0) { c = temp[base_name]; temp[base_name] = '\0'; fnt->tfm_path = newstring(temp); temp[base_name] = c; } if (have_sfd) { /* the prefix and the sfd file name */ if (temp[base_name]) fnt->outname = newstring(temp + base_name); fnt->sfdname = newstring(temp + sfd_begin); } else postfix_begin = base_name; /* * Get the extension. */ lastext = -1; for (i = postfix_begin; temp[i]; i++) if (temp[i] == '.') lastext = i; if (argc == 2 && lastext >= 0) { temp[lastext] = '\0'; /* remove TTF file extension */ lastext = -1; } if (lastext == -1) fnt->tfm_ext = newstring(".tfm"); else { fnt->tfm_ext = newstring(temp + lastext); temp[lastext] = '\0'; } if (have_sfd) { if (temp[postfix_begin]) fnt->outname_postfix = newstring(temp + postfix_begin); } else { if (temp[base_name]) fnt->outname = newstring(temp + base_name); else oops("Invalid tfm file name."); } /* * Now we can process the remaining parameters. */ if (have_sfd) { if (makevpl) { warning("Ignoring `-v' and `-V' switches for subfonts."); makevpl = 0; } if (vpl_name) if ((fnt->vplout = fopen(vpl_name, "wb")) == NULL) oops("Cannot open ovp output file."); if (have_capheight) warning("Ignoring `-c' switch for subfonts."); if (fnt->inencname || fnt->outencname) { warning("Ignoring `-p', `-t', and `-T' switches for subfonts."); fnt->inencname = NULL; fnt->outencname = NULL; } if (fnt->y_offsetparam && !fnt->rotate) warning("Ignoring `-y' switch for non-rotated subfonts."); if (fnt->PSnames) { warning("Ignoring `-n' or '-N' switch for subfonts."); fnt->PSnames = No; } init_sfd(fnt, True); } else { if (have_capheight && fnt->capheight < 0.01) oops("Bad small caps height."); if (vpl_name) if ((fnt->vplout = fopen(vpl_name, "wb")) == NULL) oops("Cannot open vpl output file."); if (fnt->subfont_ligs) { warning("Ignoring `-l' switch for non-subfont."); fnt->subfont_ligs = False; } if (fnt->rotate) { warning("Ignoring `-x' switch for non-subfont."); fnt->rotate = False; } if (fnt->write_enc) { warning("Ignoring `-w' switch for non-subfont."); fnt->write_enc = False; } if (fnt->y_offsetparam) warning("Ignoring `-y' switch for non-subfont."); } if (fnt->PSnames == Only) { if (fnt->pidparam || fnt->eidparam) { warning("Ignoring `-P' and `-E' options if `-N' switch is selected."); fnt->pidparam = NULL; fnt->eidparam = NULL; } } if (vpl_name) free(vpl_name); free(temp); }
void preloadmodel(const char *name) { if(!name || !name[0] || models.access(name) || preloadmodels.htfind(name) >= 0) return; preloadmodels.add(newstring(name)); }
void setup(int argc, char **argv) { int c, fd, i; char *fp, *dp; Tokenrow tr; extern void setup_kwtab(void); setup_kwtab(); while ((c = getopt(argc, argv, "MNOVv+I:D:U:F:lg")) != -1) switch (c) { case 'N': for (i=0; i<NINCLUDE; i++) if (includelist[i].always==1) includelist[i].deleted = 1; break; case 'I': for (i=NINCLUDE-2; i>=0; i--) { if (includelist[i].file==NULL) { includelist[i].always = 1; includelist[i].file = optarg; break; } } if (i<0) error(FATAL, "Too many -I directives"); break; case 'D': case 'U': setsource("<cmdarg>", -1, optarg); maketokenrow(3, &tr); gettokens(&tr, 1); doadefine(&tr, c); unsetsource(); break; case 'M': Mflag++; break; case 'v': fprintf(stderr, "%s %s\n", argv[0], rcsid); break; case 'V': verbose++; break; case '+': Cplusplus++; break; default: break; } dp = "."; fp = "<stdin>"; fd = 0; if (optind<argc) { if ((fp = strrchr(argv[optind], '/')) != NULL) { int len = fp - argv[optind]; dp = (char*)newstring((uchar*)argv[optind], len+1, 0); dp[len] = '\0'; } fp = (char*)newstring((uchar*)argv[optind], strlen(argv[optind]), 0); if ((fd = open(fp, 0)) <= 0) error(FATAL, "Can't open input file %s", fp); } if (optind+1<argc) { int fdo = creat(argv[optind+1], 0666); if (fdo<0) error(FATAL, "Can't open output file %s", argv[optind+1]); dup2(fdo, 1); } if(Mflag) setobjname(fp); includelist[NINCLUDE-1].always = 0; includelist[NINCLUDE-1].file = dp; setsource(fp, fd, NULL); }
/* * local function to read an expression */ static LVAL _readexpr(tpLspObject pLSP,FILE *f) { int ch,ch1,ch2,i; LVAL p; char *s; double dval; long lval; spaceat(ch,f); if( ch == EOF ) { return NIL; } if( ch == pLSP->cClose ) { return NIL; } if( ch == pLSP->cOpen )/* Read a cons node. */ return readcons(pLSP,f); /**** Note: XLISP allows 1E++10 as a symbol. This is dangerous. We do not change XLISP (so far), but here I exclude all symbol names starting with numeral. */ if( const_p1(ch) )/* Read a symbol. */ { for( i = 0 ; const_p(ch) ; i++ ){ if( storech(pLSP,i,ch) )return NIL; ch = getC(pLSP,f); } UNGETC(ch); /* Recognize NIL and nil symbols. */ if( !strcmp(BUFFER,"NIL") || !strcmp(BUFFER,"nil") ) return NIL; p = newsymbol(); s = StrDup( BUFFER ); if( null(p) || s == NULL )return NIL; setsymbol(p,s); return p; } if( ch == '\"' ){ ch = GETC(f); storech(pLSP,0,0); /* inititalize the buffer */ if( ch != '\"' )goto SimpleString; ch = GETC(f); if( ch != '\"' ){ UNGETC(ch); ch = '\"';/* ch should hold the first character of the string that is " now */ goto SimpleString; } ch = GETC(f); /* multi line string */ for( i = 0 ; ch != EOF ; i++ ){ if( ch == '\"' ){ ch1 = GETC(f); ch2 = GETC(f); if( ch1 == '\"' && ch2 == '\"' )break; UNGETC(ch2); UNGETC(ch1); } if( ch == '\\' ){ ch = GETC(f); s = escapers; while( *s ){ if( *s++ == ch ){ ch = *s; break; } if( *s )s++; } } if( storech(pLSP,i,ch) )return NIL; ch = GETC(f); } p = newstring(); s = StrDup( BUFFER ); if( null(p) || s == NULL )return NIL; setstring(p,s); return p; } if( ch == '\"' ){/* Read a string. */ ch = GETC(f);/* Eat the " character. */ SimpleString: for( i = 0 ; ch != '\"' && ch != EOF ; i++ ){ if( ch == '\\' ){ ch = GETC(f); s = escapers; while( *s ){ if( *s++ == ch ){ ch = *s; break; } if( *s )s++; } } if( ch == '\n' )return NIL; if( storech(pLSP,i,ch) )return NIL; ch = GETC(f); } p = newstring(); s = StrDup( BUFFER ); if( null(p) || s == NULL ) { return NIL; } setstring(p,s); return p; } if( numeral1(ch) ) { for( i = 0 ; isinset(ch,"0123456789+-eE.") ; i++ ) { if( storech(pLSP,i,ch) )return NIL; ch = getC(pLSP,f); } UNGETC(ch); cnumeric(BUFFER,&i,&dval,&lval); switch( i ) { case 0: return NIL; case 1: /* A float number is coming. */ p = newfloat(); if( null(p) ) { return NIL; } setfloat(p,dval); return p; case 2: /* An integer is coming. */ p = newint(); if( null(p) ) { return NIL; } setint(p,lval); return p; default: return NIL; } } return NIL; }
int execute(char *p, bool isdown) // all evaluation happens here, recursively { const int MAXWORDS = 25; // limit, remove char *w[MAXWORDS]; int val = 0; for(bool cont = true; cont;) // for each ; seperated statement { int numargs = MAXWORDS; loopi(MAXWORDS) // collect all argument values { w[i] = (char*) ""; if(i>numargs) continue; char *s = parseword(p); // parse and evaluate exps if(!s) { numargs = i; s = (char*) ""; }; if(*s=='$') s = lookup(s); // substitute variables w[i] = s; }; p += strcspn(p, ";\n\0"); cont = *p++!=0; // more statements if this isn't the end of the string const char *c = w[0]; if(*c=='/') c++; // strip irc-style command prefix if(!*c) continue; // empty statement ident *id = idents->access(c); if(!id) { val = ATOI(c); if(!val && *c!='0') console::out("unknown command: %s", c); } else switch(id->type) { case ID_COMMAND: // game defined commands switch(id->narg) // use very ad-hoc function signature, and just call it { case ARG_1INT: if(isdown) ((void (__cdecl *)(int))id->fun)(ATOI(w[1])); break; case ARG_2INT: if(isdown) ((void (__cdecl *)(int, int))id->fun)(ATOI(w[1]), ATOI(w[2])); break; case ARG_3INT: if(isdown) ((void (__cdecl *)(int, int, int))id->fun)(ATOI(w[1]), ATOI(w[2]), ATOI(w[3])); break; case ARG_4INT: if(isdown) ((void (__cdecl *)(int, int, int, int))id->fun)(ATOI(w[1]), ATOI(w[2]), ATOI(w[3]), ATOI(w[4])); break; case ARG_NONE: if(isdown) ((void (__cdecl *)())id->fun)(); break; case ARG_1STR: if(isdown) ((void (__cdecl *)(char *))id->fun)(w[1]); break; case ARG_2STR: if(isdown) ((void (__cdecl *)(char *, char *))id->fun)(w[1], w[2]); break; case ARG_3STR: if(isdown) ((void (__cdecl *)(char *, char *, char*))id->fun)(w[1], w[2], w[3]); break; case ARG_5STR: if(isdown) ((void (__cdecl *)(char *, char *, char*, char*, char*))id->fun)(w[1], w[2], w[3], w[4], w[5]); break; case ARG_DOWN: ((void (__cdecl *)(bool))id->fun)(isdown); break; case ARG_DWN1: ((void (__cdecl *)(bool, char *))id->fun)(isdown, w[1]); break; case ARG_1EXP: if(isdown) val = ((int (__cdecl *)(int))id->fun)(execute(w[1])); break; case ARG_2EXP: if(isdown) val = ((int (__cdecl *)(int, int))id->fun)(execute(w[1]), execute(w[2])); break; case ARG_1EST: if(isdown) val = ((int (__cdecl *)(char *))id->fun)(w[1]); break; case ARG_2EST: if(isdown) val = ((int (__cdecl *)(char *, char *))id->fun)(w[1], w[2]); break; case ARG_VARI: if(isdown) { string r; // limit, remove r[0] = 0; for(int i = 1; i<numargs; i++) { strcat_s(r, w[i]); // make string-list out of all arguments if(i==numargs-1) break; strcat_s(r, " "); }; ((void (__cdecl *)(char *))id->fun)(r); break; } }; break; case ID_VAR: // game defined variabled if(isdown) { if(!w[1][0]) console::out("%s = %d", c, *id->storage); // var with no value just prints its current value else { if(id->min>id->max) { console::out("variable is read-only"); } else { int i1 = ATOI(w[1]); if(i1<id->min || i1>id->max) { i1 = i1<id->min ? id->min : id->max; // clamp to valid range console::out("valid range for %s is %d..%d", c, id->min, id->max); } *id->storage = i1; }; if(id->fun) ((void (__cdecl *)())id->fun)(); // call trigger function if available }; }; break; case ID_ALIAS: // alias, also used as functions and (global) variables for(int i = 1; i<numargs; i++) { sprintf_sd(t)("arg%d", i); // set any arguments as (global) arg values so functions can access them alias(t, w[i]); }; char *action = newstring(id->action); // create new string here because alias could rebind itself val = execute(action, isdown); gp()->deallocstr(action); break; }; loopj(numargs) gp()->deallocstr(w[j]); }; return val; };
void makefont(char *name, int dpi, int bdpi) { register char *p, *q; register int m, n; int modegiven = 0; #if defined MSDOS || defined OS2 || defined(ATARIST) double t; #endif if (command == 0) if (secure == 0 && (command=getenv("MAKETEXPK"))) command = newstring(command); else command = defcommand; for (p=command, q=buf; *p; p++) if (*p != '%') *q++ = *p; else { switch (*++p) { case 'n' : case 'N' : strcpy(q, name); break; case 'd' : case 'D' : sprintf(q, "%d", dpi); break; case 'b' : case 'B' : sprintf(q, "%d", bdpi); break; case 'o' : case 'O' : sprintf(q, "%s", mfmode ? mfmode : "default"); modegiven = 1; break; case 'm' : case 'M' : /* * Here we want to return a string. If we can find some integer * m such that floor(0.5 + bdpi * 1.2 ^ (m/2)) = dpi, we write out * magstep(m/2) * where m/2 is a decimal number; else we write out * dpi/bdpi * We do this for the very slight improvement in accuracy that * magstep() gives us over the rounded dpi/bdpi. */ m = 0; if (dpi < bdpi) { while (1) { m--; n = magstep(m, bdpi); if (n == dpi) break; if (n < dpi || m < -40) { m = 9999; break; } } } else if (dpi > bdpi) { while (1) { m++; n = magstep(m, bdpi); if (n == dpi) break; if (n > dpi || m > 40) { m = 9999; break; } } } #if defined MSDOS || defined OS2 /* write out magnification as decimal number */ if (m == 9999) { t = (double)dpi/bdpi; } else { if (m < 0) n = -m; else n = m; if (n & 1) { n &= ~1; t = 1.095445115; } else t = 1.0; while (n > 0) { n -= 2; t = t * 1.2; } if (m < 0) t = 1 / t; } sprintf(q, "%12.9f", t); #else #ifndef ATARIST if (m == 9999) { #else { #endif sprintf(q, "%d+%d/%d", dpi/bdpi, dpi%bdpi, bdpi); } else if (m >= 0) { sprintf(q, "magstep\\(%d.%d\\)", m/2, (m&1)*5); } else { sprintf(q, "magstep\\(-%d.%d\\)", (-m)/2, (m&1)*5); } #endif break; case 0 : *q = 0; break; default: *q++ = *p; *q = 0; break; }
PRIVATE BVECTOR getPrintString_body(VMSTATE vms, OBJ x, int depth) { char buf[80]; if (x == NULL) return newstring("null"); if (NUMP(x)) { sprintf(buf, "%ld", (long) NUM(x)); return newstring(buf); } if (SINGLETONP(x)) { if (x == true) return newstring("true"); if (x == false) return newstring("false"); if (x == undefined) return newstring("undefined"); return newstring("#<unknown-singleton>"); } if (OBJECTP(x)) return newstring("#<object>"); if (BVECTORP(x)) return (BVECTOR) x; if (OVECTORP(x)) { OVECTOR ov = (OVECTOR) x; switch (ov->type) { case T_HASHTABLE: return newstring("#<hashtable>"); case T_SLOT: return newstring("#<slot>"); case T_METHOD: return newstring("#<method>"); case T_CLOSURE: return newstring("#<closure>"); case T_SYMBOL: return (BVECTOR) AT(ov, SY_NAME); case T_PRIM: return bvector_concat(newstring("#<prim "), bvector_concat((BVECTOR) AT((OVECTOR) AT(ov, PR_NAME), SY_NAME), newstring(">"))); case T_FRAME: return newstring("#<frame>"); case T_VMREGS: return newstring("#<vmregs>"); case T_CONNECTION: return newstring("#<connection>"); case T_CONTINUATION: return newstring("#<continuation>"); case T_USERHASHLINK: return newstring("#<hashlink>"); default: return newstring("#<unknown-ovector-type>"); } } if (VECTORP(x)) { if (depth < 5) { VECTOR v = (VECTOR) x; BVECTOR result = newstring("["); int i; for (i = 0; i < (int) x->length - 1; i++) { result = bvector_concat(result, getPrintString_body(vms, AT(v, i), depth + 1)); result = bvector_concat(result, newstring(", ")); } if (x->length > 0) result = bvector_concat(result, getPrintString_body(vms, AT(v, x->length - 1), depth + 1)); return bvector_concat(result, newstring("]")); } else return newstring("[...]"); } return newstring("unhandled-type-getPrintString"); }
EntityHandlerType() { name = newstring("none?"); }
Line * inlist(FILE *fp) { int c,i; char *s; Point p; Line *l=0; while (1) { c=fgetc(fp); switch (c) { case '\n': break; default: do c = fgetc(fp); while (c != '\n'); break; case 'w': case 'l': l = newline(inpoint(fp),l); l->Q = inpoint(fp); break; case 'b': l = newbox(inpoint(fp),l); l->Q = inpoint(fp); break; case 'd': l = newdots(inpoint(fp),l); l->Q = inpoint(fp); break; case 'z': l = newmacro(inpoint(fp),l); l->Q = inpoint(fp); break; case 's': s = instring(fp); i = inint(fp); p = inpoint(fp); if (*s != 0) { l = newstring(p,i,l); setstring((String *)l,s); } break; case 't': /* turn a jraw text into two graw strings */ s = instring(fp); i = jtog(inint(fp)); p = Pt(0,(showgrey ? GRID*2 : GRID)); l = newstring(p,i,l); setstring((String *)l,s); s = instring(fp); inint(fp); p = inpoint(fp); if (*s != 0) { /* gad, what a mess */ l = newstring(add(p,l->P),i,l); setstring((String *)l,s); l->next->P = p; } else /* watch carefully */ l->P = p; break; case 'r': l = newref(intern(instring(fp)),l); break; case 'i': s = intern(instring(fp)); l = newinst(inpoint(fp),s,l); break; case 'm': nest = 1; l = newmaster(intern(instring(fp)),l); ((Master *)l)->dl = inlist(fp); break; case 'e': if (nest == 0) dprint("found end of no macro\n"); nest = 0; case -1: return l; } } }
EntityHandlerType() { name = newstring("position"); }
EntityHandlerType() { name = newstring("teleport"); }
EntityHandlerType() { name = newstring("spotlight"); }
char *exchangestr(char *o, const char *n) { delete[] o; return newstring(n); }
// XXX EMSCRIPTEN: load different player models at runtime void setplayermodelinfo(const char *ffa, const char *blueteam, const char *redteam, const char *hudguns, const char *vwep, const char *quad, const char *armour0, const char *armour1, const char *armour2, const char *ffaicon, const char *blueicon, const char *redicon, bool ragdoll) { assert(numplayermodels < MAX_PLAYER_MODELS); playermodelinfo &p = playermodels[numplayermodels++]; p.ffa = ffa ? newstring(ffa) : NULL; p.blueteam = blueteam ? newstring(blueteam) : NULL; p.redteam = redteam ? newstring(redteam) : NULL; p.hudguns = hudguns ? newstring(hudguns) : NULL; p.vwep = vwep ? newstring(vwep) : NULL; p.quad = quad ? newstring(quad) : NULL; p.armour[0] = armour0 ? newstring(armour0) : NULL; p.armour[1] = armour1 ? newstring(armour1) : NULL; p.armour[2] = armour2 ? newstring(armour2) : NULL; p.ffaicon = ffaicon ? newstring(ffaicon) : NULL; p.blueicon = blueicon ? newstring(blueicon) : NULL; p.redicon = redicon ? newstring(redicon) : NULL; p.ragdoll = ragdoll; }
/* Add new string. The actual string is assumed to be permanent. */ struct Ebl_WStrent * ebl_wstrtabadd (struct Ebl_WStrtab *st, const wchar_t *str, size_t len) { struct Ebl_WStrent *newstr; struct Ebl_WStrent **sep; /* Compute the string length if the caller doesn't know it. */ if (len == 0) len = wcslen (str) + 1; /* Make sure all "" strings get offset 0 but only if the table was created with a special null entry in mind. */ if (len == 1 && st->null.string != NULL) return &st->null; /* Allocate memory for the new string and its associated information. */ newstr = newstring (st, str, len); if (newstr == NULL) return NULL; /* Search in the array for the place to insert the string. If there is no string with matching prefix and no string with matching leading substring, create a new entry. */ sep = searchstring (&st->root, newstr); if (*sep != newstr) { /* This is not the same entry. This means we have a prefix match. */ if ((*sep)->len > newstr->len) { struct Ebl_WStrent *subs; /* Check whether we already know this string. */ for (subs = (*sep)->next; subs != NULL; subs = subs->next) if (subs->len == newstr->len) { /* We have an exact match with a substring. Free the memory we allocated. */ st->left += st->backp - (char *) newstr; st->backp = (char *) newstr; return subs; } /* We have a new substring. This means we don't need the reverse string of this entry anymore. */ st->backp -= newstr->len; st->left += newstr->len; newstr->next = (*sep)->next; (*sep)->next = newstr; } else if ((*sep)->len != newstr->len) { /* When we get here it means that the string we are about to add has a common prefix with a string we already have but it is longer. In this case we have to put it first. */ st->total += newstr->len - (*sep)->len; newstr->next = *sep; newstr->left = (*sep)->left; newstr->right = (*sep)->right; *sep = newstr; } else { /* We have an exact match. Free the memory we allocated. */ st->left += st->backp - (char *) newstr; st->backp = (char *) newstr; newstr = *sep; } } else st->total += newstr->len; return newstr; }
void checkligkern(char *s, Font *fnt) { char *mlist[5]; char *os; char *orig_s, *pos; size_t offset[5]; int n; os = newstring(s); orig_s = s; s++; while (isspace(*s)) s++; if (strncmp(s, "LIGKERN", 7) == 0) { fnt->sawligkern = True; s += 7; while (isspace(*s)) s++; pos = s; while (*pos) { for (n = 0; n < 5;) { if (*pos == '\0') break; offset[n] = pos - orig_s; mlist[n] = paramstring(&pos); if (strcmp(mlist[n], ";") == 0) break; n++; } if (n > 4) boops(os, pos - orig_s, "Too many parameters in lig kern data."); if (n < 3) boops(os, pos - orig_s, "Too few parameters in lig kern data."); if (n == 3 && strcmp(mlist[1], "{}") == 0) /* rmkern command */ rmkern(mlist[0], mlist[2], (ttfinfo *)0, fnt); else if (n == 3 && strcmp(mlist[1], "<>") == 0) /* addkern */ addkern(mlist[0], mlist[2], fnt); else if (n == 3 && strcmp(mlist[0], "||") == 0 && strcmp(mlist[1], "=") == 0) /* bc command */ { ttfinfo *ti = findadobe("||", fnt->charlist); if (fnt->boundarychar != -1) boops(os, offset[0], "Multiple boundary character commands?"); if (sscanf(mlist[2], "%d", &n) != 1) boops(os, offset[2], "Expected number assignment for boundary char."); if (n < 0 || n > 0xFF) boops(os, offset[2], "Boundary character number must be 0..0xFF."); fnt->boundarychar = n; if (ti == NULL) oops("Internal error: boundary char."); ti->outcode = n; /* prime the pump, so to speak, for lig/kerns */ } else if (n == 4) { int op = -1; ttfinfo *ti; for (n = 0; encligops[n]; n++) if (strcmp(mlist[2], encligops[n]) == 0) { op = n; break; } if (op < 0) boops(os, offset[2], "Bad ligature op specified."); if (NULL != (ti = findadobe(mlist[0], fnt->charlist))) { lig *lig; if (findadobe(mlist[2], fnt->charlist)) /* remove coincident kerns */ rmkern(mlist[0], mlist[1], ti, fnt); if (strcmp(mlist[3], "||") == 0) boops(os, offset[3], "You can't lig to the boundary character!"); if (!fnt->fixedpitch) /* fixed pitch fonts get *0* ligs */ { for (lig = ti->ligs; lig; lig = lig->next) if (strcmp(lig->succ, mlist[1]) == 0) break; /* we'll re-use this structure */ if (lig == NULL) { lig = newlig(); lig->succ = newstring(mlist[1]); lig->next = ti->ligs; ti->ligs = lig; } lig->sub = newstring(mlist[3]); lig->op = op; if (strcmp(mlist[1], "||") == 0) { lig->boundleft = 1; if (strcmp(mlist[0], "||") == 0) boops(os, offset[0], "You can't lig boundarychar boundarychar!"); } else lig->boundleft = 0; } } } else boops(os, offset[0], "Bad form in LIGKERN command."); } } free(os); }
void doinclude(Tokenrow* trp) { char fname[256], iname[256]; Includelist* ip; int angled, len, fd, i; trp->tp += 1; if (trp->tp >= trp->lp) goto syntax; if (trp->tp->type != STRING && trp->tp->type != LT) { len = trp->tp - trp->bp; expandrow(trp, "<include>"); trp->tp = trp->bp + len; } if (trp->tp->type == STRING) { len = trp->tp->len - 2; if (len > sizeof(fname) - 1) len = sizeof(fname) - 1; strncpy(fname, (char*)trp->tp->t + 1, len); angled = 0; } else if (trp->tp->type == LT) { len = 0; trp->tp++; while (trp->tp->type != GT) { if (trp->tp > trp->lp || len + trp->tp->len + 2 >= sizeof(fname)) goto syntax; strncpy(fname + len, (char*)trp->tp->t, trp->tp->len); len += trp->tp->len; trp->tp++; } angled = 1; } else goto syntax; trp->tp += 2; if (trp->tp < trp->lp || len == 0) goto syntax; fname[len] = '\0'; appendDirToIncludeList(basepath(fname)); if (fname[0] == '/') { fd = open(fname, 0); strcpy(iname, fname); } else for (fd = -1, i = NINCLUDE - 1; i >= 0; i--) { ip = &includelist[i]; if (ip->file == NULL || ip->deleted || (angled && ip->always == 0)) continue; if (strlen(fname) + strlen(ip->file) + 2 > sizeof(iname)) continue; strcpy(iname, ip->file); strcat(iname, "/"); strcat(iname, fname); if ((fd = open(iname, 0)) >= 0) break; } if (Mflag > 1 || (!angled && Mflag == 1)) { write(1, objname, strlen(objname)); write(1, iname, strlen(iname)); write(1, "\n", 1); } if (fd >= 0) { if (++incdepth > 10) error(FATAL, "#include too deeply nested"); setsource((char*)newstring((uchar*)iname, strlen(iname), 0), fd, NULL); genline(); } else { trp->tp = trp->bp + 2; error(ERROR, "Could not find include file %r", trp); } return; syntax: error(ERROR, "Syntax error in #include"); return; }
Cmd * parsecmd(int nest) { int i, c; Cmdtab *ct; Cmd *cp, *ncp; Cmd cmd; cmd.next = cmd.ccmd = 0; cmd.re = 0; cmd.flag = cmd.num = 0; cmd.addr = compoundaddr(); if(skipbl() == -1) return 0; if((c=getch())==-1) return 0; cmd.cmdc = c; if(cmd.cmdc=='c' && nextc()=='d'){ /* sleazy two-character case */ getch(); /* the 'd' */ cmd.cmdc='c'|0x100; } i = lookup(cmd.cmdc); if(i >= 0){ if(cmd.cmdc == '\n') goto Return; /* let nl_cmd work it all out */ ct = &cmdtab[i]; if(ct->defaddr==aNo && cmd.addr) error(Enoaddr); if(ct->count) cmd.num = getnum(ct->count); if(ct->regexp){ /* x without pattern -> .*\n, indicated by cmd.re==0 */ /* X without pattern is all files */ if((ct->cmdc!='x' && ct->cmdc!='X') || ((c = nextc())!=' ' && c!='\t' && c!='\n')){ skipbl(); if((c = getch())=='\n' || c<0) error(Enopattern); okdelim(c); cmd.re = getregexp(c); if(ct->cmdc == 's'){ cmd.ctext = newstring(); getrhs(cmd.ctext, c, 's'); if(nextc() == c){ getch(); if(nextc() == 'g') cmd.flag = getch(); } } } } if(ct->addr && (cmd.caddr=simpleaddr())==0) error(Eaddress); if(ct->defcmd){ if(skipbl() == '\n'){ getch(); cmd.ccmd = newcmd(); cmd.ccmd->cmdc = ct->defcmd; }else if((cmd.ccmd = parsecmd(nest))==0) panic("defcmd"); }else if(ct->text) cmd.ctext = collecttext(); else if(ct->token) cmd.ctext = collecttoken(ct->token); else atnl(); }else switch(cmd.cmdc){ case '{': cp = 0; do{ if(skipbl()=='\n') getch(); ncp = parsecmd(nest+1); if(cp) cp->next = ncp; else cmd.ccmd = ncp; }while(cp = ncp); break; case '}': atnl(); if(nest==0) error(Enolbrace); return 0; default: error_c(Eunk, cmd.cmdc); } Return: cp = newcmd(); *cp = cmd; return cp; }
char *exchangestr(char *o, const char *n) { gp()->deallocstr(o); return newstring(n); };
static bool readzipdirectory(const char *archname, FILE *f, int entries, int offset, uint size, vector<zipfile> &files) { uchar *buf = new uchar[size], *src = buf; if(fseek(f, offset, SEEK_SET) < 0 || fread(buf, 1, size, f) != size) { delete[] buf; return false; } loopi(entries) { if(src + ZIP_FILE_SIZE > &buf[size]) break; zipfileheader hdr; hdr.signature = lilswap(*(uint *)src); src += 4; hdr.version = lilswap(*(ushort *)src); src += 2; hdr.needversion = lilswap(*(ushort *)src); src += 2; hdr.flags = lilswap(*(ushort *)src); src += 2; hdr.compression = lilswap(*(ushort *)src); src += 2; hdr.modtime = lilswap(*(ushort *)src); src += 2; hdr.moddate = lilswap(*(ushort *)src); src += 2; hdr.crc32 = lilswap(*(uint *)src); src += 4; hdr.compressedsize = lilswap(*(uint *)src); src += 4; hdr.uncompressedsize = lilswap(*(uint *)src); src += 4; hdr.namelength = lilswap(*(ushort *)src); src += 2; hdr.extralength = lilswap(*(ushort *)src); src += 2; hdr.commentlength = lilswap(*(ushort *)src); src += 2; hdr.disknumber = lilswap(*(ushort *)src); src += 2; hdr.internalattribs = lilswap(*(ushort *)src); src += 2; hdr.externalattribs = lilswap(*(uint *)src); src += 4; hdr.offset = lilswap(*(uint *)src); src += 4; if(hdr.signature != ZIP_FILE_SIGNATURE) break; if(!hdr.namelength || !hdr.uncompressedsize || (hdr.compression && (hdr.compression != Z_DEFLATED || !hdr.compressedsize))) { src += hdr.namelength + hdr.extralength + hdr.commentlength; continue; } if(src + hdr.namelength > &buf[size]) break; string pname; int namelen = min((int)hdr.namelength, (int)sizeof(pname)-1); memcpy(pname, src, namelen); pname[namelen] = '\0'; path(pname); char *name = newstring(pname); zipfile &f = files.add(); f.name = name; f.header = hdr.offset; f.size = hdr.uncompressedsize; f.compressedsize = hdr.compression ? hdr.compressedsize : 0; #ifndef STANDALONE if(dbgzip) conoutf(CON_DEBUG, "%s: file %s, size %d, compress %d, flags %x", archname, name, hdr.uncompressedsize, hdr.compression, hdr.flags); #endif src += hdr.namelength + hdr.extralength + hdr.commentlength; } delete[] buf; return files.length() > 0; }
void control(Tokenrow *trp) { Nlist *np; Token *tp; tp = trp->tp; if (tp->type!=NAME) { if (tp->type==NUMBER) goto kline; if (tp->type != NL) error(ERROR, "Unidentifiable control line"); return; /* else empty line */ } if ((np = lookup(tp, 0))==NULL || (np->flag&ISKW)==0 && !skipping) { error(WARNING, "Unknown preprocessor control %t", tp); return; } if (skipping) { if ((np->flag&ISKW)==0) return; switch (np->val) { case KENDIF: if (--ifdepth<skipping) skipping = 0; --cursource->ifdepth; setempty(trp); return; case KIFDEF: case KIFNDEF: case KIF: if (++ifdepth >= NIF) error(FATAL, "#if too deeply nested"); ++cursource->ifdepth; return; case KELIF: case KELSE: if (ifdepth<=skipping) break; return; default: return; } } switch (np->val) { case KDEFINE: dodefine(trp); break; case KUNDEF: tp += 1; if (tp->type!=NAME || trp->lp - trp->bp != 4) { error(ERROR, "Syntax error in #undef"); break; } if ((np = lookup(tp, 0)) != NULL) np->flag &= ~ISDEFINED; break; case KPRAGMA: return; case KIFDEF: case KIFNDEF: case KIF: if (++ifdepth >= NIF) error(FATAL, "#if too deeply nested"); ++cursource->ifdepth; ifsatisfied[ifdepth] = 0; if (eval(trp, np->val)) ifsatisfied[ifdepth] = 1; else skipping = ifdepth; break; case KELIF: if (ifdepth==0) { error(ERROR, "#elif with no #if"); return; } if (ifsatisfied[ifdepth]==2) error(ERROR, "#elif after #else"); if (eval(trp, np->val)) { if (ifsatisfied[ifdepth]) skipping = ifdepth; else { skipping = 0; ifsatisfied[ifdepth] = 1; } } else skipping = ifdepth; break; case KELSE: if (ifdepth==0 || cursource->ifdepth==0) { error(ERROR, "#else with no #if"); return; } if (ifsatisfied[ifdepth]==2) error(ERROR, "#else after #else"); if (trp->lp - trp->bp != 3) error(ERROR, "Syntax error in #else"); skipping = ifsatisfied[ifdepth]? ifdepth: 0; ifsatisfied[ifdepth] = 2; break; case KENDIF: if (ifdepth==0 || cursource->ifdepth==0) { error(ERROR, "#endif with no #if"); return; } --ifdepth; --cursource->ifdepth; if (trp->lp - trp->bp != 3) error(WARNING, "Syntax error in #endif"); break; case KERROR: trp->tp = tp+1; error(WARNING, "#error directive: %r", trp); break; case KLINE: trp->tp = tp+1; expandrow(trp, "<line>"); tp = trp->bp+2; kline: if (tp+1>=trp->lp || tp->type!=NUMBER || tp+3<trp->lp || (tp+3==trp->lp && ((tp+1)->type!=STRING)||*(tp+1)->t=='L')){ error(ERROR, "Syntax error in #line"); return; } cursource->line = atol((char*)tp->t)-1; if (cursource->line<0 || cursource->line>=32768) error(WARNING, "#line specifies number out of range"); tp = tp+1; if (tp+1<trp->lp) cursource->filename=(char*)newstring(tp->t+1,tp->len-2,0); return; case KDEFINED: error(ERROR, "Bad syntax for control line"); break; case KINCLUDE: doinclude(trp); trp->lp = trp->bp; return; case KEVAL: eval(trp, np->val); break; default: error(ERROR, "Preprocessor control `%t' not yet implemented", tp); break; } setempty(trp); return; }
void schedule(const char *s) { type = ACTION; val.s = newstring(s); }
void addpackagedir(const char *dir) { string pdir; copystring(pdir, dir); if(fixpackagedir(pdir) > 0) packagedirs.add(newstring(pdir)); }
void schedule(ident *var, char *s) { type = STRING; id = var; val.s = newstring(s); }
char * resourcepath(const char * file) { return newstring(file); }
static inline void loopiter(ident *id, identstack &stack, const char *s) { tagval v; v.setstr(newstring(s)); loopiter(id, stack, v); }
int main(int argc, char *argv[]) { Font font; ttfinfo *ti; #ifdef MIKTEX miktex_initialize(); #endif init_font_structure(&font); TeX_search_init(argv[0], "ttf2tfm", "TTF2TFM"); if (argc == 1) { fputs("ttf2tfm: Need at least one file argument.\n", stderr); fputs("Try `ttf2tfm --help' for more information.\n", stderr); exit(1); } if (argc == 2) { if (strcmp(argv[1], "--help") == 0) usage(); else if (strcmp(argv[1], "--version") == 0) version(); } handle_options(argc, argv, &font); if (font.sfdname) { while (get_sfd(&font, True)) { char *temp, *ttemp; int i, start, end, len; get_tfm_fullname(&font); /* * Extract base name of sfd file. */ temp = newstring(font.sfdname); len = strlen(temp); start = 0; for (i = len - 1; i >= 0; i--) if (temp[i] == '/' || temp[i] == ':' || temp[i] == '\\') { start = i + 1; break; } end = len; for (i = len - 1; i >= 0; i--) if (temp[i] == '.') { end = i; break; } temp[end] = '\0'; ttemp = (char *)mymalloc(strlen(temp + start) + 4 + 1); sprintf(ttemp, "CJK-%s", temp + start); font.codingscheme = ttemp; free(temp); readttf(&font, quiet, True); if (font.replacements) warning("Replacement glyphs will be ignored."); /* second try to get an xheight value */ if (font.xheight == 0) { if (NULL != (ti = findadobe("x", font.charlist))) font.xheight = ti->ury; else if (font.pid == 3 && font.eid == 1 && NULL != (ti = findadobe(".c0x78", font.charlist))) font.xheight = ti->ury; else font.xheight = 400; } if (NULL != (ti = findadobe("space", font.charlist))) font.fontspace = ti->width; else if (NULL != (ti = findadobe(".c0x20", font.charlist))) font.fontspace = ti->width; else font.fontspace = transform(500, 0, font.efactor, font.slant); if (font.ligname) get_sfd(&font, False); /* read sfd files for ligatures */ if (buildtfm(&font)) { writetfm(&font); if (font.write_enc) writeenc(&font); if (font.vplout) add_subfont_list(&font); } } close_sfd(); if (font.vplout) { writeovp(&font); fclose(font.vplout); release_subfont_list(&font); } } else { get_tfm_fullname(&font); readttf(&font, quiet, False); replace_glyphs(&font); /* second try to get an xheight value */ if (font.xheight == 0) { if (NULL != (ti = findadobe("x", font.charlist))) font.xheight = ti->ury; else if (font.pid == 3 && font.eid == 1 && NULL != (ti = findadobe(".c0x78", font.charlist))) font.xheight = ti->ury; else font.xheight = 400; } if (NULL != (ti = findadobe("space", font.charlist))) font.fontspace = ti->width; else if (NULL != (ti = findadobe(".c0x20", font.charlist))) font.fontspace = ti->width; else font.fontspace = transform(500, 0, font.efactor, font.slant); handlereencoding(&font); buildtfm(&font); writetfm(&font); } if (makevpl) { assignchars(&font); if (makevpl > 1) upmap(&font); writevpl(&font, makevpl, forceoctal); fclose(font.vplout); } consttfonts(&font); exit(0); /* for safety reasons */ return 0; /* never reached */ }
EntityHandlerType() { name = newstring("envmap"); }