[BACK]Return to miscf.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / builtin

Annotation of OpenXM_contrib2/asir2000/builtin/miscf.c, Revision 1.20

1.7       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
1.8       noro       26:  * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
1.7       noro       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:  *
1.20    ! noro       48:  * $OpenXM: OpenXM_contrib2/asir2000/builtin/miscf.c,v 1.19 2003/10/20 00:21:09 takayama Exp $
1.7       noro       49: */
1.1       noro       50: #include "ca.h"
                     51: #include "parse.h"
1.17      noro       52: #if !defined(VISUAL) && defined(DO_PLOT)
1.1       noro       53: #include <X11/Xlib.h>
                     54: #include <X11/cursorfont.h>
                     55: #endif
                     56:
1.12      noro       57: #if defined(VISUAL)
                     58: #include <stdlib.h>
                     59: #include <windows.h>
                     60: #endif
                     61:
1.1       noro       62: void Pquit(), Pdebug(), Pnmono(), Pnez(), Popt(), Pshell(), Pheap();
1.20    ! noro       63: void Ptoplevel();
1.1       noro       64: void Perror(), Perror3(), Pversion(), Pflist(), Pdelete_history(), Ppause(), Pxpause();
                     65: void Pr2g(), Pread_cmo(), Pwrite_cmo();
                     66: void Pgc(),Pbatch(),Psend_progress();
                     67: void Pnull_command();
                     68: void Pgetenv();
1.9       noro       69: void Pget_addr(),Phex_dump();
                     70: void Ppeek(),Ppoke();
1.12      noro       71: void Psleep();
1.18      noro       72: void Premove_module();
                     73: void Pmodule_list();
1.19      takayama   74: void Pmodule_definedp();
1.1       noro       75:
                     76: void delete_history(int,int);
                     77:
                     78: struct ftab misc_tab[] = {
1.18      noro       79:        {"module_list",Pmodule_list,0},
                     80:        {"remove_module",Premove_module,1},
1.19      takayama   81:        {"module_definedp",Pmodule_definedp,1},
1.12      noro       82:        {"sleep",Psleep,1},
1.1       noro       83:        {"null_command",Pnull_command,-99999},
                     84:        {"getenv",Pgetenv,1},
                     85:        {"end",Pquit,0},
                     86:        {"quit",Pquit,0},
                     87:        {"debug",Pdebug,0},
                     88:        {"shell",Pshell,-2},
                     89:        {"heap",Pheap,-1},
1.11      noro       90:        {"version",Pversion,-99999},
1.1       noro       91:        {"nmono",Pnmono,1},
1.20    ! noro       92:        {"toplevel",Ptoplevel,-1},
1.1       noro       93:        {"error",Perror,1},
                     94:        {"error3",Perror3,3},
                     95:        {"nez",Pnez,1},
1.18      noro       96:        {"flist",Pflist,-1},
1.1       noro       97:        {"delete_history",Pdelete_history,-2},
                     98:        {"pause",Ppause,0},
                     99:        {"gc",Pgc,0},
                    100:        {"batch",Pbatch,2},
                    101:        {"send_progress",Psend_progress,-2},
1.9       noro      102:        {"get_addr",Pget_addr,1},
                    103:        {"hex_dump",Phex_dump,2},
                    104:        {"peek",Ppeek,1},
                    105:        {"poke",Ppoke,2},
1.16      noro      106: #if !defined(VISUAL) && defined(DO_PLOT)
1.1       noro      107:        {"xpause",Pxpause,0},
                    108: #endif
                    109: #if 0
                    110:        {"opt",Popt,1},
                    111: #endif
                    112:        {0,0,0},
                    113: };
1.12      noro      114:
                    115: void Psleep(arg,rp)
                    116: NODE arg;
                    117: Q *rp;
                    118: {
                    119:        int ms;
                    120:
                    121:        ms = QTOS((Q)ARG0(arg));
                    122: #if defined(VISUAL)
                    123:        Sleep(ms);
                    124: #else
                    125:        usleep(ms*1000);
                    126: #endif
                    127:        *rp = ONE;
                    128: }
1.1       noro      129:
1.18      noro      130: void Pmodule_list(rp)
                    131: LIST *rp;
                    132: {
                    133:        char *name;
                    134:        NODE r,r1,m;
                    135:        STRING s;
                    136:
                    137:        r = 0;
                    138:        for ( m = MODULE_LIST; m; m = NEXT(m) ) {
                    139:                MKSTR(s,((MODULE)BDY(m))->name);
                    140:                MKNODE(r1,s,r); r = r1;
                    141:        }
                    142:        MKLIST(*rp,r);
                    143: }
                    144:
                    145: void Premove_module(arg,rp)
                    146: NODE arg;
                    147: Q *rp;
                    148: {
                    149:        NODE pm,m;
                    150:        char *name;
                    151:
                    152:        asir_assert(ARG0(arg),O_STR,"remove_module");
                    153:        name = BDY((STRING)ARG0(arg));
                    154:        for ( pm = 0, m = MODULE_LIST; m; pm = m, m = NEXT(m) )
                    155:                if ( !strcmp(name,((MODULE)BDY(m))->name) ) {
                    156:                        if ( !pm )
                    157:                                MODULE_LIST = NEXT(MODULE_LIST);
                    158:                        else
                    159:                                NEXT(pm) = NEXT(m);
                    160:                        *rp = ONE;
                    161:                        return;
1.19      takayama  162:                }
                    163:        *rp = 0;
                    164: }
                    165:
                    166: void Pmodule_definedp(arg,rp)
                    167: NODE arg;
                    168: Q *rp;
                    169: {
                    170:        NODE m;
                    171:        char *name;
                    172:
                    173:        asir_assert(ARG0(arg),O_STR,"module_definedp");
                    174:        name = BDY((STRING)ARG0(arg));
                    175:     /* bug: the linear search is used here. The list of module shoud be sorted
                    176:        and cashed, and binary search should be used. */
                    177:        for (m = MODULE_LIST; m; m = NEXT(m) )
                    178:                if ( !strcmp(name,((MODULE)BDY(m))->name) ) {
                    179:                        *rp = ONE;
                    180:                        return ;
1.18      noro      181:                }
                    182:        *rp = 0;
                    183: }
                    184:
1.1       noro      185: void Pgetenv(arg,rp)
                    186: NODE arg;
                    187: STRING *rp;
                    188: {
                    189:        char *e,*f;
                    190:        int len;
                    191:
                    192:        e = (char *)getenv(BDY((STRING)ARG0(arg)));
                    193:        if ( e ) {
                    194:                len = strlen(e);
                    195:                f = (char *)MALLOC_ATOMIC(len+1);
                    196:                strcpy(f,e);
                    197:                MKSTR(*rp,f);
                    198:        } else
                    199:                *rp = 0;
                    200: }
                    201:
                    202: void Pnull_command(arg,rp)
                    203: NODE arg;
                    204: Q *rp;
                    205: {
                    206:        *rp = 0;
                    207: }
                    208:
                    209: void Pquit(rp)
                    210: pointer *rp;
                    211: {
                    212:        if ( !NEXT(asir_infile) )
                    213:                asir_terminate(2);
                    214:        else {
                    215:                closecurrentinput();
1.5       noro      216:                if ( !asir_infile->fp && strcmp(asir_infile->name,"string") )
1.1       noro      217:                        asir_terminate(2);
                    218:        }
                    219:        *rp = 0;
                    220: }
                    221:
                    222: void Pdebug(rp)
                    223: pointer *rp;
                    224: {
                    225:        debug(0); *rp = 0;
                    226: }
                    227:
                    228: void Pshell(arg,rp)
                    229: NODE arg;
                    230: Q *rp;
                    231: {
                    232:        char *com = 0;
                    233:        char *pstr = 0;
                    234:        int status;
                    235:
                    236:        if ( arg ) {
                    237:                asir_assert(ARG0(arg),O_STR,"shell");
                    238:                com = BDY((STRING)ARG0(arg));
                    239:                if ( NEXT(arg) )
                    240:                        pstr = BDY((STRING)ARG1(arg));
                    241:        }
                    242:        status = system(com);
                    243:        STOQ(status,*rp);
                    244: }
                    245:
                    246: void Pnmono(arg,rp)
                    247: NODE arg;
                    248: Q *rp;
                    249: {
                    250:        Obj obj;
                    251:        int n;
                    252:
                    253:        obj = (Obj)ARG0(arg);
                    254:        if ( !obj || OID(obj) > O_R )
                    255:                *rp = 0;
                    256:        else
                    257:                switch (OID(obj)) {
                    258:                        case O_N: case O_P:
                    259:                                n = nmonop((P)obj); STOQ(n,*rp); break;
                    260:                        case O_R:
                    261:                                n = nmonop(NM((R)obj)) + nmonop(DN((R)obj));
                    262:                                STOQ(n,*rp); break;
                    263:                }
                    264: }
                    265:
                    266: void Pheap(arg,rp)
                    267: NODE arg;
                    268: Q *rp;
                    269: {
                    270:        int h0,h;
                    271:        void GC_expand_hp(int);
                    272:
                    273:        h0 = get_heapsize();
                    274:        if ( arg ) {
                    275:                h = QTOS((Q)ARG0(arg));
                    276:                if ( h > h0 )
                    277:                        GC_expand_hp(h-h0);
                    278:        }
                    279:        h = get_heapsize();
                    280:        STOQ(h,*rp);
                    281: }
                    282:
                    283: unsigned int get_asir_version();
1.11      noro      284: char *get_asir_distribution();
1.1       noro      285:
1.11      noro      286: void Pversion(arg,rp)
                    287: NODE arg;
                    288: Obj *rp;
1.1       noro      289: {
                    290:        unsigned int version;
1.11      noro      291:        char *distribution;
                    292:        Q q;
                    293:        STRING str;
                    294:        NODE n;
                    295:        LIST l;
1.1       noro      296:
                    297:        version = get_asir_version();
1.11      noro      298:        distribution = get_asir_distribution();
1.13      noro      299:        UTOQ(version,q);
1.11      noro      300:        if ( !argc(arg) )
                    301:                *rp = (Obj)q;
                    302:        else {
                    303:                MKSTR(str,distribution);
                    304:                n = mknode(2,q,str);
                    305:                MKLIST(l,n);
                    306:                *rp = (Obj)l;
                    307:        }
1.1       noro      308: }
                    309:
                    310: extern int nez;
                    311:
                    312: void Pnez(arg,rp)
                    313: NODE arg;
                    314: pointer *rp;
                    315: {
                    316:        nez = ARG0(arg) ? 1 : 0; *rp = 0;
                    317: }
                    318:
                    319: void Perror(arg,rp)
                    320: NODE arg;
                    321: Q *rp;
                    322: {
                    323:        char *s;
                    324:
                    325:        if ( !arg || !ARG0(arg) || (OID((Obj)ARG0(arg)) != O_STR) )
                    326:                s = "";
                    327:        else
                    328:                s = BDY((STRING)ARG0(arg));
                    329:        error(s);
1.20    ! noro      330:        *rp = 0;
        !           331: }
        !           332:
        !           333: void Ptoplevel(arg,rp)
        !           334: NODE arg;
        !           335: Q *rp;
        !           336: {
        !           337:        char *s;
        !           338:
        !           339:        if ( !arg || !ARG0(arg) || (OID((Obj)ARG0(arg)) != O_STR) )
        !           340:                s = "";
        !           341:        else
        !           342:                s = BDY((STRING)ARG0(arg));
        !           343:        toplevel(s);
1.1       noro      344:        *rp = 0;
                    345: }
                    346:
                    347: void Perror3(arg,rp)
                    348: NODE arg;
                    349: Q *rp;
                    350: {
                    351:        int code;
                    352:        char *reason,*action;
                    353:
                    354:        asir_assert(ARG0(arg),O_N,"error3");
                    355:        asir_assert(ARG1(arg),O_STR,"error3");
                    356:        asir_assert(ARG2(arg),O_STR,"error3");
                    357:        code = QTOS((Q)ARG0(arg));
                    358:        reason = BDY((STRING)ARG1(arg));
                    359:        action = BDY((STRING)ARG2(arg));
1.3       noro      360: #if defined(VISUAL)
1.1       noro      361:        set_error(code,reason,action);
1.3       noro      362: #endif
1.1       noro      363:        error("");
                    364:        *rp = 0;
                    365: }
                    366:
1.18      noro      367: void Pflist(arg,rp)
                    368: NODE arg;
1.1       noro      369: LIST *rp;
                    370: {
                    371:        char *n;
                    372:        STRING name;
1.18      noro      373:        char *mname;
                    374:        NODE t,r,r0,m;
1.1       noro      375:        LIST l;
                    376:
1.18      noro      377:        if ( argc(arg) ) {
                    378:                /* module name is specified */
                    379:                asir_assert(ARG0(arg),O_STR,"flist");
                    380:                mname = BDY((STRING)ARG0(arg));
                    381:                r0 = 0;
                    382:                for ( m = MODULE_LIST; m; m = NEXT(m) ) {
                    383:                        if ( !strcmp(mname,((MODULE)BDY(m))->name) ) {
                    384:                                t = ((MODULE)BDY(m))->usrf_list;
                    385:                                for ( r0 = 0; t; t = NEXT(t) )
                    386:                                        if ( ((FUNC)BDY(t))->id != A_UNDEF ) {
                    387:                                                n = NAME((FUNC)BDY(t)); MKSTR(name,n);
                    388:                                                MKNODE(r,name,r0); r0 = r;
                    389:                                }
                    390:                        }
1.1       noro      391:                }
1.18      noro      392:        } else {
                    393:                for ( t = usrf, r0 = 0; t; t = NEXT(t) )
                    394:                        if ( ((FUNC)BDY(t))->id != A_UNDEF ) {
                    395:                                n = NAME((FUNC)BDY(t)); MKSTR(name,n);
                    396:                                MKNODE(r,name,r0); r0 = r;
                    397:                        }
                    398:                for ( t = ubinf; t; t = NEXT(t) )
                    399:                        if ( ((FUNC)BDY(t))->id != A_UNDEF ) {
                    400:                                n = NAME((FUNC)BDY(t)); MKSTR(name,n);
                    401:                                MKNODE(r,name,r0); r0 = r;
                    402:                        }
                    403:                for ( t = sysf; t; t = NEXT(t) )
                    404:                        if ( ((FUNC)BDY(t))->id != A_UNDEF ) {
                    405:                                n = NAME((FUNC)BDY(t)); MKSTR(name,n);
                    406:                                MKNODE(r,name,r0); r0 = r;
                    407:                        }
                    408:        }
1.1       noro      409:        MKLIST(l,r0); *rp = l;
                    410: }
                    411:
                    412: void Pdelete_history(arg,rp)
                    413: NODE arg;
                    414: Q *rp;
                    415: {
                    416:        switch ( argc(arg) ) {
                    417:                case 0: default:
                    418:                        delete_history(0,(int)APVS->n);
                    419:                        break;
                    420:                case 1:
                    421:                        delete_history(QTOS((Q)ARG0(arg)),1);
                    422:                        break;
                    423:        }
                    424:        *rp = 0;
                    425: }
                    426:
                    427: void delete_history(start,n)
                    428: int start,n;
                    429: {
                    430:        int i,max;
                    431:
                    432:        max = APVS->n;
                    433:        if ( start < 0 || start >= max )
                    434:                return;
                    435:        if ( start + n > max )
                    436:                n = max - start;
                    437:        for ( i = 0; i < n; i++ )
                    438:                APVS->va[start+i].priv = 0;
                    439: }
                    440:
                    441: void Ppause(rp)
                    442: LIST *rp;
                    443: {
                    444:        char buf[BUFSIZ];
                    445:
                    446:        fgets(buf,BUFSIZ,stdin);
                    447:        *rp = 0;
                    448: }
                    449:
                    450: void Pgc(rp)
                    451: LIST *rp;
                    452: {
                    453:        GC_gcollect();
                    454:        *rp = 0;
                    455: }
                    456:
                    457: int exec_file(char *,char *);
                    458:
                    459: void Pbatch(arg,rp)
                    460: NODE arg;
                    461: Q *rp;
                    462: {
                    463:        int ret;
                    464:
                    465:        ret = exec_file(BDY((STRING)ARG0(arg)),BDY((STRING)ARG1(arg)));
                    466:        STOQ(ret,*rp);
                    467: }
                    468:
1.16      noro      469: #if !defined(VISUAL) && defined(DO_PLOT)
1.1       noro      470: void Pxpause(rp)
                    471: Q *rp;
                    472: {
                    473:        if ( !init_display() )
                    474:                *rp = 0;
                    475:        else {
                    476:                grab_pointer(); *rp = ONE;
                    477:        }
                    478: }
                    479:
                    480: static Display *display;
                    481: static Window rootwin;
                    482:
                    483: init_display()
                    484: {
                    485:        char *dname;
                    486:        unsigned int tmp;
                    487:        static int initialized;
                    488:        int argc;
                    489:        char *argv[1];
                    490:
                    491:        if ( initialized )
                    492:                return 1;
                    493:        else
                    494:                initialized = 1;
                    495:        dname = (char *)getenv("DISPLAY");
                    496:
                    497:        display = XOpenDisplay(dname);
                    498:        if ( !display ) {
                    499:                fprintf(stderr,"Can't open display\n");
                    500:                return 0;
                    501:        }
                    502:        rootwin = RootWindow(display,DefaultScreen(display));
                    503: }
                    504:
                    505: grab_pointer()
                    506: {
                    507:        XEvent ev;
                    508:        static Cursor cursor;
                    509:
                    510:        if ( !cursor )
                    511:                cursor = XCreateFontCursor(display,XC_leftbutton);
                    512:        XGrabPointer(display,rootwin,True,ButtonPressMask,GrabModeAsync,GrabModeAsync,None,cursor,CurrentTime);
                    513:        while ( 1 ) {
                    514:                XNextEvent(display,&ev);
                    515:                if ( ev.xany.type == ButtonPress )
                    516:                        break;
                    517:        }
                    518:        XUngrabPointer(display,CurrentTime);
                    519:        XSync(display,False);
                    520:        return;
                    521: }
                    522: #endif
                    523:
                    524: void Psend_progress(NODE arg,Q *rp)
                    525: {
                    526: #if defined(VISUAL)
                    527:        short per;
                    528:        char *msg;
                    529:
                    530:        per = (short)QTOS((Q)BDY(arg)); arg = NEXT(arg);
                    531:        if ( arg )
                    532:                msg = BDY((STRING)BDY(arg));
                    533:        else
                    534:                msg = "";
                    535:        send_progress(per,msg);
                    536: #endif
1.9       noro      537:        *rp = 0;
                    538: }
                    539:
                    540: void Pget_addr(arg,rp)
                    541: NODE arg;
                    542: Q *rp;
                    543: {
                    544:        pointer obj;
                    545:        unsigned int u,l;
                    546:        N n;
                    547:
                    548:        obj = ARG0(arg);
                    549:        if ( sizeof(pointer) == sizeof(unsigned int) ) {
                    550:                UTOQ((unsigned int)obj,*rp);
                    551:        } else {
                    552:                /* a pointer must fit in long */
                    553:                u = ((unsigned long)obj)>>32;
                    554:                l = ((unsigned long)obj)&(unsigned long)0xffffffff;
                    555:                if ( u ) {
                    556:                        n = NALLOC(2); PL(n) = 2; BD(n)[0] = l; BD(n)[1] = u;
                    557:                        NTOQ(n,1,*rp);
                    558:                } else {
                    559:                        UTOQ(l,*rp);
                    560:                }
                    561:        }
                    562: }
                    563:
                    564: unsigned char *qtoaddr(q)
                    565: Q q;
                    566: {
                    567:        unsigned char *addr;
                    568:        N n;
                    569:
                    570:        if ( !q )
                    571:                return 0;
                    572:        n = NM(q);
                    573:        if ( (sizeof(pointer) == sizeof(unsigned int)) || (PL(n) == 1) )
                    574:                addr = (char *)BD(n)[0];
                    575:        else {
                    576:                /* a pointer must fit in long */
                    577:                addr = (char *)((((unsigned long)BD(n)[1])<<32)
                    578:                        | ((unsigned long)BD(n)[0]));
                    579:        }
                    580:        return addr;
                    581: }
                    582:
                    583: void Phex_dump(arg,rp)
                    584: NODE arg;
                    585: Q *rp;
                    586: {
                    587:        unsigned char *start;
                    588:        int len,i;
                    589:
                    590:        *rp = 0;
                    591:        start = qtoaddr((Q)ARG0(arg));
                    592:        len = QTOS((Q)ARG1(arg));
                    593:        for ( i = 0; i < len; i++ ) {
                    594:                if ( !(i%16) )
                    595:                        fprintf(asir_out,"%08x: ",start+i);
                    596:                fprintf(asir_out,"%02x",start[i]);
                    597:                if ( !((i+1)%16) )
                    598:                        fprintf(asir_out,"\n");
                    599:                else if ( !((i+1)%4) )
                    600:                        fprintf(asir_out," ");
                    601:        }
                    602:        if ( i%16 )
                    603:                fprintf(asir_out,"\n");
                    604: }
                    605:
                    606: void Ppeek(arg,rp)
                    607: NODE arg;
                    608: Q *rp;
                    609: {
                    610:        unsigned int b;
                    611:        unsigned char *a;
                    612:
                    613:        a = qtoaddr((Q)ARG0(arg));
                    614:        b = (unsigned int) (*a);
                    615:        UTOQ(b,*rp);
                    616: }
                    617:
                    618: void Ppoke(arg,rp)
                    619: NODE arg;
                    620: Q *rp;
                    621: {
                    622:        unsigned char *addr;
                    623:
                    624:        addr = qtoaddr((Q)ARG0(arg));
                    625:        *addr = (unsigned char)QTOS((Q)ARG1(arg));
1.1       noro      626:        *rp = 0;
                    627: }
                    628:
                    629: #if 0
                    630: static int optimize;
                    631: static struct oN oPSN[1000];
                    632: static struct oQ oPSZ[1000],oMSZ[1000];
                    633: static szinit = 0;
                    634:
                    635: void Popt(arg,rp)
                    636: NODE arg;
                    637: pointer *rp;
                    638: {
                    639:        optimize = ARG0(arg) ? 1 : 0; *rp = 0;
                    640: }
                    641:
                    642:
                    643: void sz_init() {
                    644:        int i;
                    645:        Q t;
                    646:
                    647:        for ( i = 1; i < 1000; i++ ) {
                    648:                oPSN[i].p = 1; oPSN[i].b[0] = i;
                    649:                t = &oPSZ[i];
                    650:                OID(t) = O_N; NID(t) = N_Q; SGN(t) = 1; NM(t) = &oPSN[i]; DN(t) = 0;
                    651:                t = &oMSZ[i];
                    652:                OID(t) = O_N; NID(t) = N_Q; SGN(t) = -1; NM(t) = &oPSN[i]; DN(t) = 0;
                    653:        }
                    654:        szinit = 1;
                    655: }
                    656:
                    657: optobj(p)
                    658: Obj *p;
                    659: {
                    660:        Obj t;
                    661:        int n;
                    662:        DCP dc;
                    663:
                    664:        if ( t = *p )
                    665:                switch ( OID(t) ) {
                    666:                        case O_N:
                    667:                                if ( (NID(t)==N_Q) && INT(t) && (PL(NM((Q)t))==1) ) {
                    668:                                        n = QTOS((Q)t);
                    669:                                        if ( !szinit )
                    670:                                                sz_init();
                    671:                                        if ( n < 1000 )
                    672:                                                *p = (Obj)(SGN((Q)t)>0?&oPSZ[n]:&oMSZ[n]);
                    673:                                }
                    674:                                break;
                    675:                        case O_P:
                    676:                                for ( dc = DC((P)t); dc; dc = NEXT(dc) ) {
                    677:                                        optobj(&DEG(dc)); optobj(&COEF(dc));
                    678:                                }
                    679:                                break;
                    680:                        case O_R:
                    681:                                optobj(&NM((R)t)); optobj(&DN((R)t)); break;
                    682:                        default:
                    683:                                break;
                    684:                }
                    685: }
                    686: #endif

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>