2 * Copyright 2004 Timo Hirvonen
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 #include <read_wrapper.h>
27 ssize_t
read_wrapper(struct input_plugin_data
*ip_data
, void *buffer
, size_t count
)
31 if (ip_data
->metaint
== 0) {
32 /* no metadata in the stream */
33 return read(ip_data
->fd
, buffer
, count
);
36 if (ip_data
->counter
== ip_data
->metaint
) {
41 rc
= read(ip_data
->fd
, &byte
, 1);
47 len
= ((int)byte
) * 16;
48 ip_data
->metadata
[0] = 0;
49 rc
= read_all(ip_data
->fd
, ip_data
->metadata
, len
);
53 ip_data
->metadata
[0] = 0;
56 ip_data
->metadata
[len
] = 0;
57 ip_data
->metadata_changed
= 1;
61 if (count
+ ip_data
->counter
> ip_data
->metaint
)
62 count
= ip_data
->metaint
- ip_data
->counter
;
63 rc
= read(ip_data
->fd
, buffer
, count
);
65 ip_data
->counter
+= rc
;