Mercurial > audlegacy
annotate audacious/vfs_common.c @ 2195:1c4ac61fd5fa trunk
[svn] - update Polish translation care of it's maintainer
author | nenolod |
---|---|
date | Fri, 22 Dec 2006 05:37:06 -0800 |
parents | e0e50e151bab |
children |
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 |
2059 | 21 /** |
22 * vfs_fputc: | |
23 * @c: A character to write to the stream. | |
24 * @stream: A #VFSFile object representing the stream. | |
25 * | |
26 * Writes a character to a stream. | |
27 * | |
28 * Return value: The character on success, or EOF. | |
29 **/ | |
1669
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
30 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
|
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 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
|
33 |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
34 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
|
35 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
|
36 } |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
37 |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
38 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
|
39 } |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
40 |
2059 | 41 /** |
42 * vfs_fgets: | |
43 * @s: A buffer to put the string in. | |
44 * @n: The amount of characters to read. | |
45 * @stream: A #VFSFile object representing the stream. | |
46 * | |
47 * Reads a set of characters from a stream. | |
48 * | |
49 * Return value: The string on success, or NULL. | |
50 **/ | |
1617 | 51 gchar *vfs_fgets(gchar *s, gint n, VFSFile *stream) |
52 { | |
53 gint c; | |
54 register gchar *p; | |
55 | |
56 if(n<=0) return NULL; | |
57 | |
58 p = s; | |
59 | |
60 while (--n) { | |
61 if ((c = vfs_getc(stream))== EOF) { | |
62 break; | |
63 } | |
64 if ((*p++ = c) == '\n') { | |
65 break; | |
66 } | |
67 } | |
68 if (p > s) { | |
69 *p = 0; | |
70 return s; | |
71 } | |
72 | |
73 return NULL; | |
74 } | |
1669
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
75 |
2059 | 76 /** |
77 * vfs_fputc: | |
78 * @s: A string to write to the stream. | |
79 * @stream: A #VFSFile object representing the stream. | |
80 * | |
81 * Writes a string to a VFS stream. | |
82 * | |
83 * Return value: The amount of bytes written. | |
84 **/ | |
1669
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
85 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
|
86 { |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
87 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
|
88 |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
89 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
|
90 } |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
91 |
2059 | 92 /** |
93 * vfs_vfprintf: | |
94 * @stream: A #VFSFile object representing the stream. | |
95 * @format: A printf-style format string. | |
96 * @args: A va_list of args to use. | |
97 * | |
98 * Writes a formatted string to a VFS stream via a va_list of args. | |
99 * | |
100 * Return value: The amount of bytes written. | |
101 **/ | |
1669
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
102 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
|
103 { |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
104 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
|
105 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
|
106 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
|
107 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
|
108 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
|
109 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
|
110 } |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
111 |
2059 | 112 /** |
113 * vfs_fprintf: | |
114 * @stream: A #VFSFile object representing the stream. | |
115 * @format: A printf-style format string. | |
2060 | 116 * @...: A list of args to use. |
2059 | 117 * |
118 * Writes a formatted string to a VFS stream. | |
119 * | |
120 * Return value: The amount of bytes written. | |
121 **/ | |
1669
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
122 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
|
123 { |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
124 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
|
125 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
|
126 |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
127 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
|
128 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
|
129 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
|
130 |
07143b97314d
[svn] fprintf implementation in the VFS common layer by Luca Barbato. Use it in the Container plugins.
chainsaw
parents:
1617
diff
changeset
|
131 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
|
132 } |