Mercurial > hg > dmlib
comparison src/dmres.c @ 1885:e69de47d2419
Implement resource helper functions dmfprintf() and dmvfprintf().
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 25 Jun 2018 13:24:50 +0300 |
parents | 08b0cbadbc45 |
children | a137e49e9f0d |
comparison
equal
deleted
inserted
replaced
1884:47fe47f01fea | 1885:e69de47d2419 |
---|---|
1261 } | 1261 } |
1262 | 1262 |
1263 | 1263 |
1264 /* Helper resource access routines | 1264 /* Helper resource access routines |
1265 */ | 1265 */ |
1266 int dmvfprintf(DMResource *fh, const char *fmt, va_list ap) | |
1267 { | |
1268 int len; | |
1269 char *str = dm_strdup_vprintf_len(fmt, ap, &len); | |
1270 if (str == NULL) | |
1271 { | |
1272 fh->error = DMERR_MALLOC; | |
1273 return -1; | |
1274 } | |
1275 | |
1276 return dmfwrite(str, 1, len, fh); | |
1277 } | |
1278 | |
1279 | |
1280 int dmfprintf(DMResource *fh, const char *fmt, ...) | |
1281 { | |
1282 int res; | |
1283 va_list ap; | |
1284 | |
1285 va_start(ap, fmt); | |
1286 res = dmvfprintf(fh, fmt, ap); | |
1287 va_end(ap); | |
1288 | |
1289 return res; | |
1290 } | |
1291 | |
1292 | |
1266 BOOL dmf_read_str(DMResource *fh, void *ptr, const size_t len) | 1293 BOOL dmf_read_str(DMResource *fh, void *ptr, const size_t len) |
1267 { | 1294 { |
1268 return dmfread(ptr, len, 1, fh) == 1; | 1295 return dmfread(ptr, len, 1, fh) == 1; |
1269 } | 1296 } |
1270 | 1297 |