/* @(#)osyvmsb.c 17.1.1.1 (ESO-DMD) 01/25/02 17:36:25 */ /*=========================================================================== 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 010423 last update ===========================================================================*/ #include #include #include #include #include #define BIT_0 0x1 static int status, n, ii, mm; static short int iosb[4]; static char msg[260]; /* */ void OSY_MESSAGE(statsys,errmsg) /* ++++++++++++++++++++++++++++++++++++++++++++++++++ .IDENTIFICATION function OSY_MESSAGE C-version 1.00 870804 K. Banse ESO - Garching .KEYWORDS system messages .PURPOSE display system message for given status .ALGORITHM use system service SYS$GETMSG !!! this code is operating system dependant !!! .INPUT/OUTPUT use as OSY_MESSAGE(status,errmsg) input par: statsys: int status code errmsg: char * buffer for message (should be >= 80) -------------------------------------------------- */ int statsys; char *errmsg; { int msglen; static int rms_errcnt = 9; static int rms_erros[] = {0x1c0dc, 0x1c04a, 0x1c00a, 0x184c4, 0x184cc, 0x1828a, 0x18292, 0x18544, 0x1829a}; static char *rms_errmsg[] = {"Cannot close file.","Directory not found.", "File creation error.","Bad device (type).", "Error in directory name.","File is locked.", "File is not found.","Device full.", "Not matching file protection."}; char byte_array[4]; struct dsc$descriptor_s name_descr1; /* set up the VAX-11 descriptor structure */ name_descr1.dsc$b_class = DSC$K_CLASS_S; name_descr1.dsc$b_dtype = DSC$K_DTYPE_T; /* now execute the system service */ msglen = 0; ii = SYS$GETMSG(statsys,&msglen,&name_descr1,15,byte_array); if (ii & BIT_0) { (void) strncpy(errmsg,name_descr1.dsc$a_pointer,msglen); errmsg[msglen] = '\0'; } else { for (n=0; n= 'a') && (c <= 'z')) msg[n] = c + cdif; else msg[n] = c; } msg[n] = '\0'; /* set up the VAX-11 descriptor structure */ name_descr1.dsc$w_length = n; name_descr1.dsc$a_pointer = msg; name_descr1.dsc$b_class = DSC$K_CLASS_S; name_descr1.dsc$b_dtype = DSC$K_DTYPE_T; name_descr2.dsc$w_length = lvmsin; name_descr2.dsc$a_pointer = vmsname; name_descr2.dsc$b_class = DSC$K_CLASS_S; name_descr2.dsc$b_dtype = DSC$K_DTYPE_T; /* now execute the system service */ *lvmsout = 0; status = SYS$TRNLOG(&name_descr1,lvmsout,&name_descr2,&byt1,&byt2,0); if (*lvmsout > lvmsin) status = ERR_INPINV; else { vmsname[*lvmsout] = '\0'; status = ERR_NORMAL; } return status; } /* */ int OSY_WAKE() { status = SYS$WAKE(0,0); if (status & BIT_0) status = ERR_NORMAL; else { MID_ERROR("'OSY","OSY_WAKE",status,1); status = ERR_INPINV; } return status; } /* */ int OSY_WVB(iochan,pbuf,nobyt,vbn) /* C C++++++++++++++++++++++++++++++++++++++++++++++++++ C C.IDENTIFICATION C function OSY_WVB C-version 1.00 851124 C OSY_RVB 1.00 851124 C K. Banse ESO - Garching C !! Modifed 900626 for elementary i/o mode (FO) C source code on file OSYWVB.C C C.KEYWORDS C virtual blocks on disk C C.PURPOSE C write, read virtual blocks from disk C C.ALGORITHM C use system service QIOW C !!! this code is operating system dependant !!! C C.INPUT/OUTPUT C use as status = OSY_WVB(iochan,pbuf,nobyt,vbn) C OSY_RVB(iochan,pbuf,nobyt,vbn) C C input par: C IOCHAN: int I/O channel assigned to disk file C PBUF: char pointer pointer to buffer for disk transfer C NOBYT: int no. of bytes to be transferred C VBN: int starting virtual block for data transfer C C return value: C STATUS: int return status C C-------------------------------------------------- C */ int iochan,nobyt,vbn; char *pbuf; { int bytes; char block[512]; if (iochan < 0) /* memory frame */ { int idx; idx = -1 - iochan; /* recalculate VMEM index */ status = MID_VMIO(1,idx,pbuf,nobyt,vbn); if (status == ERR_NORMAL) return status; MID_ERROR("'OSY","OSY_WVB/QIOW",-1,0); return ERR_INPINV; } /* Write only multiple of 512 bytes ... */ status = SS$_NORMAL; bytes = nobyt & (~511); if (bytes) { status = SYS$QIOW(0,iochan,IO$_WRITEVBLK,iosb,0,0,pbuf,bytes,vbn,0,0,0); pbuf += bytes; } /* Write remaining part ... */ bytes = nobyt & (511); if ((status & BIT_0) && bytes) { int i; vbn += nobyt>>9; status = SYS$QIOW(0,iochan,IO$_READVBLK,iosb,0,0,block,512,vbn,0,0,0); for (i=0; i