use isxdigit and apps_tohex
Replace ad-hoc ascii->hex with isxdigit and new app_tohex. Reviewed-by: Andy Polyakov <appro@openssl.org>
This commit is contained in:
39
apps/apps.c
39
apps/apps.c
@@ -2673,6 +2673,45 @@ int app_access(const char* name, int flag)
|
||||
#endif
|
||||
}
|
||||
|
||||
int app_hex(char c)
|
||||
{
|
||||
switch (c) {
|
||||
default:
|
||||
case '0':
|
||||
return 0;
|
||||
case '1':
|
||||
return 1;
|
||||
case '2':
|
||||
return 2;
|
||||
case '3':
|
||||
return 3;
|
||||
case '4':
|
||||
return 4;
|
||||
case '5':
|
||||
return 5;
|
||||
case '6':
|
||||
return 6;
|
||||
case '7':
|
||||
return 7;
|
||||
case '8':
|
||||
return 8;
|
||||
case '9':
|
||||
return 9;
|
||||
case 'a': case 'A':
|
||||
return 0x0A;
|
||||
case 'b': case 'B':
|
||||
return 0x0B;
|
||||
case 'c': case 'C':
|
||||
return 0x0C;
|
||||
case 'd': case 'D':
|
||||
return 0x0D;
|
||||
case 'e': case 'E':
|
||||
return 0x0E;
|
||||
case 'f': case 'F':
|
||||
return 0x0F;
|
||||
}
|
||||
}
|
||||
|
||||
/* app_isdir section */
|
||||
#ifdef _WIN32
|
||||
int app_isdir(const char *name)
|
||||
|
||||
Reference in New Issue
Block a user