static PyObject * ETContext_open(ETContextObject* self, PyObject *args) { DWORD dwRet; ET_OPENINFO OpenInfo; PyObject *pyOpenInfo=NULL; if (!PyArg_ParseTuple(args, "|O", &pyOpenInfo)) { return NULL; } Py_XINCREF(pyOpenInfo); #if defined(WIN32) if(NULL != pyOpenInfo){ //printf("PyTuple_Check(pyOpenInfo)=%d\n",PyTuple_Check(pyOpenInfo)); //printf("PyTuple_Size(pyOpenInfo)=%d\n",PyTuple_Size(pyOpenInfo)); //printf("PyInt_Check(PyTuple_GetItem(pyOpenInfo,0)=%d\n",PyInt_Check(PyTuple_GetItem(pyOpenInfo,0))); //printf("PyInt_Check(PyTuple_GetItem(pyOpenInfo,1))=%d\n",PyInt_Check(PyTuple_GetItem(pyOpenInfo,1))); if(!PyTuple_Check(pyOpenInfo) || 2!=PyTuple_Size(pyOpenInfo) || !PyInt_Check(PyTuple_GetItem(pyOpenInfo,0)) || !PyInt_Check(PyTuple_GetItem(pyOpenInfo,1))){ INVALID_PARAMS("Open Info must be a tuple with 2 integers.",NULL); } OpenInfo.dwOpenInfoSize=PyInt_AsUnsignedLongMask(PyTuple_GetItem(pyOpenInfo,0)); OpenInfo.dwShareMode=PyInt_AsUnsignedLongMask(PyTuple_GetItem(pyOpenInfo,1)); //printf("OpenInfo: %08x,%08x\n",OpenInfo.dwOpenInfoSize,OpenInfo.dwShareMode); dwRet= ETOpenEx(&self->context,&OpenInfo); }else{ dwRet = ETOpen(&self->context); } #else dwRet = ETOpen(&self->context); #endif /*WIN32 | LINUX*/ Py_XDECREF(pyOpenInfo); DWRET_VALIDATE(dwRet,NULL); Py_XINCREF(self); return self; }
static int et199_encrypt_init(void *encrypt) { int dwCount = 0; int dwRet = 0; ENCRYPT *encrypt_ins = encrypt; struct ET_CONTEXT *pContext = (struct ET_CONTEXT *)encrypt_ins->private_data; dwRet = ETEnum(0, &dwCount); if(dwRet != ET_E_INSUFFICIENT_BUFFER && dwRet) { PostError("ETEnum 1", dwRet); return PROBE_ERR; } if(dwCount > PCONTEXT_COUNT) { return MORE_DEV; } memset(pContext, 0, sizeof(struct ET_CONTEXT)*dwCount); dwRet = ETEnum(pContext, &dwCount); if(dwRet) { PostError("ETEnum 2", dwRet); return PROBE_ERR; } //Open ET199 dwRet = ETOpen(&pContext[0]); if(dwRet) { PostError("ETOpen", dwRet); return OPENDEV_ERR; } dwRet = et199_encrypt_verfiy_serial_num(encrypt_ins); if(dwRet != 0) { return dwRet; } return SUCCESS; }