OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
epr_api.c
Go to the documentation of this file.
1 /*
2  * $Id: epr_api.c,v 1.1.1.1 2004-10-28 19:22:21 norman Exp $
3  *
4  * Copyright (C) 2002 by Brockmann Consult (info@brockmann-consult.de)
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the
8  * Free Software Foundation. This program is distributed in the hope it will
9  * be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
10  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  * See the GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16  */
17 
18 #include <assert.h>
19 #include <errno.h>
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <string.h>
23 #include <time.h>
24 
25 #include "epr_api.h"
26 #include "epr_core.h"
27 #include "epr_string.h"
28 #include "epr_ptrarray.h"
29 #include "epr_swap.h"
30 
31 #include "epr_dddb.h"
32 
33 
34 
35 /*********************************** API ***********************************/
36 
41  EPR_FLogHandler log_handler,
42  EPR_FErrHandler err_handler)
43 {
44  if (epr_api.init_flag) {
45  return e_err_none;
46  }
47 
48  epr_clear_err();
49 
50  /* Determine endian order architecture */
52  epr_api.little_endian_order = EPR_TRUE;
53  } else if (epr_is_big_endian_order()) {
54  epr_api.little_endian_order = EPR_FALSE;
55  } else {
57  "epr_init_api: failed to determine endian order");
58  return epr_get_last_err_code();
59  }
60 
61  epr_api.log_level = log_level;
62  epr_api.log_handler = log_handler;
63  epr_api.err_handler = err_handler;
64  epr_api.last_err_code = e_err_none;
65  epr_api.last_err_message = NULL;
66  epr_api.init_flag = EPR_TRUE;
67 
69  epr_log(e_log_info, "API successfully initialized");
70 
71  if (epr_api.little_endian_order) {
72  epr_log(e_log_debug, "running on a little endian order architecture");
73  } else {
74  epr_log(e_log_debug, "running on a big endian order architecture");
75  }
76 
77  return epr_get_last_err_code();
78 }
79 
80 
81 /*
82  Function: epr_close_api
83  Access: public API
84  Changelog: 2002/01/05 mp initial version
85  */
91 {
92  epr_clear_err();
93 
94  if (epr_api.init_flag) {
95  epr_log(e_log_info, "ENVISAT product reader API is being closed");
96  epr_api.last_err_code = e_err_none;
97  epr_free_and_null_string(&epr_api.last_err_message);
98  epr_api.init_flag = EPR_FALSE;
99  }
100 }
101 
102 
103 /*
104  Function: epr_set_log_handler
105  Access: public API
106  Changelog: 2002/01/05 nf initial version
107  */
116 {
117  epr_api.log_handler = log_handler;
118 }
119 
120 
121 void epr_log_message(EPR_ELogLevel log_level, const char* log_message)
122 {
123  struct tm* ptm;
124  time_t millis;
125 
126  time(&millis);
127  ptm = gmtime(&millis);
128 
129  fprintf(stdout,
130  "%c %04d/%02d/%02d %02d:%02d:%02d - %s\n",
131  log_level == e_log_debug ? 'D' :
132  log_level == e_log_info ? 'I' :
133  log_level == e_log_warning ? 'W' :
134  log_level == e_log_error ? 'E' : '?',
135  ptm->tm_year + 1900,
136  ptm->tm_mon + 1,
137  ptm->tm_mday,
138  ptm->tm_hour,
139  ptm->tm_min,
140  ptm->tm_sec,
141  log_message);
142 }
143 
144 
@ e_log_debug
Definition: epr_api.h:125
enum EPR_LogLevel EPR_ELogLevel
Definition: epr_api.h:163
@ e_log_warning
Definition: epr_api.h:127
#define NULL
Definition: decode_rs.h:63
@ e_err_none
Definition: epr_api.h:77
EPR_SAPI epr_api
Definition: epr_core.c:43
float tm[MODELMAX]
int epr_init_api(EPR_ELogLevel log_level, EPR_FLogHandler log_handler, EPR_FErrHandler err_handler)
Definition: epr_api.c:40
@ e_err_unknown_endian_order
Definition: epr_api.h:110
void(* EPR_FErrHandler)(EPR_EErrCode err_code, const char *err_message)
Definition: epr_api.h:181
void(* EPR_FLogHandler)(EPR_ELogLevel log_level, const char *log_message)
Definition: epr_api.h:182
int epr_is_little_endian_order()
Definition: epr_swap.c:152
@ e_log_error
Definition: epr_api.h:128
void epr_log_message(EPR_ELogLevel log_level, const char *log_message)
Definition: epr_api.c:121
void epr_set_log_handler(EPR_FLogHandler log_handler)
Definition: epr_api.c:115
@ e_log_info
Definition: epr_api.h:126
void epr_log(EPR_ELogLevel log_level, const char *log_message)
Definition: epr_core.c:199
void epr_clear_err()
Definition: epr_core.c:247
#define EPR_PRODUCT_API_VERSION_STR
Definition: epr_api.h:33
void epr_set_err(EPR_EErrCode err_code, const char *err_message)
Definition: epr_core.c:221
#define EPR_PRODUCT_API_NAME_STR
Definition: epr_api.h:32
this program makes no use of any feature of the SDP Toolkit that could generate such a then geolocation is calculated at that and then aggregated up to Resolved feature request Bug by adding three new int8 SDSs for each high resolution offsets between the high resolution geolocation and a bi linear interpolation extrapolation of the positions This can be used to reconstruct the high resolution geolocation Resolved Bug by delaying cumulation of gflags until after validation of derived products Resolved Bug by setting Latitude and Longitude to the correct fill resolving to support Near Real Time because they may be unnecessary if use of entrained ephemeris and attitude data is turned resolving bug report Corrected to filter out Aqua attitude records with missing status helping resolve bug MOD_PR03 will still correctly write scan and pixel data that does not depend upon the start time
Definition: HISTORY.txt:248
EPR_EErrCode epr_get_last_err_code()
Definition: epr_core.c:265
void epr_free_and_null_string(char **str)
Definition: epr_string.c:370
#define EPR_FALSE
Definition: epr_api.h:203
#define EPR_TRUE
Definition: epr_api.h:202
int epr_is_big_endian_order()
Definition: epr_swap.c:171
void epr_close_api()
Definition: epr_api.c:90