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

Annotation of OpenXM_contrib2/asir2000/plot/ox_plot.c, Revision 1.21

1.5       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.6       noro       26:  * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
1.5       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.21    ! noro       48:  * $OpenXM: OpenXM_contrib2/asir2000/plot/ox_plot.c,v 1.20 2004/02/13 05:48:36 saito Exp $
1.5       noro       49: */
1.1       noro       50: #include "ca.h"
                     51: #include "parse.h"
                     52: #include "ox.h"
                     53: #include "ifplot.h"
                     54: #include "version.h"
1.3       noro       55: #include <signal.h>
1.19      ohara      56: #if defined(PARI)
1.2       noro       57: #include "genpari.h"
                     58: #endif
1.1       noro       59:
                     60: void ox_usr1_handler();
                     61:
1.8       noro       62: extern int asir_OperandStackSize;
                     63: extern Obj *asir_OperandStack;
                     64: extern int asir_OperandStackPtr;
                     65:
1.15      noro       66: /* environement is defined in libpari.a */
1.20      saito      67: #if !(PARI_VERSION_CODE > 131588)
1.15      noro       68: extern jmp_buf environnement;
1.20      saito      69: #endif
1.1       noro       70:
                     71: extern int do_message;
                     72: extern int ox_flushing;
1.14      noro       73: extern JMP_BUF ox_env;
1.1       noro       74: extern MATHCAP my_mathcap;
1.10      noro       75: extern char LastError[];
1.1       noro       76:
1.21    ! noro       77: void create_error(ERR *,unsigned int ,char *,LIST );
1.1       noro       78:
1.8       noro       79: void ox_io_init();
1.17      noro       80: void ox_asir_init(int,char **,char *);
1.8       noro       81: Obj asir_pop_one();
                     82: void asir_push_one(Obj);
                     83: void asir_end_flush();
                     84: int asir_executeString();
                     85: void asir_evalName(unsigned int);
                     86: void asir_setName(unsigned int);
                     87: void asir_pops();
                     88: void asir_popString();
                     89: void asir_popCMO(unsigned int);
                     90: void asir_popSerializedLocalObject();
                     91: char *name_of_cmd(unsigned int);
                     92: char *name_of_id(int);
                     93: LIST asir_GetErrorList();
1.7       noro       94:
1.8       noro       95: static void asir_do_cmd(unsigned int,unsigned int);
1.1       noro       96: static void process_ox();
                     97: static void asir_executeFunction();
                     98:
1.9       noro       99: #if defined(VISUAL)
                    100: void ox_plot_main()
                    101: #else
                    102: void ox_plot_main(int argc,char **argv)
                    103: #endif
                    104: {
1.1       noro      105:        int ds;
                    106:        fd_set r;
                    107:        int n;
1.12      noro      108:        int use_x;
1.1       noro      109:
1.9       noro      110: #if !defined(VISUAL)
1.17      noro      111:        ox_asir_init(argc,argv,"ox_plot");
1.12      noro      112:        use_x = init_plot_display(argc,argv);
                    113:        if ( use_x )
                    114:                ds = ConnectionNumber(display);
                    115:        else
                    116:                fprintf(stderr,"Entering no X mode\n");
1.9       noro      117: #endif
1.1       noro      118:        if ( do_message )
                    119:                fprintf(stderr,"I'm an ox_plot, Version %d.\n",ASIR_VERSION);
                    120:
1.14      noro      121:        if ( SETJMP(ox_env) ) {
1.1       noro      122:                while ( NEXT(asir_infile) )
                    123:                        closecurrentinput();
                    124:                reset_current_computation();
                    125:                ox_send_sync(0);
                    126:        }
                    127:        while ( 1 ) {
1.9       noro      128: #if defined(VISUAL)
                    129:                process_ox();
                    130: #else
1.1       noro      131:                if ( ox_data_is_available(0) )
                    132:                        process_ox();
1.12      noro      133:                else if ( use_x ) {
1.1       noro      134:                        FD_ZERO(&r);
                    135:                        FD_SET(3,&r); FD_SET(ds,&r);
                    136:                        select(FD_SETSIZE,&r,NULL,NULL,NULL);
                    137:                        if ( FD_ISSET(3,&r) )
                    138:                                process_ox();
                    139:                        else if ( FD_ISSET(ds,&r) )
                    140:                                process_xevent();
                    141:                }
                    142:        }
1.9       noro      143: #endif
1.1       noro      144: }
                    145:
                    146: static void process_ox()
                    147: {
                    148:        int id;
                    149:        unsigned int cmd;
                    150:        Obj obj;
                    151:        ERR err;
                    152:        unsigned int serial;
                    153:        int ret;
                    154:
                    155:        serial = ox_recv(0,&id,&obj);
                    156:        if ( do_message )
                    157:                fprintf(stderr,"#%d Got %s",serial,name_of_id(id));
                    158:        switch ( id ) {
                    159:                case OX_COMMAND:
                    160:                        cmd = ((USINT)obj)->body;
                    161:                        if ( ox_flushing )
                    162:                                break;
                    163:                        if ( do_message )
                    164:                                fprintf(stderr," %s\n",name_of_cmd(cmd));
1.14      noro      165:                        if ( ret = SETJMP(main_env) ) {
1.1       noro      166:                                if ( ret == 1 ) {
1.21    ! noro      167:                                        create_error(&err,serial,LastError,0);
1.1       noro      168:                                        asir_push_one((Obj)err);
                    169:                                }
                    170:                                break;
                    171:                        }
                    172:                        asir_do_cmd(cmd,serial);
                    173:                        break;
                    174:                case OX_DATA:
                    175:                case OX_LOCAL_OBJECT_ASIR:
                    176:                        if ( ox_flushing )
                    177:                                break;
                    178:                        if ( do_message )
                    179:                                fprintf(stderr," -> data pushed");
                    180:                        asir_push_one(obj);
                    181:                        break;
                    182:                case OX_SYNC_BALL:
                    183:                                asir_end_flush();
                    184:                        break;
                    185:                default:
                    186:                        break;
                    187:        }
                    188:        if ( do_message )
                    189:                fprintf(stderr,"\n");
                    190: }
                    191:
                    192: static void asir_do_cmd(unsigned int cmd,unsigned int serial)
                    193: {
                    194:        MATHCAP client_mathcap;
1.4       noro      195:        LIST list;
                    196:        int i;
                    197:        Q q;
1.1       noro      198:
                    199:        switch ( cmd ) {
1.4       noro      200:                case SM_dupErrors:
                    201:                        list = asir_GetErrorList();
                    202:                        asir_push_one((Obj)list);
                    203:                        break;
                    204:                case SM_getsp:
1.8       noro      205:                        i = asir_OperandStackPtr+1;
1.4       noro      206:                        STOQ(i,q);
                    207:                        asir_push_one((Obj)q);
                    208:                        break;
1.1       noro      209:                case SM_popSerializedLocalObject:
                    210:                        asir_popSerializedLocalObject();
                    211:                        break;
                    212:                case SM_popCMO:
                    213:                        asir_popCMO(serial);
                    214:                        break;
                    215:                case SM_popString:
                    216:                        asir_popString();
                    217:                        break;
                    218:                case SM_setName:
                    219:                        asir_setName(serial);
                    220:                        break;
                    221:                case SM_evalName:
                    222:                        asir_evalName(serial);
                    223:                        break;
                    224:                case SM_executeStringByLocalParser:
                    225:                        asir_executeString();
                    226:                        break;
                    227:                case SM_executeFunction:
1.10      noro      228:                        asir_executeFunction(serial);
1.1       noro      229:                        break;
                    230:                case SM_shutdown:
                    231:                        asir_terminate(2);
                    232:                        break;
                    233:                case SM_pops:
                    234:                        asir_pops();
                    235:                        break;
                    236:                case SM_mathcap:
                    237:                        asir_push_one((Obj)my_mathcap);
                    238:                        break;
                    239:                case SM_setMathcap:
                    240:                        client_mathcap = (MATHCAP)asir_pop_one();
                    241:                        store_remote_mathcap(0,client_mathcap);
                    242:                        break;
1.18      noro      243:                case SM_nop:
1.1       noro      244:                default:
                    245:                        break;
                    246:        }
                    247: }
                    248:
1.13      noro      249: static void asir_executeFunction(int serial)
1.1       noro      250: {
                    251:        char *func;
                    252:        int argc;
                    253:        int id;
                    254:        FUNC f;
                    255:        Q ret;
                    256:        VL vl;
1.10      noro      257:        ERR err;
1.1       noro      258:        NODE n,n1;
1.12      noro      259:        LIST bytes;
1.1       noro      260:
                    261:        func = ((STRING)asir_pop_one())->body;
                    262:        argc = (int)(((USINT)asir_pop_one())->body);
                    263:
                    264:        for ( n = 0; argc; argc-- ) {
                    265:                NEXTNODE(n,n1);
                    266:                BDY(n1) = (pointer)asir_pop_one();
                    267:        }
                    268:        if ( n )
                    269:                NEXT(n1) = 0;
                    270:        id = -1;
1.9       noro      271:        if ( !strcmp(func,"plot") ) {
1.1       noro      272:                id = plot(n);
1.9       noro      273:                STOQ(id,ret); asir_push_one((Obj)ret);
1.12      noro      274:        } else if ( !strcmp(func,"memory_plot") ) {
                    275:                memory_plot(n,&bytes); asir_push_one((Obj)bytes);
1.9       noro      276:        } else if ( !strcmp(func,"arrayplot") ) {
1.1       noro      277:                id = arrayplot(n);
1.9       noro      278:                STOQ(id,ret); asir_push_one((Obj)ret);
                    279:        } else if ( !strcmp(func,"open_canvas") ) {
                    280:                id = open_canvas(n);
                    281:                STOQ(id,ret); asir_push_one((Obj)ret);
                    282:        } else if ( !strcmp(func,"plotover") ) {
                    283:                plotover(n);
                    284:        } else if ( !strcmp(func,"drawcircle") ) {
                    285:                drawcircle(n);
                    286:        } else if ( !strcmp(func,"draw_obj") ) {
1.10      noro      287:                if ( draw_obj(n) < 0 ) {
1.21    ! noro      288:                        create_error(&err,serial,LastError,0);
1.10      noro      289:                        asir_push_one((Obj)err);
                    290:                }
1.16      noro      291:        } else if ( !strcmp(func,"draw_string") ) {
                    292:                if ( draw_string(n) < 0 ) {
1.21    ! noro      293:                        create_error(&err,serial,LastError,0);
1.16      noro      294:                        asir_push_one((Obj)err);
                    295:                }
1.9       noro      296:        } else if ( !strcmp(func,"clear_canvas") ) {
                    297:                clear_canvas(n);
                    298:        }
1.1       noro      299: }

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