Annotation of OpenXM_contrib2/asir2018/builtin/miscf.c, Revision 1.1
1.1 ! noro 1: /*
! 2: * Copyright (c) 1994-2000 FUJITSU LABORATORIES LIMITED
! 3: * All rights reserved.
! 4: *
! 5: * FUJITSU LABORATORIES LIMITED ("FLL") hereby grants you a limited,
! 6: * non-exclusive and royalty-free license to use, copy, modify and
! 7: * redistribute, solely for non-commercial and non-profit purposes, the
! 8: * computer program, "Risa/Asir" ("SOFTWARE"), subject to the terms and
! 9: * conditions of this Agreement. For the avoidance of doubt, you acquire
! 10: * only a limited right to use the SOFTWARE hereunder, and FLL or any
! 11: * third party developer retains all rights, including but not limited to
! 12: * copyrights, in and to the SOFTWARE.
! 13: *
! 14: * (1) FLL does not grant you a license in any way for commercial
! 15: * purposes. You may use the SOFTWARE only for non-commercial and
! 16: * non-profit purposes only, such as academic, research and internal
! 17: * business use.
! 18: * (2) The SOFTWARE is protected by the Copyright Law of Japan and
! 19: * international copyright treaties. If you make copies of the SOFTWARE,
! 20: * with or without modification, as permitted hereunder, you shall affix
! 21: * to all such copies of the SOFTWARE the above copyright notice.
! 22: * (3) An explicit reference to this SOFTWARE and its copyright owner
! 23: * shall be made on your publication or presentation in any form of the
! 24: * results obtained by use of the SOFTWARE.
! 25: * (4) In the event that you modify the SOFTWARE, you shall notify FLL by
! 26: * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
! 27: * for such modification or the source code of the modified part of the
! 28: * SOFTWARE.
! 29: *
! 30: * THE SOFTWARE IS PROVIDED AS IS WITHOUT ANY WARRANTY OF ANY KIND. FLL
! 31: * MAKES ABSOLUTELY NO WARRANTIES, EXPRESSED, IMPLIED OR STATUTORY, AND
! 32: * EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS
! 33: * FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT OF THIRD PARTIES'
! 34: * RIGHTS. NO FLL DEALER, AGENT, EMPLOYEES IS AUTHORIZED TO MAKE ANY
! 35: * MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS WARRANTY.
! 36: * UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT,
! 37: * OR OTHERWISE, SHALL FLL BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY
! 38: * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL
! 39: * DAMAGES OF ANY CHARACTER, INCLUDING, WITHOUT LIMITATION, DAMAGES
! 40: * ARISING OUT OF OR RELATING TO THE SOFTWARE OR THIS AGREEMENT, DAMAGES
! 41: * FOR LOSS OF GOODWILL, WORK STOPPAGE, OR LOSS OF DATA, OR FOR ANY
! 42: * DAMAGES, EVEN IF FLL SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF
! 43: * SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. EVEN IF A PART
! 44: * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY
! 45: * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
! 46: * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
! 47: *
! 48: * $OpenXM$
! 49: */
! 50: #include "ca.h"
! 51: #include "parse.h"
! 52: #include <string.h>
! 53: #if !defined(VISUAL) && defined(DO_PLOT)
! 54: #include <X11/Xlib.h>
! 55: #include <X11/cursorfont.h>
! 56: #endif
! 57:
! 58: #if defined(VISUAL) || defined(__MINGW32__)
! 59: #include <direct.h>
! 60: #include <stdlib.h>
! 61: #include <windows.h>
! 62: #else
! 63: #include <unistd.h>
! 64: #include <sys/param.h>
! 65: #endif
! 66:
! 67: void Pgetcwd(), Pchdir();
! 68: void Pset_secure_mode();
! 69: void Pset_secure_flag();
! 70: void Pquit(), Pdebug(), Pnmono(), Pnez(), Popt(), Pshell(), Pheap();
! 71: void Ptoplevel();
! 72: void Perror(), Perror3(), Pversion(), Pcopyright(), Pflist(), Pdelete_history(), Ppause(), Pxpause();
! 73: void Pr2g(), Pread_cmo(), Pwrite_cmo();
! 74: void Pgc(),Pbatch(),Psend_progress();
! 75: void Pnull_command();
! 76: void Pgetenv();
! 77: void Pget_addr(),Phex_dump();
! 78: void Ppeek(),Ppoke();
! 79: void Psleep();
! 80: void Premove_module();
! 81: void Pmodule_list();
! 82: void Pmodule_definedp();
! 83: void Ptest();
! 84:
! 85: void delete_history(int,int);
! 86: void grab_pointer();
! 87:
! 88: struct ftab misc_tab[] = {
! 89: {"pwd",Pgetcwd,0},
! 90: {"chdir",Pchdir,1},
! 91: {"set_secure_mode",Pset_secure_mode,-1},
! 92: {"set_secure_flag",Pset_secure_flag,-2},
! 93: {"module_list",Pmodule_list,0},
! 94: {"remove_module",Premove_module,1},
! 95: {"module_definedp",Pmodule_definedp,1},
! 96: {"sleep",Psleep,1},
! 97: {"null_command",Pnull_command,-99999},
! 98: {"getenv",Pgetenv,1},
! 99: {"end",Pquit,0},
! 100: {"quit",Pquit,0},
! 101: {"debug",Pdebug,0},
! 102: {"shell",Pshell,-2},
! 103: {"heap",Pheap,-1},
! 104: {"version",Pversion,-99999},
! 105: {"copyright",Pcopyright,0},
! 106: {"nmono",Pnmono,1},
! 107: {"toplevel",Ptoplevel,-1},
! 108: {"error",Perror,1},
! 109: {"error3",Perror3,3},
! 110: {"nez",Pnez,1},
! 111: {"flist",Pflist,-1},
! 112: {"delete_history",Pdelete_history,-2},
! 113: {"pause",Ppause,0},
! 114: {"gc",Pgc,0},
! 115: {"batch",Pbatch,2},
! 116: {"send_progress",Psend_progress,-2},
! 117: {"get_addr",Pget_addr,1},
! 118: {"hex_dump",Phex_dump,2},
! 119: {"peek",Ppeek,1},
! 120: {"poke",Ppoke,2},
! 121: #if !defined(VISUAL) && defined(DO_PLOT)
! 122: {"xpause",Pxpause,0},
! 123: #endif
! 124: #if 0
! 125: {"opt",Popt,1},
! 126: #endif
! 127: {0,0,0},
! 128: };
! 129:
! 130: void Pgetcwd(STRING *rp)
! 131: {
! 132: char *r;
! 133: #if defined(VISUAL) || defined(__MINGW32__)
! 134: char buf[_MAX_PATH];
! 135: _getcwd(buf, _MAX_PATH);
! 136: #else
! 137: char buf[MAXPATHLEN];
! 138: getcwd(buf, MAXPATHLEN);
! 139: #endif
! 140: r = (char *)MALLOC_ATOMIC(strlen(buf)+1);
! 141: strcpy(r,buf);
! 142: MKSTR(*rp,r);
! 143: }
! 144:
! 145: void Pchdir(NODE arg, Z *rp)
! 146: {
! 147: char *dir = BDY((STRING)ARG0(arg));
! 148: #if defined(VISUAL) || defined(__MINGW32__)
! 149: int status = _chdir(dir);
! 150: #else
! 151: int status = chdir(dir);
! 152: #endif
! 153: STOQ(status,*rp);
! 154: }
! 155:
! 156: void Pset_secure_mode(NODE arg,Z *rp)
! 157: {
! 158: int s;
! 159: if ( argc(arg) )
! 160: setsecuremode(QTOS((Q)ARG0(arg)));
! 161: s = getsecuremode();
! 162: STOQ(s,*rp);
! 163: }
! 164:
! 165: void Pset_secure_flag(NODE arg,Z *rp)
! 166: {
! 167: int ac,s,status;
! 168: Obj f;
! 169: char *fname;
! 170:
! 171: ac = argc(arg);
! 172: if ( !ac )
! 173: error("set_secure_flag : a function name must be specified");
! 174: if ( ac == 2 )
! 175: s = QTOS((Q)ARG1(arg));
! 176: else
! 177: s = 1;
! 178: f = ARG0(arg);
! 179: if ( !f )
! 180: error("set_secure_flag : invalid argument");
! 181: switch ( OID(f) ) {
! 182: case O_STR:
! 183: fname = BDY((STRING)f); break;
! 184: case O_P:
! 185: fname = NAME(VR((P)f)); break;
! 186: default:
! 187: error("set_secure_flag : invalid argument"); break;
! 188: }
! 189: status = setsecureflag(fname,s);
! 190: if ( status < 0 )
! 191: error("set_secure_flag : function not found");
! 192: STOQ(s,*rp);
! 193: }
! 194:
! 195: void Ptest(NODE arg,Z *rp)
! 196: {
! 197: int r;
! 198:
! 199: r = equalr(CO,ARG0(arg),ARG1(arg));
! 200: STOQ(r,*rp);
! 201: }
! 202:
! 203: void Psleep(NODE arg,Z *rp)
! 204: {
! 205: int ms;
! 206:
! 207: ms = QTOS((Q)ARG0(arg));
! 208: #if defined(VISUAL) || defined(__MINGW32__)
! 209: Sleep(ms);
! 210: #else
! 211: usleep(ms*1000);
! 212: #endif
! 213: *rp = ONE;
! 214: }
! 215:
! 216: void Pmodule_list(rp)
! 217: LIST *rp;
! 218: {
! 219: char *name;
! 220: NODE r,r1,m;
! 221: STRING s;
! 222:
! 223: r = 0;
! 224: for ( m = MODULE_LIST; m; m = NEXT(m) ) {
! 225: MKSTR(s,((MODULE)BDY(m))->name);
! 226: MKNODE(r1,s,r); r = r1;
! 227: }
! 228: MKLIST(*rp,r);
! 229: }
! 230:
! 231: void Premove_module(NODE arg,Z *rp)
! 232: {
! 233: NODE pm,m;
! 234: char *name;
! 235:
! 236: asir_assert(ARG0(arg),O_STR,"remove_module");
! 237: name = BDY((STRING)ARG0(arg));
! 238: for ( pm = 0, m = MODULE_LIST; m; pm = m, m = NEXT(m) )
! 239: if ( !strcmp(name,((MODULE)BDY(m))->name) ) {
! 240: if ( !pm )
! 241: MODULE_LIST = NEXT(MODULE_LIST);
! 242: else
! 243: NEXT(pm) = NEXT(m);
! 244: *rp = ONE;
! 245: return;
! 246: }
! 247: *rp = 0;
! 248: }
! 249:
! 250: void Pmodule_definedp(NODE arg,Z *rp)
! 251: {
! 252: NODE m;
! 253: char *name;
! 254:
! 255: asir_assert(ARG0(arg),O_STR,"module_definedp");
! 256: name = BDY((STRING)ARG0(arg));
! 257: /* bug: the linear search is used here. The list of module shoud be sorted
! 258: and cashed, and binary search should be used. */
! 259: for (m = MODULE_LIST; m; m = NEXT(m) )
! 260: if ( !strcmp(name,((MODULE)BDY(m))->name) ) {
! 261: *rp = ONE;
! 262: return ;
! 263: }
! 264: *rp = 0;
! 265: }
! 266:
! 267: void Pgetenv(NODE arg,STRING *rp)
! 268: {
! 269: char *e,*f;
! 270: size_t len;
! 271:
! 272: e = (char *)getenv(BDY((STRING)ARG0(arg)));
! 273: if ( e ) {
! 274: len = strlen(e);
! 275: f = (char *)MALLOC_ATOMIC(len+1);
! 276: strcpy(f,e);
! 277: MKSTR(*rp,f);
! 278: } else
! 279: *rp = 0;
! 280: }
! 281:
! 282: void Pnull_command(NODE arg,Z *rp)
! 283: {
! 284: *rp = 0;
! 285: }
! 286:
! 287: void Pquit(rp)
! 288: pointer *rp;
! 289: {
! 290: if ( asir_infile && NEXT(asir_infile) && asir_infile->ready_for_longjmp )
! 291: LONGJMP(asir_infile->jmpbuf,1);
! 292: else {
! 293: closecurrentinput();
! 294: asir_terminate(2);
! 295: }
! 296: *rp = 0;
! 297: }
! 298:
! 299: void Pdebug(rp)
! 300: pointer *rp;
! 301: {
! 302: debug(0); *rp = 0;
! 303: }
! 304:
! 305: void Pshell(NODE arg,Z *rp)
! 306: {
! 307: char *com = 0;
! 308: char *pstr = 0;
! 309: int status;
! 310:
! 311: if ( arg ) {
! 312: asir_assert(ARG0(arg),O_STR,"shell");
! 313: com = BDY((STRING)ARG0(arg));
! 314: if ( NEXT(arg) )
! 315: pstr = BDY((STRING)ARG1(arg));
! 316: }
! 317: status = system(com);
! 318: STOQ(status,*rp);
! 319: }
! 320:
! 321: void Pnmono(NODE arg,Z *rp)
! 322: {
! 323: Obj obj;
! 324: int n;
! 325:
! 326: obj = (Obj)ARG0(arg);
! 327: if ( !obj || OID(obj) > O_R )
! 328: *rp = 0;
! 329: else
! 330: switch (OID(obj)) {
! 331: case O_N: case O_P:
! 332: n = nmonop((P)obj); STOQ(n,*rp); break;
! 333: case O_R:
! 334: n = nmonop(NM((R)obj)) + nmonop(DN((R)obj));
! 335: STOQ(n,*rp); break;
! 336: }
! 337: }
! 338:
! 339: void Pheap(NODE arg,Z *rp)
! 340: {
! 341: size_t h0,h;
! 342: void GC_expand_hp(int);
! 343:
! 344: h0 = get_heapsize();
! 345: if ( arg ) {
! 346: h = QTOS((Q)ARG0(arg));
! 347: if ( h > h0 )
! 348: GC_expand_hp(h-h0);
! 349: }
! 350: h = get_heapsize();
! 351: UTOQ(h,*rp);
! 352: }
! 353:
! 354: unsigned int get_asir_version();
! 355: char *get_asir_distribution();
! 356:
! 357: void Pversion(NODE arg,Obj *rp)
! 358: {
! 359: unsigned int version;
! 360: char *distribution;
! 361: Z q;
! 362: STRING str;
! 363: NODE n;
! 364: LIST l;
! 365:
! 366: version = get_asir_version();
! 367: distribution = get_asir_distribution();
! 368: UTOQ(version,q);
! 369: if ( !argc(arg) )
! 370: *rp = (Obj)q;
! 371: else {
! 372: MKSTR(str,distribution);
! 373: n = mknode(2,q,str);
! 374: MKLIST(l,n);
! 375: *rp = (Obj)l;
! 376: }
! 377: }
! 378:
! 379: char *scopyright();
! 380:
! 381: void Pcopyright(rp)
! 382: STRING *rp;
! 383: {
! 384: MKSTR(*rp,scopyright());
! 385: }
! 386:
! 387: extern int nez;
! 388:
! 389: void Pnez(NODE arg,Z *rp)
! 390: {
! 391: nez = ARG0(arg) ? 1 : 0; *rp = 0;
! 392: }
! 393:
! 394: void Perror(NODE arg,Z *rp)
! 395: {
! 396: char *s;
! 397:
! 398: if ( !arg || !ARG0(arg) || (OID((Obj)ARG0(arg)) != O_STR) )
! 399: s = "";
! 400: else
! 401: s = BDY((STRING)ARG0(arg));
! 402: error(s);
! 403: *rp = 0;
! 404: }
! 405:
! 406: void Ptoplevel(NODE arg,Z *rp)
! 407: {
! 408: char *s;
! 409:
! 410: if ( !arg || !ARG0(arg) || (OID((Obj)ARG0(arg)) != O_STR) )
! 411: s = "";
! 412: else
! 413: s = BDY((STRING)ARG0(arg));
! 414: goto_toplevel(s);
! 415: *rp = 0;
! 416: }
! 417:
! 418: void Perror3(NODE arg,Z *rp)
! 419: {
! 420: int code;
! 421: char *reason,*action;
! 422:
! 423: asir_assert(ARG0(arg),O_N,"error3");
! 424: asir_assert(ARG1(arg),O_STR,"error3");
! 425: asir_assert(ARG2(arg),O_STR,"error3");
! 426: code = QTOS((Q)ARG0(arg));
! 427: reason = BDY((STRING)ARG1(arg));
! 428: action = BDY((STRING)ARG2(arg));
! 429: #if defined(VISUAL) || defined(__MINGW32__)
! 430: set_error(code,reason,action);
! 431: #endif
! 432: error("");
! 433: *rp = 0;
! 434: }
! 435:
! 436: void Pflist(NODE arg,LIST *rp)
! 437: {
! 438: char *n;
! 439: STRING name;
! 440: char *mname;
! 441: NODE t,r,r0,m;
! 442: LIST l;
! 443:
! 444: if ( argc(arg) ) {
! 445: /* module name is specified */
! 446: asir_assert(ARG0(arg),O_STR,"flist");
! 447: mname = BDY((STRING)ARG0(arg));
! 448: r0 = 0;
! 449: for ( m = MODULE_LIST; m; m = NEXT(m) ) {
! 450: if ( !strcmp(mname,((MODULE)BDY(m))->name) ) {
! 451: t = ((MODULE)BDY(m))->usrf_list;
! 452: for ( r0 = 0; t; t = NEXT(t) )
! 453: if ( ((FUNC)BDY(t))->id != A_UNDEF ) {
! 454: n = NAME((FUNC)BDY(t)); MKSTR(name,n);
! 455: MKNODE(r,name,r0); r0 = r;
! 456: }
! 457: }
! 458: }
! 459: } else {
! 460: for ( t = usrf, r0 = 0; t; t = NEXT(t) )
! 461: if ( ((FUNC)BDY(t))->id != A_UNDEF ) {
! 462: n = NAME((FUNC)BDY(t)); MKSTR(name,n);
! 463: MKNODE(r,name,r0); r0 = r;
! 464: }
! 465: for ( t = ubinf; t; t = NEXT(t) )
! 466: if ( ((FUNC)BDY(t))->id != A_UNDEF ) {
! 467: n = NAME((FUNC)BDY(t)); MKSTR(name,n);
! 468: MKNODE(r,name,r0); r0 = r;
! 469: }
! 470: for ( t = sysf; t; t = NEXT(t) )
! 471: if ( ((FUNC)BDY(t))->id != A_UNDEF ) {
! 472: n = NAME((FUNC)BDY(t)); MKSTR(name,n);
! 473: MKNODE(r,name,r0); r0 = r;
! 474: }
! 475: }
! 476: MKLIST(l,r0); *rp = l;
! 477: }
! 478:
! 479: void Pdelete_history(NODE arg,Z *rp)
! 480: {
! 481: switch ( argc(arg) ) {
! 482: case 0: default:
! 483: delete_history(0,(int)APVS->n);
! 484: break;
! 485: case 1:
! 486: delete_history(QTOS((Q)ARG0(arg)),1);
! 487: break;
! 488: }
! 489: *rp = 0;
! 490: }
! 491:
! 492: void delete_history(start,n)
! 493: int start,n;
! 494: {
! 495: int i,max;
! 496:
! 497: max = APVS->n;
! 498: if ( start < 0 || start >= max )
! 499: return;
! 500: if ( start + n > max )
! 501: n = max - start;
! 502: for ( i = 0; i < n; i++ )
! 503: APVS->va[start+i].priv = 0;
! 504: }
! 505:
! 506: void Ppause(rp)
! 507: LIST *rp;
! 508: {
! 509: char buf[BUFSIZ];
! 510:
! 511: fgets(buf,BUFSIZ,stdin);
! 512: *rp = 0;
! 513: }
! 514:
! 515: void Pgc(rp)
! 516: LIST *rp;
! 517: {
! 518: GC_gcollect();
! 519: *rp = 0;
! 520: }
! 521:
! 522: int exec_file(char *,char *);
! 523:
! 524: void Pbatch(NODE arg,Z *rp)
! 525: {
! 526: int ret;
! 527:
! 528: ret = exec_file(BDY((STRING)ARG0(arg)),BDY((STRING)ARG1(arg)));
! 529: STOQ(ret,*rp);
! 530: }
! 531:
! 532: #if !defined(VISUAL) && defined(DO_PLOT)
! 533: int init_display();
! 534:
! 535: void Pxpause(Z *rp)
! 536: {
! 537: if ( !init_display() )
! 538: *rp = 0;
! 539: else {
! 540: grab_pointer(); *rp = ONE;
! 541: }
! 542: }
! 543:
! 544: static Display *display;
! 545: static Window rootwin;
! 546:
! 547: int init_display()
! 548: {
! 549: char *dname;
! 550: unsigned int tmp;
! 551: static int initialized;
! 552: int argc;
! 553: char *argv[1];
! 554:
! 555: if ( initialized )
! 556: return 1;
! 557: else
! 558: initialized = 1;
! 559: dname = (char *)getenv("DISPLAY");
! 560:
! 561: display = XOpenDisplay(dname);
! 562: if ( !display ) {
! 563: fprintf(stderr,"Can't open display\n");
! 564: return 0;
! 565: }
! 566: rootwin = RootWindow(display,DefaultScreen(display));
! 567: }
! 568:
! 569: void grab_pointer()
! 570: {
! 571: XEvent ev;
! 572: static Cursor cursor;
! 573:
! 574: if ( !cursor )
! 575: cursor = XCreateFontCursor(display,XC_leftbutton);
! 576: XGrabPointer(display,rootwin,True,ButtonPressMask,GrabModeAsync,GrabModeAsync,None,cursor,CurrentTime);
! 577: while ( 1 ) {
! 578: XNextEvent(display,&ev);
! 579: if ( ev.xany.type == ButtonPress )
! 580: break;
! 581: }
! 582: XUngrabPointer(display,CurrentTime);
! 583: XSync(display,False);
! 584: return;
! 585: }
! 586: #endif
! 587:
! 588: void Psend_progress(NODE arg,Z *rp)
! 589: {
! 590: #if defined(VISUAL)
! 591: short per;
! 592: char *msg;
! 593:
! 594: per = (short)QTOS((Q)BDY(arg)); arg = NEXT(arg);
! 595: if ( arg )
! 596: msg = BDY((STRING)BDY(arg));
! 597: else
! 598: msg = "";
! 599: send_progress(per,msg);
! 600: #endif
! 601: *rp = 0;
! 602: }
! 603:
! 604: void Pget_addr(NODE arg,Z *rp)
! 605: {
! 606: pointer obj;
! 607:
! 608: obj = ARG0(arg);
! 609: UTOQ((unsigned long)obj,*rp);
! 610: }
! 611:
! 612: unsigned char *qtoaddr(Z q)
! 613: {
! 614: if ( !q )
! 615: return 0;
! 616: else
! 617: return (unsigned char *)QTOS(q);
! 618: }
! 619:
! 620: void Phex_dump(NODE arg,Z *rp)
! 621: {
! 622: unsigned char *start;
! 623: int len,i;
! 624:
! 625: *rp = 0;
! 626: start = qtoaddr((Z)ARG0(arg));
! 627: len = QTOS((Q)ARG1(arg));
! 628: for ( i = 0; i < len; i++ ) {
! 629: if ( !(i%16) )
! 630: fprintf(asir_out,"%08x: ",start+i);
! 631: fprintf(asir_out,"%02x",start[i]);
! 632: if ( !((i+1)%16) )
! 633: fprintf(asir_out,"\n");
! 634: else if ( !((i+1)%4) )
! 635: fprintf(asir_out," ");
! 636: }
! 637: if ( i%16 )
! 638: fprintf(asir_out,"\n");
! 639: }
! 640:
! 641: void Ppeek(NODE arg,Z *rp)
! 642: {
! 643: unsigned long b;
! 644: unsigned char *a;
! 645:
! 646: a = qtoaddr((Z)ARG0(arg));
! 647: b = (unsigned long) (*a);
! 648: UTOQ(b,*rp);
! 649: }
! 650:
! 651: void Ppoke(NODE arg,Z *rp)
! 652: {
! 653: unsigned char *addr;
! 654:
! 655: addr = qtoaddr((Z)ARG0(arg));
! 656: *addr = (unsigned char)QTOS((Q)ARG1(arg));
! 657: *rp = 0;
! 658: }
! 659:
! 660: #if 0
! 661: static int optimize;
! 662: static struct oN oPSN[1000];
! 663: static struct oQ oPSZ[1000],oMSZ[1000];
! 664: static szinit = 0;
! 665:
! 666: void Popt(NODE arg,Z *rp)
! 667: {
! 668: optimize = ARG0(arg) ? 1 : 0; *rp = 0;
! 669: }
! 670:
! 671:
! 672: void sz_init() {
! 673: int i;
! 674: Q t;
! 675:
! 676: for ( i = 1; i < 1000; i++ ) {
! 677: oPSN[i].p = 1; oPSN[i].b[0] = i;
! 678: t = &oPSZ[i];
! 679: OID(t) = O_N; NID(t) = N_Q; SGN(t) = 1; NM(t) = &oPSN[i]; DN(t) = 0;
! 680: t = &oMSZ[i];
! 681: OID(t) = O_N; NID(t) = N_Q; SGN(t) = -1; NM(t) = &oPSN[i]; DN(t) = 0;
! 682: }
! 683: szinit = 1;
! 684: }
! 685:
! 686: optobj(Obj *p)
! 687: {
! 688: Obj t;
! 689: int n;
! 690: DCP dc;
! 691:
! 692: if ( t = *p )
! 693: switch ( OID(t) ) {
! 694: case O_N:
! 695: if ( (NID(t)==N_Q) && INT(t) && (PL(NM((Q)t))==1) ) {
! 696: n = QTOS((Q)t);
! 697: if ( !szinit )
! 698: sz_init();
! 699: if ( n < 1000 )
! 700: *p = (Obj)(SGN((Q)t)>0?&oPSZ[n]:&oMSZ[n]);
! 701: }
! 702: break;
! 703: case O_P:
! 704: for ( dc = DC((P)t); dc; dc = NEXT(dc) ) {
! 705: optobj(&DEG(dc)); optobj(&COEF(dc));
! 706: }
! 707: break;
! 708: case O_R:
! 709: optobj(&NM((R)t)); optobj(&DN((R)t)); break;
! 710: default:
! 711: break;
! 712: }
! 713: }
! 714: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>