| 1 |
/*=========================================================================== |
| 2 |
Copyright (C) 1995-2009 European Southern Observatory (ESO) |
| 3 |
|
| 4 |
This program is free software; you can redistribute it and/or |
| 5 |
modify it under the terms of the GNU General Public License as |
| 6 |
published by the Free Software Foundation; either version 2 of |
| 7 |
the License, or (at your option) any later version. |
| 8 |
|
| 9 |
This program is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
GNU General Public License for more details. |
| 13 |
|
| 14 |
You should have received a copy of the GNU General Public |
| 15 |
License along with this program; if not, write to the Free |
| 16 |
Software Foundation, Inc., 675 Massachusetts Ave, Cambridge, |
| 17 |
MA 02139, USA. |
| 18 |
|
| 19 |
Correspondence concerning ESO-MIDAS should be addressed as follows: |
| 20 |
Internet e-mail: [email protected] |
| 21 |
Postal address: European Southern Observatory |
| 22 |
Data Management Division |
| 23 |
Karl-Schwarzschild-Strasse 2 |
| 24 |
D 85748 Garching bei Muenchen |
| 25 |
GERMANY |
| 26 |
===========================================================================*/ |
| 27 |
|
| 28 |
/*+++++++++++++++++++++++++++++ SC interface module SCKA ++++++++++++++++++++ |
| 29 |
.LANGUAGE C |
| 30 |
.IDENTIFICATION Module SCKA |
| 31 |
.AUTHOR K. Banse ESO - Garching |
| 32 |
.KEYWORDS standard interfaces, keyword data base |
| 33 |
.ENVIRONMENT VMS and UNIX |
| 34 |
.COMMENTS |
| 35 |
holds SCKFND, SCKINF, SCKPRx routines |
| 36 |
|
| 37 |
.VERSION [1.00] 920210: copy all the relevant stuff of SCK |
| 38 |
|
| 39 |
090318 last modif |
| 40 |
-----------------------------------------------------------------------------*/ |
| 41 |
|
| 42 |
#include <fileexts.h> |
| 43 |
|
| 44 |
|
| 45 |
/* |
| 46 |
|
| 47 |
*/ |
| 48 |
|
| 49 |
int SCKFND(key,type,noelem,bytelem) |
| 50 |
|
| 51 |
/*++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 52 |
.PURPOSE |
| 53 |
provide info about keyword 'key' |
| 54 |
.ALGORITHM |
| 55 |
use MID_FNDKEY to find key + related info |
| 56 |
.RETURNS |
| 57 |
always status = 0 (ok) |
| 58 |
--------------------------------------------------*/ |
| 59 |
|
| 60 |
char *key /* IN: keyword name */; |
| 61 |
char *type /* OUT: type of key - I, R, C, D or ' ' */; |
| 62 |
int *noelem /* OUT: no. of elements */; |
| 63 |
int *bytelem /* OUT: no. of bytes per element */; |
| 64 |
|
| 65 |
{ |
| 66 |
int kunit; |
| 67 |
|
| 68 |
|
| 69 |
*type = ' '; /* find keyword */ |
| 70 |
(void) MID_FNDKEY(key,type,bytelem,noelem,&kunit); |
| 71 |
|
| 72 |
return ERR_NORMAL; /* ignore status - always return ERR_NORMAL */ |
| 73 |
} |
| 74 |
|
| 75 |
/* |
| 76 |
|
| 77 |
*/ |
| 78 |
|
| 79 |
int SCKINF(npos,fno,buf,lbuf,numbuf) |
| 80 |
|
| 81 |
/*++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 82 |
.PURPOSE |
| 83 |
provide info about keyword at position 'npos' |
| 84 |
.ALGORITHM |
| 85 |
go through the keywords directory and provide the desired info |
| 86 |
.RETURNS |
| 87 |
return status ( 0 = ok ) |
| 88 |
--------------------------------------------------*/ |
| 89 |
|
| 90 |
int npos /* IN : position of keyword */; |
| 91 |
int fno /* IN :specifies desired info, |
| 92 |
1 = NAME, 2 = TYPE, 3 = SIZE */; |
| 93 |
char *buf /* OUT : buffer for NAME + TYPE info */; |
| 94 |
int lbuf /* IN : max. length of buffer above */; |
| 95 |
int *numbuf /* OUT: buffer for SIZE info */; |
| 96 |
|
| 97 |
{ |
| 98 |
register int nr; |
| 99 |
int nn, found; |
| 100 |
short int bytty; |
| 101 |
static int old_pos = -1; |
| 102 |
|
| 103 |
struct KEY_STRUCT *keypntr; |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
if ( (fno < 1) || (fno > 4) || (npos < 0) ) |
| 109 |
{ /* wrong argument `fno' or `npos' */ |
| 110 |
old_pos = -1; /* force new beginning... */ |
| 111 |
MID_E1(8,"...",ERR_INPINV,1); |
| 112 |
return ERR_INPINV; |
| 113 |
} |
| 114 |
|
| 115 |
found = -1; |
| 116 |
|
| 117 |
|
| 118 |
/* if different keyword number (position) we have to search again */ |
| 119 |
|
| 120 |
if (npos != old_pos) |
| 121 |
{ |
| 122 |
old_pos = npos; |
| 123 |
nn = -1; |
| 124 |
|
| 125 |
|
| 126 |
/* first global, then local keys */ |
| 127 |
|
| 128 |
keypntr = KEYALL.KEYNAMES; |
| 129 |
for (nr=0; nr<=KEYALL.GLOBNO; nr++,keypntr++) |
| 130 |
{ |
| 131 |
if (likely(keypntr->IDENT[0] != '/')) |
| 132 |
{ |
| 133 |
nn ++; |
| 134 |
if (nn == npos) |
| 135 |
{ |
| 136 |
found = nr; |
| 137 |
goto do_it; |
| 138 |
} |
| 139 |
} |
| 140 |
} |
| 141 |
|
| 142 |
keypntr = KEYALL.KEYNAMES + KEYALL.GLOBENT; |
| 143 |
for (nr=KEYALL.GLOBENT; nr<KEYALL.LOCNO; nr++,keypntr++) |
| 144 |
{ |
| 145 |
if (keypntr->IDENT[0] != '/') |
| 146 |
{ |
| 147 |
nn ++; |
| 148 |
if (nn == npos) |
| 149 |
{ |
| 150 |
found = nr; |
| 151 |
goto do_it; |
| 152 |
} |
| 153 |
} |
| 154 |
} |
| 155 |
|
| 156 |
/* nothing found at npos */ |
| 157 |
|
| 158 |
memset((void *)buf,32,(size_t)lbuf); |
| 159 |
*numbuf = 0; |
| 160 |
old_pos = -1; /* => new search next time */ |
| 161 |
return (ERR_NORMAL); |
| 162 |
} |
| 163 |
|
| 164 |
do_it: |
| 165 |
keypntr = KEYALL.KEYNAMES + found; |
| 166 |
|
| 167 |
if (fno == 1) |
| 168 |
{ |
| 169 |
if (lbuf > 15) /* keywords, max. length = 15 */ |
| 170 |
{ |
| 171 |
(void) strncpy(buf,keypntr->IDENT,(size_t)15); |
| 172 |
buf[15] = '\0'; |
| 173 |
} |
| 174 |
else |
| 175 |
(void) strncpy(buf,keypntr->IDENT,(size_t)lbuf); |
| 176 |
if (lbuf > KEY_NAMELEN) buf[KEY_NAMELEN] = '\0'; |
| 177 |
} |
| 178 |
else if (fno == 2) |
| 179 |
{ |
| 180 |
bytty = keypntr->BYTELEM; |
| 181 |
MID_TYPINFO(keypntr->IDENT[15],bytty,buf,lbuf); |
| 182 |
} |
| 183 |
else |
| 184 |
*numbuf = keypntr->NOELEM; |
| 185 |
|
| 186 |
return ERR_NORMAL; |
| 187 |
|
| 188 |
} |
| 189 |
|
| 190 |
/* |
| 191 |
|
| 192 |
*/ |
| 193 |
|
| 194 |
int SCKPRC(prompt,key,noelm,felem,maxvals,actvals,values,unit,null) |
| 195 |
|
| 196 |
/*++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 197 |
.PURPOSE |
| 198 |
display prompt string and read keyword data from terminal |
| 199 |
.ALGORITHM |
| 200 |
use lower level routines MID_CPROMPT |
| 201 |
.RETURNS |
| 202 |
return status ( 0 = ok ) |
| 203 |
--------------------------------------------------*/ |
| 204 |
|
| 205 |
char *prompt /* IN : prompt string (null terminated) */; |
| 206 |
char *key /* IN : name of keyword */; |
| 207 |
int noelm /* IN : for character array, CHAR*noelm */; |
| 208 |
int felem /* IN : 1st data item to be read */; |
| 209 |
int maxvals /* IN : no. of elements to get */; |
| 210 |
int *actvals /* OUT: actual no. of elements returned */; |
| 211 |
char *values /* OUT: buffer for data values */; |
| 212 |
int *unit /* OUT: address of unit-pointer */; |
| 213 |
int *null /* OUT: no. of null values in keyword */; |
| 214 |
|
| 215 |
{ |
| 216 |
int status, e_c; |
| 217 |
|
| 218 |
|
| 219 |
*actvals = maxvals; |
| 220 |
status = MID_CPROMPT(prompt,actvals,values,null); |
| 221 |
|
| 222 |
if (status == ERR_NODATA) |
| 223 |
{ |
| 224 |
*actvals = 0; /* signal, if nothing came in */ |
| 225 |
*values = ' '; |
| 226 |
return status; |
| 227 |
} |
| 228 |
|
| 229 |
if (status == ERR_NORMAL) |
| 230 |
{ /* store the stuff into the relevant keyword */ |
| 231 |
e_c = ERRO_CONT; |
| 232 |
ERRO_CONT = 1; /* we don't want to stop inside SCKWRC */ |
| 233 |
status = SCKWRC(key,noelm,values,felem,*actvals,unit); |
| 234 |
ERRO_CONT = e_c; |
| 235 |
} |
| 236 |
|
| 237 |
if (status != ERR_NORMAL) MID_E1(6,key,status,1); |
| 238 |
return status; |
| 239 |
} |
| 240 |
/* |
| 241 |
|
| 242 |
*/ |
| 243 |
|
| 244 |
int SCKPRD(prompt,key,felem,maxvals,actvals,values,unit,null) |
| 245 |
/*++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 246 |
.PURPOSE |
| 247 |
display prompt string and read keyword data from terminal |
| 248 |
.ALGORITHM |
| 249 |
use lower level routines MID_DPROMPT |
| 250 |
.RETURNS |
| 251 |
return status ( 0 = ok ) |
| 252 |
--------------------------------------------------*/ |
| 253 |
|
| 254 |
char *prompt /* IN : prompt string (null terminated) */; |
| 255 |
char *key /* IN : name of keyword */; |
| 256 |
int felem /* IN : 1st data item to be read */; |
| 257 |
int maxvals /* IN : no. of elements to get */; |
| 258 |
int *actvals /* OUT: actual no. of elements returned */; |
| 259 |
double *values /* OUT: buffer for data values */; |
| 260 |
int *unit /* OUT: address of unit-pointer */; |
| 261 |
int *null /* OUT: no. of null values in keyword */; |
| 262 |
|
| 263 |
{ |
| 264 |
int status, e_c; |
| 265 |
|
| 266 |
|
| 267 |
*actvals = maxvals; |
| 268 |
status = MID_DPROMPT(prompt,actvals,values,null); |
| 269 |
|
| 270 |
if (status == ERR_NODATA) |
| 271 |
{ |
| 272 |
*actvals = 0; /* signal, if nothing came in */ |
| 273 |
*values = 0.0; |
| 274 |
return status; |
| 275 |
} |
| 276 |
|
| 277 |
if (status == ERR_NORMAL) |
| 278 |
{ /* store the stuff into the relevant keyword */ |
| 279 |
e_c = ERRO_CONT; |
| 280 |
ERRO_CONT = 1; /* we don't want to stop inside SCKWRD */ |
| 281 |
status = SCKWRD(key,values,felem,*actvals,unit); |
| 282 |
ERRO_CONT = e_c; |
| 283 |
} |
| 284 |
|
| 285 |
if (status != ERR_NORMAL) MID_E1(6,key,status,1); |
| 286 |
return status; |
| 287 |
} |
| 288 |
/* |
| 289 |
|
| 290 |
*/ |
| 291 |
|
| 292 |
int SCKPRI(prompt,key,felem,maxvals,actvals,values,unit,null) |
| 293 |
/*++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 294 |
.PURPOSE |
| 295 |
display prompt string and read keyword data from terminal |
| 296 |
.ALGORITHM |
| 297 |
use lower level routines MID_IPROMPT |
| 298 |
.RETURNS |
| 299 |
return status ( 0 = ok ) |
| 300 |
--------------------------------------------------*/ |
| 301 |
|
| 302 |
char *prompt /* IN : prompt string (null terminated) */; |
| 303 |
char *key /* IN : name of keyword */; |
| 304 |
int felem /* IN : 1st data item to be read */; |
| 305 |
int maxvals /* IN : no. of elements to get */; |
| 306 |
int *actvals /* OUT: actual no. of elements returned */; |
| 307 |
int *values /* OUT: buffer for data values */; |
| 308 |
int *unit /* OUT: address of unit-pointer */; |
| 309 |
int *null /* OUT: no. of null values in keyword */; |
| 310 |
|
| 311 |
{ |
| 312 |
int status, e_c; |
| 313 |
|
| 314 |
|
| 315 |
*actvals = maxvals; |
| 316 |
status = MID_IPROMPT(prompt,actvals,values,null); |
| 317 |
|
| 318 |
if (status == ERR_NODATA) |
| 319 |
{ |
| 320 |
*actvals = 0; /* signal, if nothing came in */ |
| 321 |
*values = 0; |
| 322 |
return status; |
| 323 |
} |
| 324 |
|
| 325 |
if (status == ERR_NORMAL) |
| 326 |
{ /* store the stuff into the relevant keyword */ |
| 327 |
e_c = ERRO_CONT; |
| 328 |
ERRO_CONT = 1; /* we don't want to stop inside SCKWRI */ |
| 329 |
status = SCKWRI(key,values,felem,*actvals,unit); |
| 330 |
ERRO_CONT = e_c; |
| 331 |
} |
| 332 |
|
| 333 |
if (status != ERR_NORMAL) MID_E1(6,key,status,1); |
| 334 |
return status; |
| 335 |
} |
| 336 |
/* |
| 337 |
|
| 338 |
*/ |
| 339 |
|
| 340 |
int SCKPRR(prompt,key,felem,maxvals,actvals,values,unit,null) |
| 341 |
/*++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 342 |
.PURPOSE |
| 343 |
display prompt string and read keyword data from terminal |
| 344 |
.ALGORITHM |
| 345 |
use lower level routines MID_RPROMPT |
| 346 |
.RETURNS |
| 347 |
return status ( 0 = ok ) |
| 348 |
--------------------------------------------------*/ |
| 349 |
|
| 350 |
char *prompt /* IN : prompt string (null terminated) */; |
| 351 |
char *key /* IN : name of keyword */; |
| 352 |
int felem /* IN : 1st data item to be read */; |
| 353 |
int maxvals /* IN : no. of elements to get */; |
| 354 |
int *actvals /* OUT: actual no. of elements returned */; |
| 355 |
float *values /* OUT: buffer for data values */; |
| 356 |
int *unit /* OUT: address of unit-pointer */; |
| 357 |
int *null /* OUT: no. of null values in keyword */; |
| 358 |
|
| 359 |
{ |
| 360 |
int status, e_c; |
| 361 |
|
| 362 |
|
| 363 |
*actvals = maxvals; |
| 364 |
status = MID_RPROMPT(prompt,actvals,values,null); |
| 365 |
|
| 366 |
if (status == ERR_NODATA) |
| 367 |
{ |
| 368 |
*actvals = 0; /* signal, if nothing came in */ |
| 369 |
*values = 0.0; |
| 370 |
return status; |
| 371 |
} |
| 372 |
|
| 373 |
if (status == ERR_NORMAL) |
| 374 |
{ /* store the stuff into the relevant keyword */ |
| 375 |
e_c = ERRO_CONT; |
| 376 |
ERRO_CONT = 1; /* we don't want to stop inside SCKWRR */ |
| 377 |
status = SCKWRR(key,values,felem,*actvals,unit); |
| 378 |
ERRO_CONT = e_c; |
| 379 |
} |
| 380 |
|
| 381 |
if (status != ERR_NORMAL) MID_E1(6,key,status,1); |
| 382 |
return status; |
| 383 |
} |
| 384 |
/* |
| 385 |
|
| 386 |
*/ |
| 387 |
|
| 388 |
int SCKPRS(prompt,key,felem,maxvals,actvals,values,unit,null) |
| 389 |
/*++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 390 |
.PURPOSE |
| 391 |
display prompt string and read keyword data from terminal |
| 392 |
.ALGORITHM |
| 393 |
use lower level routines MID_SPROMPT |
| 394 |
.RETURNS |
| 395 |
return status ( 0 = ok ) |
| 396 |
--------------------------------------------------*/ |
| 397 |
|
| 398 |
char *prompt /* IN : prompt string (null terminated) */; |
| 399 |
char *key /* IN : name of keyword */; |
| 400 |
int felem /* IN : 1st data item to be read */; |
| 401 |
int maxvals /* IN : no. of elements to get */; |
| 402 |
int *actvals /* OUT: actual no. of elements returned */; |
| 403 |
size_t *values /* OUT: buffer for size_t values */; |
| 404 |
int *unit /* OUT: address of unit-pointer */; |
| 405 |
int *null /* OUT: no. of null values in keyword */; |
| 406 |
|
| 407 |
{ |
| 408 |
int status, e_c; |
| 409 |
|
| 410 |
|
| 411 |
*actvals = maxvals; |
| 412 |
status = MID_SPROMPT(prompt,actvals,values,null); |
| 413 |
|
| 414 |
if (status == ERR_NODATA) |
| 415 |
{ |
| 416 |
*actvals = 0; /* signal, if nothing came in */ |
| 417 |
*values = 0; |
| 418 |
return status; |
| 419 |
} |
| 420 |
|
| 421 |
if (status == ERR_NORMAL) |
| 422 |
{ /* store the stuff into the relevant keyword */ |
| 423 |
e_c = ERRO_CONT; |
| 424 |
ERRO_CONT = 1; /* we don't want to stop inside SCKWRD */ |
| 425 |
status = SCKWRS(key,values,felem,*actvals,unit); |
| 426 |
ERRO_CONT = e_c; |
| 427 |
} |
| 428 |
|
| 429 |
if (status != ERR_NORMAL) MID_E1(6,key,status,1); |
| 430 |
return status; |
| 431 |
} |
| 432 |
|
| 433 |
|