3rdparty/licenseReport: Add seperate LGPL checks
[haiku.git] / src / add-ons / media / plugins / asf_reader / libasf / byteio.c
blob3b5131774905bba31c6c608078cc1f8ec0f0ae11
1 /* libasf - An Advanced Systems Format media file parser
2 * Copyright (C) 2006-2010 Juho Vähä-Herttua
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 #include <string.h>
21 #include "asfint.h"
22 #include "byteio.h"
24 int
25 asf_byteio_read(asf_iostream_t *iostream, uint8_t *data, int size)
27 int read = 0, tmp;
29 if (!iostream->read) {
30 return ASF_ERROR_INTERNAL;
33 while ((tmp = iostream->read(iostream->opaque, data+read, size-read)) > 0) {
34 read += tmp;
35 if (read == size) {
36 return read;
40 /* FIXME: should return tmp if any bytes were read, but the
41 rest of the code needs to be fixed before that */
43 return (tmp == 0) ? ASF_ERROR_EOF : ASF_ERROR_IO;