File: numio.h

package info (click to toggle)
spd 1.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 3,572 kB
  • sloc: ansic: 25,938; fortran: 10,483; sh: 1,032; makefile: 75
file content (212 lines) | stat: -rw-r--r-- 8,887 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
/*
 *   Project: The SPD Image correction and azimuthal regrouping
 *                      http://forge.epn-campus.eu/projects/show/azimuthal
 *
 *   Copyright (C) 2005-2010 European Synchrotron Radiation Facility
 *                           Grenoble, France
 *
 *   Principal authors: P. Boesecke (boesecke@esrf.fr)
 *                      R. Wilcke (wilcke@esrf.fr)
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as published
 *   by the Free Software Foundation, either version 3 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 Lesser General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   and the GNU Lesser General Public License  along with this program.
 *   If not, see <http://www.gnu.org/licenses/>.
 */

/*+++***********************************************************************
NAME

    numio.h

SYNOPSIS

    #include "numio.h"

DESCRIPTION
    Header of the module "numio.c"

***********************************************************************---*/
#ifndef _numio_
# define _numio_

/***************************************************************************
* General Definitions                                                      *
***************************************************************************/

#ifndef PRIVATE
#  define PRIVATE static // used to declare variables of private type 
#endif

#ifndef PUBLIC
#  define PUBLIC         // used to declare variables of public type 
#endif

/****************************************************************************
*  Include                                                                  *
****************************************************************************/
# include <stdio.h>
# include <stdlib.h>
# include <stdarg.h>
# include <string.h>
# include <ctype.h>
# include <limits.h>
# include <errno.h>
# include <fcntl.h>
# include <math.h>
# include <float.h>

# include "gamma.h"

/******************************************************************************
* Constants                                                                   *
******************************************************************************/

# define NUM_PI        3.1415926535897932384626

/****************************************************************************
* Number Program List Structure Definition                                  *
****************************************************************************/
typedef struct Num_Var {
  char * Key;                            /* Pointer to variable key string */
  double Value;                                   /* Value of the variable */
  int    Used;                                           /* number of uses */
  struct Num_Var *Previous,*Next;                  /* prev./next variables */
} NumVar;
 
typedef struct Num_Accu {
  long   Number;                                     /* Accumulator number */
  double Value;                                /* Value of the accumulator */
  struct Num_Accu *Previous,*Next;              /* prev./next accumulators */
} NumAccu;
 
typedef struct Num_Instr {
  int    Command;                                               /* Command */
  int    Nargs;                           /* Number of required parameters */
  double Value;                                                   /* Value */
  double *Address;                                              /* Address */
  struct Num_Instr *Previous,*Next;                 /*prev./next instructs.*/
} NumInstr;
 
typedef struct Num_Prog {
  char * Name;                                   /* pointer to name string */
  NumVar * VariableList;                              /* list of variables */
  NumAccu * AccumulatorList;                       /* list of accumulators */
  NumAccu * CurrentAccumulator;         /* pointer to current accumulators */
  NumInstr * InstructionList;                      /* list of instructions */
  NumInstr * CompiledList;                /* list of compiled instructions */
  struct Num_Prog *Previous,*Next;            /* previous and next program */
} NumProg;

/***************************************************************************
* Functions                                                                *
***************************************************************************/

PUBLIC extern long       num_str2long ( const char *str, const char **tail, 
                                        int *perrval);

PUBLIC extern double   num_str2double ( const char *str, const char **tail, 
                                        int *perrval);

PUBLIC extern char      *num_long2str ( char buffer[], unsigned long buflen,
                                        long value, int * perrval );

PUBLIC extern char      *num_long2hex ( char buffer[], unsigned long buflen,
                                        long value, int * perrval );
 
PUBLIC extern char    *num_double2str ( char buffer[], unsigned long buflen,
                                        double value, const char * unit,
                                        int ndigits, int * perrval );

PUBLIC extern char     *num_double2hex( char buffer[], unsigned long buflen,
                                        double value, int ndigits, 
                                        int * perrval );
 
PUBLIC extern NumProg   *num_str2prog ( const char *name,
                                        const char *str, const char **tail, 
                                        int *perrval, int nvar, ... );

PUBLIC extern int          num_chkvar ( NumProg * program, int n, 
                                        int *perrval );

PUBLIC extern double      num_runprog ( NumProg * program, int *perrval,
                                        ... );

PUBLIC extern NumProg *num_searchprog ( const char *name, int *perrval );

PUBLIC extern int          num_rmprog ( NumProg * program, int *perrval );

PUBLIC extern char    *num_errval2str ( char buffer[], unsigned long buflen, 
                                        int errval );

PUBLIC extern int num_strncasecmp(const char *s1, const char *s2, size_t n);

PUBLIC extern void numio_debug ( int debug );

PUBLIC extern char *numio_version ( void );

PUBLIC extern long num_prog_variables             ( NumProg *program );

PUBLIC extern long num_prog_accumulators          ( NumProg *program );

PUBLIC extern long num_prog_instructions          ( NumProg *program, int mode);

PUBLIC extern size_t num_prog_variable_size       ( NumProg *program );

PUBLIC extern size_t num_prog_accumulator_size    ( NumProg *program );

PUBLIC extern size_t num_prog_instruction_size    ( NumProg *program, int mode);

PUBLIC extern size_t num_prog_size                ( NumProg * program );

PUBLIC extern size_t num_prog_size_all            ( void );

PUBLIC extern int num_prog_print_variable_list    ( FILE * out, 
                                                   NumProg *program,
                                                   int level, int verbose );

PUBLIC extern int num_prog_print_accumulator_list ( FILE * out, 
                                                   NumProg *program,
                                                   int level, int verbose );

PUBLIC extern int num_prog_print_instruction_list ( FILE * out, 
                                                   NumProg *program, int mode, 
                                                   int level, int verbose );

PUBLIC extern int num_prog_print_list             ( FILE * out, 
                                                    NumProg * program,
                                                    int level, int verbose );

/***************************************************************************
* Error Values                                                             *
***************************************************************************/

# define NumSuccess                0
# define NumMemoryAllocationError  1
# define NumScanError              2 
# define NumCommaExpected          3 
# define NumBadParenthesis         4 
# define NumNoFloatNumber          5
# define NumNoFloatFunction        6
# define NumDomainError            7
# define NumNoIntegerNumber        8
# define NumIntegerOverflow        9 
# define NumDivByZero             10 
# define NumWriteError            11 
# define NumNoVariable            12
# define NumVariableError         13
# define NumProgramError          14 
# define NumNoInstruction         15
# define NumNoAccumulator         16

#endif