comparison src/xs_support.c @ 657:acaba070cf49

Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 02 Apr 2008 19:46:59 +0300
parents a50428d6cc49
children b0743dc9165d
comparison
equal deleted inserted replaced
656:e9257f006f41 657:acaba070cf49
22 */ 22 */
23 #include "xs_support.h" 23 #include "xs_support.h"
24 #include <ctype.h> 24 #include <ctype.h>
25 25
26 26
27 #ifndef __AUDACIOUS_NEWVFS__ 27 guint16 xs_fread_be16(xs_file_t *f)
28 /* File handling
29 */
30 t_xs_file *xs_fopen(const gchar *path, const gchar *mode)
31 {
32 return fopen(path, mode);
33 }
34
35
36 gint xs_fclose(t_xs_file *f)
37 {
38 return fclose(f);
39 }
40
41
42 gint xs_fgetc(t_xs_file *f)
43 {
44 return fgetc(f);
45 }
46
47
48 size_t xs_fread(void *p, size_t s, size_t n, t_xs_file *f)
49 {
50 return fread(p, s, n, f);
51 }
52
53
54 gint xs_feof(t_xs_file *f)
55 {
56 return feof(f);
57 }
58
59
60 gint xs_ferror(t_xs_file *f)
61 {
62 return ferror(f);
63 }
64
65
66 glong xs_ftell(t_xs_file *f)
67 {
68 return ftell(f);
69 }
70
71
72 gint xs_fseek(t_xs_file *f, glong o, gint w)
73 {
74 return fseek(f, o, w);
75 }
76 #endif
77
78
79 guint16 xs_fread_be16(t_xs_file *f)
80 { 28 {
81 return (((guint16) xs_fgetc(f)) << 8) | ((guint16) xs_fgetc(f)); 29 return (((guint16) xs_fgetc(f)) << 8) | ((guint16) xs_fgetc(f));
82 } 30 }
83 31
84 32
85 guint32 xs_fread_be32(t_xs_file *f) 33 guint32 xs_fread_be32(xs_file_t *f)
86 { 34 {
87 return (((guint32) xs_fgetc(f)) << 24) | 35 return (((guint32) xs_fgetc(f)) << 24) |
88 (((guint32) xs_fgetc(f)) << 16) | 36 (((guint32) xs_fgetc(f)) << 16) |
89 (((guint32) xs_fgetc(f)) << 8) | 37 (((guint32) xs_fgetc(f)) << 8) |
90 ((guint32) xs_fgetc(f)); 38 ((guint32) xs_fgetc(f));
91 } 39 }
92 40
93 41
94 /* Load a file to a buffer, return 0 on success, negative value on error 42 /* Load a file to a buffer, return 0 on success, negative value on error
95 */ 43 */
96 gint xs_fload_buffer(const gchar *pcFilename, guint8 **buf, size_t *bufSize) 44 gint xs_fload_buffer(const gchar *filename, guint8 **buf, size_t *bufSize)
97 { 45 {
98 t_xs_file *f; 46 xs_file_t *f;
99 glong seekPos; 47 glong seekPos;
100 48
101 /* Open file, get file size */ 49 /* Open file, get file size */
102 if ((f = xs_fopen(pcFilename, "rb")) == NULL) 50 if ((f = xs_fopen(filename, "rb")) == NULL)
103 return -1; 51 return -1;
104 52
105 xs_fseek(f, 0, SEEK_END); 53 xs_fseek(f, 0, SEEK_END);
106 seekPos = xs_ftell(f); 54 seekPos = xs_ftell(f);
107 55
137 return -4; 85 return -4;
138 } 86 }
139 } 87 }
140 88
141 89
142
143
144
145 /* Copy a string 90 /* Copy a string
146 */ 91 */
147 gchar *xs_strncpy(gchar *pDest, const gchar *pSource, size_t n) 92 gchar *xs_strncpy(gchar *pDest, const gchar *pSource, size_t n)
148 { 93 {
149 const gchar *s; 94 const gchar *s;
296 { 241 {
297 while (pcStr[*piPos] && isdigit(pcStr[*piPos])) 242 while (pcStr[*piPos] && isdigit(pcStr[*piPos]))
298 (*piPos)++; 243 (*piPos)++;
299 } 244 }
300 245
301
302 #ifndef HAVE_MEMSET
303 void *xs_memset(void *p, int c, size_t n)
304 {
305 guint8 *dp;
306
307 dp = (guint8 *) p;
308 while (n--)
309 *(dp++) = c;
310
311 return p;
312 }
313 #endif