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

Annotation of OpenXM_contrib2/asir2000/io/tcpf.c, Revision 1.15

1.10      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.11      noro       26:  * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
1.10      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.
1.15    ! noro       47:  * $OpenXM: OpenXM_contrib2/asir2000/io/tcpf.c,v 1.14 2000/09/27 09:27:24 noro Exp $
1.10      noro       48: */
1.1       noro       49: #if INET
                     50: #include "ca.h"
                     51: #include "parse.h"
                     52: #include "com.h"
                     53: #include <signal.h>
                     54: #if !defined(VISUAL)
                     55: #include <sys/types.h>
                     56: #include <pwd.h>
                     57: #endif
                     58: #include "ox.h"
                     59:
                     60: #if defined(VISUAL)
1.15    ! noro       61: #include <stdlib.h>
1.1       noro       62: #include <winsock.h>
1.15    ! noro       63: #include <process.h>
1.1       noro       64: #endif
                     65:
                     66: #define OX_XTERM "ox_xterm"
                     67:
                     68: #if !defined(_PA_RISC1_1)
                     69: #define RSH "rsh"
                     70: #else
                     71: #define RSH "remsh"
                     72: #endif
                     73:
                     74: static struct m_c {
                     75:        int m,c,af_unix;
                     76: } *m_c_tab;
                     77:
                     78: static int m_c_i,m_c_s;
                     79:
                     80: #if MPI
                     81: extern int mpi_nprocs;
                     82: #define valid_mctab_index(ind)\
1.8       noro       83: if((ind)<0||(ind)>=mpi_nprocs){error("invalid server id");}
1.1       noro       84: #else
                     85: #define valid_mctab_index(ind)\
                     86: if((ind)<0||(ind)>=m_c_i||\
1.8       noro       87: ((m_c_tab[ind].m<0)&&(m_c_tab[ind].c<0))){error("invalid server id");}
1.1       noro       88: #endif
                     89:
                     90: int register_server();
                     91: int get_mcindex(int);
                     92:
1.8       noro       93: void Pox_send_raw_cmo(), Pox_recv_raw_cmo();
                     94:
1.1       noro       95: void Pox_launch(),Pox_launch_nox(),Pox_launch_main();
                     96: void Pox_launch_generic();
                     97: void Pox_shutdown();
                     98:
1.5       noro       99: void Pox_rpc(),Pox_cmo_rpc(),Pox_reset(),Pox_intr(),Pox_sync(),Pox_select();
1.1       noro      100:
                    101: void Pox_push_local(),Pox_push_cmo(),Pox_push_vl(),Pox_push_cmd();
                    102:
                    103: void Pox_pop_local(),Pox_pop_cmo();
                    104: void Pox_pop0_local(),Pox_pop0_cmo();
                    105: void Pox_pop_string(),Pox_pop0_string();
                    106: void Pox_get(),Pox_pops();
                    107:
                    108: void Pox_execute_function(),Pox_execute_string();
                    109: void Pox_setname(), Pox_evalname();
                    110: void Pox_flush();
                    111: void Pgenerate_port(),Ptry_bind_listen(),Ptry_connect(),Ptry_accept();
                    112: void Pregister_server();
                    113: void Pox_get_serverinfo();
1.8       noro      114: void Pox_mpi_myid(), Pox_mpi_nprocs();
1.1       noro      115:
                    116: void ox_launch_generic();
                    117:
                    118: pointer bevalf();
                    119:
                    120: struct ftab tcp_tab[] = {
1.8       noro      121:        {"ox_send_raw_cmo",Pox_send_raw_cmo,2},
                    122:        {"ox_recv_raw_cmo",Pox_recv_raw_cmo,1},
1.1       noro      123:        {"ox_get_serverinfo",Pox_get_serverinfo,-1},
                    124:        {"generate_port",Pgenerate_port,-1},
                    125:        {"try_bind_listen",Ptry_bind_listen,1},
                    126:        {"try_connect",Ptry_connect,2},
                    127:        {"try_accept",Ptry_accept,2},
                    128:        {"register_server",Pregister_server,4},
                    129:        {"ox_flush",Pox_flush,1},
                    130:        {"ox_launch",Pox_launch,-3},
                    131:        {"ox_launch_nox",Pox_launch_nox,-3},
                    132:        {"ox_launch_generic",Pox_launch_generic,7},
                    133:        {"ox_shutdown",Pox_shutdown,1},
                    134:
                    135:        {"ox_rpc",Pox_rpc,-99999999},
                    136:        {"ox_cmo_rpc",Pox_cmo_rpc,-99999999},
                    137:
                    138:        {"ox_sync",Pox_sync,1},
1.8       noro      139: #if MPI
                    140:        {"ox_mpi_myid",Pox_mpi_myid,0},
                    141:        {"ox_mpi_nprocs",Pox_mpi_nprocs,0},
                    142: #endif
1.1       noro      143: #if !MPI
                    144:        {"ox_reset",Pox_reset,-2},
1.5       noro      145:        {"ox_intr",Pox_intr,1},
1.1       noro      146:        {"ox_select",Pox_select,-2},
                    147: #endif
                    148:
                    149:        {"ox_pop_string",Pox_pop_string,1},
                    150:        {"ox_pop0_string",Pox_pop0_string,1},
                    151:        {"ox_pop_local",Pox_pop_local,1},
                    152:        {"ox_pop0_local",Pox_pop0_local,1},
                    153:        {"ox_pop_cmo",Pox_pop_cmo,1},
                    154:        {"ox_pop0_cmo",Pox_pop0_cmo,1},
1.3       noro      155:        {"ox_get",Pox_get,-1},
1.1       noro      156:        {"ox_pops",Pox_pops,-2},
                    157:
                    158:        {"ox_push_vl",Pox_push_vl,1},
                    159:        {"ox_push_local",Pox_push_local,-99999999},
                    160:        {"ox_push_cmo",Pox_push_cmo,-99999999},
                    161:        {"ox_push_cmd",Pox_push_cmd,2},
                    162:
                    163:        {"ox_setname",Pox_setname,2},
                    164:        {"ox_evalname",Pox_evalname,2},
                    165:
                    166:        {"ox_execute_string",Pox_execute_string,2},
                    167:        {"ox_execute_function",Pox_execute_function,3},
                    168:
                    169:
                    170:        {0,0,0},
                    171: };
                    172:
                    173: extern struct IOFP iofp[];
                    174: extern MATHCAP my_mathcap;
1.6       noro      175: extern int ox_exchange_mathcap;
1.1       noro      176:
                    177: char *getenv();
                    178:
1.8       noro      179: #if MPI
                    180: extern int mpi_myid, mpi_nprocs;
                    181:
                    182: void Pox_mpi_myid(rp)
                    183: Q *rp;
                    184: {
                    185:        STOQ(mpi_myid,*rp);
                    186: }
                    187:
                    188: void Pox_mpi_nprocs(rp)
                    189: Q *rp;
                    190: {
                    191:        STOQ(mpi_nprocs,*rp);
                    192: }
                    193: #endif
                    194:
1.1       noro      195: void Pox_get_serverinfo(arg,rp)
                    196: NODE arg;
                    197: LIST *rp;
                    198: {
                    199:        int i,c;
                    200:        Q sid;
                    201:        NODE t,n0,n;
                    202:        LIST list,l;
                    203:
                    204:        if ( !arg ) {
                    205:                for ( i = 0, n0 = 0; i < m_c_i; i++ )
1.8       noro      206:                        if ( (m_c_tab[i].m>=0) || (m_c_tab[i].c>=0) ) {
1.1       noro      207:                                c = m_c_tab[i].c;
                    208:                                ox_get_serverinfo(c,&list);
                    209:                                STOQ(i,sid);
                    210:                                t = mknode(2,sid,list);
                    211:                                MKLIST(l,t);
                    212:                                NEXTNODE(n0,n);
                    213:                                BDY(n) = (pointer)l;
                    214:                        }
                    215:                if ( n0 )
                    216:                        NEXT(n) = 0;
                    217:                MKLIST(*rp,n0);
                    218:        } else {
                    219:                i = QTOS((Q)ARG0(arg));
1.8       noro      220:                if ( i >= 0 && i < m_c_i && ((m_c_tab[i].m>=0) || (m_c_tab[i].c>=0)) )
1.1       noro      221:                        ox_get_serverinfo(m_c_tab[i].c,rp);
                    222:                else {
                    223:                        MKLIST(*rp,0);
                    224:                }
                    225:        }
                    226: }
                    227:
                    228: /*
                    229:   if noarg or arg[0]==0 then use IP socket and return a port number
                    230:   else use UNIX socket and return a string which represents a path name
                    231: */
                    232:
                    233: void Pgenerate_port(arg,rp)
                    234: NODE arg;
                    235: Obj *rp;
                    236: {
                    237:        char port_str[BUFSIZ];
                    238:        int port;
                    239:        char *s;
                    240:        STRING str;
                    241:        Q q;
                    242:
                    243:        if ( !arg || !ARG0(arg) ) {
                    244:                generate_port(0,port_str);
                    245:                port = atoi(port_str);
                    246:                STOQ(port,q);
                    247:                *rp = (Obj)q;
                    248:        } else {
                    249:                generate_port(1,port_str);
                    250:                s = (char *)MALLOC(strlen(port_str)+1);
                    251:                strcpy(s,port_str);
                    252:                MKSTR(str,s);
                    253:                *rp = (Obj)str;
                    254:        }
                    255: }
                    256:
                    257: /*
                    258:  try_bind_listen(port)
                    259: */
                    260:
                    261: void Ptry_bind_listen(arg,rp)
                    262: NODE arg;
                    263: Q *rp;
                    264: {
                    265:        char port_str[BUFSIZ];
                    266:        int port,s,use_unix;
                    267:
                    268:        if ( !ARG0(arg) || NUM(ARG0(arg)) ) {
                    269:                port = QTOS((Q)ARG0(arg));
                    270:                sprintf(port_str,"%d",port);
                    271:                use_unix = 0;
                    272:        } else {
                    273:                strcpy(port_str,BDY((STRING)ARG0(arg)));
                    274:                use_unix = 1;
                    275:        }
                    276:        s = try_bind_listen(use_unix,port_str);
                    277:        STOQ(s,*rp);
                    278: }
                    279:
                    280: /*
                    281:  try_connect(host,port)
                    282: */
                    283:
                    284: void Ptry_connect(arg,rp)
                    285: NODE arg;
                    286: Q *rp;
                    287: {
                    288:        char port_str[BUFSIZ];
                    289:        char *host;
                    290:        int port,s,use_unix;
                    291:
                    292:        if ( !ARG1(arg) || NUM(ARG1(arg)) ) {
                    293:                port = QTOS((Q)ARG1(arg));
                    294:                sprintf(port_str,"%d",port);
                    295:                use_unix = 0;
                    296:        } else {
                    297:                strcpy(port_str,BDY((STRING)ARG1(arg)));
                    298:                use_unix = 1;
                    299:        }
                    300:        host = BDY((STRING)ARG0(arg));
                    301:        s = try_connect(use_unix,host,port_str);
                    302:        STOQ(s,*rp);
                    303: }
                    304:
                    305: /*
                    306:  try_accept(sock,port)
                    307: */
                    308:
                    309: void Ptry_accept(arg,rp)
                    310: NODE arg;
                    311: Q *rp;
                    312: {
                    313:        int use_unix,s;
                    314:
                    315:        if ( !ARG1(arg) || NUM(ARG1(arg)) )
                    316:                use_unix = 0;
                    317:        else
                    318:                use_unix = 1;
                    319:        s = try_accept(use_unix,QTOS((Q)ARG0(arg)));
                    320:        STOQ(s,*rp);
                    321: }
                    322:
                    323: /*
                    324:  register_server(cs,cport,ss,sport)
                    325: */
                    326:
                    327: void Pregister_server(arg,rp)
                    328: NODE arg;
                    329: Q *rp;
                    330: {
                    331:        int cs,ss,cn,sn,ind,use_unix,id;
                    332:        char cport_str[BUFSIZ],sport_str[BUFSIZ];
                    333:        MATHCAP server_mathcap;
                    334:
                    335:        cs = QTOS((Q)ARG0(arg));
                    336:        ss = QTOS((Q)ARG2(arg));
                    337:        if ( !ARG1(arg) || NUM(ARG1(arg)) ) {
                    338:                sprintf(cport_str,"%d",QTOS((Q)ARG1(arg)));
                    339:                use_unix = 0;
                    340:        } else {
                    341:                strcpy(cport_str,BDY((STRING)ARG1(arg)));
                    342:                use_unix = 1;
                    343:        }
                    344:        if ( !ARG3(arg) || NUM(ARG3(arg)) ) {
                    345:                if ( use_unix )
                    346:                        error("register_server : the protocol should conincide for two sockets");
                    347:                sprintf(sport_str,"%d",QTOS((Q)ARG3(arg)));
                    348:        } else {
                    349:                if ( !use_unix )
                    350:                        error("register_server : the protocol should conincide for two sockets");
                    351:                strcpy(sport_str,BDY((STRING)ARG3(arg)));
                    352:        }
                    353:
                    354:        /* client mode */
                    355:        cn = get_iofp(cs,cport_str,0);
                    356:        sn = get_iofp(ss,sport_str,0);
1.12      noro      357:        /* get_iofp returns -1 if the laucher could not spawn the server */
                    358:        if ( sn < 0 ) {
                    359:                /* we should terminate the launcher */
                    360:                ox_send_cmd(cn,SM_shutdown); ox_flush_stream_force(cn);
                    361:                STOQ(-1,*rp);
                    362:                return;
                    363:        }
1.1       noro      364:
                    365:        /* register server to the server list */
                    366:        ind = register_server(use_unix,cn,sn);
                    367:
1.6       noro      368:        if ( ox_exchange_mathcap ) {
                    369:                /* request remote mathcap */
                    370:                ox_send_cmd(sn,SM_mathcap);
                    371:                ox_send_cmd(sn,SM_popCMO);
                    372:                ox_flush_stream_force(sn);
                    373:                ox_recv(sn,&id,&server_mathcap);
                    374:                store_remote_mathcap(sn,server_mathcap);
                    375:
                    376:                /* send my mathcap */
                    377:                create_my_mathcap("asir");
                    378:                ox_send_data(sn,my_mathcap);
                    379:                ox_send_cmd(sn,SM_setMathcap);
                    380:        }
1.1       noro      381:        /* return the server id */
                    382:        STOQ(ind,*rp);
                    383: }
                    384:
                    385: /*
                    386:   ox_launch_generic(host,launcher,server,use_unix,use_ssh,use_x,conn_to_serv)
                    387:
                    388:   Input
                    389:        host: hostname on which servers run
                    390:        launcher: path name of the launcher
                    391:        server: path name of the server
                    392:        use_unix: use UNIX domain socket if 1
                    393:        use_ssh: use ssh if 1
                    394:        use_x: use X11 facilities if 1
                    395:        conn_to_serv: connect to server if 1
                    396: */
                    397:
                    398: void Pox_launch_generic(arg,rp)
                    399: NODE arg;
                    400: Q *rp;
                    401: {
                    402:        int use_unix,use_ssh,use_x,conn_to_serv;
                    403:        char *host,*launcher,*server;
                    404:
                    405:        host = (arg&&ARG0(arg))?BDY((STRING)ARG0(arg)):0;
                    406:        launcher = BDY((STRING)ARG1(arg));
                    407:        server = BDY((STRING)ARG2(arg));
                    408:        use_unix = ARG3(arg) ? 1 : 0;
                    409:        use_ssh = ARG4(arg) ? 1 : 0;
                    410:        use_x = ARG5(arg) ? 1 : 0;
                    411:        conn_to_serv = QTOS((Q)ARG6(arg));
                    412:        if ( !host )
                    413:                use_unix = 1;
                    414:        ox_launch_generic(host,launcher,server,
                    415:                use_unix,use_ssh,use_x,conn_to_serv,rp);
                    416: }
                    417:
                    418: void ox_launch_generic(host,launcher,server,
                    419:                use_unix,use_ssh,use_x,conn_to_serv,rp)
                    420: char *host,*launcher,*server;
                    421: int use_unix,use_ssh,use_x,conn_to_serv;
                    422: Q *rp;
                    423: {
                    424:        int cs,ss,cn,sn,ind,id;
                    425:        char control_port_str[BUFSIZ];
                    426:        char server_port_str[BUFSIZ];
                    427:        MATHCAP server_mathcap;
                    428:
                    429:        control_port_str[0] = 0;
                    430:        server_port_str[0] = 0;
                    431:        do {
                    432:                generate_port(use_unix,control_port_str);
                    433:                generate_port(use_unix,server_port_str);
                    434:                if ( !conn_to_serv ) {
                    435:                        cs = try_bind_listen(use_unix,control_port_str);
                    436:                        ss = try_bind_listen(use_unix,server_port_str);
                    437:                }
                    438:                spawn_server(host,launcher,server,
                    439:                        use_unix,use_ssh,use_x,conn_to_serv,
                    440:                                control_port_str,server_port_str);
                    441:                if ( conn_to_serv ) {
                    442:                        cs = try_connect(use_unix,host,control_port_str);
                    443:                        ss = try_connect(use_unix,host,server_port_str);
                    444:                } else {
                    445:                        cs = try_accept(use_unix,cs);
                    446:                        ss = try_accept(use_unix,ss);
                    447:                }
                    448:        } while ( cs < 0 || ss < 0 );
                    449:
                    450:        /* client mode */
                    451:        cn = get_iofp(cs,control_port_str,0);
                    452:        sn = get_iofp(ss,server_port_str,0);
1.12      noro      453:        /* get_iofp returns -1 if the laucher could not spawn the server */
                    454:        if ( sn < 0 ) {
                    455:                /* we should terminate the launcher */
                    456:                ox_send_cmd(cn,SM_shutdown); ox_flush_stream_force(cn);
                    457:                STOQ(-1,*rp);
                    458:                return;
                    459:        }
1.1       noro      460:
                    461:        /* register server to the server list */
                    462:        ind = register_server(use_unix,cn,sn);
                    463:
1.6       noro      464:        if ( ox_exchange_mathcap ) {
                    465:                /* request remote mathcap */
                    466:                ox_send_cmd(sn,SM_mathcap);
                    467:                ox_send_cmd(sn,SM_popCMO);
                    468:                ox_flush_stream_force(sn);
                    469:                ox_recv(sn,&id,&server_mathcap);
                    470:                store_remote_mathcap(sn,server_mathcap);
                    471:
                    472:                /* send my mathcap */
                    473:                create_my_mathcap("asir");
                    474:                ox_send_data(sn,my_mathcap);
                    475:                ox_send_cmd(sn,SM_setMathcap);
                    476:        }
1.1       noro      477:        /* return the server id */
                    478:        STOQ(ind,*rp);
                    479: }
                    480:
                    481: int spawn_server(host,launcher,server,
                    482:        use_unix,use_ssh,use_x,conn_to_serv,
                    483:        control_port_str,server_port_str)
                    484: char *host,*launcher,*server;
                    485: int use_unix,use_ssh,use_x,conn_to_serv;
                    486: char *control_port_str,*server_port_str;
                    487: {
                    488:        char cmd[BUFSIZ];
                    489:        char localhost[BUFSIZ];
                    490:        char *dname,*conn_str,*rsh;
1.13      noro      491:        char dname_str[BUFSIZ];
1.15    ! noro      492:        char AsirExe[BUFSIZ];
        !           493:        STRING rootdir;
        !           494:        char prog[BUFSIZ];
        !           495:        char *av[BUFSIZ];
1.1       noro      496:
                    497:        dname = use_x ? (char *)getenv("DISPLAY") : 0;
                    498:        conn_str = conn_to_serv ? "1" : "0";
1.13      noro      499:        rsh = getenv("ASIR_RSH");
                    500:        if ( !rsh )
                    501:                rsh = use_ssh ? "ssh" : RSH;
                    502:        if ( !use_unix && dname && strstr(rsh,"ssh") ) {
                    503:                /*
                    504:                 * if "ssh" is used to invoke a remote server,
                    505:                 * we should not specify "-display".
                    506:                 */
                    507:                use_ssh = 1;
                    508:        }
1.1       noro      509:        gethostname(localhost,BUFSIZ);
1.15    ! noro      510: #if defined(VISUAL)
        !           511:        if ( !use_unix )
        !           512:                error("spawn_server : not implemented on Windows");
        !           513:        Pget_rootdir(&rootdir);
        !           514:        sprintf(AsirExe,"%s\\bin\\engine.exe",BDY(rootdir));
        !           515:        strcpy(prog,server);
        !           516:        server = strrchr(prog,'/')+1;
        !           517:        av[0] = "ox_launch";
        !           518:        av[1] = "127.0.0.1";
        !           519:        av[2] = conn_str;
        !           520:        av[3] = control_port_str;
        !           521:        av[4] = server_port_str;
        !           522:        av[5] = server;
        !           523:        av[6] = use_x ? "1" : "0";
        !           524:        av[7] = 0;
        !           525:
        !           526:        _spawnv(_P_NOWAIT,AsirExe,av);
        !           527: //     _spawnv(_P_NOWAIT,"d:\\home\\noro\\engine2000\\debug\\engine.exe",av);
        !           528: //     printf("ox_launch 127.0.0.1 %s %s %s %s 0\n",conn_str,control_port_str,server_port_str,server);
        !           529: #else
1.1       noro      530:        if ( use_unix ) {
                    531:                if ( !fork() ) {
1.2       noro      532:                        setpgid(0,getpid());
1.1       noro      533:                        if ( dname )
1.13      noro      534:                                execlp("xterm","xterm","-name",OX_XTERM,"-T","ox_launch:local","-display",dname,
1.1       noro      535:                                        "-geometry","60x10","-e",launcher,".",conn_str,
                    536:                                        control_port_str,server_port_str,server,dname,0);
                    537:                        else
                    538:                                execlp(launcher,launcher,".",conn_str,
                    539:                                        control_port_str,server_port_str,server,"0",0);
                    540:                }
                    541:        } else if ( conn_to_serv == 2 ) {
                    542:                /* special support for java */
                    543:                if ( dname )
                    544:                        sprintf(cmd,
1.13      noro      545:                                "%s -n %s \"(cd %s; xterm -name %s %s -geometry 60x10 -e java %s -host %s -control %s -data %s)>&/dev/null&\">/dev/null",
1.1       noro      546:                                rsh,host,launcher,OX_XTERM,dname,server,localhost,control_port_str,server_port_str);
                    547:                else
                    548:                        sprintf(cmd,
                    549:                                "%s -n %s \"(cd %s; java %s -host %s -control %s -data %s)>&/dev/null&\">/dev/null",
                    550:                                rsh,host,launcher,server,localhost,
                    551:                                control_port_str,server_port_str,server);
                    552:                fprintf(stderr,"%s\n",cmd);
                    553:                sleep(20);
                    554: /*             system(cmd); */
1.15    ! noro      555:        } else {
1.1       noro      556:                if ( dname )
1.13      noro      557:                        if ( use_ssh )
                    558:                        sprintf(cmd,
1.14      noro      559: "%s -f -n %s \"xterm -name %s -title ox_launch:%s -geometry 60x10 -e %s %s %s %s %s %s %s >&/dev/null\">/dev/null",
1.13      noro      560:                                rsh,host,OX_XTERM,host,launcher,localhost,conn_str,
                    561:                                control_port_str,server_port_str,server,"1");
                    562:                        else
1.1       noro      563:                        sprintf(cmd,
1.14      noro      564: "%s -n %s \"xterm -name %s -title ox_launch:%s -display %s -geometry 60x10 -e %s %s %s %s %s %s %s >&/dev/null&\">/dev/null",
1.13      noro      565:                                rsh,host,OX_XTERM,host,dname,launcher,localhost,conn_str,
1.1       noro      566:                                control_port_str,server_port_str,server,dname);
                    567:                else
                    568:                        sprintf(cmd,
1.14      noro      569: "%s -n %s \"%s %s %s %s %s %s %s >&/dev/null&\">/dev/null",
1.1       noro      570:                                rsh,host,launcher,localhost,conn_str,
                    571:                                control_port_str,server_port_str,server,"0");
                    572:                system(cmd);
                    573:        }
1.15    ! noro      574: #endif /* VISUAL */
1.1       noro      575: }
                    576:
                    577: void Pox_launch(arg,rp)
                    578: NODE arg;
                    579: Obj *rp;
                    580: {
                    581:        Pox_launch_main(1,arg,rp);
                    582: }
                    583:
                    584: void Pox_launch_nox(arg,rp)
                    585: NODE arg;
                    586: Obj *rp;
                    587: {
                    588:        Pox_launch_main(0,arg,rp);
                    589: }
                    590:
                    591: /*
                    592:        ox_launch() : invoke local ox_asir
                    593:        ox_launch(0,ox_xxx) : invoke local ox_xxx with asir_libdir/ox_launch
                    594:        ox_launch(remote,lib,ox_xxx) : invoke remote ox_xxx with lib/ox_launch
                    595: */
                    596:
                    597: void Pox_launch_main(with_x,arg,rp)
                    598: int with_x;
                    599: NODE arg;
                    600: Obj *rp;
                    601: {
                    602:        char *str;
                    603:        char *hostname,*servername,*dname;
                    604:        char *control;
                    605:        int use_unix;
                    606:        extern char *asir_libdir;
                    607:
                    608:        if ( arg && ARG0(arg) && argc(arg) != 3 )
                    609:                error("ox_launch : argument mismatch");
                    610:        control = (char *)MALLOC(BUFSIZ);
                    611:        if ( !arg || ( !ARG0(arg) && argc(arg) == 1 ) ) {
                    612:                sprintf(control,"%s/ox_launch",asir_libdir);
                    613:                use_unix = 1;
                    614:                servername = (char *)MALLOC(BUFSIZ);
                    615:                sprintf(servername,"%s/ox_asir",asir_libdir);
                    616:        } else if ( !ARG0(arg) && argc(arg) == 2 ) {
                    617:                sprintf(control,"%s/ox_launch",asir_libdir);
                    618:                use_unix = 1;
                    619:                str = BDY((STRING)ARG1(arg));
                    620:                if ( str[0] == '/' )
                    621:                        servername = str;
                    622:                else {
                    623:                        servername = (char *)MALLOC(BUFSIZ);
                    624:                        sprintf(servername,"%s/%s",asir_libdir,str);
                    625:                }
                    626:        } else {
                    627:                sprintf(control,"%s/ox_launch",BDY((STRING)ARG1(arg)));
                    628:                if ( !ARG0(arg) )
                    629:                        use_unix = 1;
                    630:                else
                    631:                        use_unix = 0;
                    632:                str = BDY((STRING)ARG2(arg));
                    633:                if ( str[0] == '/' )
                    634:                        servername = str;
                    635:                else {
                    636:                        servername = (char *)MALLOC(BUFSIZ);
                    637:                        sprintf(servername,"%s/%s",BDY((STRING)ARG1(arg)),str);
                    638:                }
                    639:        }
                    640:        if ( arg && ARG0(arg) )
                    641:                hostname = BDY((STRING)ARG0(arg));
                    642:        else
                    643:                hostname = 0;
                    644:        ox_launch_generic(hostname,control,servername,use_unix,0,with_x,0,rp);
                    645: }
                    646:
                    647: int register_server(af_unix,m,c)
                    648: int af_unix,m,c;
                    649: {
                    650:        int s,i,ci;
                    651:        struct m_c *t;
1.9       noro      652: #define INIT_TAB_SIZ 64
1.1       noro      653:
                    654:        if ( c < 0 )
                    655:                return -1;
                    656:        if ( !m_c_tab ) {
1.9       noro      657:                s = INIT_TAB_SIZ*sizeof(struct m_c);
1.8       noro      658:                m_c_tab = (struct m_c *)MALLOC_ATOMIC(s);
1.9       noro      659:                for ( i = 0; i < INIT_TAB_SIZ; i++ ) {
1.8       noro      660:                        m_c_tab[i].af_unix = 0;
                    661:                        m_c_tab[i].m = m_c_tab[i].c = -1;
                    662:                }
1.9       noro      663:                m_c_s = INIT_TAB_SIZ;
1.1       noro      664:        }
                    665: #if !MPI
                    666:        for ( i = 0; i < m_c_i; i++ )
1.8       noro      667:                if ( (m_c_tab[i].m<0) && (m_c_tab[i].c<0) )
1.1       noro      668:                        break;
                    669:        if ( i < m_c_i ) {
                    670:                m_c_tab[i].m = m; m_c_tab[i].c = c;
                    671:                m_c_tab[i].af_unix = af_unix;
                    672:                return i;
                    673:        }
                    674: #endif
                    675:        if ( m_c_i == m_c_s ) {
1.9       noro      676:                s = (m_c_s+INIT_TAB_SIZ)*sizeof(struct m_c);
1.1       noro      677:                t = (struct m_c *)MALLOC_ATOMIC(s); bzero(m_c_tab,s);
                    678:                bcopy(m_c_tab,t,m_c_s*sizeof(struct m_c));
1.9       noro      679:                for ( i = 0; i < INIT_TAB_SIZ; i++ ) {
1.8       noro      680:                        m_c_tab[m_c_s+i].af_unix = 0;
                    681:                        m_c_tab[m_c_s+i].m = m_c_tab[m_c_s+i].c = -1;
                    682:                }
1.9       noro      683:                m_c_s += INIT_TAB_SIZ; m_c_tab = t;
1.1       noro      684:        }
                    685:        m_c_tab[m_c_i].m = m; m_c_tab[m_c_i].c = c;
                    686:        m_c_tab[m_c_i].af_unix = af_unix;
                    687:        return m_c_i++;
                    688: }
                    689:
                    690: /* iofp index => m_c_tab index */
                    691:
                    692: int get_mcindex(i)
                    693: int i;
                    694: {
                    695:        int j;
                    696:
                    697:        for ( j = 0; j < m_c_i; j++ )
                    698:                if ( m_c_tab[j].c == i )
                    699:                        return j;
                    700:        return -1;
                    701: }
                    702:
                    703: /* arg = [ind0,ind1,...]; indk = index to m_c_tab */
                    704:
                    705: void Pox_select(arg,rp)
                    706: NODE arg;
                    707: LIST *rp;
                    708: {
                    709:        int fd,n,i,index,mcind;
                    710:        fd_set r,w,e;
                    711:        NODE list,t,t1;
                    712:        Q q;
                    713:        double max;
                    714:        struct timeval interval;
                    715:        struct timeval *tvp;
                    716:
                    717:        list = BDY((LIST)ARG0(arg)); arg = NEXT(arg);
                    718:        if ( arg ) {
                    719:                max = ToReal((Num)BDY(arg));
                    720:                interval.tv_sec = (int)max;
                    721:                interval.tv_usec = (int)((max-(int)max)*1000000);
                    722:                tvp = &interval;
                    723:        } else
                    724:                tvp = 0;
                    725:
                    726:        FD_ZERO(&r); FD_ZERO(&w); FD_ZERO(&e);
                    727:        for ( t = list; t; t = NEXT(t) ) {
                    728:                index = QTOS((Q)BDY(t));
                    729:                valid_mctab_index(index);
                    730:                fd = get_fd(m_c_tab[index].c); FD_SET(fd,&r);
                    731:        }
                    732:        n = select(FD_SETSIZE,&r,&w,&e,tvp);
                    733:        for ( i = 0, t = 0; n && i < FD_SETSIZE; i++ )
                    734:                if ( FD_ISSET(i,&r) ) {
                    735:                        /* index : index to iofp array */
                    736:                        index = get_index(i);
                    737:                        /* mcind : index to m_c_tab array */
                    738:                        mcind = get_mcindex(index);
                    739:                        n--; STOQ(mcind,q); MKNODE(t1,q,t); t = t1;
                    740:                }
                    741:        MKLIST(*rp,t);
                    742: }
                    743:
                    744: void Pox_flush(arg,rp)
                    745: NODE arg;
                    746: Q *rp;
                    747: {
                    748:        int index = QTOS((Q)ARG0(arg));
                    749:
                    750:        valid_mctab_index(index);
                    751:        ox_flush_stream_force(m_c_tab[index].c);
                    752:        *rp = ONE;
                    753: }
                    754:
1.8       noro      755: void Pox_send_raw_cmo(arg,rp)
                    756: NODE arg;
                    757: Obj *rp;
                    758: {
                    759:        int s;
                    760:        int index = QTOS((Q)ARG0(arg));
                    761:
                    762:        valid_mctab_index(index);
                    763:        s = m_c_tab[index].c;
                    764:        ox_write_cmo(s,(Obj)ARG1(arg));
                    765:        /* flush always */
                    766:        ox_flush_stream(s);
                    767:        *rp = 0;
                    768: }
                    769:
                    770: void Pox_recv_raw_cmo(arg,rp)
                    771: NODE arg;
                    772: Obj *rp;
                    773: {
                    774:        int s;
                    775:        int index = QTOS((Q)ARG0(arg));
                    776:
                    777:        valid_mctab_index(index);
                    778:        s = m_c_tab[index].c;
                    779:        ox_read_cmo(s,rp);
                    780: }
                    781:
1.1       noro      782: void Pox_push_local(arg,rp)
                    783: NODE arg;
                    784: Obj *rp;
                    785: {
                    786:        int s;
                    787:        struct oLIST dummy;
                    788:        VL vl;
                    789:        int index = QTOS((Q)ARG0(arg));
                    790:
                    791:        valid_mctab_index(index);
                    792:        s = m_c_tab[index].c; arg = NEXT(arg);
                    793:
                    794:        dummy.id = O_LIST; dummy.body = arg;
                    795:        get_vars_recursive((Obj)&dummy,&vl);
                    796:
                    797:        ox_send_local_ring(s,vl);
                    798:        for ( ; arg; arg = NEXT(arg) )
                    799:                ox_send_local_data(s,BDY(arg));
                    800:        *rp = 0;
                    801: }
                    802:
                    803: void Pox_push_cmo(arg,rp)
                    804: NODE arg;
                    805: Obj *rp;
                    806: {
                    807:        int s;
                    808:        int index = QTOS((Q)ARG0(arg));
                    809:
                    810:        valid_mctab_index(index);
                    811:        s = m_c_tab[index].c; arg = NEXT(arg);
                    812:        for ( ; arg; arg = NEXT(arg) )
                    813:                ox_send_data(s,BDY(arg));
                    814:        *rp = 0;
                    815: }
                    816:
                    817: void Pox_push_vl(arg,rp)
                    818: NODE arg;
                    819: Obj *rp;
                    820: {
                    821:        int s;
                    822:        int index = QTOS((Q)ARG0(arg));
                    823:
                    824:        valid_mctab_index(index);
                    825:        ox_send_local_ring(m_c_tab[index].c,CO);
                    826:        *rp = 0;
                    827: }
                    828:
                    829: void Pox_pop_local(arg,rp)
                    830: NODE arg;
                    831: Obj *rp;
                    832: {
                    833:        int s;
                    834:        int index = QTOS((Q)ARG0(arg));
                    835:
                    836:        valid_mctab_index(index);
                    837:        s = m_c_tab[index].c;
                    838:        ox_send_cmd(s,SM_popSerializedLocalObject);
                    839:        ox_flush_stream_force(s);
                    840:        ox_get_result(s,rp);
                    841: }
                    842:
                    843: void Pox_pop_cmo(arg,rp)
                    844: NODE arg;
                    845: Obj *rp;
                    846: {
                    847:        int s;
                    848:        int index = QTOS((Q)ARG0(arg));
                    849:
                    850:        valid_mctab_index(index);
                    851:        s = m_c_tab[index].c;
                    852:        ox_send_cmd(s,SM_popCMO);
                    853:        ox_flush_stream_force(s);
                    854:        ox_get_result(s,rp);
                    855: }
                    856:
                    857: void Pox_pop0_local(arg,rp)
                    858: NODE arg;
                    859: Obj *rp;
                    860: {
                    861:        int index = QTOS((Q)ARG0(arg));
                    862:
                    863:        valid_mctab_index(index);
                    864:        ox_send_cmd(m_c_tab[index].c,SM_popSerializedLocalObject);
                    865:        *rp = 0;
                    866: }
                    867:
                    868: void Pox_pop0_cmo(arg,rp)
                    869: NODE arg;
                    870: Obj *rp;
                    871: {
                    872:        int index = QTOS((Q)ARG0(arg));
                    873:
                    874:        valid_mctab_index(index);
                    875:        ox_send_cmd(m_c_tab[index].c,SM_popCMO);
                    876:        *rp = 0;
                    877: }
                    878:
                    879: void Pox_pop0_string(arg,rp)
                    880: NODE arg;
                    881: STRING *rp;
                    882: {
                    883:        int index = QTOS((Q)ARG0(arg));
                    884:
                    885:        valid_mctab_index(index);
                    886:        ox_send_cmd(m_c_tab[index].c,SM_popString);
                    887:        *rp = 0;
                    888: }
                    889:
                    890: void Pox_pop_string(arg,rp)
                    891: NODE arg;
                    892: STRING *rp;
                    893: {
                    894:        int s,id;
                    895:        int index = QTOS((Q)ARG0(arg));
                    896:
                    897:        valid_mctab_index(index);
                    898:        s = m_c_tab[index].c;
                    899:        ox_send_cmd(s,SM_popString);
                    900:        ox_flush_stream_force(s);
                    901:        ox_get_result(s,rp);
                    902: }
                    903:
                    904: void Pox_get(arg,rp)
                    905: NODE arg;
                    906: Obj *rp;
                    907: {
1.3       noro      908:        int index;
1.1       noro      909:        int s;
                    910:
1.3       noro      911:        if ( !arg ) {
                    912:                /* client->server */
                    913:                ox_get_result(0,rp);
                    914:        } else {
                    915:                /* server->client */
                    916:                index = QTOS((Q)ARG0(arg));
                    917:                valid_mctab_index(index);
                    918:                s = m_c_tab[index].c;
                    919:                ox_flush_stream_force(s);
                    920:                ox_get_result(s,rp);
                    921:        }
1.1       noro      922: }
                    923:
                    924: void Pox_pops(arg,rp)
                    925: NODE arg;
                    926: Obj *rp;
                    927: {
                    928:        int s;
                    929:        USINT n;
                    930:        int index = QTOS((Q)ARG0(arg));
                    931:
                    932:        valid_mctab_index(index);
                    933:        s = m_c_tab[index].c;
                    934:        if ( NEXT(arg) )
                    935:                MKUSINT(n,QTOS((Q)ARG1(arg)));
                    936:        else
                    937:                MKUSINT(n,1);
                    938:        ox_send_data(s,n);
                    939:        ox_send_cmd(s,SM_pops);
                    940:        *rp = 0;
                    941: }
                    942:
                    943: void Pox_execute_function(arg,rp)
                    944: NODE arg;
                    945: Obj *rp;
                    946: {
                    947:        int s;
                    948:        USINT ui;
                    949:        int index = QTOS((Q)ARG0(arg));
                    950:
                    951:        valid_mctab_index(index);
                    952:        s = m_c_tab[index].c;
                    953:        MKUSINT(ui,QTOS((Q)ARG2(arg)));
                    954:        ox_send_data(s,ui);
                    955:        ox_send_data(s,ARG1(arg));
                    956:        ox_send_cmd(s,SM_executeFunction);
                    957:        *rp = 0;
                    958: }
                    959:
                    960: void Pox_setname(arg,rp)
                    961: NODE arg;
                    962: Obj *rp;
                    963: {
                    964:        int s;
                    965:        int index = QTOS((Q)ARG0(arg));
                    966:
                    967:        valid_mctab_index(index);
                    968:        s = m_c_tab[index].c;
                    969:        ox_send_data(s,ARG1(arg));
                    970:        ox_send_cmd(s,SM_setName);
                    971:        *rp = 0;
                    972: }
                    973:
                    974: void Pox_evalname(arg,rp)
                    975: NODE arg;
                    976: Obj *rp;
                    977: {
                    978:        int s;
                    979:        int index = QTOS((Q)ARG0(arg));
                    980:
                    981:        valid_mctab_index(index);
                    982:        s = m_c_tab[index].c;
                    983:        ox_send_data(s,ARG1(arg));
                    984:        ox_send_cmd(s,SM_evalName);
                    985:        *rp = 0;
                    986: }
                    987:
                    988: void Pox_execute_string(arg,rp)
                    989: NODE arg;
                    990: Obj *rp;
                    991: {
                    992:        int s;
                    993:        int index = QTOS((Q)ARG0(arg));
                    994:
                    995:        valid_mctab_index(index);
                    996:        s = m_c_tab[index].c;
                    997:        ox_send_data(s,ARG1(arg));
                    998:        ox_send_cmd(s,SM_executeStringByLocalParser);
                    999:        *rp = 0;
                   1000: }
                   1001:
                   1002: /* arg=[sid,fname,arg0,arg1,...,arg{n-1}] */
                   1003:
                   1004: void Pox_rpc(arg,rp)
                   1005: NODE arg;
                   1006: Obj *rp;
                   1007: {
                   1008:        int s,i,n;
                   1009:        STRING f;
                   1010:        USINT ui;
                   1011:        pointer *w;
                   1012:        NODE t;
                   1013:        int index = QTOS((Q)ARG0(arg));
                   1014:
                   1015:        valid_mctab_index(index);
                   1016:        s = m_c_tab[index].c; arg = NEXT(arg);
                   1017:        f = (STRING)BDY(arg); arg = NEXT(arg);
                   1018:        ox_send_local_ring(s,CO);
                   1019:        for ( n = 0, t = arg; t; t = NEXT(t), n++ );
                   1020:        w = (pointer *)ALLOCA(n*sizeof(pointer));
                   1021:        for ( i = 0, t = arg; i < n; t = NEXT(t), i++ )
                   1022:                w[i] = BDY(t);
                   1023:        for ( i = n-1; i >= 0; i-- )
                   1024:                ox_send_local_data(s,w[i]);
                   1025:        MKUSINT(ui,n);
                   1026:        ox_send_data(s,ui);
                   1027:        ox_send_data(s,f);
                   1028:        ox_send_cmd(s,SM_executeFunction);
                   1029:        *rp = 0;
                   1030: }
                   1031:
                   1032: void Pox_cmo_rpc(arg,rp)
                   1033: NODE arg;
                   1034: Obj *rp;
                   1035: {
                   1036:        int s,i,n;
                   1037:        STRING f;
                   1038:        USINT ui;
                   1039:        NODE t;
                   1040:        pointer *w;
                   1041:        int index = QTOS((Q)ARG0(arg));
                   1042:
                   1043:        valid_mctab_index(index);
                   1044:        s = m_c_tab[index].c; arg = NEXT(arg);
                   1045:        f = (STRING)BDY(arg); arg = NEXT(arg);
                   1046:        for ( n = 0, t = arg; t; t = NEXT(t), n++ );
                   1047:        w = (pointer *)ALLOCA(n*sizeof(pointer));
                   1048:        for ( i = 0, t = arg; i < n; t = NEXT(t), i++ )
                   1049:                w[i] = BDY(t);
                   1050:        for ( i = n-1; i >= 0; i-- )
                   1051:                ox_send_data(s,w[i]);
                   1052:        MKUSINT(ui,n);
                   1053:        ox_send_data(s,ui);
                   1054:        ox_send_data(s,f);
                   1055:        ox_send_cmd(s,SM_executeFunction);
                   1056:        *rp = 0;
                   1057: }
                   1058:
                   1059: void Pox_reset(arg,rp)
                   1060: NODE arg;
                   1061: Q *rp;
                   1062: {
                   1063:        USINT t;
                   1064:        int s,id,c,m;
                   1065:        Obj obj;
                   1066:        int index = QTOS((Q)ARG0(arg));
                   1067:
                   1068:        valid_mctab_index(index);
                   1069:        m = m_c_tab[index].m;
                   1070:        c = m_c_tab[index].c;
                   1071:        if ( m >= 0 ) {
                   1072:                if ( argc(arg) == 1 ) {
                   1073:                        ox_send_cmd(m,SM_control_reset_connection);
                   1074:                        ox_flush_stream_force(m);
                   1075:                        ox_recv(m,&id,&t);
                   1076:                }
                   1077:                *rp = ONE;
                   1078: #if defined(VISUAL)
                   1079:                Sleep(100);
                   1080:                ox_send_cmd(c,SM_nop);
                   1081:                ox_flush_stream_force(c);
                   1082: #endif
                   1083:                while ( 1 ) {
                   1084:                        ox_recv(c,&id,&obj);
                   1085:                        if ( id == OX_SYNC_BALL )
                   1086:                                break;
                   1087:                }
                   1088:                ox_send_sync(c);
1.5       noro     1089:        } else
                   1090:                *rp = 0;
                   1091: }
                   1092:
                   1093: void Pox_intr(arg,rp)
                   1094: NODE arg;
                   1095: Q *rp;
                   1096: {
                   1097:        int m;
                   1098:        Obj obj;
                   1099:        int index = QTOS((Q)ARG0(arg));
                   1100:
                   1101:        valid_mctab_index(index);
                   1102:        m = m_c_tab[index].m;
                   1103:        if ( m >= 0 ) {
                   1104:                if ( argc(arg) == 1 ) {
                   1105:                        ox_send_cmd(m,SM_control_intr);
                   1106:                        ox_flush_stream_force(m);
                   1107:                }
                   1108:                *rp = ONE;
1.1       noro     1109:        } else
                   1110:                *rp = 0;
                   1111: }
                   1112:
                   1113: void Pox_sync(arg,rp)
                   1114: NODE arg;
                   1115: Q *rp;
                   1116: {
                   1117:        int c;
                   1118:        int index = QTOS((Q)ARG0(arg));
                   1119:
                   1120:        valid_mctab_index(index);
                   1121:        c = m_c_tab[index].c;
                   1122:        ox_send_sync(c);
                   1123:        *rp = 0;
                   1124: }
                   1125:
                   1126: void Pox_shutdown(arg,rp)
                   1127: NODE arg;
                   1128: Q *rp;
                   1129: {
                   1130:        int s;
                   1131:        int index = QTOS((Q)ARG0(arg));
                   1132:        int status;
                   1133:
                   1134:        valid_mctab_index(index);
                   1135:        s = m_c_tab[index].m;
                   1136:        ox_send_cmd(s,SM_shutdown);
                   1137:        free_iofp(s);
                   1138: #if !MPI && !defined(VISUAL)
                   1139:        if ( m_c_tab[index].af_unix )
                   1140:                wait(&status);
                   1141: #endif
1.8       noro     1142:        m_c_tab[index].m = -1; m_c_tab[index].c = -1;
1.1       noro     1143:        m_c_tab[index].af_unix = 0;
                   1144:        *rp = 0;
                   1145: }
                   1146:
                   1147: void Pox_push_cmd(arg,rp)
                   1148: NODE arg;
                   1149: Q *rp;
                   1150: {
1.7       noro     1151:        int ui;
1.1       noro     1152:        int index = QTOS((Q)ARG0(arg));
                   1153:
                   1154:        valid_mctab_index(index);
1.7       noro     1155:        ui = QTOS((Q)ARG1(arg));
1.1       noro     1156:        ox_send_cmd(m_c_tab[index].c,ui);
                   1157:        *rp = 0;
                   1158: }
                   1159: #endif

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