~ubuntu-branches/debian/jessie/eso-midas/jessie

« back to all changes in this revision

Viewing changes to libsrc/agl/ag_rval.c

  • Committer: Package Import Robot
  • Author(s): Ole Streicher
  • Date: 2014-04-22 14:44:58 UTC
  • Revision ID: package-import@ubuntu.com-20140422144458-okiwi1assxkkiz39
Tags: upstream-13.09pl1.2+dfsg
ImportĀ upstreamĀ versionĀ 13.09pl1.2+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* @(#)ag_rval.c        19.1 (ES0-DMD) 02/25/03 13:53:01 */
 
2
/*===========================================================================
 
3
  Copyright (C) 1995 European Southern Observatory (ESO)
 
4
 
 
5
  This program is free software; you can redistribute it and/or 
 
6
  modify it under the terms of the GNU General Public License as 
 
7
  published by the Free Software Foundation; either version 2 of 
 
8
  the License, or (at your option) any later version.
 
9
 
 
10
  This program is distributed in the hope that it will be useful,
 
11
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
  GNU General Public License for more details.
 
14
 
 
15
  You should have received a copy of the GNU General Public 
 
16
  License along with this program; if not, write to the Free 
 
17
  Software Foundation, Inc., 675 Massachusetss Ave, Cambridge, 
 
18
  MA 02139, USA.
 
19
 
 
20
  Corresponding concerning ESO-MIDAS should be addressed as follows:
 
21
        Internet e-mail: midas@eso.org
 
22
        Postal address: European Southern Observatory
 
23
                        Data Management Division 
 
24
                        Karl-Schwarzschild-Strasse 2
 
25
                        D 85748 Garching bei Muenchen 
 
26
                        GERMANY
 
27
===========================================================================*/
 
28
 
 
29
/* @(#)ag_rval.c        19.1  (OAA-ASTRONET) 02/25/03 13:53:01   */
 
30
/*
 
31
 * HEADER : ag_rval.c      - Vers 3.6.000  - Oct 1991 -  L. Fini, OAA
 
32
 *
 
33
 *
 
34
 *                           C INTERFACE MODULE
 
35
 */
 
36
 
 
37
 
 
38
#include <aglenvr.h>
 
39
#include <aglstat.h>
 
40
 
 
41
 
 
42
/*****************************************************************************/
 
43
/*CC                           AG_RVAL (C callable)                          */
 
44
 
 
45
/* AG_RVAL    Real conversion                                                */
 
46
 
 
47
 
 
48
/* Converts (decimal float) values after the = sign from a string            */
 
49
 
 
50
/* String syntax is as follows:                                              */
 
51
 
 
52
/*     "xxxxx=<value>[,<value>,...,<value>]"                                 */
 
53
 
 
54
/* where xxxx is any string and value must have the syntax required by the   */
 
55
/* atof standard library service. Multiple values are separated by commas.   */
 
56
 
 
57
/* e.g.:   AXES=1.0,4.5;                                                     */
 
58
 
 
59
/* Note: this routine is callable through the C interface only               */
 
60
 
 
61
 
 
62
int AG_RVAL (chstrg,nvals,vals) 
 
63
                              /* Returns number of values converted          */
 
64
 
 
65
 char *chstrg;                /* Input string                                */
 
66
 int  nvals;                  /* number of values to be converted            */
 
67
 float vals[];                /* Output array (at least nvals long)          */
 
68
                                                                         /*--*/
 
69
{
 
70
char *pntr;
 
71
int i,nv=0;
 
72
 
 
73
pntr=chstrg;
 
74
while(((*pntr)!='=')&&((*pntr)!='\0')) 
 
75
        pntr++;                                 /* scan till the '='     */
 
76
 
 
77
for(i=0; i<nvals; i++) {
 
78
        if(*pntr == '\0') 
 
79
                vals[i]=0.0;
 
80
        else {
 
81
                pntr++; 
 
82
                vals[i]=atof(pntr);
 
83
                while(((*pntr)!=',')&&((*pntr)!='\0')) 
 
84
                        pntr++;                 /* scan until ','     */
 
85
                nv++;                           /* count converted values   */
 
86
}
 
87
}
 
88
return(nv);
 
89
}