Mercurial > hg > dmlib
comparison dmres.c @ 166:112eb95f2fba
Improve build system granularity.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 06 Oct 2012 08:31:37 +0300 |
parents | d5cfd29c87c4 |
children | c6b4fa03744c |
comparison
equal
deleted
inserted
replaced
165:3e8e0dc30711 | 166:112eb95f2fba |
---|---|
5 * (C) Copyright 2003-2012 Tecnic Software productions (TNSP) | 5 * (C) Copyright 2003-2012 Tecnic Software productions (TNSP) |
6 */ | 6 */ |
7 #include "dmres.h" | 7 #include "dmres.h" |
8 #include <time.h> | 8 #include <time.h> |
9 | 9 |
10 #if !defined(DM_USE_PACKFS) && !defined(DM_USE_STDIO) | |
11 #error At least one of DM_USE_PACKFS, DM_USE_STDIO must be defined. | |
12 #endif | |
13 | 10 |
14 #define DMRES_LOCK(x) dmMutexLock(dfResourcesMutex) | 11 #define DMRES_LOCK(x) dmMutexLock(dfResourcesMutex) |
15 #define DMRES_UNLOCK(x) dmMutexUnlock(dfResourcesMutex) | 12 #define DMRES_UNLOCK(x) dmMutexUnlock(dfResourcesMutex) |
16 | 13 |
17 | 14 |
393 | 390 |
394 error: | 391 error: |
395 dmFree(cbuffer); | 392 dmFree(cbuffer); |
396 return res; | 393 return res; |
397 } | 394 } |
398 #endif | 395 |
399 | 396 |
400 | 397 static void dm_pack_fclose(DMResource * f) |
401 static void dm_mem_fclose(DMResource * f) | |
402 { | 398 { |
403 f->dataSize = 0; | 399 f->dataSize = 0; |
404 f->dataOffset = 0; | 400 f->dataOffset = 0; |
405 dmFree(f->data); | 401 dmFree(f->data); |
406 f->data = NULL; | 402 f->data = NULL; |
407 } | 403 } |
404 #endif | |
408 | 405 |
409 | 406 |
410 static int dm_mem_ferror(DMResource * f) | 407 static int dm_mem_ferror(DMResource * f) |
411 { | 408 { |
412 return f->error; | 409 return f->error; |
494 f->dataOffset += length; | 491 f->dataOffset += length; |
495 return nmemb; | 492 return nmemb; |
496 } | 493 } |
497 | 494 |
498 | 495 |
496 #ifdef DM_USE_PACKFS | |
499 DMResourceOps dfPackFileOps = | 497 DMResourceOps dfPackFileOps = |
500 { | 498 { |
501 dm_mem_ferror, | 499 dm_mem_ferror, |
502 dm_mem_fseek, | 500 dm_mem_fseek, |
503 dm_mem_fsize, | 501 dm_mem_fsize, |
507 NULL, | 505 NULL, |
508 dm_mem_fread, | 506 dm_mem_fread, |
509 NULL, | 507 NULL, |
510 | 508 |
511 NULL, | 509 NULL, |
512 dm_mem_fclose, | 510 dm_pack_fclose, |
513 dm_pack_preload | 511 dm_pack_preload |
514 }; | 512 }; |
513 #endif | |
515 | 514 |
516 | 515 |
517 DMResourceOps dfMemIOFileOps = | 516 DMResourceOps dfMemIOFileOps = |
518 { | 517 { |
519 dm_mem_ferror, | 518 dm_mem_ferror, |
549 #else | 548 #else |
550 handle->fops = &dfPackFileOps; | 549 handle->fops = &dfPackFileOps; |
551 #endif | 550 #endif |
552 | 551 |
553 #else | 552 #else |
554 handle->fops = &dfStdioFileOps; | 553 handle->fops = NULL; |
555 #endif | 554 #endif |
556 } | 555 } |
557 } | 556 } |
558 | 557 |
559 | 558 |