das2C
das core C utilities (v3)
Loading...
Searching...
No Matches
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 das2C, the Core Das2 C Library.
5 *
6 * Das2C 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 * Das2C 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 das2C; 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 <das3/time.h>
27#include <das3/defs.h>
28
29#ifdef __cplusplus
30extern "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
50DAS_API void _swapBufInPlace(void* pMem, size_t szEach, size_t numItems);
51
53DAS_API float swapFloat(float rIn);
54
56DAS_API void swapU4(uint32_t* pIn);
57
58#define D1ERR 10
59
63DAS_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
91DAS_API double ttime (
92 int *year, int *month, int *mday, int *yday, int *hour, int *minute,
93 double *second
94);
95
101DAS_API void emitt (
102 double tt, int *year, int *month, int *mday, int *yday,
103 int *hour, int *minute, double *second
104);
105
110DAS_API void tnorm (
111 int *year, int *month, int *mday, int *yday, int *hour, int *minute,
112 double *second
113);
114
115
128void yrdy1958(int* pYear, int* pDoy, int days_since_1958);
129
131int past_1958 (int year, int day);
132
133
148void ms2hms(int* pHour, int* pMin, float* pSec, double ms_of_day);
149
150/* generic print-message-and-exit-with-error */
151void fail (const char *message);
152
160int getpkt(char *ph, ubyte *data, int max);
161
170int fgetpkt(FILE* fin, char* ph, ubyte* data, int max);
171
172
180int 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.