Mercurial > audlegacy
changeset 811:86ca43d8a845 trunk
[svn] - implement vfs_feof() and vfs_ftell() and update the scrobbler plugin to reflect that,
by external contributor: Leonardo Boshell <leonardop -at- gentoo.org>
author | nenolod |
---|---|
date | Thu, 09 Mar 2006 19:03:27 -0800 |
parents | e9509e909193 |
children | f9a1ddb72432 |
files | Plugins/General/scrobbler/tags/ape.c Plugins/General/scrobbler/tags/id3v2.c Plugins/General/scrobbler/tags/include/ape.h Plugins/General/scrobbler/tags/include/bmp_vfs.h Plugins/General/scrobbler/tags/include/id3v2.h Plugins/General/scrobbler/tags/include/itunes.h Plugins/General/scrobbler/tags/include/vorbis.h Plugins/General/scrobbler/tags/include/wma.h Plugins/General/scrobbler/tags/itunes.c Plugins/General/scrobbler/tags/vorbis.c Plugins/General/scrobbler/tags/wma.c libaudacious/vfs.h libaudacious/vfs_gnome.c libaudacious/vfs_stdio.c |
diffstat | 14 files changed, 59 insertions(+), 46 deletions(-) [+] |
line wrap: on
line diff
--- a/Plugins/General/scrobbler/tags/ape.c Thu Mar 09 09:55:56 2006 -0800 +++ b/Plugins/General/scrobbler/tags/ape.c Thu Mar 09 19:03:27 2006 -0800 @@ -21,7 +21,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "include/bmp_vfs.h" + #include "include/ape.h" #include "include/endian.h" #include "../fmt.h" @@ -110,7 +110,7 @@ if(!strncmp((char*)bp, "APETAGEX", 8)) status = 1; } - if(status == 1 || feof(fp)) + if(status == 1 || vfs_feof(fp)) break; memmove(tag_buffer, tag_buffer + BUFFER_SIZE - 7, 7); pos += BUFFER_SIZE - 7;
--- a/Plugins/General/scrobbler/tags/id3v2.c Thu Mar 09 09:55:56 2006 -0800 +++ b/Plugins/General/scrobbler/tags/id3v2.c Thu Mar 09 19:03:27 2006 -0800 @@ -21,7 +21,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "include/bmp_vfs.h" #include "include/id3v2.h" #include "include/endian.h" #include "../fmt.h" @@ -193,7 +192,7 @@ id3header_t *id3_data = calloc(sizeof(id3header_t), 1); char id3_flags, cToInt[4]; int bottom = 0; - + vfs_fread(cToInt, 1, 3, fp); if(strncmp(cToInt, "3DI", 3) == 0) bottom = 1; @@ -550,11 +549,11 @@ { unsigned char tag_buffer[BUFFER_SIZE], *bp = tag_buffer; int pos, search = -1, i, status = 0, charsRead; - + charsRead = vfs_fread(tag_buffer, 1, 10, fp); pos = 0; bp = tag_buffer; - while(status == 0 && !feof(fp)) + while(status == 0 && !vfs_feof(fp)) { if(search == -1) { @@ -597,7 +596,7 @@ if(status == 1) pos += bp - tag_buffer; pos -= BUFFER_SIZE - 9; - if((pos < -BUFFER_SIZE + 9 || ferror(fp)) && + if((pos < -BUFFER_SIZE + 9 || vfs_feof(fp)) && status != 1) status = -1; } @@ -619,7 +618,7 @@ if(search == 0) search = -1; } - if(status < 0 || feof(fp)) + if(status < 0 || vfs_feof(fp)) return -1; else return pos;
--- a/Plugins/General/scrobbler/tags/include/ape.h Thu Mar 09 09:55:56 2006 -0800 +++ b/Plugins/General/scrobbler/tags/include/ape.h Thu Mar 09 19:03:27 2006 -0800 @@ -20,6 +20,10 @@ #ifndef APE_H #define APE_H 1 + +#include <libaudacious/vfs.h> + + typedef struct { unsigned int len;
--- a/Plugins/General/scrobbler/tags/include/bmp_vfs.h Thu Mar 09 09:55:56 2006 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ -#ifndef TAG_BMP_VFS_H -#define TAG_BMP_VFS_H 1 -#include <libaudacious/vfs.h> -#define fopen(fp, set) vfs_fopen(fp, set); feof_ctr = 1 -#define fclose(fp) vfs_fclose(fp); feof_ctr = 0 -#define fread feof_ctr = vfs_fread -#define fwrite vfs_fwrite -#define fseek vfs_fseek -#define ftell vfs_ftell -#define feof(fp) feof_ctr == 0 -#define ferror(fp) feof_ctr == 0 -#define FILE VFSFile - -/* BMP VFS does not have vfs_feof, so we have a makeshift method. */ - -static size_t feof_ctr; - -#endif
--- a/Plugins/General/scrobbler/tags/include/id3v2.h Thu Mar 09 09:55:56 2006 -0800 +++ b/Plugins/General/scrobbler/tags/include/id3v2.h Thu Mar 09 19:03:27 2006 -0800 @@ -21,6 +21,8 @@ #ifndef ID3V2_H #define ID3V2_H 1 +#include <libaudacious/vfs.h> + typedef struct { int frameid, len;
--- a/Plugins/General/scrobbler/tags/include/itunes.h Thu Mar 09 09:55:56 2006 -0800 +++ b/Plugins/General/scrobbler/tags/include/itunes.h Thu Mar 09 19:03:27 2006 -0800 @@ -20,6 +20,9 @@ #ifndef ITUNES_H #define ITUNES_H 1 + +#include <libaudacious/vfs.h> + typedef struct { unsigned char *title, *artist, *album, *genre, *year, *copyright,
--- a/Plugins/General/scrobbler/tags/include/vorbis.h Thu Mar 09 09:55:56 2006 -0800 +++ b/Plugins/General/scrobbler/tags/include/vorbis.h Thu Mar 09 19:03:27 2006 -0800 @@ -21,6 +21,8 @@ #ifndef VORBIS_H #define VORBIS_H 1 +#include <libaudacious/vfs.h> + #define READ_VORBIS 1 #define READ_FLAC 2 #define READ_OGGFLAC 3
--- a/Plugins/General/scrobbler/tags/include/wma.h Thu Mar 09 09:55:56 2006 -0800 +++ b/Plugins/General/scrobbler/tags/include/wma.h Thu Mar 09 19:03:27 2006 -0800 @@ -20,6 +20,9 @@ #ifndef WMA_H #define WMA_H 1 + +#include <libaudacious/vfs.h> + typedef struct { unsigned char *data, *name;
--- a/Plugins/General/scrobbler/tags/itunes.c Thu Mar 09 09:55:56 2006 -0800 +++ b/Plugins/General/scrobbler/tags/itunes.c Thu Mar 09 19:03:27 2006 -0800 @@ -21,7 +21,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "include/bmp_vfs.h" + #include "include/itunes.h" #include "include/endian.h" #include "../fmt.h" @@ -181,17 +181,17 @@ tag_buffer = realloc(tag_buffer, atom_size); vfs_fread(tag_buffer, 1, atom_size, fp); /* Now keep skipping until we hit a moov container atom */ - while(!feof(fp)) + while(!vfs_feof(fp)) { vfs_fread(cToInt, 1, 4, fp); atom_size = be2int(cToInt) - 4; tag_buffer = realloc(tag_buffer, atom_size); - pos = ftell(fp); + pos = vfs_ftell(fp); vfs_fread(tag_buffer, 1, atom_size, fp); if(!strncmp((char*)tag_buffer, "moov", 4)) break; } - if(feof(fp)) + if(vfs_feof(fp)) { free(tag_buffer); return -1;
--- a/Plugins/General/scrobbler/tags/vorbis.c Thu Mar 09 09:55:56 2006 -0800 +++ b/Plugins/General/scrobbler/tags/vorbis.c Thu Mar 09 19:03:27 2006 -0800 @@ -21,7 +21,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "include/bmp_vfs.h" + #include "include/vorbis.h" #include "include/endian.h" #include "../fmt.h" @@ -34,7 +34,7 @@ vorbis_t *comments = calloc(sizeof(vorbis_t), 1); unsigned char cToInt[4]; int i, lines, j = 0; - + vfs_fread(cToInt, 1, 4, fp); comments->vendorlen = le2int(cToInt); comments->vendor = malloc(comments->vendorlen); @@ -111,14 +111,14 @@ vorbis_type = *bp; if(vorbis_type == 0x03) { - pos = ftell(fp) - pagelen + + pos = vfs_ftell(fp) - pagelen + (bp - tag_buffer); status = 1; } } bp += lacing[i++]; } - if(status == 1 || feof(fp)) + if(status == 1 || vfs_feof(fp)) { free(lacing); break; @@ -131,7 +131,7 @@ free(tag_buffer); - if(feof(fp)) + if(vfs_feof(fp)) return -1; else return pos; @@ -152,7 +152,7 @@ return 1; else if((tag_id[0] & 0x80) == 0x80) return 0; - else if(feof(fp)) + else if(vfs_feof(fp)) return 0; else { @@ -200,7 +200,7 @@ { if((bp[0] & 0x7F) == 4) { - pos = ftell(fp) - pagelen + + pos = vfs_ftell(fp) - pagelen + (bp - tag_buffer); status = 1; } @@ -213,7 +213,7 @@ else bp += lacing[i++]; } - if(status == 1 || feof(fp)) + if(status == 1 || vfs_feof(fp)) break; tag_buffer = realloc(tag_buffer, 27); vfs_fread(tag_buffer, 1, 27, fp); @@ -223,7 +223,7 @@ free(tag_buffer); - if(feof(fp)) + if(vfs_feof(fp)) return -1; else return pos; @@ -262,12 +262,12 @@ segments = *bp; lacing = realloc(lacing, segments); vfs_fread(lacing, 1, segments, fp); - pos = ftell(fp); + pos = vfs_ftell(fp); free(tag_buffer); free(lacing); - if(feof(fp)) + if(vfs_feof(fp)) return -1; else return pos;
--- a/Plugins/General/scrobbler/tags/wma.c Thu Mar 09 09:55:56 2006 -0800 +++ b/Plugins/General/scrobbler/tags/wma.c Thu Mar 09 19:03:27 2006 -0800 @@ -21,7 +21,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "include/bmp_vfs.h" + #include "include/wma.h" #include "include/endian.h" #include "../fmt.h"
--- a/libaudacious/vfs.h Thu Mar 09 09:55:56 2006 -0800 +++ b/libaudacious/vfs.h Thu Mar 09 19:03:27 2006 -0800 @@ -29,10 +29,11 @@ gint whence); void vfs_rewind(VFSFile * file); glong vfs_ftell(VFSFile * file); +gboolean vfs_feof(VFSFile * file); gboolean vfs_file_test(const gchar * path, GFileTest test); - + gboolean vfs_is_writeable(const gchar * path); gboolean vfs_truncate(VFSFile * file, glong length);
--- a/libaudacious/vfs_gnome.c Thu Mar 09 09:55:56 2006 -0800 +++ b/libaudacious/vfs_gnome.c Thu Mar 09 19:03:27 2006 -0800 @@ -21,6 +21,7 @@ struct _VFSFile { GnomeVFSHandle *handle; + gboolean eof; }; @@ -52,6 +53,7 @@ return NULL; file = g_new(VFSFile, 1); + file->eof = FALSE; mode_to_gnome_vfs(mode, &g_mode, &truncate, &append); gchar *escaped_file = gnome_vfs_escape_path_string(path); @@ -119,10 +121,13 @@ result = gnome_vfs_read(file->handle, ptr, size * nmemb, &bytes_read); if (result == GNOME_VFS_OK) return bytes_read; - if (result == GNOME_VFS_ERROR_EOF) + + if (result == GNOME_VFS_ERROR_EOF) { + file->eof = TRUE; return 0; - else - return -1; + } + + return -1; } size_t @@ -193,6 +198,12 @@ } gboolean +vfs_feof(VFSFile * file) +{ + return file->eof; +} + +gboolean vfs_file_test(const gchar * path, GFileTest test) {
--- a/libaudacious/vfs_stdio.c Thu Mar 09 09:55:56 2006 -0800 +++ b/libaudacious/vfs_stdio.c Thu Mar 09 19:03:27 2006 -0800 @@ -107,6 +107,12 @@ } gboolean +vfs_feof(VFSFile * file) +{ + return (gboolean)feof(file->handle); +} + +gboolean vfs_file_test(const gchar * path, GFileTest test) { return g_file_test(path, test);