diff options
author | Sergey Glukhov <Sergey.Glukhov@sun.com> | 2008-11-27 17:05:38 +0400 |
---|---|---|
committer | Sergey Glukhov <Sergey.Glukhov@sun.com> | 2008-11-27 17:05:38 +0400 |
commit | 910d41725dcbf6e54a1d07370949e6da2b9535ca (patch) | |
tree | c61e6a14ef5de640a505489c42a67f76446e6ec7 /extra/perror.c | |
parent | 12758f9d6e5162a251c6e80840653c53afd1cb8c (diff) | |
parent | 73960af037a68dd96ae636ff84b39007f825ab0e (diff) | |
download | mariadb-git-910d41725dcbf6e54a1d07370949e6da2b9535ca.tar.gz |
5.0-bugteam->5.1-bugteam merge
Diffstat (limited to 'extra/perror.c')
-rw-r--r-- | extra/perror.c | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/extra/perror.c b/extra/perror.c index 237b2582d43..80eb2af2dae 100644 --- a/extra/perror.c +++ b/extra/perror.c @@ -185,11 +185,36 @@ static const char *get_ha_error_msg(int code) } +#if defined(__WIN__) +static my_bool print_win_error_msg(DWORD error, my_bool verbose) +{ + LPTSTR s; + if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM, + NULL, error, 0, (LPTSTR)&s, 0, + NULL)) + { + if (verbose) + printf("Win32 error code %d: %s", error, s); + else + puts(s); + LocalFree(s); + return 0; + } + return 1; +} +#endif + + + int main(int argc,char *argv[]) { int error,code,found; const char *msg; char *unknown_error = 0; +#if defined(__WIN__) + my_bool skip_win_message= 0; +#endif MY_INIT(argv[0]); if (get_options(&argc,&argv)) @@ -293,9 +318,20 @@ int main(int argc,char *argv[]) } if (!found) { - fprintf(stderr,"Illegal error code: %d\n", code); - error= 1; +#if defined(__WIN__) + if (!(skip_win_message= !print_win_error_msg((DWORD)code, verbose))) + { +#endif + fprintf(stderr,"Illegal error code: %d\n",code); + error=1; +#if defined(__WIN__) + } +#endif } +#if defined(__WIN__) + if (!skip_win_message) + print_win_error_msg((DWORD)code, verbose); +#endif } } |