comparison src/xs_support.c @ 955:3c2efa18c422

Change semantics of xs_fread_be{32,16}() functions to match xs_fread_str() and xs_fread_byte() and change the PSID/RSID file parsing for SLDB MD5 calculation to use them. Also, fix the parser so that PSID/RSID v3 files are supported correctly.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 20 Nov 2012 21:28:39 +0200
parents b2caef664524
children 0233c5fd7d5e
comparison
equal deleted inserted replaced
954:a5b118c853f5 955:3c2efa18c422
114 // XXX 114 // XXX
115 #endif 115 #endif
116 } 116 }
117 117
118 118
119 guint16 xs_fread_be16(XSFile *f) 119 gboolean xs_fread_be16(XSFile *f, guint16 *val)
120 { 120 {
121 return (((guint16) xs_fgetc(f)) << 8) | ((guint16) xs_fgetc(f)); 121 guint16 result;
122 } 122 if (xs_fread(&result, sizeof(result), 1, f) != 1)
123 123 return FALSE;
124 124 *val = GUINT16_FROM_BE(result);
125 guint32 xs_fread_be32(XSFile *f) 125 return TRUE;
126 { 126 }
127 return 127
128 (((guint32) xs_fgetc(f)) << 24) | 128
129 (((guint32) xs_fgetc(f)) << 16) | 129 gboolean xs_fread_be32(XSFile *f, guint32 *val)
130 (((guint32) xs_fgetc(f)) << 8) | 130 {
131 ((guint32) xs_fgetc(f)); 131 guint32 result;
132 if (xs_fread(&result, sizeof(result), 1, f) != 1)
133 return FALSE;
134 *val = GUINT32_FROM_BE(result);
135 return TRUE;
132 } 136 }
133 137
134 138
135 /* Load a file to a buffer, return 0 on success, negative value on error 139 /* Load a file to a buffer, return 0 on success, negative value on error
136 */ 140 */