Mercurial > hg > dmlib
comparison src/dmlib.h @ 2404:bcd33c77c605
Cosmetic cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 13 Jan 2020 20:04:54 +0200 |
parents | e149fc273f2b |
children | bc05bcfc4598 |
comparison
equal
deleted
inserted
replaced
2403:6e86a048a760 | 2404:bcd33c77c605 |
---|---|
392 } | 392 } |
393 | 393 |
394 | 394 |
395 /* Global variables | 395 /* Global variables |
396 */ | 396 */ |
397 extern char *dmProgName, | 397 extern char |
398 *dmProgDesc, | 398 *dmProgName, |
399 *dmProgVersion, | 399 *dmProgDesc, |
400 *dmProgAuthor, | 400 *dmProgVersion, |
401 *dmProgLicense; | 401 *dmProgAuthor, |
402 *dmProgLicense; | |
403 | |
402 | 404 |
403 extern int dmVerbosity; | 405 extern int dmVerbosity; |
404 void dmInitProg(char *name, char *desc, char *version, char *author, char *license); | 406 void dmInitProg(char *name, char *desc, char *version, char *author, char *license); |
405 void dmPrintBanner(FILE *outFile, const char *name, const char *usage); | 407 void dmPrintBanner(FILE *outFile, const char *name, const char *usage); |
406 | 408 |
418 DM_ATTR_PRINTF_FMT(1, 2); | 420 DM_ATTR_PRINTF_FMT(1, 2); |
419 int dmGetErrno(); | 421 int dmGetErrno(); |
420 const char *dmErrorStr(const int error); | 422 const char *dmErrorStr(const int error); |
421 | 423 |
422 #ifdef DM_DEBUG | 424 #ifdef DM_DEBUG |
423 # define dmErrorDBG dmError | 425 # define dmErrorDBG dmError |
424 # define dmErrorDBGMsg dmErrorMsg | 426 # define dmErrorDBGMsg dmErrorMsg |
425 #else | 427 #else |
426 # define dmErrorDBG(ecode, fmt, ...) (ecode) // Dummy | 428 # define dmErrorDBG(ecode, fmt, ...) (ecode) // Dummy |
427 # define dmErrorDBGMsg(fmt, ...) | 429 # define dmErrorDBGMsg(fmt, ...) |
428 #endif | 430 #endif |
429 | 431 |
430 void * dmMalloc(size_t len); | 432 void * dmMalloc(size_t len); |
431 void * dmMalloc0(size_t len); | 433 void * dmMalloc0(size_t len); |
432 void * dmRealloc(void *ptr, size_t len); | 434 void * dmRealloc(void *ptr, size_t len); |
452 DM_TRIM_START = 1, | 454 DM_TRIM_START = 1, |
453 DM_TRIM_END = 2, | 455 DM_TRIM_END = 2, |
454 DM_TRIM_BOTH = 3 | 456 DM_TRIM_BOTH = 3 |
455 }; | 457 }; |
456 | 458 |
457 | |
458 | |
459 char * dm_strdup(const char *str); | 459 char * dm_strdup(const char *str); |
460 char * dm_strndup(const char *str, const size_t n); | 460 char * dm_strndup(const char *str, const size_t n); |
461 char * dm_strdup_trim(const char *src, const int flags); | 461 char * dm_strdup_trim(const char *src, const int flags); |
462 char * dm_strndup_trim(const char *src, const size_t n, const int flags); | 462 char * dm_strndup_trim(const char *src, const size_t n, const int flags); |
463 char * dm_strdup_vprintf_len(const char *fmt, va_list args, int *len); | 463 char * dm_strdup_vprintf_len(const char *fmt, va_list args, int *len); |
488 int cr_line; | 488 int cr_line; |
489 SDL_mutex *m; | 489 SDL_mutex *m; |
490 DMMutexLock locks[8]; | 490 DMMutexLock locks[8]; |
491 } DMMutex; | 491 } DMMutex; |
492 | 492 |
493 #define dmMutexLock(x) dmDOMutexLock(x, __FILE__, (int) __LINE__) | 493 # define dmMutexLock(x) dmDOMutexLock(x, __FILE__, (int) __LINE__) |
494 #define dmMutexUnlock(x) dmDOMutexUnlock(x, __FILE__, (int) __LINE__) | 494 # define dmMutexUnlock(x) dmDOMutexUnlock(x, __FILE__, (int) __LINE__) |
495 #define dmCreateMutex(x) dmDOCreateMutex(__FILE__, (int) __LINE__) | 495 # define dmCreateMutex(x) dmDOCreateMutex(__FILE__, (int) __LINE__) |
496 | 496 |
497 int dmDOMutexLock(DMMutex *mutex, const char *file, const int line); | 497 int dmDOMutexLock(DMMutex *mutex, const char *file, const int line); |
498 int dmDOMutexUnlock(DMMutex *mutex, const char *file, const int line); | 498 int dmDOMutexUnlock(DMMutex *mutex, const char *file, const int line); |
499 DMMutex * dmDOCreateMutex(const char *file, const int line); | 499 DMMutex * dmDOCreateMutex(const char *file, const int line); |
500 void dmDestroyMutex(DMMutex *mutex); | 500 void dmDestroyMutex(DMMutex *mutex); |
501 | 501 |
502 #else | 502 #else |
503 #define DMMutex SDL_mutex | 503 # define DMMutex SDL_mutex |
504 #define dmCreateMutex() SDL_CreateMutex() | 504 # define dmCreateMutex() SDL_CreateMutex() |
505 #define dmDestroyMutex(x) SDL_DestroyMutex(x) | 505 # define dmDestroyMutex(x) SDL_DestroyMutex(x) |
506 #define dmMutexLock(x) SDL_mutexP(x) | 506 # define dmMutexLock(x) SDL_mutexP(x) |
507 #define dmMutexUnlock(x) SDL_mutexV(x) | 507 # define dmMutexUnlock(x) SDL_mutexV(x) |
508 #endif | 508 #endif |
509 | |
509 | 510 |
510 /* Endianess swapping macros | 511 /* Endianess swapping macros |
511 */ | 512 */ |
512 #define DM_SWAP_16_LE_BE(value) ((Uint16) ( \ | 513 #define DM_SWAP_16_LE_BE(value) ((Uint16) ( \ |
513 (Uint16) ((Uint16) (value) >> 8) | \ | 514 (Uint16) ((Uint16) (value) >> 8) | \ |