Skip to content

Instantly share code, notes, and snippets.

@rpothier
Last active August 6, 2019 17:24
Show Gist options
  • Save rpothier/e297d913fd1a664f179a7bfeada80052 to your computer and use it in GitHub Desktop.
Save rpothier/e297d913fd1a664f179a7bfeada80052 to your computer and use it in GitHub Desktop.
import sys
lib = 'ssl'
libsize = 3
if len(sys.argv) > 1:
lib = sys.argv[1]
libsize = len(sys.argv[1])
print '/* OpenSSL error counters from {}err.h */'.format(lib)
filename = lib + "err.h"
f = open(filename, "r")
for x in f:
y = x.split()
if len(y) > 3:
rc = y[2][:libsize+3]
if rc == lib.upper() + "_R_":
str = y[2][libsize+3:32]
str = lib.upper() + '_' + str +','
print 'COUNTER_ID(SSLERR, {:<32}"SSL error {}{}")'.format(str,y[2][:4],y[2][6:])
f.close()
import sys
lib = 'ssl'
libsize = 3
if len(sys.argv) > 1:
lib = sys.argv[1]
libsize = len(sys.argv[1])
print '/*'
print ' * ssl_count_error_lib_{}:MP_SAFE'.format(lib)
print ' */'
print 'void ssl_count_error_lib_{}(int reason)'.format(lib)
print '{'
print ' switch (reason)'
print ' {'
filename = lib + "err.h"
f = open(filename, "r")
for x in f:
y = x.split()
if len(y) > 3:
rc = y[2][:libsize+3]
if rc == lib.upper() + "_R_":
str = y[2][libsize+3:32]
if lib != 'ssl':
str = lib.upper() + '_' + str
#str += ','
print ' case {}:'.format(y[2])
print ' inc_counter(CNT_SSLERR_{});'.format(str)
print ' return;'
#print 'COUNTER_ID(SSLERR, {:<32}"SSL error {}")'.format(str,y[2])
print ' default:'
print ' inc_counter(CNT_SSLERR_LIB_{});'.format(lib.upper())
print ' return;'
print ' }'
print '}'
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment