/* @(#)scs.c 17.1.1.1 (ESO-DMD) 01/25/02 17:36:28 */ /*=========================================================================== 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 ===========================================================================*/ /*+++++++++++++++++++++++++++++ SC interface module SCS +++++++++++++++++++++ .LANGUAGE C .IDENTIFICATION Module SCS .AUTHOR K. Banse ESO - Garching 870721 .KEYWORDS standard interfaces. .ENVIRONMENT theoretically environment independant. .COMMENTS all SC_interfaces related to System + parameter: SCSPRO, SCSEPI, SCPSET 010917 last modif -----------------------------------------------------------------------------*/ #include #include #include #include #include static int NoInt = 1, CntrlC = 0, only = 0; /* ARGSUSED */ void interc(s) int s; { if (NoInt == 1) CntrlC = 1; /* just set the CntrlC flag */ else MID_ABORT(999,100); /* exit from the application */ } /* */ void tsubr() { struct termstatus tstat; int status, tcols, tlines; if (KIWORDS[OFF_MODE+2] == 1) /* VMS Batch: fixed values */ { tcols = 80; tlines = 24; } else { tcols = 80; tlines = 24; /* default to 24 lines window */ status = ostinfo(&tstat); /* get no. of columns in window/terminal */ if (status == 0) { if (tstat.columns > 8) { tcols = tstat.columns; if (tcols > 127) tcols = 127; /* respect size of record... */ } if (tstat.lines > 2) tlines = tstat.lines; } } KIWORDS[OFF_LOG+9] = tcols; /* LOG(10,11) hold that */ KIWORDS[OFF_LOG+10] = tlines; } /* */ int myINIT(from) int from; /* = 0, from monitor = 1, from application */ { register int nr; DSC_PNTR = &DSCDIR_ENTRY; ZDSC_PNTR = &ZDSCDIR_ENTRY; YDSC_PNTR = &YDSCDIR_ENTRY; MID_INITER(); /* init error business */ /* create + clear FCT structure */ MID_FCTIN(-1); /* indicate 1. time */ /* FCT_PARM[0,1] holds values for F_XD_PARM [0] = initial no. of descriptors [1] = initial total space needed for descriptors in bytes defaulted to 100 initial descriptors and 6000 bytes descr. space => total 3 LDBs (1 for directory + 2 for descrs) [2] = delete flag for extracted subframes, 1- delete, 0 - not [3] = FITS header flag 0- use all FITS keywords, 1- ignore ESO hierarchical keywords */ FCT.PARM[0] = 100; FCT.PARM[1] = 6000; FCT.PARM[2] = 1; FCT.PARM[3] = 0; /* reset */ for (nr=0; nr 0) { /* from key MONITPAR(12,13) */ FCT.PARM[0] = KIWORDS[OFF_MONPAR+11]; /* get initial no. of descr.s */ FCT.PARM[1] = KIWORDS[OFF_MONPAR+12]; /* and initial descr_data bytes */ } if (KIWORDS[OFF_AUX+9] == 123) DSC_FLAG = 'Z'; /* use previous descr. format */ } if (KIWORDS[OFF_AUX+15] == 1) /* ESO-DESC_ignore_flag set? */ { i = 1; /* Yes. Ignore ESO.xyz keywords */ (void) SCPSET(F_FITS_PARM,&i); /* in FITS headers */ } return status; } /* */ int SCSEPI() /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ .PURPOSE write keywords back + clean up everything .ALGORITHM if everything goes o.k. and we are running inside Midas, we also exit .RETURNS return status only if something went wrong or we are outside Midas!! -------------------------------------------------------------*/ { int mm, status; register int i; char cbuf[8]; struct FCT_STRUCT *fctpntr; only = 0; /* reset one_time flag */ /* if key LOG(1) = 2 we get the CPU time + log it */ if (KEYALL.ORIGIN != -1) { int fp; if (KIWORDS[OFF_LOG] == 2) { int itime; float r; char record[80]; status = OSY_TIMER('G',&itime); if (status != ERR_NORMAL) MID_E1(2,"SCFCLO",status,1); KIWORDS[OFF_AUX+1] = (int) itime; r = itime * 0.01 ; /* obtain seconds */ i = OFF_APPLIC + 2; mm = sprintf(record,"%.50s: CPU time = %g seconds\n", &KCWORDS[i],r); /* obtain program name */ (void) MID_LOG('G',record,mm); } fp = KIWORDS[OFF_OUTFLG+2]; if (fp > 0) { if (fp < 999) osaclose(fp); /* fp = 999 means "Nullo" output */ KIWORDS[OFF_OUTFLG+2] = -2; } } /* close all files still open + add to current catalog */ fctpntr = FCT.ENTRIES; for (i=0; iNAME[0] != ' ') { if (fctpntr->ACCESS == 'X') /* virtual memory only */ fctpntr->NAME[0] = ' '; else { if (fctpntr->CATALOG[0] == 'T') status = TCTCLO(i); else status = SCFCLO(i); } } fctpntr ++; } if (KEYALL.ORIGIN == -1) return 0; /* we are outside MIDAS */ KCWORDS[OFF_APPLIC] = 't'; /* indicate that normal termination */ KIWORDS[OFF_PRSTAT] = 0; NoInt = 1; /* disable exiting in CntrlC interrupt handler */ /* close logfile + write keywords back */ KIWORDS[OFF_LOG+8] = 0; /* clear print flag */ (void) MID_LOG('O',cbuf,2); /* length of cbuf not used */ cbuf[0] = ' '; status = MID_MOVKEY("O",cbuf); if (status != ERR_NORMAL) MID_E1(2,"...",status,1); ospexit(0); /* stop the child/subprocess */ return ERR_NORMAL; /* we don't get here, just for the compiler... */ } /* */ int SCPSET(para,pval) /*++++++++++++++++++++++++++++++++++++++++++++++++++ .PURPOSE set values for a parameter .ALGORITHM para is the parameter no. and pval[] the array of values for that parameter .RETURNS return status ( 0 = o.k ) --------------------------------------------------*/ int para; /* IN: parameter no. given as a symbol */ int *pval; /* IN: array with values (may be just one) */ { int i; switch (para) { case F_XD_PARM: /* specify initial LDB no. */ if (*pval<1) /* no. of inital descriptors */ return ERR_INPINV; i = *(pval+1); if (i<1) /* total descr. space in bytes */ return ERR_INPINV; FCT.PARM[0] = *pval; FCT.PARM[1] = i; return ERR_NORMAL; case F_DEL_PARM: /* delete (or not) extracted frames */ i = *pval; if (i != 1) i = 0; FCT.PARM[2] = i; /* 1 = YES - delete, 0 = NO */ return ERR_NORMAL; case F_FITS_PARM: /* handling of FITS headers */ FCT.PARM[3] = *pval; if (KEYALL.ORIGIN != -1) /* inside Midas check */ { /* against FITS_update flag */ if (KIWORDS[OFF_AUX+13] == 1) FCT.PARM[3] = 0; /* FITS files are updated! */ } /* printf ("FCT.PARM = %d, %d, %d, %d\n",FCT.PARM[0],FCT.PARM[1],FCT.PARM[2],FCT.PARM[3]); */ return ERR_NORMAL; default: return ERR_INPINV; } }