blob: e6962dfee1ca62a2b1510f1c1d87cf9b439f5b91 [file] [log] [blame]
Paul Bakker01cc3942012-05-08 08:36:15 +00001/*
2 * Translate error code to error string
3 *
Manuel Pégourié-Gonnard0edee5e2015-01-26 15:29:40 +00004 * Copyright (C) 2006-2012, ARM Limited, All Rights Reserved
Paul Bakker01cc3942012-05-08 08:36:15 +00005 *
Manuel Pégourié-Gonnarde12abf92015-01-28 17:13:45 +00006 * This file is part of mbed TLS (https://polarssl.org)
Paul Bakker01cc3942012-05-08 08:36:15 +00007 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 */
22
23#ifndef _CRT_SECURE_NO_DEPRECATE
24#define _CRT_SECURE_NO_DEPRECATE 1
25#endif
26
27#include <stdlib.h>
28#include <string.h>
29#include <stdio.h>
30
31#include "polarssl/config.h"
32
33#include "polarssl/error.h"
34
35#define USAGE \
36 "\n usage: strerror <errorcode>\n"
37
Paul Bakker8fe40dc2013-02-02 12:43:08 +010038#if !defined(POLARSSL_ERROR_C) && !defined(POLARSSL_ERROR_STRERROR_DUMMY)
Paul Bakker01cc3942012-05-08 08:36:15 +000039int main( int argc, char *argv[] )
40{
41 ((void) argc);
42 ((void) argv);
43
Paul Bakker8fe40dc2013-02-02 12:43:08 +010044 printf("POLARSSL_ERROR_C and/or POLARSSL_ERROR_STRERRO_DUMMY not defined.\n");
Paul Bakker01cc3942012-05-08 08:36:15 +000045 return( 0 );
46}
47#else
48int main( int argc, char *argv[] )
49{
50 int ret;
51
52 if( argc != 2 )
53 {
54 printf( USAGE );
55 return( 0 );
56 }
57
58 ret = atoi( argv[1] );
59 if( ret > 0 )
60 ret = - ret;
61
62 if( ret != 0 )
63 {
64 char error_buf[200];
65 error_strerror( ret, error_buf, 200 );
66 printf("Last error was: %d - %s\n\n", ret, error_buf );
67 }
68
69#if defined(_WIN32)
70 printf( " + Press Enter to exit this program.\n" );
71 fflush( stdout ); getchar();
72#endif
73
74 return( ret );
75}
76#endif /* POLARSSL_ERROR_C */