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
26#ifndef _das1_h_
27#define _das1_h_
28
29#include <stdio.h>
30#include <das3/time.h>
31#include <das3/defs.h>
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37#ifdef HOST_IS_LSB_FIRST
38
40#define swapBufIfHostLE(p, s, n) das_swapBufInPlace(p, s, n)
41
43#define swapFloatIfHostLE(x) das_swap_float(x)
44
45#else
46
47#define swapBufIfHostLE(p, s, n)
48
49#define swapFloatIfHostLE(x) x
50
51#endif
52
54DAS_API void das_swapBufInPlace(void* pMem, size_t szEach, size_t numItems);
55
57DAS_API float das_swap_float(float rIn);
58
60#define swapFloat(x) das_swap_float(x)
61
63DAS_API void swapU4(uint32_t* pIn);
64
65#define D1ERR 10
66
70DAS_API int parsetime (const char *string,
71 int *year, int *month, int *mday, int *yday,
72 int *hour, int *minute, double *second
73);
74
75
98DAS_API double ttime (
99 int *year, int *month, int *mday, int *yday, int *hour, int *minute,
100 double *second
101);
102
108DAS_API void emitt (
109 double tt, int *year, int *month, int *mday, int *yday,
110 int *hour, int *minute, double *second
111);
112
117DAS_API void tnorm (
118 int *year, int *month, int *mday, int *yday, int *hour, int *minute,
119 double *second
120);
121
122
135void yrdy1958(int* pYear, int* pDoy, int days_since_1958);
136
138int past_1958 (int year, int day);
139
140
155void ms2hms(int* pHour, int* pMin, float* pSec, double ms_of_day);
156
157/* generic print-message-and-exit-with-error */
158void fail (const char *message);
159
167int getpkt(char *ph, ubyte *data, int max);
168
177int fgetpkt(FILE* fin, char* ph, ubyte* data, int max);
178
179
187int putpkt (const char *ph, const ubyte *data, const int bytes);
188
189#ifdef __cplusplus
190}
191#endif
192
193#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 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.
DAS_API float das_swap_float(float rIn)
Reverse the byte order of a 4-byte float, returns the swapped value.
int fgetpkt(FILE *fin, char *ph, ubyte *data, int max)
Read a Tagged Das 1 packet from a file object.
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 void das_swapBufInPlace(void *pMem, size_t szEach, size_t numItems)
Swap whole buffers in place.
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.