Mercurial > audlegacy
changeset 1617:3de4bd38fe4f trunk
[svn] generic vfs_gets and m3u updated to use vfs
author | lu_zero |
---|---|
date | Tue, 05 Sep 2006 08:09:14 -0700 |
parents | 38107b41e9d3 |
children | 425a9a172319 |
files | ChangeLog Plugins/Container/m3u/m3u.c libaudacious/Makefile.in libaudacious/vfs.h libaudacious/vfs_common.c |
diffstat | 5 files changed, 72 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Mon Sep 04 22:36:30 2006 -0700 +++ b/ChangeLog Tue Sep 05 08:09:14 2006 -0700 @@ -1,3 +1,12 @@ +2006-09-05 05:36:30 +0000 George Averill <nhjm449@gmail.com> + revision [2163] + - Fix audacious-arts-helper warnings. + + + Changes: Modified: + +1 -4 trunk/Plugins/Output/arts/arts_helper/Makefile.in + + 2006-09-05 02:47:32 +0000 Yoshiki Yazawa <yaz@cc.rim.or.jp> revision [2161] - fix for the long-standing dependency oddness in our build system. now make tool surely picks up changed source files and builds required objectives.
--- a/Plugins/Container/m3u/m3u.c Mon Sep 04 22:36:30 2006 -0700 +++ b/Plugins/Container/m3u/m3u.c Tue Sep 05 08:09:14 2006 -0700 @@ -31,6 +31,7 @@ #include <sys/stat.h> #include <sys/errno.h> +#include "libaudacious/vfs.h" #include "audacious/main.h" #include "audacious/util.h" #include "audacious/playlist.h" @@ -74,22 +75,22 @@ static void playlist_load_m3u(const gchar * filename, gint pos) { - FILE *file; + VFSFile *file; gchar *line; gchar *ext_info = NULL, *ext_title = NULL; gsize line_len = 1024; gint ext_len = -1; gboolean is_extm3u = FALSE; - if (!(file = fopen(filename, "r"))) + if ((file = vfs_fopen(filename, "rb")) == NULL) return; line = g_malloc(line_len); - while (fgets(line, line_len, file)) { + while (vfs_fgets(line, line_len, file)) { while (strlen(line) == line_len - 1 && line[strlen(line) - 1] != '\n') { line_len += 1024; line = g_realloc(line, line_len); - fgets(&line[strlen(line)], 1024, file); + vfs_fgets(&line[strlen(line)], 1024, file); } while (line[strlen(line) - 1] == '\r' || @@ -130,7 +131,7 @@ pos++; } - fclose(file); + vfs_fclose(file); g_free(line); }
--- a/libaudacious/Makefile.in Mon Sep 04 22:36:30 2006 -0700 +++ b/libaudacious/Makefile.in Tue Sep 05 08:09:14 2006 -0700 @@ -1,5 +1,5 @@ include ../mk/rules.mk -include ../mk/init.mk +include ../mk/objective.mk beepincludedir = $(includedir)/audacious @@ -21,7 +21,7 @@ -I../intl CONF_SRC = configdb_$(CONFIGDB_BACKEND).c -VFS_SRC = vfs_$(VFS_BACKEND).c +VFS_SRC = vfs_$(VFS_BACKEND).c vfs_common.c SOURCES = \ $(CONF_SRC) \ @@ -43,8 +43,6 @@ beepctrl.h dirbrowser.h util.h \ formatter.h titlestring.h xml_document.h -include ../mk/objective.mk - install-posthook: @mv ${DESTDIR}/${LIBDIR}/libaudacious.so ${DESTDIR}/${LIBDIR}/libaudacious.so.3.0.0 @ln -sf ${LIBDIR}/libaudacious.so.3.0.0 \
--- a/libaudacious/vfs.h Mon Sep 04 22:36:30 2006 -0700 +++ b/libaudacious/vfs.h Tue Sep 05 08:09:14 2006 -0700 @@ -24,6 +24,10 @@ size_t nmemb, VFSFile *file); +extern gchar *vfs_fgets(gchar *s, + gint n, + VFSFile *stream); + extern gint vfs_fseek(VFSFile * file, glong offset, gint whence);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libaudacious/vfs_common.c Tue Sep 05 08:09:14 2006 -0700 @@ -0,0 +1,51 @@ +/* This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "vfs.h" + +/* FIXME low performance vfs_getc */ +gint vfs_getc(VFSFile *stream) +{ + guchar uc; + if (vfs_fread(&uc, 1, 1, stream)) + return uc; + return EOF; +} + + +gchar *vfs_fgets(gchar *s, gint n, VFSFile *stream) +{ + gint c; + register gchar *p; + + if(n<=0) return NULL; + + p = s; + + while (--n) { + if ((c = vfs_getc(stream))== EOF) { + break; + } + if ((*p++ = c) == '\n') { + break; + } + } + if (p > s) { + *p = 0; + return s; + } + + return NULL; +}