void sr_Over(cpu_t *pcpu, decode_t *pdecoded) { uint32_t tmp1 = pop(pcpu); uint32_t tmp2 = pop(pcpu); BAIL_ON_ERROR(); push(pcpu, tmp2); push(pcpu, tmp1); push(pcpu, tmp2); }
static LWMsgStatus lwmsg_peer_task_run_connect( LWMsgPeer* peer, PeerAssocTask* task, LWMsgTaskTrigger trigger, LWMsgTaskTrigger* next_trigger, LWMsgTime* next_timeout ) { LWMsgStatus status = LWMSG_STATUS_SUCCESS; status = lwmsg_assoc_connect(task->assoc, (LWMsgSession*) task->session); switch (status) { case LWMSG_STATUS_SUCCESS: task->type = PEER_TASK_DISPATCH; BAIL_ON_ERROR(status = lwmsg_peer_log_connect(task)); /* Set up the fd the assoc just created for events */ BAIL_ON_ERROR(status = lwmsg_task_set_trigger_fd(task->event_task, CONNECTION_PRIVATE(task->assoc)->fd)); break; case LWMSG_STATUS_PENDING: task->type = PEER_TASK_FINISH_CONNECT; /* Even if the connect pended, the fd is now available. Set it up for events */ BAIL_ON_ERROR(status = lwmsg_task_set_trigger_fd(task->event_task, CONNECTION_PRIVATE(task->assoc)->fd)); /* Restore status code */ status = LWMSG_STATUS_PENDING; lwmsg_peer_task_set_timeout(peer, task, &peer->timeout.establish, trigger, next_trigger, next_timeout); break; default: BAIL_ON_ERROR(status = lwmsg_peer_task_handle_assoc_error( peer, task, status)); break; } done: return status; error: goto done; }
DWORD LwSmIpcAcquireCall( LWMsgCall** ppCall ) { DWORD dwError = 0; dwError = LwSmIpcCallInit(); BAIL_ON_ERROR(dwError); dwError = MAP_LWMSG_STATUS(lwmsg_peer_acquire_call(gpClient, ppCall)); BAIL_ON_ERROR(dwError); error: return dwError; }
static LWMsgStatus lwmsg_peer_task_finish_transceive( LWMsgPeer* peer, PeerAssocTask* task ) { LWMsgStatus status = LWMSG_STATUS_PENDING; LWMsgMessage* message = NULL; while ((!task->recv_blocked && task->incoming) || (!task->send_blocked && task->outgoing)) { status = lwmsg_assoc_finish(task->assoc, &message); switch (status) { case LWMSG_STATUS_SUCCESS: if (message == &task->incoming_message) { task->incoming = LWMSG_FALSE; task->recv_partial = LWMSG_FALSE; BAIL_ON_ERROR(status = lwmsg_peer_task_dispatch_incoming_message(task)); } else if (message == &task->outgoing_message) { lwmsg_peer_log_message(task, &task->outgoing_message, LWMSG_FALSE); task->outgoing = LWMSG_FALSE; if (task->destroy_outgoing) { lwmsg_assoc_destroy_message(task->assoc, &task->outgoing_message); task->destroy_outgoing = LWMSG_FALSE; } } break; case LWMSG_STATUS_PENDING: lwmsg_peer_task_update_blocked(task); break; default: BAIL_ON_ERROR(status); } } error: return status; }
LWMsgStatus lwmsg_peer_new( const LWMsgContext* context, LWMsgProtocol* protocol, LWMsgPeer** out_peer ) { LWMsgStatus status = LWMSG_STATUS_SUCCESS; LWMsgPeer* peer = NULL; BAIL_ON_ERROR(status = LWMSG_ALLOC(&peer)); lwmsg_ring_init(&peer->connect_endpoints); lwmsg_ring_init(&peer->listen_endpoints); memset(&peer->timeout, 0xFF, sizeof(peer->timeout)); peer->context = context; BAIL_ON_ERROR(status = lwmsg_status_map_errno(pthread_mutex_init(&peer->lock, NULL))); peer->lock_init = LWMSG_TRUE; BAIL_ON_ERROR(status = lwmsg_status_map_errno(pthread_cond_init(&peer->event, NULL))); peer->event_init = LWMSG_TRUE; BAIL_ON_ERROR(status = lwmsg_task_acquire_manager(&peer->task_manager)); BAIL_ON_ERROR(status = lwmsg_task_group_new(peer->task_manager, &peer->connect_tasks)); peer->max_clients = 100; peer->max_backlog = 8; peer->protocol = protocol; *out_peer = peer; done: return status; error: if (peer) { lwmsg_peer_delete(peer); } goto done; }
static LWMsgStatus lwmsg_data_unmarshal_indirect( LWMsgDataContext* context, LWMsgUnmarshalState* state, LWMsgTypeIter* iter, LWMsgTypeIter* inner, LWMsgBuffer* buffer, unsigned char* object, size_t count ) { LWMsgStatus status = LWMSG_STATUS_SUCCESS; size_t i; unsigned char* element = NULL; if ((inner->kind == LWMSG_KIND_INTEGER || inner->kind == LWMSG_KIND_ENUM) && inner->info.kind_integer.width == 1 && inner->size == 1) { /* If the element type is an integer and the packed and unpacked sizes are both 1, then we can copy directly from the marshalled data into the object. This is an important optimization for unmarshalling character strings */ BAIL_ON_ERROR(status = lwmsg_buffer_read(buffer, object, count * inner->size)); } else { /* Otherwise, we need to unmarshal each element individually */ element = object; for (i = 0; i < count; i++) { BAIL_ON_ERROR(status = lwmsg_data_unmarshal_internal( context, state, inner, buffer, element)); element += inner->size; } } error: return status; }
void client::AddTrustedRoot( std::string Cert) { DWORD dwError = 0; PVECS_STORE pStore = NULL; dwError = VecsCreateCertStoreA( (PSTR) ServerName.c_str(), TRUSTED_ROOTS_STORE_NAME, NULL, &pStore); if (dwError == ERROR_ALREADY_EXISTS) { dwError = VecsOpenCertStoreA( (PSTR) ServerName.c_str(), TRUSTED_ROOTS_STORE_NAME, NULL, &pStore); } BAIL_ON_ERROR(dwError); dwError = VecsAddEntryA( pStore, CERT_ENTRY_TYPE_TRUSTED_CERT, NULL, (PSTR) Cert.c_str(), NULL, NULL, 0); if (dwError == ERROR_ALREADY_EXISTS) { dwError = 0; } BAIL_ON_ERROR(dwError); cleanup: if (pStore) { VecsCloseCertStore(pStore); } return; error: THROW_IF_NEEDED(dwError); goto cleanup; }
LWMsgStatus lwmsg_assoc_print_message_alloc( LWMsgAssoc* assoc, LWMsgMessage* message, char** result ) { LWMsgStatus status = LWMSG_STATUS_SUCCESS; LWMsgDataContext* context = NULL; LWMsgTypeSpec* type = NULL; LWMsgBuffer buffer = {0}; const char* tag_name = NULL; unsigned char nul = 0; buffer.wrap = realloc_wrap; buffer.data = (void*) &assoc->context; BAIL_ON_ERROR(status = lwmsg_data_context_new(&assoc->context, &context)); BAIL_ON_ERROR(status = lwmsg_protocol_get_message_name(assoc->prot, message->tag, &tag_name)); BAIL_ON_ERROR(status = lwmsg_protocol_get_message_type(assoc->prot, message->tag, &type)); if (type) { BAIL_ON_ERROR(status = lwmsg_buffer_print(&buffer, "%s: ", tag_name)); BAIL_ON_ERROR(status = lwmsg_data_print_graph( context, type, message->data, 4, &buffer)); BAIL_ON_ERROR(status = lwmsg_buffer_write(&buffer, &nul, 1)); } else { BAIL_ON_ERROR(status = lwmsg_buffer_print(&buffer, "%s", tag_name)); } *result = (char*) buffer.base; cleanup: if (context) { lwmsg_data_context_delete(context); } return status; error: *result = NULL; if (buffer.base) { lwmsg_context_free(&assoc->context, buffer.base); } goto cleanup; }
static LWMsgStatus lwmsg_archive_read_message_wrap_fd ( LWMsgBuffer* buffer, size_t needed ) { LWMsgStatus status = LWMSG_STATUS_SUCCESS; readinfo* info = buffer->data; LWMsgArchive* archive = info->archive; size_t count = 0; if (needed) { /* Read next block of data from file */ if (info->remaining == 0) { /* The message was longer than the length specified in the header */ BAIL_ON_ERROR(status = LWMSG_STATUS_MALFORMED); } else { BAIL_ON_ERROR(status = lwmsg_archive_read_fd( archive, info->data, info->remaining > sizeof(info->data) ? sizeof(info->data) : info->remaining, &count)); info->remaining -= count; buffer->end = buffer->base + count; buffer->cursor = buffer->base; } } else { if (info->remaining != 0) { /* The message was shorter than the length specified in the header */ BAIL_ON_ERROR(status = LWMSG_STATUS_MALFORMED); } } error: return status; }
DWORD LwSmTableGetEntryReverseDependencyClosure( PSM_TABLE_ENTRY pEntry, PWSTR** pppwszServiceList ) { DWORD dwError = 0; PWSTR* ppwszServiceList = NULL; PWSTR* ppwszAllServices = NULL; dwError = LwAllocateMemory(sizeof(*ppwszServiceList) * 1, OUT_PPVOID(&ppwszServiceList)); BAIL_ON_ERROR(dwError); dwError = LwSmTableEnumerateEntries(&ppwszAllServices); BAIL_ON_ERROR(dwError); dwError = LwSmTableGetEntryReverseDependencyClosureHelper( pEntry, ppwszAllServices, &ppwszServiceList); BAIL_ON_ERROR(dwError); *pppwszServiceList = ppwszServiceList; cleanup: if (ppwszAllServices) { LwSmFreeStringList(ppwszAllServices); } return dwError; error: *pppwszServiceList = NULL; if (ppwszServiceList) { LwSmFreeStringList(ppwszServiceList); } goto cleanup; }
static DWORD LwSmTableStartRecursive( PSM_TABLE_ENTRY pEntry ) { DWORD error = 0; PSM_TABLE_ENTRY pOtherEntry = NULL; PWSTR* ppServices = NULL; DWORD index = 0; /* Start all dependencies */ error = LwSmTableGetEntryDependencyClosure(pEntry, &ppServices); BAIL_ON_ERROR(error); for (index = 0; ppServices[index]; index++) { error = LwSmTableGetEntry(ppServices[index], &pOtherEntry); BAIL_ON_ERROR(error); error = LwSmTableStartEntry(pOtherEntry); BAIL_ON_ERROR(error); LwSmTableReleaseEntry(pOtherEntry); pOtherEntry = NULL; } error = LwSmTableStartEntry(pEntry); BAIL_ON_ERROR(error); error: if (ppServices) { LwSmFreeStringList(ppServices); } if (pOtherEntry) { LwSmTableReleaseEntry(pOtherEntry); } return error; }
static DWORD LwSmConfigureLogging( PCSTR pszProgramName ) { DWORD dwError = 0; LwSmLoggingInit(pszProgramName); if (gState.logLevel == 0) { if (gState.bStartAsDaemon || (gState.bContainer && !gState.pGroup)) { gState.logLevel = LW_SM_LOG_LEVEL_WARNING; } else { gState.logLevel = LW_SM_LOG_LEVEL_VERBOSE; } } LwSmSetMaxLogLevel(NULL, gState.logLevel); if (gState.pszLogFilePath) { dwError = LwSmSetLoggerToPath(NULL, gState.pszLogFilePath); BAIL_ON_ERROR(dwError); } else if (gState.bSyslog) { dwError = LwSmSetLoggerToSyslog(NULL); BAIL_ON_ERROR(dwError); } else { dwError = LwSmSetLoggerToFile(NULL, stderr); BAIL_ON_ERROR(dwError); } error: return dwError; }
/* Find or unmarshal the length of a pointer or array */ static LWMsgStatus lwmsg_data_unmarshal_indirect_prologue( LWMsgDataContext* context, LWMsgUnmarshalState* state, LWMsgTypeIter* iter, LWMsgTypeIter* inner, LWMsgBuffer* buffer, size_t* out_count ) { LWMsgStatus status = LWMSG_STATUS_SUCCESS; unsigned char temp[4]; switch (iter->info.kind_indirect.term) { case LWMSG_TERM_STATIC: /* Static lengths are easy */ *out_count = iter->info.kind_indirect.term_info.static_length; break; case LWMSG_TERM_MEMBER: /* The length is present in a member we have already unmarshalled */ BAIL_ON_ERROR(status = lwmsg_data_extract_length( iter, state->dominating_object, out_count)); break; case LWMSG_TERM_ZERO: /* The length is present in the data stream as an unsigned 32-bit integer */ BAIL_ON_ERROR(status = lwmsg_buffer_read(buffer, temp, sizeof(temp))); BAIL_ON_ERROR(status = lwmsg_convert_integer( temp, sizeof(temp), context->byte_order, out_count, sizeof(*out_count), LWMSG_NATIVE_ENDIAN, LWMSG_UNSIGNED)); break; } error: return status; }
SSOERROR IdmJsonToPasswordResetRequestData( PCSSO_JSON pJson, IDM_PASSWORD_RESET_REQUEST_DATA** ppPasswordResetRequest) { SSOERROR e = SSOERROR_NONE; IDM_PASSWORD_RESET_REQUEST_DATA* pPasswordResetRequest = NULL; if (pJson == NULL || ppPasswordResetRequest == NULL) { e = SSOERROR_INVALID_ARGUMENT; BAIL_ON_ERROR(e); } e = SSOMemoryAllocate(sizeof(IDM_PASSWORD_RESET_REQUEST_DATA), (void**) &pPasswordResetRequest); BAIL_ON_ERROR(e); e = RestJsonToData( pJson, REST_JSON_OBJECT_TYPE_STRING, NULL, "currentPassword", (void**) &(pPasswordResetRequest->currentPassword)); BAIL_ON_ERROR(e); e = RestJsonToData( pJson, REST_JSON_OBJECT_TYPE_STRING, NULL, "newPassword", (void**) &(pPasswordResetRequest->newPassword)); BAIL_ON_ERROR(e); *ppPasswordResetRequest = pPasswordResetRequest; error: if (e != SSOERROR_NONE) { IdmPasswordResetRequestDataDelete(pPasswordResetRequest); } return e; }
DWORD LwSmQueryServiceReverseDependencyClosure( LW_SERVICE_HANDLE hHandle, PWSTR** pppwszServiceList ) { DWORD dwError = 0; PWSTR* ppwszServiceList = NULL; PWSTR* ppwszAllServices = NULL; dwError = LwAllocateMemory(sizeof(*ppwszServiceList) * 1, OUT_PPVOID(&ppwszServiceList)); BAIL_ON_ERROR(dwError); dwError = LwSmEnumerateServices(&ppwszAllServices); BAIL_ON_ERROR(dwError); dwError = LwSmQueryServiceReverseDependencyClosureHelper( hHandle, ppwszAllServices, &ppwszServiceList); BAIL_ON_ERROR(dwError); *pppwszServiceList = ppwszServiceList; cleanup: if (ppwszAllServices) { LwSmFreeStringList(ppwszAllServices); } return dwError; error: *pppwszServiceList = NULL; if (ppwszServiceList) { LwSmFreeStringList(ppwszServiceList); } goto cleanup; }
DWORD ConvertAnsitoUnicodeString( PCSTR pszSrc, PWSTR* ppwszDst ) { DWORD dwError = 0; #ifdef _WIN32 PSTR pszNewString = NULL; #endif if (!pszSrc || !ppwszDst) { dwError = ERROR_INVALID_PARAMETER; } else { #ifdef _WIN32 // allocate space for new string then pass addr to output // double the original PSTR size for WPSTR ULONG srcLen = (ULONG)strlen(pszSrc)+1; ULONG destLen = (srcLen+1)*2; dwError = VMCAAllocateMemory((DWORD) destLen, (PVOID*)&pszNewString); BAIL_ON_ERROR(dwError); if (0 == MultiByteToWideChar(CP_ACP, 0, pszSrc, -1, (LPWSTR)pszNewString, destLen)) { dwError = GetLastError(); BAIL_ON_ERROR(dwError); } *ppwszDst = (LPWSTR)pszNewString; cleanup: return dwError; error: VMCAFreeMemory(pszNewString); goto cleanup; #else dwError = LwNtStatusToWin32Error( LwRtlWC16StringAllocateFromCString(ppwszDst, pszSrc)); #endif } return dwError; }
DWORD VMCAASN1ToTimeT( ASN1_TIME *pTime, time_t *ptmTime ) { /* Time format is either YYmmddHHMMSS or YYYYmmddHHMMSS */ DWORD dwError = 0; struct tm time1; int ndx = 0; const char *tmstring = (const char *) pTime->data; if(tmstring == NULL) { dwError = VMCA_CRL_NULL_TIME; BAIL_ON_ERROR(dwError); } memset(&time1, 0, sizeof(time1)); // Two digit year if(pTime->type == V_ASN1_UTCTIME) { time1.tm_year = (tmstring[ndx++] - '0') * 10; time1.tm_year += tmstring[ndx++] - '0'; if( time1.tm_year < 70) { time1.tm_year += 100; } } else if ( pTime->type == V_ASN1_GENERALIZEDTIME){ // Four digit year time1.tm_year = (tmstring[ndx++] - '0') * 1000; time1.tm_year += (tmstring[ndx++] - '0') * 100; time1.tm_year += (tmstring[ndx++] - '0') * 10; time1.tm_year += (tmstring[ndx++] - '0') * 1; time1.tm_year -=1900; } time1.tm_mon = (tmstring[ndx++] - '0') * 10; time1.tm_mon += (tmstring[ndx++] - '0') - 1; time1.tm_mday = (tmstring[ndx++] - '0') * 10; time1.tm_mday += (tmstring[ndx++] - '0'); time1.tm_hour = (tmstring[ndx++] - '0') * 10; time1.tm_hour += (tmstring[ndx++] - '0'); time1.tm_min = (tmstring[ndx++] - '0') * 10; time1.tm_min +=(tmstring[ndx++] - '0'); time1.tm_sec = (tmstring[ndx++] - '0') * 10; time1.tm_sec +=(tmstring[ndx++] - '0'); // Ignoring Z +hh 'mm' for time1 being. *ptmTime = mktime(&time1); error : return dwError; }
DWORD VMCABackupRootCAFiles( PCSTR pszRootCACertFile, PCSTR pszRootCAPrivateKeyFile, PCSTR pszRootCAPasswordFile ) { DWORD dwError = ERROR_SUCCESS; dwError = VMCABackupFiles(pszRootCACertFile); BAIL_ON_ERROR(dwError); dwError = VMCABackupFiles(pszRootCAPrivateKeyFile); BAIL_ON_ERROR(dwError); dwError = VMCABackupFiles(pszRootCAPasswordFile); BAIL_ON_ERROR(dwError); error: return dwError; }
void sr_Mod(cpu_t *pcpu, decode_t *pdecoded) { uint32_t tmp1 = pop(pcpu); uint32_t tmp2 = pop(pcpu); BAIL_ON_ERROR(); if (tmp2 == 0) { pcpu->state = Cpu_Break; return; } push(pcpu, tmp1 % tmp2); }
DWORD ConvertUnicodetoAnsiString( PCWSTR pwszSrc, PSTR* ppszDst ) { DWORD dwError = 0; #ifdef _WIN32 PSTR pszNewString = NULL; #endif if (!pwszSrc || !ppszDst) { dwError = ERROR_INVALID_PARAMETER; } else { #ifdef _WIN32 ULONG srcLen = (ULONG)wcslen(pwszSrc)+1; ULONG destLen = srcLen*2; dwError = VMCAAllocateMemory((DWORD) destLen, (PVOID*)&pszNewString); BAIL_ON_ERROR(dwError); if (0 == WideCharToMultiByte(CP_ACP, 0, pwszSrc, -1, pszNewString, destLen, NULL, NULL )) { dwError = GetLastError(); BAIL_ON_ERROR(dwError); } *ppszDst = pszNewString; cleanup: return dwError; error: VMCAFreeMemory(pszNewString); goto cleanup; #else dwError = LwNtStatusToWin32Error( LwRtlCStringAllocateFromWC16String(ppszDst, pwszSrc)); #endif } return dwError; }
LWMsgStatus lwmsg_peer_connect_fd( LWMsgPeer* peer, LWMsgEndpointType type, int fd, LWMsgSession** session ) { LWMsgStatus status = LWMSG_STATUS_SUCCESS; LWMsgBool locked = LWMSG_FALSE; PeerEndpoint* endpoint = NULL; BAIL_ON_ERROR(status = LWMSG_ALLOC(&endpoint)); endpoint->fd = fd; endpoint->type = type; PEER_LOCK(peer, locked); if (peer->connect_session) { BAIL_ON_ERROR(status = LWMSG_STATUS_INVALID_STATE); } BAIL_ON_ERROR(status = lwmsg_peer_session_new(peer, &peer->connect_session)); peer->connect_session->endpoint = endpoint; endpoint = NULL; if (session) { *session = (LWMsgSession*) peer->connect_session; } error: PEER_UNLOCK(peer, locked); if (endpoint) { free(endpoint); } return status; }
DWORD VMCAGetNextUpdateTime( X509_CRL *pCrl, time_t *pNextUpdateTime ) { DWORD dwError = 0; ASN1_TIME *pLastUpdate = NULL; ASN1_TIME *pNextUpdate = NULL; time_t tmLast = 0; time_t tmNext = 0; time_t tmDiff = 0; time_t tmNextUpdate = 0; if( (pCrl == NULL) || (pNextUpdateTime == NULL)) { dwError = ERROR_INVALID_PARAMETER; BAIL_ON_ERROR(dwError); } pLastUpdate = X509_CRL_get_lastUpdate(pCrl); pNextUpdate = X509_CRL_get_nextUpdate(pCrl); dwError = VMCAASN1ToTimeT(pLastUpdate, &tmLast); BAIL_ON_ERROR(dwError); dwError = VMCAASN1ToTimeT(pNextUpdate, &tmNext); BAIL_ON_ERROR(dwError); tmDiff = tmNext - tmLast; tmNextUpdate = time(NULL) + tmDiff; *pNextUpdateTime = tmNextUpdate; cleanup : return dwError; error : goto cleanup; }
static LWMsgStatus lwmsg_peer_task_run_accept( LWMsgPeer* peer, PeerAssocTask* task, LWMsgTaskTrigger trigger, LWMsgTaskTrigger* next_trigger, LWMsgTime* next_timeout ) { LWMsgStatus status = LWMSG_STATUS_SUCCESS; /* We already have the fd when accepting a connection, so set it up for events now */ BAIL_ON_ERROR(status = lwmsg_task_set_trigger_fd(task->event_task, CONNECTION_PRIVATE(task->assoc)->fd)); status = lwmsg_assoc_accept(task->assoc, (LWMsgSession*) task->session); switch (status) { case LWMSG_STATUS_SUCCESS: task->type = PEER_TASK_DISPATCH; BAIL_ON_ERROR(status = lwmsg_peer_log_accept(task)); break; case LWMSG_STATUS_PENDING: task->type = PEER_TASK_FINISH_ACCEPT; lwmsg_peer_task_set_timeout(peer, task, &peer->timeout.establish, trigger, next_trigger, next_timeout); break; default: BAIL_ON_ERROR(status = lwmsg_peer_task_handle_assoc_error( peer, task, status)); break; } done: return status; error: goto done; }
void client::SetLDU(std::string LDUName) { DWORD dwError = 0; dwError = VmAfdSetLDUA(ServerName.c_str(), LDUName.c_str()); BAIL_ON_ERROR(dwError); error: THROW_IF_NEEDED(dwError); }
DWORD ReadFileContentsToString(std::string FileName, PSTR *ppszData) { DWORD dwError = 0; FILE * fp = NULL; size_t stDataSize = 0; PSTR pszFileData = NULL; DWORD dwReadSize =0; fflush(NULL); // This prevents writes in Python code which lingers in Memory #ifdef _WIN32 #define stat _stat #endif struct stat filedata = { 0 }; dwError = stat(FileName.c_str(), &filedata); BAIL_ON_ERROR(dwError); stDataSize = filedata.st_size; dwError = VmAfdAllocateMemory(stDataSize + 1,(PVOID*) &pszFileData); BAIL_ON_ERROR(dwError); dwError = VmAfdOpenFilePath(FileName.c_str(), "r", &fp, 0); BAIL_ON_ERROR(dwError); dwReadSize = fread(pszFileData, 1, stDataSize, fp); if (dwReadSize != stDataSize) { dwError = VECS_GENERIC_FILE_IO; BAIL_ON_ERROR(dwError); } *ppszData = pszFileData; cleanup: if (fp != NULL) { fclose(fp); } return dwError; error: VMAFD_SAFE_FREE_MEMORY(pszFileData); goto cleanup; }
void client::SetDCPort(unsigned int port) { DWORD dwError = 0; dwError = VmAfdSetDCPortA(ServerName.c_str(), port); BAIL_ON_ERROR(dwError); error: THROW_IF_NEEDED(dwError); }
static DWORD LwSmCmdSetLogLevel( int argc, char** pArgv ) { DWORD dwError = 0; LW_SM_LOG_LEVEL level = 0; PSTR pFacility = NULL; LW_SERVICE_HANDLE hHandle = NULL; PWSTR pServiceName = NULL; if (argc < 4) { dwError = LW_ERROR_INVALID_PARAMETER; BAIL_ON_ERROR(dwError); } if (strcmp(pArgv[1], "-")) { dwError = LwMbsToWc16s(pArgv[1], &pServiceName); BAIL_ON_ERROR(dwError); dwError = LwSmAcquireServiceHandle(pServiceName, &hHandle); BAIL_ON_ERROR(dwError); } if (strcmp(pArgv[2], "-")) { pFacility = pArgv[2]; } dwError = LwSmLogLevelNameToLogLevel(pArgv[3], &level); BAIL_ON_ERROR(dwError); dwError = LwSmSetServiceLogLevel(hHandle, pFacility, level); BAIL_ON_ERROR(dwError); error: return dwError; }
LWMsgStatus lwmsg_peer_set_timeout( LWMsgPeer* peer, LWMsgTimeout type, LWMsgTime* value ) { LWMsgStatus status = LWMSG_STATUS_SUCCESS; LWMsgTime* target = NULL; lwmsg_peer_lock(peer); if (peer->state != PEER_STATE_STOPPED) { BAIL_ON_ERROR(status = LWMSG_STATUS_INVALID_STATE); } if (value != NULL && (value->seconds < 0 || value->microseconds < 0)) { PEER_RAISE_ERROR(peer->context, status = LWMSG_STATUS_INVALID_PARAMETER, "Invalid (negative) timeout value"); } switch (type) { case LWMSG_TIMEOUT_MESSAGE: target = &peer->timeout.message; break; case LWMSG_TIMEOUT_ESTABLISH: target = &peer->timeout.establish; break; case LWMSG_TIMEOUT_IDLE: target = &peer->timeout.idle; break; default: PEER_RAISE_ERROR(peer->context, status = LWMSG_STATUS_UNSUPPORTED, "Unsupported timeout type"); } if (value) { *target = *value; } else { memset(target, 0xFF, sizeof(*target)); } error: lwmsg_peer_unlock(peer); return status; }
LWMsgStatus lwmsg_archive_read_header_fd( LWMsgArchive* archive ) { LWMsgStatus status = LWMSG_STATUS_SUCCESS; ArchiveHeader header; size_t count = 0; BAIL_ON_ERROR(status = lwmsg_archive_read_fd(archive, &header, sizeof(header), &count)); if (count < sizeof(header) || memcmp(header.magic, "LWMA", 4) != 0) { BAIL_ON_ERROR(status = LWMSG_STATUS_MALFORMED); } if (header.version_major > ARCHIVE_VERSION_MAJOR || header.version_minor > ARCHIVE_VERSION_MINOR) { BAIL_ON_ERROR(status = LWMSG_STATUS_MALFORMED); } archive->version_major = header.version_major; archive->version_minor = header.version_minor; if (header.version_flags & ARCHIVE_VERSION_FLAG_BIG_ENDIAN) { archive->byte_order = LWMSG_BIG_ENDIAN; } else { archive->byte_order = LWMSG_LITTLE_ENDIAN; } lwmsg_data_context_set_byte_order(archive->data_context, archive->byte_order); BAIL_ON_ERROR(status = lwmsg_archive_read_schema_fd(archive, &header)); error: return status; }
DWORD LwSmTableRefreshEntry( PSM_TABLE_ENTRY pEntry ) { DWORD dwError = 0; BOOLEAN bLocked = FALSE; LW_SERVICE_STATUS status = {.state = LW_SERVICE_STATE_DEAD}; LOCK(bLocked, pEntry->pLock); if (!pEntry->bValid) { dwError = LW_ERROR_INVALID_HANDLE; BAIL_ON_ERROR(dwError); } dwError = LwSmTablePollEntry(pEntry, &status); BAIL_ON_ERROR(dwError); switch (status.state) { case LW_SERVICE_STATE_RUNNING: UNLOCK(bLocked, pEntry->pLock); dwError = pEntry->pVtbl->pfnRefresh(&pEntry->object); LOCK(bLocked, pEntry->pLock); BAIL_ON_ERROR(dwError); break; default: break; } cleanup: UNLOCK(bLocked, pEntry->pLock); return dwError; error: goto cleanup; }