libdas2
das2 core C utilities
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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/util.h>
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #ifdef HOST_IS_LSB_FIRST
33 
35 #define swapBufIfHostLE(p, s, n) _swapBufInPlace(p, s, n)
36 
38 #define swapFloatIfHostLE(x) swapFloat(x)
39 
40 #else
41 
42 #define swapBufIfHostLE(p, s, n)
43 
44 #define swapFloatIfHostLE(x) x
45 
46 #endif
47 
49 void _swapBufInPlace(void* pMem, size_t szEach, size_t numItems);
50 
52 float swapFloat(float rIn);
53 
54 
55 #define D1ERR 10
56 
60 int parsetime (const char *string,
61  int *year, int *month, int *mday, int *yday,
62  int *hour, int *minute, double *second);
63 
64 
87 double ttime (
88  int *year, int *month, int *mday, int *yday, int *hour, int *minute,
89  double *second
90 );
91 
97 void emitt (double tt, int *year, int *month, int *mday, int *yday,
98  int *hour, int *minute, double *second);
99 
104 void tnorm (int *year, int *month, int *mday, int *yday,
105  int *hour, int *minute, double *second);
106 
107 
120 void yrdy1958(int* pYear, int* pDoy, int days_since_1958);
121 
123 int past_1958 (int year, int day);
124 
125 
140 void ms2hms(int* pHour, int* pMin, float* pSec, double ms_of_day);
141 
142 /* generic print-message-and-exit-with-error */
143 void fail (const char *message);
144 
152 int getpkt(char *ph, void *data, int max);
153 
162 int fgetpkt(FILE* fin, char* ph, void* data, int max);
163 
164 
172 int putpkt (const char *ph, const void *data, int bytes);
173 
174 #ifdef __cplusplus
175 }
176 #endif
177 
178 #endif /* _das1_h_ */
float swapFloat(float rIn)
Swap single floats, returns new float.
double ttime(int *year, int *month, int *mday, int *yday, int *hour, int *minute, double *second)
Convert time components to double seconds since epoch.
void yrdy1958(int *pYear, int *pDoy, int days_since_1958)
Return a year and day of year given the number of days past 1958.
int fgetpkt(FILE *fin, char *ph, void *data, int max)
Read a Tagged Das 1 packet from a file object.
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...
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 putpkt(const char *ph, const void *data, int bytes)
Write das packet to stdout.
void _swapBufInPlace(void *pMem, size_t szEach, size_t numItems)
Swap whole buffers in place.
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.
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 ...
int past_1958(int year, int day)
Get the number of days since 1958-01-01 given a year and day of year.
int getpkt(char *ph, void *data, int max)
Read a Tagged Das 1 packet from stdin.