1 /* buffers-ops.c:
2 *
3 ****************************************************************
4 * Copyright (C) 2004 Tom Lord
5 *
6 * See the file "COPYING" for further information about
7 * the copyright and warranty status of this work.
8 */
9
10
11 #include "hackerlab/buffers/buffers.h"
12
13
14 /* typedefs */
15
16
17 /* __STDC__ prototypes for static functions */
18
19
20 /* declarations */
21
22
23
24 ssize_t
buf_room(ssize_t session,ssize_t buf)25 buf_room (ssize_t session, ssize_t buf)
26 {
27 t_buffer * bf;
28
29 bf = buffer_session_buffer_n (0, session, buf);
30 if (!bf)
31 return -1;
32
33 return buffer_room (bf, buffer_session_limits (session));
34 }
35
36
37 int
buf_is_empty(ssize_t session,ssize_t buf)38 buf_is_empty (ssize_t session, ssize_t buf)
39 {
40 t_buffer * bf;
41
42 bf = buffer_session_buffer_n (0, session, buf);
43 if (!bf)
44 return -1;
45
46 return buffer_is_empty (bf, buffer_session_limits (session));
47 }
48
49
50 ssize_t
buf_size(ssize_t session,ssize_t buf)51 buf_size (ssize_t session, ssize_t buf)
52 {
53 t_buffer * bf;
54
55 bf = buffer_session_buffer_n (0, session, buf);
56 if (!bf)
57 return -1;
58
59 return buffer_size (bf, buffer_session_limits (session));
60 }
61
62
63 int
buf_n(ssize_t session,ssize_t buf,ssize_t n)64 buf_n (ssize_t session, ssize_t buf, ssize_t n)
65 {
66 t_buffer * bf;
67
68 bf = buffer_session_buffer_n (0, session, buf);
69 if (!bf)
70 return -1;
71
72 return buffer_n (bf, buffer_session_limits (session), n);
73 }
74
75
76 t_uchar *
buf_burst(ssize_t * len_returned,ssize_t session,ssize_t buf,ssize_t n,ssize_t len)77 buf_burst (ssize_t * len_returned,
78 ssize_t session,
79 ssize_t buf,
80 ssize_t n,
81 ssize_t len)
82 {
83 t_buffer * bf;
84
85 bf = buffer_session_buffer_n (0, session, buf);
86 if (!bf)
87 return 0;
88
89 return buffer_burst (len_returned, bf, buffer_session_limits (session), n, len);
90 }
91
92
93 t_uchar *
buf_range(ssize_t session,ssize_t buf,ssize_t n,ssize_t len)94 buf_range (ssize_t session,
95 ssize_t buf,
96 ssize_t n,
97 ssize_t len)
98 {
99 t_buffer * bf;
100
101 bf = buffer_session_buffer_n (0, session, buf);
102 if (!bf)
103 return 0;
104
105 return buffer_range (bf, buffer_session_limits (session), n, len);
106 }
107
108
109 int
buf_insert_str_n(ssize_t session,ssize_t buf,ssize_t before_pos,t_uchar * data,ssize_t len)110 buf_insert_str_n (ssize_t session,
111 ssize_t buf,
112 ssize_t before_pos,
113 t_uchar * data,
114 ssize_t len)
115 {
116 t_buffer * bf;
117
118 bf = buffer_session_buffer_n (0, session, buf);
119 if (!bf)
120 return -1;
121
122 return buffer_insert_n (bf, buffer_session_limits (session), before_pos, data, len);
123 }
124
125
126 int
buf_delete_n(ssize_t session,ssize_t buf,ssize_t pos,ssize_t len)127 buf_delete_n (ssize_t session,
128 ssize_t buf,
129 ssize_t pos,
130 ssize_t len)
131 {
132 t_buffer * bf;
133
134 bf = buffer_session_buffer_n (0, session, buf);
135 if (!bf)
136 return -1;
137
138 return buffer_delete_n (bf, buffer_session_limits (session), pos, len);
139 }
140
141
142
143 /* tag: Tom Lord Sun Nov 21 10:10:14 2004 (buffers-ops.c)
144 */
145