GNUnet  0.11.x
gnunet_mst_lib.h
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2009-2013, 2016 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
35 #ifndef GNUNET_MST_LIB_H
36 #define GNUNET_MST_LIB_H
37 
38 #ifdef __cplusplus
39 extern "C"
40 {
41 #if 0 /* keep Emacsens' auto-indent happy */
42 }
43 #endif
44 #endif
45 
46 #include "gnunet_common.h"
47 
48 
53 
54 
68 typedef int
70  const struct GNUNET_MessageHeader *message);
71 
72 
82  void *cb_cls);
83 
84 
99 int
101  const char *buf,
102  size_t size,
103  int purge,
104  int one_shot);
105 
106 
121 int
123  struct GNUNET_NETWORK_Handle *sock,
124  int purge,
125  int one_shot);
126 
127 
139 int
141  int one_shot);
142 
143 
149 void
151 
152 
153 #if 0 /* keep Emacsens' auto-indent happy */
154 {
155 #endif
156 #ifdef __cplusplus
157 }
158 #endif
159 
160 #endif
161  /* end of group server */
163 
164 /* end of gnunet_mst_lib.h */
void * cb_cls
Closure for cb.
Definition: mst.c:53
int GNUNET_MST_next(struct GNUNET_MessageStreamTokenizer *mst, int one_shot)
Obtain the next message from the mst, assuming that there are more unprocessed messages in the intern...
Definition: mst.c:394
int(* GNUNET_MessageTokenizerCallback)(void *cls, const struct GNUNET_MessageHeader *message)
Functions with this signature are called whenever a complete message is received by the tokenizer...
void GNUNET_MST_destroy(struct GNUNET_MessageStreamTokenizer *mst)
Destroys a tokenizer.
Definition: mst.c:411
Handle to a message stream tokenizer.
Definition: mst.c:43
static char buf[2048]
struct GNUNET_MessageStreamTokenizer * GNUNET_MST_create(GNUNET_MessageTokenizerCallback cb, void *cb_cls)
Create a message stream tokenizer.
Definition: mst.c:85
int GNUNET_MST_from_buffer(struct GNUNET_MessageStreamTokenizer *mst, const char *buf, size_t size, int purge, int one_shot)
Add incoming data to the receive buffer and call the callback for all complete messages.
Definition: mst.c:114
static unsigned int size
Size of the "table".
Definition: peer.c:67
int GNUNET_MST_read(struct GNUNET_MessageStreamTokenizer *mst, struct GNUNET_NETWORK_Handle *sock, int purge, int one_shot)
Add incoming data to the receive buffer and call the callback for all complete messages.
Definition: mst.c:345
handle to a socket
Definition: network.c:52
Header for all communications.
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
GNUNET_MessageTokenizerCallback cb
Function to call on completed messages.
Definition: mst.c:48