/* @(#)internal1.c 17.1.1.1 (ES0-DMD) 01/25/02 17:37:34 */ /*=========================================================================== 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 ===========================================================================*/ /* +++++++++++++++++++++++++ INTERNAL1.C ++++++++++++++++++++++++++++++++++ K. Banse version 3.30 850821 create + initialize file MID_PROC:internal.kod or display file MID_PROC:internal.cod The file MID_PROC:internal.cod (or .kod) is organized as follows: first 4 records (of 512 bytes) hold the procedure names of max. 12 chars (without the terminating '\0'), the end of this area is indicated via '&&' . Records 5+6 hold the array of start blocks and no. of bytes for each compiled procedure stored as two unsigned short int numbers, the end of this area is indicated via a start block of 0. The following records hold the translated code for each procedure, each beginning at a record. The end of the written records is indicated by a record beginning with 20 blanks. 010424 last modif ---------------------------------------------------------------------------*/ #include #include #include #include #define BIT_0 0x1 #define FILE_MASK 0 /* CG. 920529: Set to 0. osfcreate() makes default */ #define PROC_MXLEN 12 /* */ main(argc,argv) int argc; char *argv[]; { static int block_lim=400; int nvb, iav, iostat; int chanl, indx; int total, ll, m, n, nn, stat; int fpi, fpo; unsigned short int *rec_nos; register int nr, mr; char record[3072], action[22]; char cbuf[512], line[80], file[200]; char procs[2048], procedure[PROC_MXLEN]; char *cptr, blank_str[20]; CGN_FILL(blank_str,' ',20); if (argc > 1) { if (*argv[1] == '?') { (void)printf("provide option on command line:\n"); (void) printf("INIT for init,\n"); (void)printf("Rxy for read (x=C or K, y= A or ' ')\n"); goto end_of_it; } else (void) strcpy(action,argv[1]); } else (void) strcpy(action,"rc "); CGN_UPSTR(action); (void) OSY_TRNLOG("MID_PROC",file,200,&m); #if vms if (file[m-1] != FSY_DISKEND) { if (file[m-1] != FSY_DIREND) file[m++] = FSY_DIREND; } #else if (file[m-1] != FSY_DIREND) file[m++] = FSY_DIREND; #endif (void) strcpy(&file[m],"internal.cod"); rec_nos = (unsigned short int *) &record[2048]; /* here begin the rec_nos */ if (action[0] == 'I') goto sect_5000; /* default action is: display file internal.cod or internal.kod */ m = (int) strlen(file); if (action[1] == 'K') file[m-3] = 'k'; FSY_OPNFIL(file,m,&chanl,&iostat); if ( !(iostat & BIT_0) ) goto sect_9100; /* first show procedure_names */ stat = OSY_RVB(chanl,record,3072,1); /* get first 6 records */ if (stat != 0) goto sect_9200; indx = 0; nn = 1; total = 0; while(nn>0) /* i.e. forever */ { (void)printf("%72.72s\n",&record[indx]); /* 6 names per line */ for (m=indx; m 0) { char reco[8000]; for (nr=0; nr 7999) nn = 7999; stat = OSY_RVB(chanl,reco,nn,n); if (stat != 0) goto sect_9200; indx = 0; for (mr=0; mr 0) { (void) printf("%s\n",&reco[indx]); indx += ll; } indx ++; } else if (reco[mr] == '\0') reco[mr] = ' '; } } } goto end_of_it; /* create new file internal.kod (!) */ sect_5000: m = (int) strlen(file); file[m-3] = 'k'; iav = m; #if vms FSY_CREBDF(file,m,block_lim,&nvb,&iostat); #else n = block_lim * BLOCK_SIZE; nn = osfcreate(file, n, FILE_MASK); if (nn != -1) { nvb = nn / BLOCK_SIZE; iostat = 1; } else iostat = 0; #endif if ( !(iostat & BIT_0) ) goto sect_9100; FSY_OPNFIL(file,iav,&chanl,&iostat); if ( !(iostat & BIT_0) ) goto sect_9100; /* write "clean" header records */ CGN_FILL(record,' ',2048); record[0] = '&'; record[1] = '&'; for (nr=0; nr<512; nr++) rec_nos[nr] = 0; rec_nos[0] = 7; /* point to first free record */ stat = OSY_WVB(chanl,record,3072,1); if (stat != 0) goto sect_9300; /* now clear all the remaining records */ record[0] = ' '; record[1] = ' '; for (nr=7; nr