mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2026-01-04 05:35:33 +01:00
Cleanup up non-prototyped functions (static) and const-correctness in programs
This commit is contained in:
parent
b6c5d2e1a6
commit
3c5ef71322
12 changed files with 34 additions and 88 deletions
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Key reading application
|
||||
*
|
||||
* Copyright (C) 2006-2012, Brainspark B.V.
|
||||
* Copyright (C) 2006-2013, Brainspark B.V.
|
||||
*
|
||||
* This file is part of PolarSSL (http://www.polarssl.org)
|
||||
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
|
||||
|
|
@ -56,18 +56,8 @@ struct options
|
|||
const char *filename; /* filename of the key file */
|
||||
const char *password; /* password for the private key */
|
||||
const char *password_file; /* password_file for the private key */
|
||||
int debug_level; /* level of debugging */
|
||||
} opt;
|
||||
|
||||
void my_debug( void *ctx, int level, const char *str )
|
||||
{
|
||||
if( level < opt.debug_level )
|
||||
{
|
||||
fprintf( (FILE *) ctx, "%s", str );
|
||||
fflush( (FILE *) ctx );
|
||||
}
|
||||
}
|
||||
|
||||
#define USAGE \
|
||||
"\n usage: key_app param=<>...\n" \
|
||||
"\n acceptable parameters:\n" \
|
||||
|
|
@ -75,7 +65,6 @@ void my_debug( void *ctx, int level, const char *str )
|
|||
" filename=%%s default: keyfile.key\n" \
|
||||
" password=%%s default: \"\"\n" \
|
||||
" password_file=%%s default: \"\"\n" \
|
||||
" debug_level=%%d default: 0 (disabled)\n" \
|
||||
"\n"
|
||||
|
||||
#if !defined(POLARSSL_BIGNUM_C) || !defined(POLARSSL_RSA_C) || \
|
||||
|
|
@ -115,7 +104,6 @@ int main( int argc, char *argv[] )
|
|||
opt.filename = DFL_FILENAME;
|
||||
opt.password = DFL_PASSWORD;
|
||||
opt.password_file = DFL_PASSWORD_FILE;
|
||||
opt.debug_level = DFL_DEBUG_LEVEL;
|
||||
|
||||
for( i = 1; i < argc; i++ )
|
||||
{
|
||||
|
|
@ -139,12 +127,6 @@ int main( int argc, char *argv[] )
|
|||
opt.password = q;
|
||||
else if( strcmp( p, "password_file" ) == 0 )
|
||||
opt.password_file = q;
|
||||
else if( strcmp( p, "debug_level" ) == 0 )
|
||||
{
|
||||
opt.debug_level = atoi( q );
|
||||
if( opt.debug_level < 0 || opt.debug_level > 65535 )
|
||||
goto usage;
|
||||
}
|
||||
else
|
||||
goto usage;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Key reading application
|
||||
*
|
||||
* Copyright (C) 2006-2011, Brainspark B.V.
|
||||
* Copyright (C) 2006-2013, Brainspark B.V.
|
||||
*
|
||||
* This file is part of PolarSSL (http://www.polarssl.org)
|
||||
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
|
||||
|
|
@ -73,21 +73,11 @@ struct options
|
|||
{
|
||||
int mode; /* the mode to run the application in */
|
||||
const char *filename; /* filename of the key file */
|
||||
int debug_level; /* level of debugging */
|
||||
int output_mode; /* the output mode to use */
|
||||
const char *output_file; /* where to store the constructed key file */
|
||||
} opt;
|
||||
|
||||
void my_debug( void *ctx, int level, const char *str )
|
||||
{
|
||||
if( level < opt.debug_level )
|
||||
{
|
||||
fprintf( (FILE *) ctx, "%s", str );
|
||||
fflush( (FILE *) ctx );
|
||||
}
|
||||
}
|
||||
|
||||
void write_public_key( rsa_context *rsa, const char *output_file )
|
||||
static void write_public_key( rsa_context *rsa, const char *output_file )
|
||||
{
|
||||
FILE *f;
|
||||
unsigned char output_buf[16000];
|
||||
|
|
@ -124,7 +114,7 @@ void write_public_key( rsa_context *rsa, const char *output_file )
|
|||
fclose(f);
|
||||
}
|
||||
|
||||
void write_private_key( rsa_context *rsa, const char *output_file )
|
||||
static void write_private_key( rsa_context *rsa, const char *output_file )
|
||||
{
|
||||
FILE *f;
|
||||
unsigned char output_buf[16000];
|
||||
|
|
@ -165,7 +155,6 @@ void write_private_key( rsa_context *rsa, const char *output_file )
|
|||
"\n acceptable parameters:\n" \
|
||||
" mode=private|public default: none\n" \
|
||||
" filename=%%s default: keyfile.key\n" \
|
||||
" debug_level=%%d default: 0 (disabled)\n" \
|
||||
" output_mode=private|public default: none\n" \
|
||||
" output_file=%%s defeult: keyfile.pem\n" \
|
||||
"\n"
|
||||
|
|
@ -193,7 +182,6 @@ int main( int argc, char *argv[] )
|
|||
|
||||
opt.mode = DFL_MODE;
|
||||
opt.filename = DFL_FILENAME;
|
||||
opt.debug_level = DFL_DEBUG_LEVEL;
|
||||
opt.output_mode = DFL_OUTPUT_MODE;
|
||||
opt.output_file = DFL_OUTPUT_FILENAME;
|
||||
|
||||
|
|
@ -226,12 +214,6 @@ int main( int argc, char *argv[] )
|
|||
opt.filename = q;
|
||||
else if( strcmp( p, "output_file" ) == 0 )
|
||||
opt.output_file = q;
|
||||
else if( strcmp( p, "debug_level" ) == 0 )
|
||||
{
|
||||
opt.debug_level = atoi( q );
|
||||
if( opt.debug_level < 0 || opt.debug_level > 65535 )
|
||||
goto usage;
|
||||
}
|
||||
else
|
||||
goto usage;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue