Mercurial > audlegacy
annotate libaudacious/vfs_common.c @ 1922:29d90d3f9680 trunk
[svn] - add feedback when the build_stamp is generated.
author | nenolod |
---|---|
date | Mon, 30 Oct 2006 14:01:32 -0800 |
parents | e9c24e35bd76 |
children | 8aaf0f145578 |
rev | line source |
---|---|
1617 | 1 /* This program is free software; you can redistribute it and/or modify |
2 * it under the terms of the GNU General Public License as published by | |
3 * the Free Software Foundation; either version 2 of the License, or | |
4 * (at your option) any later version. | |
5 * | |
6 * This program is distributed in the hope that it will be useful, | |
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
9 * GNU General Public License for more details. | |
10 * | |
11 * You should have received a copy of the GNU General Public License | |
12 * along with this program; if not, write to the Free Software Foundation, | |
13 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
14 */ | |
15 | |
16 #include "vfs.h" | |
1669
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
17 #include <string.h> |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
18 #include <stdlib.h> |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
19 #include <glib/gprintf.h> |
1617 | 20 |
21 | |
1669
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
22 gint vfs_fputc(gint c, VFSFile *stream) |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
23 { |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
24 guchar uc = (guchar) c; |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
25 |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
26 if (! vfs_fwrite(&uc, 1, 1, stream)) { |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
27 return EOF; |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
28 } |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
29 |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
30 return uc; |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
31 } |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
32 |
1617 | 33 gchar *vfs_fgets(gchar *s, gint n, VFSFile *stream) |
34 { | |
35 gint c; | |
36 register gchar *p; | |
37 | |
38 if(n<=0) return NULL; | |
39 | |
40 p = s; | |
41 | |
42 while (--n) { | |
43 if ((c = vfs_getc(stream))== EOF) { | |
44 break; | |
45 } | |
46 if ((*p++ = c) == '\n') { | |
47 break; | |
48 } | |
49 } | |
50 if (p > s) { | |
51 *p = 0; | |
52 return s; | |
53 } | |
54 | |
55 return NULL; | |
56 } | |
1669
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
57 |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
58 int vfs_fputs(const gchar *s, VFSFile *stream) |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
59 { |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
60 size_t n = strlen(s); |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
61 |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
62 return ((vfs_fwrite(s, 1, n, stream) == n) ? n : EOF); |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
63 } |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
64 |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
65 int vfs_vfprintf(VFSFile *stream, gchar const *format, va_list args) |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
66 { |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
67 gchar *string; |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
68 gint rv = g_vasprintf(&string, format, args); |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
69 if (rv<0) return rv; |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
70 rv = vfs_fputs(string, stream); |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
71 free (string); |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
72 return rv; |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
73 } |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
74 |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
75 int vfs_fprintf(VFSFile *stream, gchar const *format, ...) |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
76 { |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
77 va_list arg; |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
78 gint rv; |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
79 |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
80 va_start(arg, format); |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
81 rv = vfs_vfprintf(stream, format, arg); |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
82 va_end(arg); |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
83 |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
84 return rv; |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
85 } |