/* @(#)consubsa.c 17.1.1.1 (ESO-DMD) 01/25/02 17:37:01 */ /*=========================================================================== Copyright (C) 1995 European Southern Observatory (ESO) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. Correspondence concerning ESO-MIDAS should be addressed as follows: Internet e-mail: midas@eso.org Postal address: European Southern Observatory Data Management Division Karl-Schwarzschild-Strasse 2 D 85748 Garching bei Muenchen GERMANY ===========================================================================*/ /*+++++++++++++++++++++++ module consubs +++++++++++++++++++++++ .LANGUAGE C .IDENTIFICATION Module consubs .AUTHOR K. Banse ESO - Garching .KEYWORDS connection, sockets .COMMENTS holds inxcon, Mrunning .ENVIRONMENT VMS and UNIX .VERSION [1.00] 940426: pulled out from prepb.c 990830 ------------------------------------------------------------------------*/ #include #include #include #include #define READ 0 /* */ void inxcon(munit,direc) /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ .PURPOSE build up file names + clean up structures (partly) .ALGORITHM use translation of MID_WORK stored in XCONNECT.DIREC .RETURNS success code = 0, = 1 for problems +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ char *munit; /* IN: Midas unit of sender */ char *direc; /* IN: directory for file transfer */ { register int nr; int offs; XCONNECT.MYPID = oshpid(); XCONNECT.MYUNIT[0] = munit[0]; XCONNECT.MYUNIT[1] = munit[1]; if (*direc != '\0') offs = CGN_COPY(XCONNECT.SBOX,direc); /* get Midas startup directory */ else offs = 0; (void)strcpy(&XCONNECT.SBOX[offs],"FORGR .SBOX"); /* get send_box */ (void)strcpy(XCONNECT.RBOX,direc); (void)strcat(XCONNECT.RBOX,"FORGR .RBOX"); /* get receive_box */ XCONNECT.OFFS = offs + 5; /* point to sender unit */ XCONNECT.OFFR = offs + 7; /* point to receiver unit */ for (nr=0; nr 0) { retval = -1; loop = maxtime*2; while (loop > 0) { fid = osaopen(cbuf,READ); if (fid > -1) { n = osaread(fid,cbuf,20); osaclose(fid); if (n < 20) retval = 0; /* running, but not ready yet */ else return 1; } ospuwait(500000); /* wait 500 msecs */ loop --; } return retval; /* no Midas running */ } else { fid = osaopen(cbuf,READ); if (fid < 0) return -1; else { n = osaread(fid,cbuf,20); if (n < 20) retval = 0; /* running, but not ready yet */ else retval = 1; osaclose(fid); return retval; } } }