libdas2
das2 core C utilities
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
oob.h
Go to the documentation of this file.
1 /* Copyright (C) 2015-2017 Chris Piker <chris-piker@uiowa.edu>
2  *
3  * This file is part of libdas2, the Core Das2 C Library.
4  *
5  * Libdas2 is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU Lesser General Public License version 2.1 as published
7  * by the Free Software Foundation.
8  *
9  * Libdas2 is distributed in the hope that it will be useful, but WITHOUT ANY
10  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * version 2.1 along with libdas2; if not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 
25 /* Copyright 2003-2017 Chris Piker <chris-piker@uiowa.edu>
26  * Jeremy Faden <jeremy-faden@uiowa.edu>
27  *
28  * Licensed under the open source Apache License, Version 2.0 (the "License");
29  * you may not use this file except in compliance with the License. You may
30  * obtain a copy of the License at
31  *
32  * http://www.apache.org/licenses/LICENSE-2.0
33  *
34  * Unless required by applicable law or agreed to in writing, software
35  * distributed under the License is distributed on an "AS IS" BASIS,
36  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
37  * See the License for the specific language governing permissions and
38  * limitations under the License.
39  */
40 
41 
42 #ifndef _das_out_of_band_h_
43 #define _das_out_of_band_h_
44 
45 #include <das2/util.h>
46 #include <das2/buffer.h>
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
53 #define EXCEPTION_UNTYPED ""
54 
56 #define DAS2_EXCEPT_NO_DATA_IN_INTERVAL "NoDataInInterval"
57 #define DAS2_EXCEPT_ILLEGAL_ARGUMENT "IllegalArgument"
58 #define DAS2_EXCEPT_SERVER_ERROR "ServerError"
59 
60 typedef enum oob_type {OOB_EXCEPT, OOB_COMMENT} oob_t;
61 
63 typedef struct out_of_band {
64  oob_t pkttype;
65  void (*clean)(struct out_of_band* pThis);
66 } OutOfBand;
67 
71 void OutOfBand_clean(OutOfBand* pThis);
72 
73 
80 typedef struct stream_exception {
81  OutOfBand base;
82 
83  char* sType; /* NoDataInInterval, Exception */
84  size_t uTypeLen;
85 
86  char* sMsg; /* May be altered by encode function to change " to ' */
87  size_t uMsgLen;
88 
89 } OobExcept;
90 
99 void OobExcept_init(OobExcept* pThis);
100 
111 void OobExcept_set(OobExcept* pThis, const char* sType, const char* sMsg);
112 
116 DasErrCode OobExcept_decode(OobExcept* pThis, DasBuf* str);
117 
125 DasErrCode OobExcept_encode(OobExcept* pThis, DasBuf* pBuf);
126 
127 
134 typedef struct stream_comment{
135  OutOfBand base;
136 
138  char* sType;
139  size_t uTypeLen;
140 
142  char* sSrc;
143  size_t uSrcLen;
144 
146  char* sVal;
147  size_t uValLen;
148 } OobComment;
149 
158 void OobComment_init(OobComment* pThis);
159 
167 DasErrCode OobComment_encode(OobComment* pThis, DasBuf* pBuf);
168 
176 DasErrCode OobComment_decode(OobComment* pThis, DasBuf* sbuf);
177 
178 
201 DasErrCode OutOfBand_decode(DasBuf* pBuf, OutOfBand** ppObjs, int* which);
202 
203 #ifdef __cplusplus
204 }
205 #endif
206 
207 #endif /* _das_out_of_band_h_ */
void OutOfBand_clean(OutOfBand *pThis)
Clean up extra memory allocated when an out of band object is initialized.
int DasErrCode
return code type 0 indicates success, negative integer indicates failure
Definition: util.h:117
Little buffer class to handle accumulating string data.
Definition: buffer.h:49
void OobExcept_init(OobExcept *pThis)
Initialize an Exception Structure This only needs to be called once, the same structure will be reuse...
void OobComment_init(OobComment *pThis)
Initialize an Exception Structure This only needs to be called once, the same structure will be reuse...
describes an exception that can live in a stream.
Definition: oob.h:80
Utility to assist with encode and decode operations.
describes human-consumable messages that exist on the stream.
Definition: oob.h:134
DasErrCode OutOfBand_decode(DasBuf *pBuf, OutOfBand **ppObjs, int *which)
Factory function to produce out of band objects from general data.
char * sSrc
The source of the comment, typically the name of a program.
Definition: oob.h:142
char * sVal
The Comment body, for some messages this is an ASCII value.
Definition: oob.h:146
void OobExcept_set(OobExcept *pThis, const char *sType, const char *sMsg)
Set an exception structure to a particular exception.
char * sType
The type of comment, for example log:info, taskProgress, taskSize, etc.
Definition: oob.h:138
A container for Out-of-Band data.
Definition: oob.h:63