Mercurial > hg > dmlib
changeset 819:0177d4a66d48
Split dmGetFormatByExt() to dmGetC64FormatByExt().
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 16 May 2014 20:08:39 +0300 |
parents | a6452b575c63 |
children | e3fa646aef0d |
files | tools/gfxconv.c |
diffstat | 1 files changed, 27 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/tools/gfxconv.c Fri May 16 20:07:38 2014 +0300 +++ b/tools/gfxconv.c Fri May 16 20:08:39 2014 +0300 @@ -247,6 +247,29 @@ } +BOOL dmGetC64FormatByExt(const char *fext, int *format, int *subformat) +{ + int i; + if (fext == NULL) + return FALSE; + + for (i = 0; i < ndmC64ImageFormats; i++) + { + const DMC64ImageFormat *fmt = &dmC64ImageFormats[i]; + if (fmt->fext != NULL && + strcasecmp(fext, fmt->fext) == 0) + { + *format = FFMT_BITMAP; + *subformat = i; + return TRUE; + } + } + + return FALSE; +} + + + BOOL dmGetFormatByExt(const char *fext, int *format, int *subformat) { int i; @@ -265,18 +288,6 @@ } } - for (i = 0; i < ndmC64ImageFormats; i++) - { - const DMC64ImageFormat *fmt = &dmC64ImageFormats[i]; - if (fmt->fext != NULL && - strcasecmp(fext, fmt->fext) == 0) - { - *format = FFMT_BITMAP; - *subformat = i; - return TRUE; - } - } - return FALSE; } @@ -528,7 +539,8 @@ break; case 5: - if (!dmGetFormatByExt(optArg, &optOutFormat, &optOutSubFormat)) + if (!dmGetFormatByExt(optArg, &optOutFormat, &optOutSubFormat) && + !dmGetC64FormatByExt(optArg, &optOutFormat, &optOutSubFormat)) { dmError("Invalid output format '%s'.\n", optArg); return FALSE; @@ -1522,7 +1534,8 @@ dmMsg(4, "Trying to determine file format by extension.\n"); if (dext) { - dmGetFormatByExt(dext + 1, &optInFormat, &optInSubFormat); + if (!dmGetFormatByExt(dext + 1, &optInFormat, &optInSubFormat)) + dmGetC64FormatByExt(dext + 1, &optInFormat, &optInSubFormat); } }