das2C
das core C utilities (v3)
das1.h
Go to the documentation of this file.
1 /* Copyright (C) 1997-2017 Larry Granroth <larry-granroth@uiowa.edu>
2  * Chris Piker <chris-piker@uiowa.edu>
3  *
4  * This file is part of libdas2, the Core Das2 C Library.
5  *
6  * Libdas2 is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License version 2.1 as published
8  * by the Free Software Foundation.
9  *
10  * Libdas2 is distributed in the hope that it will be useful, but WITHOUT ANY
11  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * version 2.1 along with libdas2; if not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 
22 #ifndef _das1_h_
23 #define _das1_h_
24 
25 #include <stdio.h>
26 #include <das2/time.h>
27 #include <das2/defs.h>
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #ifdef HOST_IS_LSB_FIRST
34 
36 #define swapBufIfHostLE(p, s, n) _swapBufInPlace(p, s, n)
37 
39 #define swapFloatIfHostLE(x) swapFloat(x)
40 
41 #else
42 
43 #define swapBufIfHostLE(p, s, n)
44 
45 #define swapFloatIfHostLE(x) x
46 
47 #endif
48 
50 DAS_API void _swapBufInPlace(void* pMem, size_t szEach, size_t numItems);
51 
53 DAS_API float swapFloat(float rIn);
54 
56 DAS_API void swapU4(uint32_t* pIn);
57 
58 #define D1ERR 10
59 
63 DAS_API int parsetime (const char *string,
64  int *year, int *month, int *mday, int *yday,
65  int *hour, int *minute, double *second
66 );
67 
68 
91 DAS_API double ttime (
92  int *year, int *month, int *mday, int *yday, int *hour, int *minute,
93  double *second
94 );
95 
101 DAS_API void emitt (
102  double tt, int *year, int *month, int *mday, int *yday,
103  int *hour, int *minute, double *second
104 );
105 
110 DAS_API void tnorm (
111  int *year, int *month, int *mday, int *yday, int *hour, int *minute,
112  double *second
113 );
114 
115 
128 void yrdy1958(int* pYear, int* pDoy, int days_since_1958);
129 
131 int past_1958 (int year, int day);
132 
133 
148 void ms2hms(int* pHour, int* pMin, float* pSec, double ms_of_day);
149 
150 /* generic print-message-and-exit-with-error */
151 void fail (const char *message);
152 
160 int getpkt(char *ph, ubyte *data, int max);
161 
170 int fgetpkt(FILE* fin, char* ph, ubyte* data, int max);
171 
172 
180 int putpkt (const char *ph, const ubyte *data, const int bytes);
181 
182 #ifdef __cplusplus
183 }
184 #endif
185 
186 #endif /* _das1_h_ */
int past_1958(int year, int day)
Get the number of days since 1958-01-01 given a year and day of year.
void yrdy1958(int *pYear, int *pDoy, int days_since_1958)
Return a year and day of year given the number of days past 1958.
DAS_API float swapFloat(float rIn)
Swap single floats, returns new float.
DAS_API void tnorm(int *year, int *month, int *mday, int *yday, int *hour, int *minute, double *second)
normalize date and time components NOTE: yday is OUTPUT only.
int fgetpkt(FILE *fin, char *ph, ubyte *data, int max)
Read a Tagged Das 1 packet from a file object.
DAS_API void _swapBufInPlace(void *pMem, size_t szEach, size_t numItems)
Swap whole buffers in place.
DAS_API void emitt(double tt, int *year, int *month, int *mday, int *yday, int *hour, int *minute, double *second)
convert double seconds since epoch to time components.
DAS_API int parsetime(const char *string, int *year, int *month, int *mday, int *yday, int *hour, int *minute, double *second)
Convert most human-parseable time strings to numeric components returns 0 on success and non-zero on ...
DAS_API double ttime(int *year, int *month, int *mday, int *yday, int *hour, int *minute, double *second)
Convert time components to double seconds since epoch.
DAS_API void swapU4(uint32_t *pIn)
Swap uint4 in place.
void ms2hms(int *pHour, int *pMin, float *pSec, double ms_of_day)
Return the hours, minutes and seconds of a day given then number of milliseconds since the start of t...
int getpkt(char *ph, ubyte *data, int max)
Read a Tagged Das 1 packet from stdin.
int putpkt(const char *ph, const ubyte *data, const int bytes)
Write das packet to stdout.
Minimal definitions for das2 utilities that can safely be run without calling das_init().
Das Time Utilities.