2
* Copyright (c) 2009 William Pitcock
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program 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
12
* GNU 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
#include <audacious/plugin.h>
21
#ifdef HAVE_INTTYPES_H
27
VFSFile *(*vfs_fopen_impl)(const gchar *path, const gchar *mode) = NULL;
28
gint (*vfs_fclose_impl)(VFSFile * file) = NULL;
29
gsize (*vfs_fread_impl)(gpointer ptr, gsize size, gsize nmemb, VFSFile *file) = NULL;
30
gsize (*vfs_fwrite_impl)(gconstpointer ptr, gsize size, gsize nmemb, VFSFile *file) = NULL;
31
gint (*vfs_getc_impl)(VFSFile *stream) = NULL;
32
gint (*vfs_ungetc_impl)(gint c, VFSFile *stream) = NULL;
33
gint (*vfs_fseek_impl)(VFSFile *file, glong offset, gint whence) = NULL;
34
void (*vfs_rewind_impl)(VFSFile *file) = NULL;
35
glong (*vfs_ftell_impl)(VFSFile *file) = NULL;
36
gboolean (*vfs_feof_impl)(VFSFile *file) = NULL;
37
gboolean (*vfs_truncate_impl)(VFSFile *file, glong length) = NULL;
38
off_t (*vfs_fsize_impl)(VFSFile *file) = NULL;
41
vt_vfs_fopen_impl(const gchar *path, const gchar *mode)
45
ret = vfs_fopen_impl(path, mode);
46
g_print("%p fopen : path:%s : mode:%s : ret:%p\n", ret, path, mode, ret);
52
vt_vfs_fclose_impl(VFSFile *file)
56
ret = vfs_fclose_impl(file);
57
g_print("%p fclose : file:%p : ret:%d\n", file, file, ret);
63
vt_vfs_fread_impl(gpointer ptr, gsize size, gsize nmemb, VFSFile *file)
67
ret = vfs_fread_impl(ptr, size, nmemb, file);
68
g_print("%p fread : size:%" PRIu64 " : nmemb:%" PRIu64 " : ret:%" PRIu64 "\n",
69
file, (guint64) size, (guint64) nmemb, (guint64) ret);
75
vt_vfs_fwrite_impl(gconstpointer ptr, gsize size, gsize nmemb, VFSFile *file)
79
ret = vfs_fwrite_impl(ptr, size, nmemb, file);
80
g_print("%p fwrite : size:%" PRIu64 " : nmemb:%" PRIu64 " : ret:%" PRIu64 "\n",
81
file, (guint64) size, (guint64) nmemb, (guint64) ret);
87
vt_vfs_getc_impl(VFSFile *stream)
91
ret = vfs_getc_impl(stream);
92
g_print("%p getc : ret:%d\n", stream, ret);
98
vt_vfs_ungetc_impl(gint c, VFSFile *stream)
102
ret = vfs_ungetc_impl(c, stream);
103
g_print("%p ungetc : c:%d : ret:%d\n", stream, c, ret);
109
vt_vfs_fseek_impl(VFSFile *file, glong offset, gint whence)
113
ret = vfs_fseek_impl(file, offset, whence);
114
g_print("%p fseek : offset:%ld : whence:%d : ret:%d\n", file, offset, whence, ret);
120
vt_vfs_rewind_impl(VFSFile *file)
122
vfs_rewind_impl(file);
123
g_print("%p rewind\n", file);
127
vt_vfs_ftell_impl(VFSFile *file)
131
ret = vfs_ftell_impl(file);
132
g_print("%p ftell : ret:%ld\n", file, ret);
138
vt_vfs_feof_impl(VFSFile *file)
142
ret = vfs_feof_impl(file);
143
g_print("%p feof : ret:%d\n", file, ret);
149
vt_vfs_truncate_impl(VFSFile *file, glong length)
153
ret = vfs_truncate_impl(file, length);
154
g_print("%p truncate : length:%ld : ret:%d\n", file, length, ret);
160
vt_vfs_fsize_impl(VFSFile *file)
164
ret = vfs_fsize_impl(file);
165
g_print("%p fsize : ret:%lu\n", file, ret);
173
vfs_fopen_impl = aud_vfs_fopen;
174
vfs_fclose_impl = aud_vfs_fclose;
175
vfs_fread_impl = aud_vfs_fread;
176
vfs_fwrite_impl = aud_vfs_fwrite;
177
vfs_getc_impl = aud_vfs_getc;
178
vfs_ungetc_impl = aud_vfs_ungetc;
179
vfs_fseek_impl = aud_vfs_fseek;
180
vfs_rewind_impl = aud_vfs_rewind;
181
vfs_ftell_impl = aud_vfs_ftell;
182
vfs_feof_impl = aud_vfs_feof;
183
vfs_truncate_impl = aud_vfs_truncate;
184
vfs_fsize_impl = aud_vfs_fsize;
186
aud_vfs_fopen = vt_vfs_fopen_impl;
187
aud_vfs_fclose = vt_vfs_fclose_impl;
188
aud_vfs_fread = vt_vfs_fread_impl;
189
aud_vfs_fwrite = vt_vfs_fwrite_impl;
190
aud_vfs_getc = vt_vfs_getc_impl;
191
aud_vfs_ungetc = vt_vfs_ungetc_impl;
192
aud_vfs_fseek = vt_vfs_fseek_impl;
193
aud_vfs_rewind = vt_vfs_rewind_impl;
194
aud_vfs_ftell = vt_vfs_ftell_impl;
195
aud_vfs_feof = vt_vfs_feof_impl;
196
aud_vfs_truncate = vt_vfs_truncate_impl;
197
aud_vfs_fsize = vt_vfs_fsize_impl;
203
aud_vfs_fopen = vfs_fopen_impl;
204
aud_vfs_fclose = vfs_fclose_impl;
205
aud_vfs_fread = vfs_fread_impl;
206
aud_vfs_fwrite = vfs_fwrite_impl;
207
aud_vfs_getc = vfs_getc_impl;
208
aud_vfs_ungetc = vfs_ungetc_impl;
209
aud_vfs_fseek = vfs_fseek_impl;
210
aud_vfs_rewind = vfs_rewind_impl;
211
aud_vfs_ftell = vfs_ftell_impl;
212
aud_vfs_feof = vfs_feof_impl;
213
aud_vfs_truncate = vfs_truncate_impl;
214
aud_vfs_fsize = vfs_fsize_impl;
217
static GeneralPlugin vfstrace_plugin =
219
.description = "VFSTrace",
221
.cleanup = unpatch_vfs,
224
GeneralPlugin *vfstrace_gplist[] = { &vfstrace_plugin, NULL };
225
SIMPLE_GENERAL_PLUGIN(vfstrace, vfstrace_gplist);