File: obex_object.h

package info (click to toggle)
libopenobex 1.7.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, stretch
  • size: 972 kB
  • ctags: 1,552
  • sloc: ansic: 9,988; xml: 407; makefile: 96
file content (94 lines) | stat: -rw-r--r-- 3,528 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/**
	\file obex_object.h
	OBEX object related functions.
	OpenOBEX library - Free implementation of the Object Exchange protocol.

	Copyright (c) 1999, 2000 Dag Brattli, All Rights Reserved.
	Copyright (c) 1999, 2000 Pontus Fuchs, All Rights Reserved.

	OpenOBEX is free software; you can redistribute it and/or modify
	it under the terms of the GNU Lesser General Public License as
	published by the Free Software Foundation; either version 2.1 of
	the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU Lesser General Public License for more details.

	You should have received a copy of the GNU Lesser General Public
	License along with OpenOBEX. If not, see <http://www.gnu.org/>.
 */

#ifndef OBEX_OBJECT_H
#define OBEX_OBJECT_H

#include "obex_incl.h"
#include "defines.h"

#if ! defined(_WIN32)
#  include <sys/time.h>
#endif
#include <time.h>


struct databuffer;
struct databuffer_list;

struct obex_object {
	struct databuffer *tx_nonhdr_data;	/* Data before of headers (like CONNECT and SETPATH) */
	struct databuffer_list *tx_headerq;	/* List of headers to transmit*/
	struct obex_hdr_it *tx_it;

	struct databuffer *rx_nonhdr_data;	/* Data before of headers (like CONNECT and SETPATH) */
	struct databuffer_list *rx_headerq;	/* List of received headers */
	struct obex_hdr_it *rx_it;
	struct obex_hdr_it *it;

	enum obex_cmd cmd;		/* command */
	enum obex_rsp rsp;		/* response */
	enum obex_rsp lastrsp;		/* response for last packet */

	uint16_t headeroffset;		/* Where to start parsing headers */
	uint32_t hinted_body_len;	/* Hinted body-length or 0 */
	bool abort;			/* Request shall be aborted */

	enum obex_rsp_mode rsp_mode;	/* OBEX_RSP_MODE_* */

	bool suspended;			/* Temporarily stop transfering object */

	struct obex_hdr *body;		/* The body header need some extra help */
	struct obex_body *body_rcv;	/* Deliver body */
};

struct obex_object *obex_object_new(void);
int obex_object_delete(struct obex_object *object);
size_t obex_object_get_size(obex_object_t *object);
int obex_object_addheader(struct obex *self, struct obex_object *object, uint8_t hi,
			  obex_headerdata_t hv, uint32_t hv_size,
			  unsigned int flags);
int obex_object_getnextheader(struct obex_object *object, uint8_t *hi,
			      obex_headerdata_t *hv, uint32_t *hv_size);
int obex_object_reparseheaders(struct obex_object *object);
void obex_object_setcmd(struct obex_object *object, enum obex_cmd cmd);
enum obex_cmd obex_object_getcmd(const obex_object_t *object);
int obex_object_setrsp(struct obex_object *object, enum obex_rsp rsp,
		       enum obex_rsp lastrsp);
int obex_object_get_opcode(obex_object_t *object, bool allowfinalcmd,
				enum obex_mode mode);
bool obex_object_append_data(obex_object_t *object, struct databuffer *txmsg,
			     size_t tx_left);
int obex_object_finished(obex_object_t *object, bool allowfinal);

int obex_object_receive_nonhdr_data(obex_object_t *object, const void *msgdata,
				    size_t rx_left);
int obex_object_receive_headers(struct obex_object *object, const void *msgdata,
				size_t tx_left, uint64_t filter);

int obex_object_set_body_receiver(obex_object_t *object, struct obex_body *b);
const void * obex_object_read_body(obex_object_t *object, size_t *size);

int obex_object_suspend(struct obex_object *object);
int obex_object_resume(struct obex_object *object);

#endif