Mercurial > audlegacy-plugins
annotate src/adplug/core/binio_virtual.h @ 2138:76f9a4168708
Fix linking with libaudid3tag
Linking with libaudid3tag from /usr/lib/audacious, add rpath (affected to tta,
shnplug and madplug plugins)
| author | Vitaly Lipatov <lav@etersoft.ru> |
|---|---|
| date | Sat, 27 Oct 2007 19:34:46 -0500 |
| parents | 6055af71fe07 |
| children | 3134a0987162 |
| rev | line source |
|---|---|
|
339
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
1 /* |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
2 * Copyright (c) 2006 William Pitcock <nenolod -at- atheme.org> |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
3 * This code is in the public domain. |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
4 */ |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
5 |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
6 #ifndef __BINIO_VIRTUAL__ |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
7 #define __BINIO_VIRTUAL__ |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
8 |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
9 #include <binio.h> |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
10 #include <binstr.h> |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
11 |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
12 #include <string> |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
13 |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
14 #include <glib.h> |
|
1991
b0ff8640f338
Make it compile again
Christian Birchinger <joker@netswarm.net>
parents:
1978
diff
changeset
|
15 |
|
b0ff8640f338
Make it compile again
Christian Birchinger <joker@netswarm.net>
parents:
1978
diff
changeset
|
16 extern "C" { |
|
1992
6055af71fe07
It's plugin.h not vfs.h
Christian Birchinger <joker@netswarm.net>
parents:
1991
diff
changeset
|
17 #include <audacious/plugin.h> |
|
1991
b0ff8640f338
Make it compile again
Christian Birchinger <joker@netswarm.net>
parents:
1978
diff
changeset
|
18 }; |
|
339
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
19 |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
20 class vfsistream : public binistream, virtual public binio { |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
21 private: |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
22 VFSFile *fd; |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
23 |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
24 public: |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
25 vfsistream() {}; |
| 703 | 26 ~vfsistream() {}; |
| 27 | |
| 28 vfsistream(VFSFile *fd) { | |
| 29 this->fd = fd; | |
| 30 }; | |
|
339
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
31 |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
32 vfsistream(const char *file) { |
| 1978 | 33 this->fd = aud_vfs_fopen(file, "rb"); |
|
339
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
34 }; |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
35 |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
36 vfsistream(std::string &file) { |
| 1978 | 37 this->fd = aud_vfs_fopen(file.c_str(), "rb"); |
|
339
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
38 }; |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
39 |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
40 void open(const char *file) { |
| 1978 | 41 this->fd = aud_vfs_fopen(file, "rb"); |
|
339
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
42 }; |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
43 |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
44 void open(std::string &file) { |
| 1978 | 45 this->fd = aud_vfs_fopen(file.c_str(), "rb"); |
|
339
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
46 }; |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
47 |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
48 // XXX: this sucks because binio won't let us do sanity checking |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
49 Byte getByte(void) { |
| 1978 | 50 int c = aud_vfs_getc(this->fd); |
|
352
7fc7b66c8a53
[svn] - you know, it'd help if binio were better documented.
nenolod
parents:
339
diff
changeset
|
51 |
|
7fc7b66c8a53
[svn] - you know, it'd help if binio were better documented.
nenolod
parents:
339
diff
changeset
|
52 if (c == EOF) err |= Eof; |
|
7fc7b66c8a53
[svn] - you know, it'd help if binio were better documented.
nenolod
parents:
339
diff
changeset
|
53 |
|
7fc7b66c8a53
[svn] - you know, it'd help if binio were better documented.
nenolod
parents:
339
diff
changeset
|
54 return (Byte) c; |
|
339
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
55 }; |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
56 |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
57 void seek(long pos, Offset offs = Set) { |
|
352
7fc7b66c8a53
[svn] - you know, it'd help if binio were better documented.
nenolod
parents:
339
diff
changeset
|
58 switch (offs) |
|
7fc7b66c8a53
[svn] - you know, it'd help if binio were better documented.
nenolod
parents:
339
diff
changeset
|
59 { |
|
7fc7b66c8a53
[svn] - you know, it'd help if binio were better documented.
nenolod
parents:
339
diff
changeset
|
60 case Add: |
| 1978 | 61 aud_vfs_fseek(this->fd, pos, SEEK_CUR); |
|
352
7fc7b66c8a53
[svn] - you know, it'd help if binio were better documented.
nenolod
parents:
339
diff
changeset
|
62 break; |
|
7fc7b66c8a53
[svn] - you know, it'd help if binio were better documented.
nenolod
parents:
339
diff
changeset
|
63 case End: |
| 1978 | 64 aud_vfs_fseek(this->fd, pos, SEEK_END); |
|
352
7fc7b66c8a53
[svn] - you know, it'd help if binio were better documented.
nenolod
parents:
339
diff
changeset
|
65 break; |
|
7fc7b66c8a53
[svn] - you know, it'd help if binio were better documented.
nenolod
parents:
339
diff
changeset
|
66 case Set: |
|
7fc7b66c8a53
[svn] - you know, it'd help if binio were better documented.
nenolod
parents:
339
diff
changeset
|
67 default: |
| 1978 | 68 aud_vfs_fseek(this->fd, pos, SEEK_SET); |
|
352
7fc7b66c8a53
[svn] - you know, it'd help if binio were better documented.
nenolod
parents:
339
diff
changeset
|
69 break; |
|
7fc7b66c8a53
[svn] - you know, it'd help if binio were better documented.
nenolod
parents:
339
diff
changeset
|
70 } |
|
7fc7b66c8a53
[svn] - you know, it'd help if binio were better documented.
nenolod
parents:
339
diff
changeset
|
71 |
|
339
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
72 } |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
73 |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
74 long pos(void) { |
| 1978 | 75 return aud_vfs_ftell(this->fd); |
|
339
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
76 } |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
77 }; |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
78 |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
79 // XXX: binio sucks and doesn't let us just combine the two. |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
80 class vfsostream : public binostream, virtual public binio { |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
81 private: |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
82 VFSFile *fd; |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
83 |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
84 public: |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
85 vfsostream() {}; |
| 703 | 86 ~vfsostream() {}; |
| 87 | |
| 88 vfsostream(VFSFile *fd) { | |
| 89 this->fd = fd; | |
| 90 }; | |
|
339
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
91 |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
92 vfsostream(const char *file) { |
| 1978 | 93 this->fd = aud_vfs_fopen(file, "wb"); |
|
339
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
94 }; |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
95 |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
96 vfsostream(std::string &file) { |
| 1978 | 97 this->fd = aud_vfs_fopen(file.c_str(), "wb"); |
|
339
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
98 }; |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
99 |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
100 void open(const char *file) { |
| 1978 | 101 this->fd = aud_vfs_fopen(file, "wb"); |
|
339
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
102 }; |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
103 |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
104 void open(std::string &file) { |
| 1978 | 105 this->fd = aud_vfs_fopen(file.c_str(), "wb"); |
|
339
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
106 }; |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
107 |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
108 // XXX: this sucks because binio won't let us do sanity checking |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
109 void putByte(Byte b) { |
| 1978 | 110 aud_vfs_fwrite(&b, 1, 1, this->fd); |
|
339
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
111 }; |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
112 |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
113 void seek(long pos, Offset offs = Set) { |
|
352
7fc7b66c8a53
[svn] - you know, it'd help if binio were better documented.
nenolod
parents:
339
diff
changeset
|
114 switch (offs) |
|
7fc7b66c8a53
[svn] - you know, it'd help if binio were better documented.
nenolod
parents:
339
diff
changeset
|
115 { |
|
7fc7b66c8a53
[svn] - you know, it'd help if binio were better documented.
nenolod
parents:
339
diff
changeset
|
116 case Add: |
| 1978 | 117 aud_vfs_fseek(this->fd, pos, SEEK_CUR); |
|
352
7fc7b66c8a53
[svn] - you know, it'd help if binio were better documented.
nenolod
parents:
339
diff
changeset
|
118 break; |
|
7fc7b66c8a53
[svn] - you know, it'd help if binio were better documented.
nenolod
parents:
339
diff
changeset
|
119 case End: |
| 1978 | 120 aud_vfs_fseek(this->fd, pos, SEEK_END); |
|
352
7fc7b66c8a53
[svn] - you know, it'd help if binio were better documented.
nenolod
parents:
339
diff
changeset
|
121 break; |
|
7fc7b66c8a53
[svn] - you know, it'd help if binio were better documented.
nenolod
parents:
339
diff
changeset
|
122 case Set: |
|
7fc7b66c8a53
[svn] - you know, it'd help if binio were better documented.
nenolod
parents:
339
diff
changeset
|
123 default: |
| 1978 | 124 aud_vfs_fseek(this->fd, pos, SEEK_SET); |
|
352
7fc7b66c8a53
[svn] - you know, it'd help if binio were better documented.
nenolod
parents:
339
diff
changeset
|
125 break; |
|
7fc7b66c8a53
[svn] - you know, it'd help if binio were better documented.
nenolod
parents:
339
diff
changeset
|
126 } |
|
7fc7b66c8a53
[svn] - you know, it'd help if binio were better documented.
nenolod
parents:
339
diff
changeset
|
127 |
|
339
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
128 } |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
129 |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
130 long pos(void) { |
| 1978 | 131 return aud_vfs_ftell(this->fd); |
|
339
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
132 } |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
133 }; |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
134 |
|
d19ac60697ec
[svn] - implement virtual class to use VFS through binio
nenolod
parents:
diff
changeset
|
135 #endif |
