X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=contrib%2Fgregbook%2Frpng2-win.c;h=eda176eee335f278aa134a31d566582abf06c94c;hb=refs%2Ftags%2Fupstream%2F1.6.13;hp=9f7ad78dd57021c48a50d595e12a4aa5e0710976;hpb=5ab0f6df7ecb95c9b816ece7a88a8df92b0cb2af;p=platform%2Fupstream%2Flibpng.git diff --git a/contrib/gregbook/rpng2-win.c b/contrib/gregbook/rpng2-win.c index 9f7ad78..eda176e 100644 --- a/contrib/gregbook/rpng2-win.c +++ b/contrib/gregbook/rpng2-win.c @@ -32,6 +32,9 @@ - 2.01: fixed 64-bit typo in readpng2.c - 2.02: fixed improper display of usage screen on PNG error(s); fixed unexpected-EOF and file-read-error cases + - 2.03: removed runtime MMX-enabling/disabling and obsolete -mmx* options + - 2.04: + (GR-P) --------------------------------------------------------------------------- @@ -95,7 +98,33 @@ #include #include /* only for PvdM background code */ #include +#ifdef __CYGWIN__ +/* getch replacement. Turns out, we don't really need this, + * but leave it here if we ever enable any of the uses of + * _getch in the main code + */ +#include +#include +#include +int repl_getch( void ) +{ + char ch; + int fd = fileno(stdin); + struct termio old_tty, new_tty; + + ioctl(fd, TCGETA, &old_tty); + new_tty = old_tty; + new_tty.c_lflag &= ~(ICANON | ECHO | ISIG); + ioctl(fd, TCSETA, &new_tty); + fread(&ch, 1, sizeof(ch), stdin); + ioctl(fd, TCSETA, &old_tty); + + return ch; +} +#define _getch repl_getch +#else #include /* only for _getch() */ +#endif /* all for PvdM background code: */ #ifndef PI @@ -269,7 +298,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode) filename = (char *)NULL; memset(&rpng2_info, 0, sizeof(mainprog_info)); - +#ifndef __CYGWIN__ /* Next reenable console output, which normally goes to the bit bucket * for windowed apps. Closing the console window will terminate the * app. Thanks to David.Geldreich@realviz.com for supplying the magical @@ -278,7 +307,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode) AllocConsole(); freopen("CONOUT$", "a", stderr); freopen("CONOUT$", "a", stdout); - +#endif /* Set the default value for our display-system exponent, i.e., the * product of the CRT exponent and the exponent corresponding to @@ -395,18 +424,6 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode) } } else if (!strncmp(*argv, "-timing", 2)) { timing = TRUE; -#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__)) - } else if (!strncmp(*argv, "-nommxfilters", 7)) { - rpng2_info.nommxfilters = TRUE; - } else if (!strncmp(*argv, "-nommxcombine", 7)) { - rpng2_info.nommxcombine = TRUE; - } else if (!strncmp(*argv, "-nommxinterlace", 7)) { - rpng2_info.nommxinterlace = TRUE; - } else if (!strcmp(*argv, "-nommx")) { - rpng2_info.nommxfilters = TRUE; - rpng2_info.nommxcombine = TRUE; - rpng2_info.nommxinterlace = TRUE; -#endif } else { if (**argv != '-') { filename = *argv; @@ -424,15 +441,14 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode) /* print usage screen if any errors up to this point */ if (error) { +#ifndef __CYGWIN__ int ch; +#endif fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname); readpng2_version_info(); fprintf(stderr, "\n" "Usage: %s [-gamma exp] [-bgcolor bg | -bgpat pat] [-timing]\n" -#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__)) - " %*s [[-nommxfilters] [-nommxcombine] [-nommxinterlace] | -nommx]\n" -#endif " %*s file.png\n\n" " exp \ttransfer-function exponent (``gamma'') of the display\n" "\t\t system in floating-point format (e.g., ``%.1f''); equal\n" @@ -445,21 +461,24 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode) "\t\t transparent images; overrides -bgcolor option\n" " -timing\tenables delay for every block read, to simulate modem\n" "\t\t download of image (~36 Kbps)\n" -#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__)) - " -nommx*\tdisable optimized MMX routines for decoding row filters,\n" - "\t\t combining rows, and expanding interlacing, respectively\n" -#endif "\nPress Q, Esc or mouse button 1 after image is displayed to quit.\n" +#ifndef __CYGWIN__ "Press Q or Esc to quit this usage screen. ", +#else + , +#endif PROGNAME, -#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__)) +#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__)) && \ + !(defined(__CYGWIN__) || defined(__MINGW32__)) (int)strlen(PROGNAME), " ", #endif (int)strlen(PROGNAME), " ", default_display_exponent, num_bgpat); fflush(stderr); +#ifndef __CYGWIN__ do ch = _getch(); while (ch != 'q' && ch != 'Q' && ch != 0x1B); +#endif exit(1); } @@ -496,18 +515,24 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode) if (error) { +#ifndef __CYGWIN__ int ch; +#endif fprintf(stderr, PROGNAME ": aborting.\n"); +#ifndef __CYGWIN__ do ch = _getch(); while (ch != 'q' && ch != 'Q' && ch != 0x1B); +#endif exit(2); } else { fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname); +#ifndef __CYGWIN__ fprintf(stderr, "\n [console window: closing this window will terminate %s]\n\n", PROGNAME); +#endif fflush(stderr); } @@ -567,7 +592,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode) "(unexpectedly) while reading PNG image file\n"); exit(3); } else /* if (error) */ { - // will print error message below + /* will print error message below */ } break; } @@ -1150,7 +1175,12 @@ static void rpng2_win_finish_display() rpng2_info.state = kDone; printf( - "Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n"); +#ifndef __CYGWIN__ + "Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n" +#else + "Done. Press mouse button 1 (within image window) to quit.\n" +#endif + ); fflush(stdout); }