int wmain(int argc, wchar_t* argv[]) { DWORD dwError = 0; PSTR* ppszArgs = NULL; int iArg = 0; dwError = VmDirAllocateMemory(sizeof(PSTR) * argc, (PVOID*)&ppszArgs); BAIL_ON_VMDIR_ERROR(dwError); for (; iArg < argc; iArg++) { dwError = VmDirAllocateStringAFromW(argv[iArg], &ppszArgs[iArg]); BAIL_ON_VMDIR_ERROR(dwError); } dwError = VmDirMain(argc, ppszArgs); BAIL_ON_VMDIR_ERROR(dwError); error: if (ppszArgs) { for (iArg = 0; iArg < argc; iArg++) { VMDIR_SAFE_FREE_MEMORY(ppszArgs[iArg]); } VmDirFreeMemory(ppszArgs); } return dwError; }
static DWORD _allocateSuperlogTableRow( PVMDIR_SUPERLOG_ENTRY_LDAPOPERATION pEntry, PVMDIR_SUPERLOG_TABLE_COLUMN_SET pCols, PVMDIR_SUPERLOG_TABLE_ROW *ppRow ) { DWORD dwError = 0; PVMDIR_SUPERLOG_TABLE_ROW pRow = NULL; dwError = VmDirAllocateMemory( sizeof(VMDIR_SUPERLOG_TABLE_ROW), (PVOID*)&pRow); BAIL_ON_VMDIR_ERROR(dwError); memset(pRow->colVals, 0, sizeof(pRow->colVals)); if (pCols->isColumnSet[LOGIN_DN]) { dwError = VmDirAllocateStringAFromW( pEntry->pwszLoginDN, &pRow->colVals[LOGIN_DN]); BAIL_ON_VMDIR_ERROR(dwError); } if (pCols->isColumnSet[IP]) { dwError = VmDirAllocateStringAFromW( pEntry->pwszClientIP, &pRow->colVals[IP]); BAIL_ON_VMDIR_ERROR(dwError); } if (pCols->isColumnSet[PORT]) { dwError = VmDirAllocateStringPrintf( &pRow->colVals[PORT], "%u", pEntry->dwClientPort ); BAIL_ON_VMDIR_ERROR(dwError); } if (pCols->isColumnSet[OPERATION]) { dwError = VmDirAllocateStringAFromW( pEntry->pwszOperation, &pRow->colVals[OPERATION]); BAIL_ON_VMDIR_ERROR(dwError); } if (pCols->isColumnSet[STRING]) { dwError = VmDirAllocateStringAFromW( pEntry->pwszString, &pRow->colVals[STRING]); BAIL_ON_VMDIR_ERROR(dwError); } if (pCols->isColumnSet[ERROR_CODE]) { dwError = VmDirAllocateStringPrintf( &pRow->colVals[ERROR_CODE], "%u", pEntry->dwErrorCode ); BAIL_ON_VMDIR_ERROR(dwError); } pRow->count = 1; pRow->totalTime = pEntry->iEndTime - pEntry->iStartTime; *ppRow = pRow; cleanup: return dwError; error: if (pRow) { VMDIR_SAFE_FREE_MEMORY(pRow->colVals[LOGIN_DN]); VMDIR_SAFE_FREE_MEMORY(pRow->colVals[IP]); VMDIR_SAFE_FREE_MEMORY(pRow->colVals[PORT]); VMDIR_SAFE_FREE_MEMORY(pRow->colVals[OPERATION]); VMDIR_SAFE_FREE_MEMORY(pRow->colVals[STRING]); VMDIR_SAFE_FREE_MEMORY(pRow->colVals[ERROR_CODE]); VMDIR_SAFE_FREE_MEMORY(pRow); } goto cleanup; }
static DWORD _VmDirCopyFromRpcMachineInfo( PVMDIR_MACHINE_INFO_W pMachineInfoIn, PVMDIR_MACHINE_INFO_A* ppMachineInfoOut ) { DWORD dwError = 0; PVMDIR_MACHINE_INFO_A pMachineInfo = NULL; if (!pMachineInfoIn || !ppMachineInfoOut) { dwError = ERROR_INVALID_PARAMETER; BAIL_ON_VMDIR_ERROR(dwError); } dwError = VmDirAllocateMemory( sizeof(VMDIR_MACHINE_INFO_A), (PVOID*)&pMachineInfo ); BAIL_ON_VMDIR_ERROR(dwError); dwError = VmDirAllocateStringAFromW( pMachineInfoIn->pwszPassword, &pMachineInfo->pszPassword ); BAIL_ON_VMDIR_ERROR(dwError); dwError = VmDirAllocateStringAFromW( pMachineInfoIn->pwszSiteName, &pMachineInfo->pszSiteName ); BAIL_ON_VMDIR_ERROR(dwError); dwError = VmDirAllocateStringAFromW( pMachineInfoIn->pwszComputerDN, &pMachineInfo->pszComputerDN ); BAIL_ON_VMDIR_ERROR(dwError); dwError = VmDirAllocateStringAFromW( pMachineInfoIn->pwszMachineGUID, &pMachineInfo->pszMachineGUID ); BAIL_ON_VMDIR_ERROR(dwError); *ppMachineInfoOut = pMachineInfo; cleanup: return dwError; error: if (ppMachineInfoOut) { *ppMachineInfoOut = NULL; } if (pMachineInfo) { VmDirFreeMachineInfoA(pMachineInfo); } goto cleanup; }
static DWORD _generateHashMapKeyString( PVMDIR_SUPERLOG_ENTRY_LDAPOPERATION pEntry, PVMDIR_SUPERLOG_TABLE_COLUMN_SET pCols, PSTR *ppszKey ) { static PCSTR pcszEmptyColumn = "--"; static PCSTR pcszColumnDelimeter = "||"; DWORD dwError = 0; PSTR pszKey = NULL; PSTR pszLoginDN = NULL; PSTR pszIP = NULL; PSTR pszPort = NULL; PSTR pszOperation = NULL; PSTR pszString = NULL; PSTR pszErrorCode = NULL; if (pCols->isColumnSet[LOGIN_DN]) { dwError = VmDirAllocateStringAFromW(pEntry->pwszLoginDN, &pszLoginDN); BAIL_ON_VMDIR_ERROR(dwError); } else { dwError = VmDirAllocateStringA(pcszEmptyColumn, &pszLoginDN); BAIL_ON_VMDIR_ERROR(dwError); } if (pCols->isColumnSet[IP]) { dwError = VmDirAllocateStringAFromW(pEntry->pwszClientIP, &pszIP); BAIL_ON_VMDIR_ERROR(dwError); } else { dwError = VmDirAllocateStringA(pcszEmptyColumn, &pszIP); BAIL_ON_VMDIR_ERROR(dwError); } if (pCols->isColumnSet[PORT]) { dwError = VmDirAllocateStringPrintf(&pszPort, "%u", pEntry->dwClientPort); BAIL_ON_VMDIR_ERROR(dwError); } else { dwError = VmDirAllocateStringA(pcszEmptyColumn, &pszPort); BAIL_ON_VMDIR_ERROR(dwError); } if (pCols->isColumnSet[OPERATION]) { dwError = VmDirAllocateStringAFromW(pEntry->pwszOperation, &pszOperation); BAIL_ON_VMDIR_ERROR(dwError); } else { dwError = VmDirAllocateStringA(pcszEmptyColumn, &pszOperation); BAIL_ON_VMDIR_ERROR(dwError); } if (pCols->isColumnSet[STRING]) { dwError = VmDirAllocateStringAFromW(pEntry->pwszString, &pszString); BAIL_ON_VMDIR_ERROR(dwError); } else { dwError = VmDirAllocateStringA(pcszEmptyColumn, &pszString); BAIL_ON_VMDIR_ERROR(dwError); } if (pCols->isColumnSet[ERROR_CODE]) { dwError = VmDirAllocateStringPrintf(&pszErrorCode, "%u", pEntry->dwErrorCode); BAIL_ON_VMDIR_ERROR(dwError); } else { dwError = VmDirAllocateStringA(pcszEmptyColumn, &pszErrorCode); BAIL_ON_VMDIR_ERROR(dwError); } dwError = VmDirAllocateStringPrintf( &pszKey, "%s%s%s%s%s%s%s%s%s%s%s", pszLoginDN, pcszColumnDelimeter, pszIP, pcszColumnDelimeter, pszPort, pcszColumnDelimeter, pszOperation, pcszColumnDelimeter, pszString, pcszColumnDelimeter, pszErrorCode ); BAIL_ON_VMDIR_ERROR(dwError); *ppszKey = pszKey; cleanup: VMDIR_SAFE_FREE_MEMORY(pszLoginDN); VMDIR_SAFE_FREE_MEMORY(pszIP); VMDIR_SAFE_FREE_MEMORY(pszPort); VMDIR_SAFE_FREE_MEMORY(pszOperation); VMDIR_SAFE_FREE_MEMORY(pszString); VMDIR_SAFE_FREE_MEMORY(pszErrorCode); return dwError; error: VMDIR_SAFE_FREE_MEMORY(pszKey); goto cleanup; }