1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2/*
3 * Copyright (C) 2000-2003, Ximian, Inc.
4 */
5
6#ifndef __SOUP_MESSAGE_BODY_H__
7#define __SOUP_MESSAGE_BODY_H__ 1
8
9#include <libsoup/soup-types.h>
10
11G_BEGIN_DECLS
12
13typedef enum {
14 SOUP_MEMORY_STATIC,
15 SOUP_MEMORY_TAKE,
16 SOUP_MEMORY_COPY,
17 SOUP_MEMORY_TEMPORARY
18} SoupMemoryUse;
19
20typedef struct {
21 const char *data;
22 gsize length;
23} SoupBuffer;
24
25SOUP_AVAILABLE_IN_2_4
26GType soup_buffer_get_type (void);
27#define SOUP_TYPE_BUFFER (soup_buffer_get_type ())
28
29SOUP_AVAILABLE_IN_2_4
30SoupBuffer *soup_buffer_new (SoupMemoryUse use,
31 gconstpointer data,
32 gsize length);
33SOUP_AVAILABLE_IN_2_32
34SoupBuffer *soup_buffer_new_take (guchar *data,
35 gsize length);
36SOUP_AVAILABLE_IN_2_4
37SoupBuffer *soup_buffer_new_subbuffer (SoupBuffer *parent,
38 gsize offset,
39 gsize length);
40
41SOUP_AVAILABLE_IN_2_4
42SoupBuffer *soup_buffer_new_with_owner (gconstpointer data,
43 gsize length,
44 gpointer owner,
45 GDestroyNotify owner_dnotify);
46SOUP_AVAILABLE_IN_2_4
47gpointer soup_buffer_get_owner (SoupBuffer *buffer);
48SOUP_AVAILABLE_IN_2_32
49void soup_buffer_get_data (SoupBuffer *buffer,
50 const guint8 **data,
51 gsize *length);
52SOUP_AVAILABLE_IN_2_40
53GBytes *soup_buffer_get_as_bytes (SoupBuffer *buffer);
54
55SOUP_AVAILABLE_IN_2_4
56SoupBuffer *soup_buffer_copy (SoupBuffer *buffer);
57SOUP_AVAILABLE_IN_2_4
58void soup_buffer_free (SoupBuffer *buffer);
59
60typedef struct {
61 const char *data;
62 goffset length;
63} SoupMessageBody;
64
65SOUP_AVAILABLE_IN_2_4
66GType soup_message_body_get_type (void);
67#define SOUP_TYPE_MESSAGE_BODY (soup_message_body_get_type ())
68
69SOUP_AVAILABLE_IN_2_4
70SoupMessageBody *soup_message_body_new (void);
71
72SOUP_AVAILABLE_IN_2_24
73void soup_message_body_set_accumulate(SoupMessageBody *body,
74 gboolean accumulate);
75SOUP_AVAILABLE_IN_2_24
76gboolean soup_message_body_get_accumulate(SoupMessageBody *body);
77
78SOUP_AVAILABLE_IN_2_4
79void soup_message_body_append (SoupMessageBody *body,
80 SoupMemoryUse use,
81 gconstpointer data,
82 gsize length);
83SOUP_AVAILABLE_IN_2_32
84void soup_message_body_append_take (SoupMessageBody *body,
85 guchar *data,
86 gsize length);
87SOUP_AVAILABLE_IN_2_4
88void soup_message_body_append_buffer (SoupMessageBody *body,
89 SoupBuffer *buffer);
90SOUP_AVAILABLE_IN_2_4
91void soup_message_body_truncate (SoupMessageBody *body);
92SOUP_AVAILABLE_IN_2_4
93void soup_message_body_complete (SoupMessageBody *body);
94
95SOUP_AVAILABLE_IN_2_4
96SoupBuffer *soup_message_body_flatten (SoupMessageBody *body);
97
98SOUP_AVAILABLE_IN_2_4
99SoupBuffer *soup_message_body_get_chunk (SoupMessageBody *body,
100 goffset offset);
101
102SOUP_AVAILABLE_IN_2_24
103void soup_message_body_got_chunk (SoupMessageBody *body,
104 SoupBuffer *chunk);
105SOUP_AVAILABLE_IN_2_24
106void soup_message_body_wrote_chunk (SoupMessageBody *body,
107 SoupBuffer *chunk);
108
109SOUP_AVAILABLE_IN_2_4
110void soup_message_body_free (SoupMessageBody *body);
111
112G_END_DECLS
113
114#endif /* __SOUP_MESSAGE_BODY_H__ */
115