cryptlib  3.4.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros
Classes | Namespaces | Functions | Variables
cryptlibConverter.py File Reference

Go to the source code of this file.

Classes

class  cryptlibConverter.ParamStruct
 
class  cryptlibConverter.CryptHandle
 

Namespaces

namespace  cryptlibConverter
 

Functions

def cryptlibConverter.parseEnumContents
 
def cryptlibConverter.parseFunctionParams
 
def cryptlibConverter.expandFunctionPrototype
 
def cryptlibConverter.__init__
 
def cryptlibConverter.__int__
 
def cryptlibConverter.__str__
 
def cryptlibConverter.__repr__
 
def cryptlibConverter.__getattr__
 
def cryptlibConverter.__setattr__
 
def cryptlibConverter.__init__
 

Variables

list cryptlibConverter.inFile sys.argv[1]
 
list cryptlibConverter.outDir sys.argv[2]
 
list cryptlibConverter.language sys.argv[3]
 
string cryptlibConverter.typedefEnumTemplate "// %(typedefName)s"
 
string cryptlibConverter.typedefEnumElementTemplate "public static final int %(name)-NPADs = %(value)-VPADs;"
 
string cryptlibConverter.typedefEnumElementTemplateComment " // %(comment)s"
 
string cryptlibConverter.simpleEnumElementTemplate "public static final int %(name)-NPADs = %(value)-VPADs;"
 
string cryptlibConverter.simpleEnumElementTemplateComment " // %(comment)s"
 
string cryptlibConverter.defineNPad "40"
 
string cryptlibConverter.defineVPad "4"
 
 cryptlibConverter.defineTemplate simpleEnumElementTemplate
 
 cryptlibConverter.defineTemplateComment simpleEnumElementTemplateComment
 
string cryptlibConverter.exceptionPrefix
 
string cryptlibConverter.exceptionPostfix
 
string cryptlibConverter.exceptionTemplate
 
string cryptlibConverter.cryptQueryInfoString
 
string cryptlibConverter.cryptObjectInfoString
 
int cryptlibConverter.addFunctionWrappers 1
 
 cryptlibConverter.wholeFunctionDeclaration None
 
string cryptlibConverter.functionDeclaration "public static native "
 
string cryptlibConverter.returnIntDeclaration "int "
 
string cryptlibConverter.returnVoidDeclaration "void "
 
string cryptlibConverter.paramsPrefix "("
 
string cryptlibConverter.paramsPostfix ") throws CryptException;"
 
string cryptlibConverter.paramWhiteSpace "\t\t\t\t\t\t"
 
string cryptlibConverter.paramVoidPtrTemplate "java.nio.ByteBuffer %(name)s,\n"
 
int cryptlibConverter.addFunctionAlternate 1
 
tuple cryptlibConverter.paramVoidPtrAlternate ("java.nio.ByteBuffer", "byte[]")
 
string cryptlibConverter.paramCharPtrTemplate "String %(name)s,\n"
 
string cryptlibConverter.paramIntTemplate "int %(name)s,\n"
 
string cryptlibConverter.paramIntTypeTemplate "int %(name)s, // %(type)s\n"
 
string cryptlibConverter.wrapperLengthTemplate "%(1)s == null ? 0 : %(1)s.capacity(), "
 
string cryptlibConverter.wrapperStringLengthTemplate "%(1)s == null ? 0 : %(1)s.getBytes().length, "
 
tuple cryptlibConverter.wrapperStringReplace ("java.nio.ByteBuffer", "String")
 
string cryptlibConverter.wrapperStringTemplate '%(1)s == null ? null : %(1)s.getBytes()'
 
string cryptlibConverter.paramEnumTypeTemplate "int %(name)s, // %(type)s\n"
 
string cryptlibConverter.commentPrefix "//"
 
string cryptlibConverter.classPrefix "package cryptlib;\n\nimport java.nio.*;\n\npublic class crypt\n{\n"
 
string cryptlibConverter.classPostfix "\n};"
 
 cryptlibConverter.sFuncs None
 
 cryptlibConverter.sInts None
 
string cryptlibConverter.moduleFunctionEntry "\t{ \"crypt%s\", python_crypt%s, METH_VARARGS }, "
 
string cryptlibConverter.pyBeforeExceptions r""
 
string cryptlibConverter.pyBeforeFuncs
 
string cryptlibConverter.pyBeforeModuleFunctions
 
string cryptlibConverter.pyBeforeInts r""
 
string cryptlibConverter.pyAfterInts "}"
 
tuple cryptlibConverter.outFile os.path.join(outDir, "cryptlib.py")
 
string cryptlibConverter.sModFuncs ""
 
string cryptlibConverter.setupPy r""
 
tuple cryptlibConverter.s open(inFile)
 
int cryptlibConverter.inFileTabSize 4
 
dictionary cryptlibConverter.nameSpace {}
 
list cryptlibConverter.enumTypes []
 
list cryptlibConverter.intTypes []
 
list cryptlibConverter.structTypes []
 
list cryptlibConverter.rawTypes ["char", "int", "void"]
 
list cryptlibConverter.functionNames []
 
dictionary cryptlibConverter.rawParamStructsDict {}
 
dictionary cryptlibConverter.newParamStructsDict {}
 
dictionary cryptlibConverter.newReturnStructsDict {}
 
dictionary cryptlibConverter.newDiscardedStructsDict {}
 
dictionary cryptlibConverter.lengthIndicesDict {}
 
dictionary cryptlibConverter.offsetIndicesDict {}
 
dictionary cryptlibConverter.errors {}
 
tuple cryptlibConverter.endifMatch re.search(r"#endif.*?\n", s, re.DOTALL)
 
tuple cryptlibConverter.ifdefIndex s.rfind("#if", 0, endifMatch.start())
 
tuple cryptlibConverter.functionParamterPattern re.compile(r"((C_CHECK_RETVAL|C_NONNULL_ARG\s*\(\s*\([ \t0-9,]+\s*\)\s*\))\s+(\\\n)?)", re.DOTALL)
 
tuple cryptlibConverter.deleteExtended functionParamterPattern.search(s)
 
tuple cryptlibConverter.typedefEnumPattern re.compile(r"typedef[ \t]+enum[ \t]+{([^}]*)}\s*(\w*);", re.DOTALL)
 
tuple cryptlibConverter.typedefEnumMatch typedefEnumPattern.search(s)
 
tuple cryptlibConverter.enumTuples parseEnumContents(enumContents, nameSpace, "typedef")
 
tuple cryptlibConverter.namePad str( max( [len(e[0]) for e in enumTuples] ) )
 
tuple cryptlibConverter.valuePad str( max( [len(e[1]) for e in enumTuples] ) )
 
tuple cryptlibConverter.newTypedefEnum typedefEnumTemplate%vars()
 
tuple cryptlibConverter.paddedTemplate typedefEnumElementTemplate.replace("NPAD", namePad)
 
tuple cryptlibConverter.newEnum paddedTemplate%vars()
 
tuple cryptlibConverter.simpleEnumPattern re.compile(r"enum[ \t]+{([^}]*)};", re.DOTALL)
 
tuple cryptlibConverter.simpleEnumMatch simpleEnumPattern.search(s)
 
tuple cryptlibConverter.enumContents simpleEnumMatch.group(1)
 
string cryptlibConverter.newSimpleEnum ""
 
tuple cryptlibConverter.definePattern re.compile(r"#define[ \t]+(\w+)[ \t]+([-\w]+)[ \t]*(/\*.*\*/*)?")
 
 cryptlibConverter.exceptionString exceptionPrefix
 
tuple cryptlibConverter.defineMatch definePattern.search(s)
 
tuple cryptlibConverter.name name.replace("CRYPT_", "")
 
tuple cryptlibConverter.newDefine paddedTemplate%vars()
 
list cryptlibConverter.comment comment[2:-2]
 
tuple cryptlibConverter.define defineMatch.group()
 
tuple cryptlibConverter.typedefIntPattern re.compile(r"typedef[ \t]+int[ \t]+([^ \t]*)[ \t]*;[ \t]*\n")
 
tuple cryptlibConverter.typedefIntMatch typedefIntPattern.search(s)
 
tuple cryptlibConverter.typedefInt typedefIntMatch.group()
 
tuple cryptlibConverter.typedefIntName typedefIntMatch.group(1)
 
string cryptlibConverter.newTypedefInt "CRYPTLIBCONVERTER - NOT NEEDED: "
 
tuple cryptlibConverter.typedefStructPattern re.compile(r"typedef[ \t]+struct[ \t]\{[^}]*}[ \t]*([^;]+);")
 
tuple cryptlibConverter.typedefStructMatch typedefStructPattern.search(s)
 
tuple cryptlibConverter.typedefStruct typedefStructMatch.group()
 
tuple cryptlibConverter.typedefStructName typedefStructMatch.group(1)
 
string cryptlibConverter.newTypedefStruct "CRYPTLIBCONVERTER - NOT SUPPORTED:\n"
 
tuple cryptlibConverter.functionPattern re.compile(r"C_RET[ \t]+([^ \t]+)[ \t]*\(([^\)]*)\);", re.DOTALL)
 
tuple cryptlibConverter.functionMatch functionPattern.search(s)
 
tuple cryptlibConverter.function functionMatch.group()
 
list cryptlibConverter.functionName functionName[len("crypt") : ]
 
tuple cryptlibConverter.paramStructs parseFunctionParams(functionParams)
 
int cryptlibConverter.discardIntIndex 1
 
int cryptlibConverter.returnIntIndex 1
 
int cryptlibConverter.returnVoidPtrIndex 1
 
int cryptlibConverter.discardInLengthIndex1 1
 
int cryptlibConverter.discardInLengthIndex2 1
 
int cryptlibConverter.index 1
 
list cryptlibConverter.p2 paramStructs[index-1]
 
list cryptlibConverter.newParamStructs
 
list cryptlibConverter.offsetIndices []
 
list cryptlibConverter.lengthIndices []
 
list cryptlibConverter.p newParamStructs[index]
 
tuple cryptlibConverter.newp ParamStruct()
 
 cryptlibConverter.newFunction wholeFunctionDeclaration%functionName
 
 cryptlibConverter.newFunctionWrapper newFunction
 
string cryptlibConverter.newFunctionWrapperArgs ""
 
 cryptlibConverter.newFunctionStringWrapper newFunction
 
string cryptlibConverter.newFunctionStringWrapperArgs ""
 
 cryptlibConverter.template paramVoidPtrTemplate
 
 cryptlibConverter.previousBufferName p.name
 
list cryptlibConverter.anyMoreParams
 
tuple cryptlibConverter.newFunctionWrapper2 newFunctionWrapper.replace(*paramVoidPtrAlternate)
 
tuple cryptlibConverter.match re.search(r"/\*(.*?)\*/", s, re.DOTALL)
 
tuple cryptlibConverter.commentStrings (commentPrefix + match.group(1) + " ")
 
list cryptlibConverter.newComment commentStrings[0]
 
tuple cryptlibConverter.idx commentString.find("\n")
 
tuple cryptlibConverter.f open("crypt.java", "w")
 
tuple cryptlibConverter.startIndex s.find("#undef")
 
tuple cryptlibConverter.endIndex s.find("/*\n * Class", startIndex)
 
 cryptlibConverter.sold s
 
list cryptlibConverter.s2 sold[startIndex : endIndex]
 
list cryptlibConverter.rawParamStructs [p,p2]
 
string cryptlibConverter.voidTag "Array"
 
 cryptlibConverter.returnName None
 
 cryptlibConverter.discardName None
 
tuple cryptlibConverter.returnType newReturnStructsDict.get(functionName)
 
tuple cryptlibConverter.returnCategory newReturnStructsDict.get(functionName)
 
tuple cryptlibConverter.newFunctionParams expandFunctionPrototype(functionPrototype, newParamStructs)
 
string cryptlibConverter.newFunctionBody "\nint status = 0;\n"
 
string cryptlibConverter.arguments ""
 
list cryptlibConverter.arrayNames [p.name for p in newParamStructs if p.isPtr]
 
list cryptlibConverter.charArrayNames [p.name for p in newParamStructs if p.isPtr and p.type=="char"]
 
list cryptlibConverter.voidArrayNames [p.name for p in newParamStructs if p.isPtr and p.type=="void"]
 
list cryptlibConverter.outVoidArrayNames [p.name for p in newParamStructs if p.isPtr and p.type=="void" and p.isOut]
 
tuple cryptlibConverter.argumentsWithNull arguments.replace("%sPtr + %sOffset" % (n,n), "NULL")
 
 cryptlibConverter.lengthName returnName
 
string cryptlibConverter.moduleFunctions ""
 
string cryptlibConverter.parseFormatString ""
 
list cryptlibConverter.parseArgsList []
 
int cryptlibConverter.flagForAddRandomHack 0
 
tuple cryptlibConverter.lines newFunctionBody.split("\n")
 
int cryptlibConverter.brackets 0
 
list cryptlibConverter.line lines[count]
 
string cryptlibConverter.parameters ""
 
 cryptlibConverter.algoName
 
 cryptlibConverter.blockSize
 
 cryptlibConverter.minKeySize
 
 cryptlibConverter.keySize
 
 cryptlibConverter.maxKeySize
 
 cryptlibConverter.objectType
 
 cryptlibConverter.cryptAlgo
 
 cryptlibConverter.cryptMode
 
 cryptlibConverter.hashAlgo
 
 cryptlibConverter.salt