PlayerStatus_t Player_Generic_c::InjectData( PlayerPlayback_t Playback, Buffer_t Buffer ) { unsigned int i; unsigned int Length; void *Data; PlayerInputMuxType_t MuxType; PlayerStatus_t Status; #ifdef __TDT__ DemultiplexorStatus_t DemuxStatus; #endif PlayerInputDescriptor_t *Descriptor; // Status = Buffer->ObtainMetaDataReference( MetaDataInputDescriptorType, (void **)(&Descriptor) ); if( Status != PlayerNoError ) { report( severity_error, "Player_Generic_c::InjectData - Unable to obtain the meta data input descriptor.\n" ); return Status; } // if( Descriptor->MuxType == MuxTypeUnMuxed ) { // // Un muxed data, call the appropriate collator // Status = Buffer->ObtainDataReference( NULL, &Length, &Data ); if( Status != PlayerNoError ) { report( severity_error, "Player_Generic_c::InjectData - unable to obtain data reference.\n" ); return Status; } Status = Descriptor->UnMuxedStream->Collator->Input( Descriptor, Length, Data ); } else { // // Data is muxed - seek a demultiplexor and pass on the call // for( i=0; i<DemultiplexorCount; i++ ) { Demultiplexors[i]->GetHandledMuxType( &MuxType ); if( MuxType == Descriptor->MuxType ) break; } if( i < DemultiplexorCount ) { #ifdef __TDT__ DemuxStatus = Demultiplexors[i]->Demux( Playback, Descriptor->DemultiplexorContext, Buffer ); #else Status = Demultiplexors[i]->Demux( Playback, Descriptor->DemultiplexorContext, Buffer ); #endif } else { report( severity_error, "Player_Generic_c::InjectData - No suitable demultiplexor registerred for this MuxType (%d).\n", Descriptor->MuxType ); Status = PlayerUnknowMuxType; } } #ifdef __TDT__ if(DemuxStatus == DemultiplexorBufferOverflow) for(PlayerStream_t Stream = Playback->ListOfStreams; Stream != NULL; Stream = Stream->Next) Stream->Collator->DiscardAccumulatedData(); #endif // // Release the buffer // Buffer->DecrementReferenceCount( IdentifierGetInjectBuffer ); return Status; }
static int dostring (lua_State *L, const char *s, const char *name) { int status = luaL_loadbuffer(L, s, strlen(s), name) || docall(L, 0, 1); return report(L, status); }
static int dochunk (lua_State *L, int status) { if (status == LUA_OK) status = docall(L, 0, 0); return report(L, status); }
CodecStatus_t Codec_MmeVideoMpeg2_c::DumpSetStreamParameters(void *Parameters) { MPEG2_SetGlobalParamSequence_t *StreamParams; // StreamParams = (MPEG2_SetGlobalParamSequence_t *)Parameters; report(severity_info, "AZA - STREAM PARAMS %08x\n", StreamParams); report(severity_info, "AZA - StructSize = %d\n", StreamParams->StructSize); report(severity_info, "AZA - MPEGStreamTypeFlag = %d\n", StreamParams->MPEGStreamTypeFlag); report(severity_info, "AZA - horizontal_size = %d\n", StreamParams->horizontal_size); report(severity_info, "AZA - vertical_size = %d\n", StreamParams->vertical_size); report(severity_info, "AZA - progressive_sequence = %d\n", StreamParams->progressive_sequence); report(severity_info, "AZA - chroma_format = %d\n", StreamParams->chroma_format); report(severity_info, "AZA - MatrixFlags = %d\n", StreamParams->MatrixFlags); report(severity_info, "AZA - intra_quantiser_matrix = %02x %02x %02x %02x %02x %02x %02x %02x\n", StreamParams->intra_quantiser_matrix[0], StreamParams->intra_quantiser_matrix[1], StreamParams->intra_quantiser_matrix[2], StreamParams->intra_quantiser_matrix[3], StreamParams->intra_quantiser_matrix[4], StreamParams->intra_quantiser_matrix[5], StreamParams->intra_quantiser_matrix[6], StreamParams->intra_quantiser_matrix[7]); report(severity_info, "AZA - non_intra_quantiser_matrix = %02x %02x %02x %02x %02x %02x %02x %02x\n", StreamParams->non_intra_quantiser_matrix[0], StreamParams->non_intra_quantiser_matrix[1], StreamParams->non_intra_quantiser_matrix[2], StreamParams->non_intra_quantiser_matrix[3], StreamParams->non_intra_quantiser_matrix[4], StreamParams->non_intra_quantiser_matrix[5], StreamParams->non_intra_quantiser_matrix[6], StreamParams->non_intra_quantiser_matrix[7]); report(severity_info, "AZA - chroma_intra_quantiser_matrix = %02x %02x %02x %02x %02x %02x %02x %02x\n", StreamParams->chroma_intra_quantiser_matrix[0], StreamParams->chroma_intra_quantiser_matrix[1], StreamParams->chroma_intra_quantiser_matrix[2], StreamParams->chroma_intra_quantiser_matrix[3], StreamParams->chroma_intra_quantiser_matrix[4], StreamParams->chroma_intra_quantiser_matrix[5], StreamParams->chroma_intra_quantiser_matrix[6], StreamParams->chroma_intra_quantiser_matrix[7]); report(severity_info, "AZA - chroma_non_intra_quantiser_matrix = %02x %02x %02x %02x %02x %02x %02x %02x\n", StreamParams->chroma_non_intra_quantiser_matrix[0], StreamParams->chroma_non_intra_quantiser_matrix[1], StreamParams->chroma_non_intra_quantiser_matrix[2], StreamParams->chroma_non_intra_quantiser_matrix[3], StreamParams->chroma_non_intra_quantiser_matrix[4], StreamParams->chroma_non_intra_quantiser_matrix[5], StreamParams->chroma_non_intra_quantiser_matrix[6], StreamParams->chroma_non_intra_quantiser_matrix[7]); return CodecNoError; }
static int proc_maps_report (Dwfl *dwfl, FILE *f, GElf_Addr sysinfo_ehdr, pid_t pid) { unsigned int last_dmajor = -1, last_dminor = -1; uint64_t last_ino = -1; char *last_file = NULL; Dwarf_Addr low = 0, high = 0; inline bool report (void) { if (last_file != NULL) { Dwfl_Module *mod = INTUSE(dwfl_report_module) (dwfl, last_file, low, high); free (last_file); last_file = NULL; if (unlikely (mod == NULL)) return true; } return false; } char *line = NULL; size_t linesz; ssize_t len; while ((len = getline (&line, &linesz, f)) > 0) { if (line[len - 1] == '\n') line[len - 1] = '\0'; Dwarf_Addr start, end, offset; unsigned int dmajor, dminor; uint64_t ino; int nread = -1; if (sscanf (line, "%" PRIx64 "-%" PRIx64 " %*s %" PRIx64 " %x:%x %" PRIi64 " %n", &start, &end, &offset, &dmajor, &dminor, &ino, &nread) < 6 || nread <= 0) { free (line); return ENOEXEC; } /* If this is the special mapping AT_SYSINFO_EHDR pointed us at, report the last one and then this special one. */ if (start == sysinfo_ehdr && start != 0) { if (report ()) { bad_report: free (line); fclose (f); return -1; } low = start; high = end; if (asprintf (&last_file, "[vdso: %d]", (int) pid) < 0 || report ()) goto bad_report; } char *file = line + nread + strspn (line + nread, " \t"); if (file[0] == '\0' || (ino == 0 && dmajor == 0 && dminor == 0)) /* This line doesn't indicate a file mapping. */ continue; if (last_file != NULL && ino == last_ino && dmajor == last_dmajor && dminor == last_dminor) { /* This is another portion of the same file's mapping. */ assert (!strcmp (last_file, file)); high = end; } else { /* This is a different file mapping. Report the last one. */ if (report ()) goto bad_report; low = start; high = end; last_file = strdup (file); last_ino = ino; last_dmajor = dmajor; last_dminor = dminor; } } free (line); int result = ferror_unlocked (f) ? errno : feof_unlocked (f) ? 0 : ENOEXEC; /* Report the final one. */ bool lose = report (); return result != 0 ? result : lose ? -1 : 0; }
int main(int , char** ) { #if defined(_MSC_VER) compile_msvc compile_policy; #else //compile_bjam compile_policy; compile_clang compile_policy; #endif typedef std::vector<algorithm> v_a_type; v_a_type algorithms; algorithms.push_back(algorithm("area")); algorithms.push_back(algorithm("clear")); algorithms.push_back(algorithm("correct")); algorithms.push_back(algorithm("centroid")); // NOTE: current doc contains 2D / 3D algorithms.push_back(algorithm("envelope")); algorithms.push_back(algorithm("length")); algorithms.push_back(algorithm("is_simple")); algorithms.push_back(algorithm("is_valid")); algorithms.push_back(algorithm("num_points")); algorithms.push_back(algorithm("perimeter")); algorithms.push_back(algorithm("covered_by", 2)); algorithms.push_back(algorithm("distance", 2)); algorithms.push_back(algorithm("crosses", 2)); algorithms.push_back(algorithm("disjoint", 2)); algorithms.push_back(algorithm("equals", 2)); algorithms.push_back(algorithm("intersects", 2)); algorithms.push_back(algorithm("overlaps", 2)); algorithms.push_back(algorithm("within", 2)); typedef std::vector<cs> cs_type; cs_type css; css.push_back(cs("cartesian")); // css.push_back(cs("spherical<bg::degree>")); // css.push_back(cs("spherical<bg::radian>")); boost::timer timer; for (v_a_type::const_iterator it = algorithms.begin(); it != algorithms.end(); ++it) { /*([heading Behavior] [table [[Case] [Behavior] ] [[__2dim__][All combinations of: box, ring, polygon, multi_polygon]] [[__other__][__nyiversion__]] [[__sph__][__nyiversion__]] [[Three dimensional][__nyiversion__]] ]*/ std::ostringstream name; name << "../../../../reference/status/" << it->name << "_status.qbk"; std::ofstream out(name.str().c_str()); out << "[heading Supported geometries]" << std::endl; cs_type::const_iterator cit = css.begin(); { // Construct the table std::vector<std::vector<int> > table; for (int type = point; type < geometry_count; type++) { table.push_back(report(compile_policy, type, *it, true, true, 2, cit->name)); } #if SURPRESS // Detect red rows/columns std::vector<int> lines_status(table.size(), false); std::vector<int> columns_status(table[0].size(), false); for (unsigned int i = 0; i != table.size(); ++i) { for (unsigned int j = 0; j != table[i].size(); ++j) { lines_status[i] |= table[i][j]; columns_status[j] |= table[i][j]; } } #endif // Display the table out << "[table" << std::endl << "["; if (it->arity > 1) { out << "[ ]"; for (int type = point; type < geometry_count; type++) { #if SURPRESS if (!columns_status[type]) continue; #endif out << "[" << geometry_string(type) << "]"; } } else { out << "[Geometry][Status]"; } out << "]" << std::endl; for (unsigned int i = 0; i != table.size(); ++i) { #if SURPRESS if (!lines_status[i]) continue; #endif out << "["; out << "[" << geometry_string(i) << "]"; for (unsigned int j = 0; j != table[i].size(); ++j) { #if SURPRESS if (!columns_status[j]) continue; #endif out << "[ [$img/" << (table[i][j] ? "ok" : "nyi") << ".png] ]"; } out << "]" << std::endl; } out << "]" << std::endl; } } std::cout << "TIME: " << timer.elapsed() << std::endl; return 0; }
static enum view_flag prompt_toggle_option(struct view *view, const char *argv[], struct prompt_toggle *toggle, char msg[SIZEOF_STR]) { char name[SIZEOF_STR]; enum_name_copy(name, toggle->name, strlen(toggle->name)); if (!strcmp(toggle->type, "bool")) { bool *opt = toggle->opt; *opt = !*opt; string_format_size(msg, SIZEOF_STR, "set %s = %s", name, *opt ? "yes" : "no"); } else if (!strncmp(toggle->type, "enum", 4)) { const char *type = toggle->type + STRING_SIZE("enum "); enum author *opt = toggle->opt; const struct enum_map *map = find_enum_map(type); *opt = (*opt + 1) % map->size; string_format_size(msg, SIZEOF_STR, "set %s = %s", name, enum_name(map->entries[*opt])); } else if (!strcmp(toggle->type, "int")) { const char *arg = argv[2] ? argv[2] : "1"; int diff = atoi(arg); int *opt = toggle->opt; if (!diff) diff = *arg == '-' ? -1 : 1; if (opt == &opt_diff_context && diff < 0) { if (!*opt) { report("Diff context cannot be less than zero"); return VIEW_NO_FLAGS; } if (*opt < -diff) diff = -*opt; } if (opt == &opt_title_overflow) { *opt = *opt ? -*opt : 50; if (*opt < 0) { string_format_size(msg, SIZEOF_STR, "set %s = no", name); return toggle->flags; } } *opt += diff; string_format_size(msg, SIZEOF_STR, "set %s = %d", name, *opt); } else if (!strcmp(toggle->type, "double")) { const char *arg = argv[2] ? argv[2] : "1.0"; double *opt = toggle->opt; int sign = 1; double diff; if (*arg == '-') { sign = -1; arg++; } if (parse_step(&diff, arg) != SUCCESS) diff = strtod(arg, NULL); *opt += sign * diff; string_format_size(msg, SIZEOF_STR, "set %s = %.2f", name, *opt); } else if (!strcmp(toggle->type, "const char **")) { const char ***opt = toggle->opt; bool found = TRUE; int i; for (i = 2; argv[i]; i++) { if (!find_arg(*opt, argv[i])) { found = FALSE; break; } } if (found) { int next, pos; for (next = 0, pos = 0; (*opt)[pos]; pos++) { const char *arg = (*opt)[pos]; if (find_arg(argv + 2, arg)) { free((void *) arg); continue; } (*opt)[next++] = arg; } (*opt)[next] = NULL; } else if (!argv_copy(opt, argv + 2)) { report("Failed to append arguments"); return VIEW_NO_FLAGS; } } else { die("Unsupported `:toggle %s` (%s)", name, toggle->type); } return toggle->flags; }
void Player_Generic_c::ProcessPostManifest(PlayerStream_t Stream) { PlayerStatus_t Status; RingStatus_t RingStatus; Buffer_t Buffer; Buffer_t OriginalCodedFrameBuffer; BufferType_t BufferType; PlayerControlStructure_t *ControlStructure; ParsedFrameParameters_t *ParsedFrameParameters; PlayerSequenceNumber_t *SequenceNumberStructure; unsigned long long LastEntryTime; unsigned long long SequenceNumber; unsigned long long MaximumActualSequenceNumberSeen; unsigned long long Time; unsigned int AccumulatedBeforeControlMessagesCount; unsigned int AccumulatedAfterControlMessagesCount; bool ProcessNow; unsigned int *Count; PlayerBufferRecord_t *Table; VideoOutputTiming_t *OutputTiming; unsigned long long Now; // LastEntryTime = OS_GetTimeInMicroSeconds(); SequenceNumber = INVALID_SEQUENCE_VALUE; MaximumActualSequenceNumberSeen = 0; Time = INVALID_TIME; AccumulatedBeforeControlMessagesCount = 0; AccumulatedAfterControlMessagesCount = 0; // // Signal we have started // /* this should really be atomic_inc_return() == expected, with correct memory barriers, to have a lockless design! */ OS_LockMutex(&Lock); Stream->ProcessRunningCount++; if (Stream->ProcessRunningCount == Stream->ExpectedProcessCount) OS_SetEvent(&Stream->StartStopEvent); OS_UnLockMutex(&Lock); // // Main Loop // while (!Stream->Terminating) { RingStatus = Stream->ManifestedBufferRing->Extract((unsigned int *)(&Buffer), PLAYER_MAX_EVENT_WAIT); Now = OS_GetTimeInMicroSeconds(); if (Stream->ReTimeQueuedFrames && ((Now - Stream->ReTimeStart) > PLAYER_MAX_TIME_IN_RETIMING)) Stream->ReTimeQueuedFrames = false; if (RingStatus == RingNothingToGet) continue; Stream->BuffersComingOutOfManifestation = true; Buffer->GetType(&BufferType); Buffer->TransferOwnership(IdentifierProcessPostManifest); // // Deal with a coded frame buffer // if (BufferType == Stream->DecodeBufferType) { Stream->FramesFromManifestorCount++; #if 0 { static unsigned long long LastTime = 0; static unsigned long long LastActualTime = 0; VideoOutputTiming_t *OutputTiming; Buffer->ObtainMetaDataReference(MetaDataVideoOutputTimingType, (void **)&OutputTiming); report(severity_info, "Post Dn = %d %d, I = %d, TFF = %d, DS= %6lld, DAS = %6lld, S = %016llx, AS = %016llx\n", OutputTiming->DisplayCount[0], OutputTiming->DisplayCount[1], OutputTiming->Interlaced, OutputTiming->TopFieldFirst, OutputTiming->SystemPlaybackTime - LastTime, OutputTiming->ActualSystemPlaybackTime - LastActualTime, OutputTiming->SystemPlaybackTime, OutputTiming->ActualSystemPlaybackTime); LastTime = OutputTiming->SystemPlaybackTime; LastActualTime = OutputTiming->ActualSystemPlaybackTime; } #endif // // Obtain a sequence number from the buffer // Status = Buffer->ObtainAttachedBufferReference(Stream->CodedFrameBufferType, &OriginalCodedFrameBuffer); if (Status != PlayerNoError) { report(severity_error, "Player_Generic_c::ProcessPostManifest - Unable to obtain the the original coded frame buffer - Implementation error\n"); Buffer->DecrementReferenceCount(IdentifierProcessPostManifest); continue; } Status = OriginalCodedFrameBuffer->ObtainMetaDataReference(MetaDataSequenceNumberType, (void **)(&SequenceNumberStructure)); if (Status != PlayerNoError) { report(severity_error, "Player_Generic_c::ProcessPostManifest - Unable to obtain the meta data \"SequenceNumber\" - Implementation error\n"); Buffer->DecrementReferenceCount(IdentifierProcessPostManifest); continue; } Status = Buffer->ObtainMetaDataReference(MetaDataParsedFrameParametersReferenceType, (void **)(&ParsedFrameParameters)); if (Status != PlayerNoError) { report(severity_error, "Player_Generic_c::ProcessPostManifest - Unable to obtain the meta data \"ParsedFrameParametersReference\" - Implementation error\n"); Buffer->DecrementReferenceCount(IdentifierProcessPostManifest); continue; } // // Check for whether or not we are in re-timing // if (Stream->ReTimeQueuedFrames && !SequenceNumberStructure->MarkerFrame) { Status = Buffer->ObtainMetaDataReference((Stream->StreamType == StreamTypeVideo ? MetaDataVideoOutputTimingType : MetaDataAudioOutputTimingType), (void **)&OutputTiming); if (Status != PlayerNoError) { report(severity_error, "Player_Generic_c::ProcessPostManifest - Unable to obtain the meta data \"%s\" - Implementation error\n", (Stream->StreamType == StreamTypeVideo ? "VideoOutputTiming" : "AudioOutputTiming")); Buffer->DecrementReferenceCount(IdentifierProcessPostManifest); continue; } if (ValidTime(OutputTiming->ActualSystemPlaybackTime)) { Stream->ReTimeQueuedFrames = false; } else { Stream->OutputTimer->GenerateFrameTiming(Buffer); Status = Stream->OutputTimer->TestForFrameDrop(Buffer, OutputTimerBeforeManifestation); if (!Stream->Terminating && (Status == OutputTimerNoError)) { Stream->FramesToManifestorCount++; Stream->Manifestor->QueueDecodeBuffer(Buffer); continue; } } } // // Extract the sequence number, and write the timing statistics // //report( severity_info, "MQ Post Man %d - %d\n", Stream->StreamType, ParsedFrameParameters->DisplayFrameIndex ); SequenceNumberStructure->TimeEntryInProcess3 = OS_GetTimeInMicroSeconds(); SequenceNumberStructure->DeltaEntryInProcess3 = SequenceNumberStructure->TimeEntryInProcess3 - LastEntryTime; LastEntryTime = SequenceNumberStructure->TimeEntryInProcess3; SequenceNumber = SequenceNumberStructure->Value; MaximumActualSequenceNumberSeen = max(SequenceNumber, MaximumActualSequenceNumberSeen); Time = ParsedFrameParameters->NativePlaybackTime; ProcessStatistics(Stream, SequenceNumberStructure); if (SequenceNumberStructure->MarkerFrame) { Stream->DiscardingUntilMarkerFramePostM = false; Time = INVALID_TIME; } // // Process any outstanding control messages to be applied before this buffer // ProcessAccumulatedControlMessages(Stream, &AccumulatedBeforeControlMessagesCount, PLAYER_MAX_POSTM_MESSAGES, Stream->AccumulatedBeforePostMControlMessages, SequenceNumber, Time); // // Pass buffer back into output timer // and release the buffer. // if (!SequenceNumberStructure->MarkerFrame) Stream->OutputTimer->RecordActualFrameTiming(Buffer); if (!SequenceNumberStructure->MarkerFrame && !Stream->CodecReset) Stream->Codec->ReleaseDecodeBuffer(Buffer); else Buffer->DecrementReferenceCount(IdentifierProcessPostManifest); // // Process any outstanding control messages to be applied after this buffer // ProcessAccumulatedControlMessages(Stream, &AccumulatedAfterControlMessagesCount, PLAYER_MAX_POSTM_MESSAGES, Stream->AccumulatedAfterPostMControlMessages, SequenceNumber, Time); } // // Deal with a player control structure // else if (BufferType == BufferPlayerControlStructureType) { Buffer->ObtainDataReference(NULL, NULL, (void **)(&ControlStructure)); ProcessNow = (ControlStructure->SequenceType == SequenceTypeImmediate) || ((SequenceNumber != INVALID_SEQUENCE_VALUE) && (ControlStructure->SequenceValue <= MaximumActualSequenceNumberSeen)); if (ProcessNow) ProcessControlMessage(Stream, Buffer, ControlStructure); else { if ((ControlStructure->SequenceType == SequenceTypeBeforeSequenceNumber) || (ControlStructure->SequenceType == SequenceTypeBeforePlaybackTime)) { Count = &AccumulatedBeforeControlMessagesCount; Table = Stream->AccumulatedBeforePostMControlMessages; } else { Count = &AccumulatedAfterControlMessagesCount; Table = Stream->AccumulatedAfterPostMControlMessages; } AccumulateControlMessage(Buffer, ControlStructure, Count, PLAYER_MAX_POSTM_MESSAGES, Table); } } else { report(severity_error, "Player_Generic_c::ProcessPostManifest - Unknown buffer type received - Implementation error.\n"); Buffer->DecrementReferenceCount(); } } report(severity_info, "3333 Holding control structures %d\n", AccumulatedBeforeControlMessagesCount + AccumulatedAfterControlMessagesCount); // // Make sur no one will wait for these // Stream->ReTimeQueuedFrames = false; // // Signal we have terminated // /* this should really be atomic_dec_and_test(), with correct memory barriers, to have a lockless design! */ OS_LockMutex(&Lock); Stream->ProcessRunningCount--; if (Stream->ProcessRunningCount == 0) OS_SetEvent(&Stream->StartStopEvent); OS_UnLockMutex(&Lock); }
static void check_address_records(dns_view_t *view, dns_db_t *hints, dns_db_t *db, dns_name_t *name, isc_stdtime_t now) { isc_result_t hresult, rresult, result; dns_rdataset_t hintrrset, rootrrset; dns_rdata_t rdata = DNS_RDATA_INIT; dns_name_t *foundname; dns_fixedname_t fixed; dns_rdataset_init(&hintrrset); dns_rdataset_init(&rootrrset); dns_fixedname_init(&fixed); foundname = dns_fixedname_name(&fixed); hresult = dns_db_find(hints, name, NULL, dns_rdatatype_a, 0, now, NULL, foundname, &hintrrset, NULL); rresult = dns_db_find(db, name, NULL, dns_rdatatype_a, DNS_DBFIND_GLUEOK, now, NULL, foundname, &rootrrset, NULL); if (hresult == ISC_R_SUCCESS && (rresult == ISC_R_SUCCESS || rresult == DNS_R_GLUE)) { result = dns_rdataset_first(&rootrrset); while (result == ISC_R_SUCCESS) { dns_rdata_reset(&rdata); dns_rdataset_current(&rootrrset, &rdata); if (!inrrset(&hintrrset, &rdata)) report(view, name, ISC_TRUE, &rdata); result = dns_rdataset_next(&rootrrset); } result = dns_rdataset_first(&hintrrset); while (result == ISC_R_SUCCESS) { dns_rdata_reset(&rdata); dns_rdataset_current(&hintrrset, &rdata); if (!inrrset(&rootrrset, &rdata)) report(view, name, ISC_FALSE, &rdata); result = dns_rdataset_next(&hintrrset); } } if (hresult == ISC_R_NOTFOUND && (rresult == ISC_R_SUCCESS || rresult == DNS_R_GLUE)) { result = dns_rdataset_first(&rootrrset); while (result == ISC_R_SUCCESS) { dns_rdata_reset(&rdata); dns_rdataset_current(&rootrrset, &rdata); report(view, name, ISC_TRUE, &rdata); result = dns_rdataset_next(&rootrrset); } } if (dns_rdataset_isassociated(&rootrrset)) dns_rdataset_disassociate(&rootrrset); if (dns_rdataset_isassociated(&hintrrset)) dns_rdataset_disassociate(&hintrrset); /* * Check AAAA records. */ hresult = dns_db_find(hints, name, NULL, dns_rdatatype_aaaa, 0, now, NULL, foundname, &hintrrset, NULL); rresult = dns_db_find(db, name, NULL, dns_rdatatype_aaaa, DNS_DBFIND_GLUEOK, now, NULL, foundname, &rootrrset, NULL); if (hresult == ISC_R_SUCCESS && (rresult == ISC_R_SUCCESS || rresult == DNS_R_GLUE)) { result = dns_rdataset_first(&rootrrset); while (result == ISC_R_SUCCESS) { dns_rdata_reset(&rdata); dns_rdataset_current(&rootrrset, &rdata); if (!inrrset(&hintrrset, &rdata)) report(view, name, ISC_TRUE, &rdata); dns_rdata_reset(&rdata); result = dns_rdataset_next(&rootrrset); } result = dns_rdataset_first(&hintrrset); while (result == ISC_R_SUCCESS) { dns_rdata_reset(&rdata); dns_rdataset_current(&hintrrset, &rdata); if (!inrrset(&rootrrset, &rdata)) report(view, name, ISC_FALSE, &rdata); dns_rdata_reset(&rdata); result = dns_rdataset_next(&hintrrset); } } if (hresult == ISC_R_NOTFOUND && (rresult == ISC_R_SUCCESS || rresult == DNS_R_GLUE)) { result = dns_rdataset_first(&rootrrset); while (result == ISC_R_SUCCESS) { dns_rdata_reset(&rdata); dns_rdataset_current(&rootrrset, &rdata); report(view, name, ISC_TRUE, &rdata); dns_rdata_reset(&rdata); result = dns_rdataset_next(&rootrrset); } } if (dns_rdataset_isassociated(&rootrrset)) dns_rdataset_disassociate(&rootrrset); if (dns_rdataset_isassociated(&hintrrset)) dns_rdataset_disassociate(&hintrrset); }
static int view_driver(struct view *view, enum request request) { int i; if (request == REQ_NONE) return TRUE; if (request >= REQ_RUN_REQUESTS) { request = open_run_request(view, request); // exit quickly rather than going through view_request and back if (request == REQ_QUIT) return FALSE; } request = view_request(view, request); if (request == REQ_NONE) return TRUE; switch (request) { case REQ_MOVE_UP: case REQ_MOVE_DOWN: case REQ_MOVE_PAGE_UP: case REQ_MOVE_PAGE_DOWN: case REQ_MOVE_FIRST_LINE: case REQ_MOVE_LAST_LINE: move_view(view, request); break; case REQ_SCROLL_FIRST_COL: case REQ_SCROLL_LEFT: case REQ_SCROLL_RIGHT: case REQ_SCROLL_LINE_DOWN: case REQ_SCROLL_LINE_UP: case REQ_SCROLL_PAGE_DOWN: case REQ_SCROLL_PAGE_UP: case REQ_SCROLL_WHEEL_DOWN: case REQ_SCROLL_WHEEL_UP: scroll_view(view, request); break; case REQ_VIEW_GREP: open_grep_view(view); break; case REQ_VIEW_MAIN: case REQ_VIEW_DIFF: case REQ_VIEW_LOG: case REQ_VIEW_TREE: case REQ_VIEW_HELP: case REQ_VIEW_BRANCH: case REQ_VIEW_BLAME: case REQ_VIEW_BLOB: case REQ_VIEW_STATUS: case REQ_VIEW_STAGE: case REQ_VIEW_PAGER: case REQ_VIEW_STASH: open_view(view, request, OPEN_DEFAULT); break; case REQ_NEXT: case REQ_PREVIOUS: if (view->parent) { int line; view = view->parent; line = view->pos.lineno; view_request(view, request); move_view(view, request); if (view_is_displayed(view)) update_view_title(view); if (line != view->pos.lineno) view_request(view, REQ_ENTER); } else { move_view(view, request); } break; case REQ_VIEW_NEXT: { int nviews = displayed_views(); int next_view = (current_view + 1) % nviews; if (next_view == current_view) { report("Only one view is displayed"); break; } current_view = next_view; /* Blur out the title of the previous view. */ update_view_title(view); report_clear(); break; } case REQ_REFRESH: report("Refreshing is not supported by the %s view", view->name); break; case REQ_PARENT: report("Moving to parent is not supported by the the %s view", view->name); break; case REQ_BACK: report("Going back is not supported for by %s view", view->name); break; case REQ_MAXIMIZE: if (displayed_views() == 2) maximize_view(view, TRUE); break; case REQ_OPTIONS: case REQ_TOGGLE_LINENO: case REQ_TOGGLE_DATE: case REQ_TOGGLE_AUTHOR: case REQ_TOGGLE_FILENAME: case REQ_TOGGLE_GRAPHIC: case REQ_TOGGLE_REV_GRAPH: case REQ_TOGGLE_REFS: case REQ_TOGGLE_CHANGES: case REQ_TOGGLE_IGNORE_SPACE: case REQ_TOGGLE_ID: case REQ_TOGGLE_FILES: case REQ_TOGGLE_TITLE_OVERFLOW: case REQ_TOGGLE_FILE_SIZE: case REQ_TOGGLE_UNTRACKED_DIRS: case REQ_TOGGLE_VERTICAL_SPLIT: { char action[SIZEOF_STR] = ""; enum view_flag flags = toggle_option(view, request, action); if (flags == VIEW_FLAG_RESET_DISPLAY) { resize_display(); redraw_display(TRUE); } else { foreach_displayed_view(view, i) { if (view_has_flags(view, flags) && !view->unrefreshable) reload_view(view); else redraw_view(view); } } if (*action) report("%s", action); } break; case REQ_TOGGLE_SORT_FIELD: case REQ_TOGGLE_SORT_ORDER: report("Sorting is not yet supported for the %s view", view->name); break; case REQ_DIFF_CONTEXT_UP: case REQ_DIFF_CONTEXT_DOWN: report("Changing the diff context is not yet supported for the %s view", view->name); break; case REQ_SEARCH: case REQ_SEARCH_BACK: search_view(view, request); break; case REQ_FIND_NEXT: case REQ_FIND_PREV: find_next(view, request); break; case REQ_STOP_LOADING: foreach_view(view, i) { if (view->pipe) report("Stopped loading the %s view", view->name), end_update(view, TRUE); } break; case REQ_SHOW_VERSION: report("tig-%s (built %s)", TIG_VERSION, __DATE__); return TRUE; case REQ_SCREEN_REDRAW: redraw_display(TRUE); break; case REQ_EDIT: report("Nothing to edit"); break; case REQ_ENTER: report("Nothing to enter"); break; case REQ_VIEW_CLOSE: /* XXX: Mark closed views by letting view->prev point to the * view itself. Parents to closed view should never be * followed. */ if (view->prev && view->prev != view) { maximize_view(view->prev, TRUE); view->prev = view; break; } /* Fall-through */ case REQ_QUIT: return FALSE; default: report("Unknown key, press %s for help", get_view_key(view, REQ_VIEW_HELP)); return TRUE; } return TRUE; }
static enum request run_prompt_command(struct view *view, char *cmd) { enum request request; if (!cmd) return REQ_NONE; if (string_isnumber(cmd)) { int lineno = view->pos.lineno + 1; if (parse_int(&lineno, cmd, 1, view->lines + 1) == SUCCESS) { select_view_line(view, lineno - 1); report_clear(); } else { report("Unable to parse '%s' as a line number", cmd); } } else if (iscommit(cmd)) { string_ncopy(view->env->search, cmd, strlen(cmd)); request = view_request(view, REQ_JUMP_COMMIT); if (request == REQ_JUMP_COMMIT) { report("Jumping to commits is not supported by the '%s' view", view->name); } } else if (strlen(cmd) == 1) { struct key_input input = { { cmd[0] } }; return get_keybinding(&view->ops->keymap, &input); } else if (cmd[0] == '/' || cmd[0] == '?') { const char *search = cmd + 1; if (!strcmp(search, view->env->search)) return cmd[0] == '/' ? REQ_FIND_NEXT : REQ_FIND_PREV; string_ncopy(view->env->search, search, strlen(search)); return cmd[0] == '/' ? REQ_SEARCH : REQ_SEARCH_BACK; } else if (cmd[0] == '!') { struct view *next = VIEW(REQ_VIEW_PAGER); const char *argv[SIZEOF_ARG]; int argc = 0; cmd++; /* When running random commands, initially show the * command in the title. However, it maybe later be * overwritten if a commit line is selected. */ string_ncopy(next->ref, cmd, strlen(cmd)); if (!argv_from_string(argv, &argc, cmd)) { report("Too many arguments"); } else if (!argv_format(view->env, &next->argv, argv, FALSE, TRUE)) { report("Argument formatting failed"); } else { next->dir = NULL; open_view(view, REQ_VIEW_PAGER, OPEN_PREPARED); } } else { request = get_request(cmd); if (request != REQ_UNKNOWN) return request; char *args = strchr(cmd, ' '); if (args) { *args++ = 0; if (set_option(cmd, args) == SUCCESS) { request = !view->unrefreshable ? REQ_REFRESH : REQ_SCREEN_REDRAW; if (!strcmp(cmd, "color")) init_colors(); resize_display(); redraw_display(TRUE); } } return request; } return REQ_NONE; }
static enum request open_run_request(struct view *view, enum request request) { struct run_request *req = get_run_request(request); const char **argv = NULL; bool confirmed = FALSE; request = REQ_NONE; if (!req) { report("Unknown run request"); return request; } if (argv_format(view->env, &argv, req->argv, FALSE, TRUE)) { if (req->internal) { char cmd[SIZEOF_STR]; if (argv_to_string(argv, cmd, sizeof(cmd), " ")) { request = run_prompt_command(view, cmd); } } else { confirmed = !req->confirm; if (req->confirm) { char cmd[SIZEOF_STR], prompt[SIZEOF_STR]; const char *and_exit = req->exit ? " and exit" : ""; if (argv_to_string(argv, cmd, sizeof(cmd), " ") && string_format(prompt, "Run `%s`%s?", cmd, and_exit) && prompt_yesno(prompt)) { confirmed = TRUE; } } if (confirmed && argv_remove_quotes(argv)) { if (req->silent) io_run_bg(argv); else open_external_viewer(argv, NULL, !req->exit, ""); } } } if (argv) argv_free(argv); free(argv); if (request == REQ_NONE) { if (req->confirm && !confirmed) request = REQ_NONE; else if (req->exit) request = REQ_QUIT; else if (view_has_flags(view, VIEW_REFRESH) && !view->unrefreshable) request = REQ_REFRESH; } return request; }
void Trace::finish(PRL_RESULT code_) const { boost::property_tree::ptree t; t.put("result", PRL_RESULT_TO_STRING(code_)); report(t); }
void Trace::start() const { boost::property_tree::ptree t; t.put("start", m_uuid.toStdString()); report(t); }
void info_mod(struct xmp_module_info *mi, int mode) { int i; int num_seq; int total_time; report("Module name : %s\n", mi->mod->name); report("Module type : %s", mi->mod->type); if (mode != XMP_MODE_AUTO) { struct player_mode *pm; for (pm = pmode; pm->name != NULL; pm++) { if (pm->mode == mode) { report(" [play as:%s]", pm->desc); break; } } } report("\nModule length: %d patterns\n", mi->mod->len); report("Patterns : %d\n", mi->mod->pat); report("Instruments : %d\n", mi->mod->ins); report("Samples : %d\n", mi->mod->smp); report("Channels : %d [ ", mi->mod->chn); for (i = 0; i < mi->mod->chn; i++) { if (mi->mod->xxc[i].flg & XMP_CHANNEL_SYNTH) { report("S "); } else if (mi->mod->xxc[i].flg & XMP_CHANNEL_MUTE) { report("- "); } else if (mi->mod->xxc[i].flg & XMP_CHANNEL_SURROUND) { report("^ "); } else { report("%x ", mi->mod->xxc[i].pan >> 4); } } report("]\n"); total_time = mi->seq_data[0].duration; report("Duration : %dmin%02ds", (total_time + 500) / 60000, ((total_time + 500) / 1000) % 60); /* Check non-zero-length sequences */ num_seq = 0; for (i = 0; i < mi->num_sequences; i++) { if (mi->seq_data[i].duration > 0) num_seq++; } if (num_seq > 1) { report(" (main sequence)\n"); for (i = 1; i < mi->num_sequences; i++) { int dur = mi->seq_data[i].duration; if (dur == 0) { continue; } report(" %dmin%02ds " "(sequence %d at position %02X)\n", (dur + 500) / 60000, ((dur + 500) / 1000) % 60, i, mi->seq_data[i].entry_point); } } else { report("\n"); } }
/**Intended to be called in a separate thread. * \sa saveScreenShot() */ void MainWindowActions::saveScreenShotThreaded(QImage pixmap, QString filename) { pixmap.save(filename, "png"); report("Saved screenshot to " + filename); reporter()->playScreenShotSound(); }
static void test(void) { mps_pool_t pool; mps_thr_t thread; mps_root_t root; mps_chain_t chain; mps_fmt_t format; mps_ap_t ap, ap2; mycell *a, *b; mps_res_t res; int i; /* create an arena that can't grow beyond 30 M */ cdie(mps_arena_create(&arena, mps_arena_class_vm(), (size_t) (1024*1024*30)), "create arena"); cdie(mps_thread_reg(&thread, arena), "register thread"); cdie(mps_root_create_reg(&root, arena, mps_rank_ambig(), 0, thread, mps_stack_scan_ambig, stackpointer, 0), "create root"); cdie( mps_fmt_create_A(&format, arena, &fmtA), "create format"); cdie(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create"); cdie( mps_pool_create(&pool, arena, mps_class_amc(), format, chain), "create pool"); cdie( mps_ap_create(&ap, pool, mps_rank_exact()), "create ap"); /* allocate until full */ i = 0; b = NULL; while (allocrone(&a, ap, 128, mps_rank_exact()) == MPS_RES_OK) { i++; setref(a, 0, b); b = a; } comment("%d objs allocated.", i); /* try to allocate 10 times */ cdie(mps_ap_create(&ap2, pool, mps_rank_exact()), "create second ap"); mps_ap_destroy(ap); for (i = 0; i < 10; i++) { res = allocrone(&a, ap2, 128, mps_rank_exact()); report("predie", "%s", err_text(res)); } /* now let everything die, and try to allocate 10 times */ mps_root_destroy(root); for (i = 0; i < 10; i++) { res = allocrone(&a, ap2, 128, mps_rank_exact()); report("postdie", "%s", err_text(res)); } mps_ap_destroy(ap2); comment("Destroyed ap."); mps_pool_destroy(pool); comment("Destroyed pool."); mps_fmt_destroy(format); comment("Destroyed format."); mps_chain_destroy(chain); comment("Destroyed chain."); mps_thread_dereg(thread); comment("Deregistered thread."); mps_arena_destroy(arena); comment("Destroyed arena."); }
static void iterate_files(const char *path, const long *files, long start_at, long end_at, int progress) { uint64_t tot_ok, tot_corrupted, tot_changed, tot_overwritten, tot_size; struct timeval tot_dt = { .tv_sec = 0, .tv_usec = 0 }; double read_speed; const char *unit; int and_read_all = 1; int or_missing_file = 0; long number = start_at; UNUSED(end_at); tot_ok = tot_corrupted = tot_changed = tot_overwritten = tot_size = 0; printf(" SECTORS " " ok/corrupted/changed/overwritten\n"); while (*files >= 0) { uint64_t sec_ok, sec_corrupted, sec_changed, sec_overwritten, file_size; int read_all; or_missing_file = or_missing_file || (*files != number); for (; number < *files; number++) { char *full_fn; const char *filename; full_fn = full_fn_from_number(&filename, "", number); assert(full_fn); printf("Missing file %s\n", filename); free(full_fn); } number++; validate_file(path, *files, &sec_ok, &sec_corrupted, &sec_changed, &sec_overwritten, &file_size, &read_all, &tot_dt, progress); tot_ok += sec_ok; tot_corrupted += sec_corrupted; tot_changed += sec_changed; tot_overwritten += sec_overwritten; tot_size += file_size; and_read_all = and_read_all && read_all; files++; } assert(tot_size / SECTOR_SIZE == (tot_ok + tot_corrupted + tot_changed + tot_overwritten)); /* Notice that not reporting `missing' files after the last file * in @files is important since @end_at could be very large. */ report("\n Data OK:", tot_ok); report("Data LOST:", tot_corrupted + tot_changed + tot_overwritten); report("\t Corrupted:", tot_corrupted); report("\tSlightly changed:", tot_changed); report("\t Overwritten:", tot_overwritten); if (or_missing_file) printf("WARNING: Not all F3 files in the range %li to %li are available\n", start_at + 1, number); if (!and_read_all) printf("WARNING: Not all data was read due to I/O error(s)\n"); /* Reading speed. */ read_speed = (double)tot_size / dt_to_s(&tot_dt); unit = adjust_unit(&read_speed); printf("Average reading speed: %.2f %s/s\n", read_speed, unit); } int main(int argc, char **argv) { const long *files; struct args args = { /* Defaults. */ .start_at = 0, .end_at = LONG_MAX - 1, /* If stdout isn't a terminal, supress progress. */ .show_progress = isatty(STDOUT_FILENO), }; /* Read parameters. */ argp_parse(&argp, argc, argv, 0, NULL, &args); print_header(stdout, "read"); files = ls_my_files(args.dev_path, args.start_at, args.end_at); iterate_files(args.dev_path, files, args.start_at, args.end_at, args.show_progress); free((void *)files); return 0; }
static char * prompt_input(const char *prompt, input_handler handler, void *data) { enum input_status status = INPUT_OK; static char buf[SIZEOF_STR]; unsigned char chars_length[SIZEOF_STR]; struct key_input input; size_t promptlen = strlen(prompt); int pos = 0, chars = 0; buf[pos] = 0; while (status == INPUT_OK || status == INPUT_SKIP) { update_status("%s%.*s", prompt, pos, buf); switch (get_input(pos + promptlen, &input, FALSE)) { case KEY_RETURN: case KEY_ENTER: case '\n': status = pos ? INPUT_STOP : INPUT_CANCEL; break; case KEY_BACKSPACE: if (pos > 0) { int len = chars_length[--chars]; pos -= len; buf[pos] = 0; } else { status = INPUT_CANCEL; } break; case KEY_ESC: status = INPUT_CANCEL; break; default: if (pos >= sizeof(buf)) { report("Input string too long"); return NULL; } status = handler(data, buf, &input); if (status == INPUT_OK) { int len = strlen(input.data.bytes); string_ncopy_do(buf + pos, sizeof(buf) - pos, input.data.bytes, len); pos += len; chars_length[chars++] = len; } } } report_clear(); if (status == INPUT_CANCEL) return NULL; buf[pos++] = 0; return buf; }
STATIC int primloop(lprec *lp, MYBOOL feasible) { int i, j, k, ok = TRUE; LREAL theta = 0.0; REAL *prow = NULL, *drow = NULL, *pcol = NULL, prevobj, epsvalue; MYBOOL primal = TRUE, minit; MYBOOL pivdynamic, bfpfinal = FALSE; int oldpivrule, oldpivmode, pivrule, Blandswitches, colnr, rownr, lastnr, minitcount = 0; int Rcycle = 0, Ccycle = 0, Ncycle = 0, changedphase = FALSE; int *nzdrow = NULL, *workINT = NULL; /* Add sufficent number of artificial variables to make the problem feasible through the first phase; delete when primal feasibility has been achieved */ lp->Extrap = 0; #ifdef EnablePrimalPhase1 if(!feasible) { #ifdef Paranoia if(!verifyBasis(lp)) report(lp, SEVERE, "primloop: No valid basis for artificial variables\n"); #endif #if 0 /* First check if we can get away with a single artificial variable */ if(lp->equalities == 0) { i = (int) feasibilityOffset(lp, !primal); add_artificial(lp, i); } else #endif /* Otherwise add as many as is necessary to force basic feasibility */ for(i = 1; i <= lp->rows; i++) add_artificial(lp, i); } if(lp->spx_trace) report(lp, DETAILED, "Extrap count = %d\n", lp->Extrap); #endif if(lp->spx_trace) report(lp, DETAILED, "Entered primal simplex algorithm with feasibility %s\n", my_boolstr(feasible)); /* Create work arrays */ #ifdef UseSparseReducedCost allocINT(lp, &nzdrow, lp->sum + 1, FALSE); #endif allocREAL(lp, &prow, lp->sum + 1, TRUE); allocREAL(lp, &drow, lp->sum + 1, TRUE); allocREAL(lp, &pcol, lp->rows + 1, TRUE); /* Refactorize the basis and set status variables */ i = my_if(is_bb_action(lp, ACTION_REBASE), INITSOL_SHIFTZERO, INITSOL_USEZERO); if(((lp->spx_status == SWITCH_TO_PRIMAL) && !lp->justInverted) || (lp->Extrap != 0) || is_bb_action(lp, ACTION_REINVERT)) { simplexPricer(lp, (MYBOOL)!primal); /* Do basis crashing before refactorization, if specified */ invert(lp, (MYBOOL) i, TRUE); } else { if(is_bb_action(lp, ACTION_RECOMPUTE)) recompute_solution(lp, (MYBOOL) i); restartPricer(lp, (MYBOOL)!primal); } lp->bb_action = ACTION_NONE; lp->spx_status = RUNNING; lp->doIterate = FALSE; minit = ITERATE_MAJORMAJOR; prevobj = lp->rhs[0]; oldpivmode = lp->piv_strategy; oldpivrule = get_piv_rule(lp); pivdynamic = ANTICYCLEBLAND && is_piv_mode(lp, PRICE_ADAPTIVE); epsvalue = lp->epspivot; Blandswitches = 0; rownr = 0; colnr = 0; lastnr = 0; lp->rejectpivot[0] = 0; if(feasible) lp->simplex_mode = SIMPLEX_Phase2_PRIMAL; else lp->simplex_mode = SIMPLEX_Phase1_PRIMAL; /* Iterate while we are successful; exit when the model is infeasible/unbounded, or we must terminate due to numeric instability or user-determined reasons */ while(lp->spx_status == RUNNING) { if(lp->spx_trace) if(lastnr > 0) report(lp, NORMAL, "primloop: Objective at iteration %8d is " RESULTVALUEMASK " (%4d: %4d %s- %4d)\n", get_total_iter(lp), lp->rhs[0], rownr, lastnr, my_if(minit == ITERATE_MAJORMAJOR, "<","|"), colnr); pivrule = get_piv_rule(lp); if(pivdynamic && ((pivrule != PRICER_FIRSTINDEX) || (pivrule != oldpivrule)) #if PrimalPivotStickiness==2 && (lp->fixedvars == 0) #elif PrimalPivotStickiness==1 && feasible #endif ) { /* Check if we have a stationary solution */ if((minit == ITERATE_MAJORMAJOR) && !lp->justInverted && (fabs(my_reldiff(lp->rhs[0], prevobj)) < epsvalue)) { Ncycle++; /* Start to monitor for variable cycling if this is the initial stationarity */ if(Ncycle <= 1) { Ccycle = colnr; Rcycle = rownr; } /* Check if we should change pivoting strategy due to stationary variable cycling */ else if((pivrule == oldpivrule) && (((MAX_STALLCOUNT > 1) && (Ncycle > MAX_STALLCOUNT)) || (Ccycle == rownr) || (Rcycle == colnr))) { /* First check if we should give up on Bland's rule and try perturbed bound relaxation instead */ #ifdef EnableStallAntiDegen if((MAX_BLANDSWITCH >= 0) && (Blandswitches >= MAX_BLANDSWITCH)) { lp->spx_status = DEGENERATE; break; } #endif Blandswitches++; lp->piv_strategy = PRICER_FIRSTINDEX; /* There is no advanced normalization for Bland's rule, restart at end */ Ccycle = 0; Rcycle = 0; Ncycle = 0; if(lp->spx_trace) report(lp, DETAILED, "primloop: Detected cycling at iteration %d; changed to FIRST INDEX rule!\n", get_total_iter(lp)); } } #if 0 /* Handle cycling or stationary situations by switching to the dual simplex */ else if((pivrule == oldpivrule) && feasible && (lp->simplex_strategy & SIMPLEX_DYNAMIC)) { lp->spx_status = SWITCH_TO_DUAL; if(lp->total_iter == 0) report(lp, NORMAL, "Start dual simplex for finalization at iteration %8d\n", get_total_iter(lp)); break; } #endif /* Change back to original selection strategy as soon as possible */ else if((minit == ITERATE_MAJORMAJOR) && (pivrule != oldpivrule)) { lp->piv_strategy = oldpivmode; restartPricer(lp, AUTOMATIC); /* Pricer restart following Bland's rule */ Ccycle = 0; Rcycle = 0; Ncycle = 0; if(lp->spx_trace) report(lp, DETAILED, "...returned to original pivot selection rule at iteration %d.\n", get_total_iter(lp)); } } /* Store current LP value for reference at next iteration */ prevobj = lp->rhs[0]; lp->doIterate = FALSE; lp->doInvert = FALSE; /* Find best column to enter the basis */ RetryCol: if(!changedphase) { i = 0; do { if(partial_countBlocks(lp, (MYBOOL) !primal) > 1) partial_blockStep(lp, (MYBOOL) !primal); colnr = colprim(lp, (MYBOOL) (minit == ITERATE_MINORRETRY), drow, nzdrow); i++; } while ((colnr == 0) && (i < partial_countBlocks(lp, (MYBOOL) !primal))); #ifdef FinalOptimalErrorLimitation /* Do additional checking that we have a correct identification of optimality */ if((colnr == 0) && !lp->justInverted) { lp->doInvert = TRUE; i = invert(lp, INITSOL_USEZERO, TRUE); colnr = colprim(lp, FALSE, drow, nzdrow); } #endif } if(colnr > 0) { changedphase = FALSE; fsolve(lp, colnr, pcol, workINT, lp->epsmachine, 1.0, TRUE); /* Solve entering column for Pi */ #ifdef UseRejectionList if(is_anti_degen(lp, ANTIDEGEN_COLUMNCHECK) && !check_degeneracy(lp, pcol, NULL)) { if(lp->rejectpivot[0] < DEF_MAXPIVOTRETRY/3) { i = ++lp->rejectpivot[0]; lp->rejectpivot[i] = colnr; report(lp, DETAILED, "Entering column %d found to be non-improving due to degeneracy!\n", colnr); goto RetryCol; } else { lp->rejectpivot[0] = 0; report(lp, DETAILED, "Gave up trying to find a strictly improving entering column!\n"); } } #endif /* Find the leaving variable that gives the most stringent bound on the entering variable */ theta = drow[colnr]; rownr = rowprim(lp, colnr, &theta, pcol); #if 0 report(lp, NORMAL, "Iteration %d: Enter %d, Leave %d\n", lp->current_iter, colnr, rownr); #endif /* See if we can do a straight artificial<->slack replacement (when "colnr" is a slack) */ if((lp->Extrap != 0) && (rownr == 0) && (colnr <= lp->rows)) rownr = findAnti_artificial(lp, colnr); if(rownr > 0) { lp->rejectpivot[0] = 0; lp->bfp_prepareupdate(lp, rownr, colnr, pcol); } else if(lp->spx_status == UNBOUNDED) { report(lp, DETAILED, "primloop: The model is primal unbounded.\n"); break; } #ifdef UseRejectionList else if(lp->rejectpivot[0] < DEF_MAXPIVOTRETRY) { lp->spx_status = RUNNING; if(lp->justInverted) { lp->rejectpivot[0]++; lp->rejectpivot[lp->rejectpivot[0]] = colnr; report(lp, DETAILED, "...trying to recover via another pivot column!\n"); } else { lp->doInvert = TRUE; invert(lp, INITSOL_USEZERO, TRUE); } goto RetryCol; } #endif else { /* Assume failure if we are still unsuccessful and the model is not unbounded */ if((rownr == 0) && (lp->spx_status == RUNNING)) { report(lp, IMPORTANT, "primloop: Could not find a leaving variable for entering %d (iteration %d)\n", colnr, get_total_iter(lp)); lp->spx_status = NUMFAILURE; } } } #ifdef EnablePrimalPhase1 else if(!feasible || isPhase1(lp)) { if(feasiblePhase1(lp, epsvalue)) { lp->spx_status = RUNNING; if(lp->bb_totalnodes == 0) { report(lp, NORMAL, "Found feasibility by primal simplex at iteration %8d\n", get_total_iter(lp)); if((lp->usermessage != NULL) && (lp->msgmask & MSG_LPFEASIBLE)) lp->usermessage(lp, lp->msghandle, MSG_LPFEASIBLE); } changedphase = FALSE; feasible = TRUE; lp->simplex_mode = SIMPLEX_Phase2_PRIMAL; /* We can do two things now; 1) delete the rows belonging to those variables, since they are redundant, OR 2) drive out the existing artificial variables via pivoting. */ if(lp->Extrap > 0) { #ifdef Phase1EliminateRedundant /* If it is not a MIP model we can try to delete redundant rows */ if((lp->bb_totalnodes == 0) && (MIP_count(lp) == 0)) { while(lp->Extrap > 0) { i = lp->rows; while((i > 0) && (lp->var_basic[i] <= lp->sum-lp->Extrap)) i--; #ifdef Paranoia if(i <= 0) { report(lp, SEVERE, "primloop: Could not find redundant artificial.\n"); break; } #endif /* Obtain column and row indeces */ j = lp->var_basic[i]-lp->rows; k = get_artificialRow(lp, j); /* Delete row before column due to basis "compensation logic" */ if(lp->is_basic[k]) { lp->is_basic[lp->rows+j] = FALSE; del_constraint(lp, k); } else setBasisVar(lp, i, k); del_column(lp, j); lp->Extrap--; } lp->basis_valid = TRUE; } /* Otherwise we drive out the artificials by elimination pivoting */ else { eliminate_artificials(lp, prow); lp->doIterate = FALSE; } #else lp->Extrap = my_flipsign(lp->Extrap); #endif } lp->doInvert = TRUE; prevobj = lp->infinite; } else { lp->spx_status = INFEASIBLE; minit = ITERATE_MAJORMAJOR; if(lp->spx_trace) report(lp, NORMAL, "Model infeasible by primal simplex at iteration %8d\n", get_total_iter(lp)); } } #endif /* Pivot row/col and update the inverse */ if(lp->doIterate) { lastnr = lp->var_basic[rownr]; if(lp->justInverted) minitcount = 0; else if(minitcount > MAX_MINITUPDATES) { recompute_solution(lp, INITSOL_USEZERO); minitcount = 0; } minit = performiteration(lp, rownr, colnr, theta, primal, NULL, NULL, pcol, NULL); if(minit != ITERATE_MAJORMAJOR) minitcount++; if((lp->spx_status == USERABORT) || (lp->spx_status == TIMEOUT)) break; else if(minit == ITERATE_MINORMAJOR) continue; #ifdef UsePrimalReducedCostUpdate /* Do a fast update of the reduced costs in preparation for the next iteration */ if(minit == ITERATE_MAJORMAJOR) update_reducedcosts(lp, primal, lastnr, colnr, pcol, drow); #endif #ifdef EnablePrimalPhase1 /* Detect if an auxiliary variable has left the basis and delete it; if the non-basic variable only changed bound (a "minor iteration"), the basic artificial variable did not leave and there is nothing to do */ if((minit == ITERATE_MAJORMAJOR) && (lastnr > lp->sum - abs(lp->Extrap))) { #ifdef Paranoia if(lp->is_basic[lastnr] || !lp->is_basic[colnr]) report(lp, SEVERE, "primloop: Invalid basis indicator for variable %d at iteration %d\n", lastnr, get_total_iter(lp)); #endif del_column(lp, lastnr-lp->rows); if(lp->Extrap > 0) lp->Extrap--; else lp->Extrap++; if(lp->Extrap == 0) { colnr = 0; prevobj = lp->infinite; changedphase = TRUE; } } #endif } if(lp->spx_status == SWITCH_TO_DUAL) ; else if(!changedphase && lp->bfp_mustrefactorize(lp)) { i = invert(lp, INITSOL_USEZERO, FALSE); #ifdef ResetMinitOnReinvert minit = ITERATE_MAJORMAJOR; #endif if((lp->spx_status == USERABORT) || (lp->spx_status == TIMEOUT)) break; else if(!i) { lp->spx_status = SINGULAR_BASIS; break; } /* Check whether we are still feasible or not... */ if(!isPrimalFeasible(lp, lp->epspivot)) { lp->spx_status = LOSTFEAS; } } userabort(lp, -1); } if (lp->piv_strategy != oldpivmode) lp->piv_strategy = oldpivmode; #ifdef EnablePrimalPhase1 /* Remove any remaining artificial variables (feasible or infeasible model) */ lp->Extrap = abs(lp->Extrap); if(lp->Extrap > 0) { clear_artificials(lp); if(lp->spx_status != OPTIMAL) restore_basis(lp); i = invert(lp, INITSOL_USEZERO, TRUE); } #ifdef Paranoia if(!verifyBasis(lp)) report(lp, SEVERE, "primloop: Invalid basis detected due to internal error\n"); #endif /* Switch to dual phase 1 simplex for MIP models during B&B phases */ if((lp->bb_totalnodes == 0) && (MIP_count(lp) > 0) && ((lp->simplex_strategy & SIMPLEX_Phase1_DUAL) == 0)) { lp->simplex_strategy &= !SIMPLEX_Phase1_PRIMAL; lp->simplex_strategy += SIMPLEX_Phase1_DUAL; } #endif FREE(nzdrow); FREE(drow); FREE(prow); FREE(pcol); return(ok); } /* primloop */
enum request run_prompt_command(struct view *view, const char *argv[]) { enum request request; const char *cmd = argv[0]; size_t cmdlen = cmd ? strlen(cmd) : 0; if (!cmd) return REQ_NONE; if (string_isnumber(cmd)) { int lineno = view->pos.lineno + 1; if (parse_int(&lineno, cmd, 1, view->lines + 1) == SUCCESS) { select_view_line(view, lineno - 1); report_clear(); } else { report("Unable to parse '%s' as a line number", cmd); } } else if (iscommit(cmd)) { string_ncopy(view->env->search, cmd, cmdlen); return REQ_JUMP_COMMIT; } else if (cmdlen > 1 && (cmd[0] == '/' || cmd[0] == '?')) { char search[SIZEOF_STR]; if (!argv_to_string(argv, search, sizeof(search), " ")) { report("Failed to copy search string"); return REQ_NONE; } if (!strcmp(search + 1, view->env->search)) return cmd[0] == '/' ? REQ_FIND_NEXT : REQ_FIND_PREV; string_ncopy(view->env->search, search + 1, strlen(search + 1)); return cmd[0] == '/' ? REQ_SEARCH : REQ_SEARCH_BACK; } else if (cmdlen > 1 && cmd[0] == '!') { struct view *next = &pager_view; bool copied; /* Trim the leading '!'. */ argv[0] = cmd + 1; copied = argv_format(view->env, &next->argv, argv, FALSE, TRUE); argv[0] = cmd; if (!copied) { report("Argument formatting failed"); } else { /* When running random commands, initially show the * command in the title. However, it maybe later be * overwritten if a commit line is selected. */ argv_to_string(next->argv, next->ref, sizeof(next->ref), " "); next->dir = NULL; open_pager_view(view, OPEN_PREPARED | OPEN_WITH_STDERR); } } else if (!strcmp(cmd, "toggle")) { char action[SIZEOF_STR] = ""; enum view_flag flags = prompt_toggle(view, argv, action); int i; if (flags & VIEW_RESET_DISPLAY) { resize_display(); redraw_display(TRUE); } foreach_displayed_view(view, i) { if (view_has_flags(view, flags) && !view->unrefreshable) reload_view(view); else redraw_view(view); } if (*action) report("%s", action); } else {
STATIC int dualloop(lprec *lp, MYBOOL feasible) { int i, ok = TRUE; LREAL theta = 0.0; REAL *drow = NULL, *prow = NULL, *pcol = NULL, prevobj, epsvalue; MYBOOL primal = FALSE, forceoutEQ = FALSE; MYBOOL minit, pivdynamic, bfpfinal = FALSE; int oldpivrule, oldpivmode, pivrule, Blandswitches, colnr, rownr, lastnr, minitcount = 0; int Rcycle = 0, Ccycle = 0, Ncycle = 0, changedphase = TRUE; #ifdef FixInaccurateDualMinit int minitcolnr = 0; #endif int *nzprow = NULL, *workINT = NULL; if(lp->spx_trace) report(lp, DETAILED, "Entering dual simplex algorithm\n"); /* Set Extrad value to force dual feasibility; reset when "local optimality" has been achieved or a dual non-feasibility has been encountered (no candidate for a first leaving variable) */ if(feasible) lp->Extrad = 0; else lp->Extrad = feasibilityOffset(lp, (MYBOOL)!primal); if(lp->spx_trace) report(lp, DETAILED, "Extrad = %g\n", (double)lp->Extrad); /* Allocate work arrays */ allocREAL(lp, &drow, lp->sum + 1, TRUE); #ifdef UseSparseReducedCost allocINT(lp, &nzprow, lp->sum + 1, FALSE); #endif allocREAL(lp, &prow, lp->sum + 1, TRUE); allocREAL(lp, &pcol, lp->rows + 1, TRUE); /* Refactorize the basis and set status variables */ i = my_if(is_bb_action(lp, ACTION_REBASE), INITSOL_SHIFTZERO, INITSOL_USEZERO); if(((lp->spx_status == SWITCH_TO_DUAL) && !lp->justInverted) || (lp->Extrad != 0) || is_bb_action(lp, ACTION_REINVERT)) { simplexPricer(lp, (MYBOOL)!primal); /* Do basis crashing before refactorization, if specified */ invert(lp, (MYBOOL) i, TRUE); } else { if(is_bb_action(lp, ACTION_RECOMPUTE)) recompute_solution(lp, (MYBOOL) i); restartPricer(lp, (MYBOOL)!primal); } lp->bb_action = ACTION_NONE; lp->spx_status = RUNNING; lp->doIterate = FALSE; minit = ITERATE_MAJORMAJOR; prevobj = lp->rhs[0]; oldpivmode = lp->piv_strategy; oldpivrule = get_piv_rule(lp); pivdynamic = ANTICYCLEBLAND && is_piv_mode(lp, PRICE_ADAPTIVE); epsvalue = lp->epspivot; Blandswitches = 0; rownr = 0; colnr = -1; /* Used to detect infeasibility at the beginning of the dual loop */ lastnr = 0; lp->rejectpivot[0] = 0; if(feasible) lp->simplex_mode = SIMPLEX_Phase2_DUAL; else lp->simplex_mode = SIMPLEX_Phase1_DUAL; /* Check if we have equality slacks in the basis and we should try to drive them out in order to reduce chance of degeneracy in Phase 1 */ if(!feasible && (lp->fixedvars > 0) && is_anti_degen(lp, ANTIDEGEN_FIXEDVARS)) { forceoutEQ = AUTOMATIC; } while(lp->spx_status == RUNNING) { if(lp->spx_trace) if(lastnr > 0) report(lp, NORMAL, "dualloop: Objective at iteration %8d is " RESULTVALUEMASK " (%4d: %4d %s- %4d)\n", get_total_iter(lp), lp->rhs[0], rownr, lastnr, my_if(minit == ITERATE_MAJORMAJOR, "<","|"), colnr); pivrule = get_piv_rule(lp); if(pivdynamic && ((pivrule != PRICER_FIRSTINDEX) || (pivrule != oldpivrule)) #if DualPivotStickiness==2 /* Stays with pricing rule as long as possible (also preserves accuracy) */ && (lp->fixedvars == 0) #elif DualPivotStickiness==1 /* Stays with pricing rule only if the model is infeasible */ && feasible #endif ) { /* Check if we have a stationary solution */ if((minit == ITERATE_MAJORMAJOR) && !lp->justInverted && (fabs(my_reldiff(lp->rhs[0], prevobj)) < epsvalue)) { Ncycle++; /* Start to monitor for variable cycling if this is the initial stationarity */ if(Ncycle <= 1) { Ccycle = colnr; Rcycle = rownr; } /* Check if we should change pivoting strategy due to stationary variable cycling */ else if((pivrule == oldpivrule) && (((MAX_STALLCOUNT > 1) && (Ncycle > MAX_STALLCOUNT)) || (Ccycle == rownr) || (Rcycle == colnr))) { /* First check if we should give up on Bland's rule and try perturbed bound relaxation instead */ #ifdef EnableStallAntiDegen if((MAX_BLANDSWITCH >= 0) && (Blandswitches >= MAX_BLANDSWITCH)) { lp->spx_status = DEGENERATE; break; } #endif Blandswitches++; lp->piv_strategy = PRICER_FIRSTINDEX; /* There is no advanced normalization for Bland's rule, restart at end */ Ccycle = 0; Rcycle = 0; Ncycle = 0; if(lp->spx_trace) report(lp, DETAILED, "dualloop: Detected cycling at iteration %d; changed to FIRST INDEX rule!\n", get_total_iter(lp)); } } /* Handle cycling or stationary situations by switching to the primal simplex */ else if((pivrule == oldpivrule) && feasible && (lp->simplex_strategy & SIMPLEX_DYNAMIC)) { lp->spx_status = SWITCH_TO_PRIMAL; break; } /* Change back to original selection strategy as soon as possible */ else if((minit == ITERATE_MAJORMAJOR) && (pivrule != oldpivrule)) { lp->piv_strategy = oldpivmode; restartPricer(lp, AUTOMATIC); /* Pricer restart following Bland's rule */ Ccycle = 0; Rcycle = 0; Ncycle = 0; if(lp->spx_trace) report(lp, DETAILED, "...returned to original pivot selection rule at iteration %d.\n", get_total_iter(lp)); } } /* Store current LP value for reference at next iteration */ changedphase = FALSE; prevobj = lp->rhs[0]; lastnr = lp->var_basic[rownr]; lp->doInvert = FALSE; /* Do minor iterations (non-basic variable bound switches) for as long as possible since this is a cheap way of iterating */ #ifdef Phase1DualPriceEqualities RetryRow: #endif if(minit != ITERATE_MINORRETRY) { /* forceoutEQ FALSE : Only eliminate assured "good" violated equality constraint slacks AUTOMATIC: Seek more elimination of equality constraint slacks (but not as aggressive as the rule used in lp_solve v4.0 and earlier) TRUE: Force remaining equality slacks out of the basis */ i = 0; do { if(partial_countBlocks(lp, (MYBOOL) !primal) > 1) partial_blockStep(lp, (MYBOOL) !primal); rownr = rowdual(lp, forceoutEQ); i++; } while ((rownr == 0) && (i < partial_countBlocks(lp, (MYBOOL) !primal))); lastnr = lp->var_basic[rownr]; } if(rownr > 0) { #ifdef UseRejectionList RetryCol: #endif lp->doIterate = FALSE; colnr = coldual(lp, rownr, (MYBOOL)(minit == ITERATE_MINORRETRY), prow, nzprow, drow, NULL); if(colnr > 0) { lp->doIterate = TRUE; fsolve(lp, colnr, pcol, workINT, lp->epsmachine, 1.0, TRUE); #ifdef FixInaccurateDualMinit /* Prevent bound flip-flops during minor iterations; used to detect infeasibility after triggering of minor iteration accuracy management */ if(colnr != minitcolnr) minitcolnr = 0; #endif /* Getting division by zero here; catch it and try to recover */ if(pcol[rownr] == 0) { if(lp->spx_trace) report(lp, DETAILED, "dualloop: Attempt to divide by zero (pcol[%d])\n", rownr); lp->doIterate = FALSE; if(!lp->justInverted) { report(lp, DETAILED, "...trying to recover by reinverting!\n"); lp->doInvert = TRUE; bfpfinal = FALSE; } #ifdef UseRejectionList else if(lp->rejectpivot[0] < DEF_MAXPIVOTRETRY) { lp->rejectpivot[0]++; lp->rejectpivot[lp->rejectpivot[0]] = colnr; if(lp->bb_totalnodes == 0) report(lp, DETAILED, "...trying to recover via another pivot column!\n"); goto RetryCol; } #endif else { if(lp->bb_totalnodes == 0) report(lp, DETAILED, "...cannot recover by reinverting.\n"); lp->spx_status = NUMFAILURE; ok = FALSE; } } else { lp->rejectpivot[0] = 0; theta = lp->bfp_prepareupdate(lp, rownr, colnr, pcol); /* Verify numeric accuracy of the inverse and change to the "theoretically" correct version of the theta */ if((lp->improve & IMPROVE_INVERSE) && (my_reldiff(fabs(theta),fabs(prow[colnr])) > lp->epspivot*10.0*log(2.0+50.0*lp->rows))) { lp->doInvert = TRUE; bfpfinal = TRUE; #ifdef IncreasePivotOnReducedAccuracy if(lp->bfp_pivotcount(lp) < 2*DEF_MAXPIVOTRETRY) lp->epspivot *= 2.0; #endif report(lp, DETAILED, "dualloop: Refactorizing at iteration %d due to loss of accuracy.\n", get_total_iter(lp)); } theta = prow[colnr]; compute_theta(lp, rownr, &theta, !lp->is_lower[colnr], 0, primal); } } #ifdef FixInaccurateDualMinit /* Reinvert and try another row if we did not find a bound-violated leaving column */ else if((minit != ITERATE_MAJORMAJOR) && (colnr != minitcolnr)) { minitcolnr = colnr; lp->doInvert = TRUE; i = invert(lp, INITSOL_USEZERO, TRUE); if((lp->spx_status == USERABORT) || (lp->spx_status == TIMEOUT)) break; else if(!i) { lp->spx_status = SINGULAR_BASIS; break; } minit = ITERATE_MAJORMAJOR; continue; } #endif else { if(lp->justInverted && (lp->simplex_mode == SIMPLEX_Phase2_DUAL)) lp->spx_status = LOSTFEAS; #if 1 else if(!lp->justInverted && (lp->bb_level <= 1)) { #else else if(!lp->justInverted) { #endif lp->doIterate = FALSE; lp->doInvert = TRUE; bfpfinal = TRUE; } else { if((lp->spx_trace && (lp->bb_totalnodes == 0)) || (lp->bb_trace && (lp->bb_totalnodes > 0))) report(lp, DETAILED, "Model lost dual feasibility.\n"); lp->spx_status = INFEASIBLE; ok = FALSE; break; } } } else { /* New code to solve to optimality using the dual, but only if the user has specified a preference for the dual simplex - KE added 20030731 */ lp->doIterate = FALSE; bfpfinal = TRUE; if((lp->Extrad != 0) && (colnr < 0) && !isPrimalFeasible(lp, lp->epsprimal)) { if(feasible) { if(lp->bb_totalnodes == 0) report(lp, DETAILED, "Model is dual infeasible and primal feasible\n"); lp->spx_status = SWITCH_TO_PRIMAL; lp->doInvert = (MYBOOL) (lp->Extrad != 0); lp->Extrad = 0; } else { if(lp->bb_totalnodes == 0) report(lp, NORMAL, "Model is primal and dual infeasible\n"); lp->spx_status = INFEASIBLE; ok = FALSE; } break; } else if(lp->Extrad == 0) { /* We are feasible (and possibly also optimal) */ feasible = TRUE; lp->simplex_mode = SIMPLEX_Phase2_DUAL; /* Check if we still have equality slacks stuck in the basis; drive them out? */ if((lp->fixedvars > 0) && lp->bb_totalnodes == 0) #ifdef Paranoia report(lp, NORMAL, #else report(lp, DETAILED, #endif "Found dual solution with %d fixed slack variables left basic\n", lp->fixedvars); #ifdef Phase1DualPriceEqualities if(forceoutEQ != TRUE) { forceoutEQ = TRUE; goto RetryRow; } colnr = 0; #else #if 1 /* Problem: Check if we are dual degenerate and need to switch to the primal simplex (there is a flaw in the dual simplex code) */ colnr = colprim(lp, FALSE, drow, nzprow); #else colnr = 0; #endif #endif if(colnr == 0) lp->spx_status = OPTIMAL; else { lp->spx_status = SWITCH_TO_PRIMAL; if(lp->total_iter == 0) report(lp, NORMAL, "Use primal simplex for finalization at iteration %8d\n", get_total_iter(lp)); } if((lp->total_iter == 0) && (lp->spx_status == OPTIMAL)) report(lp, NORMAL, "Optimal solution with dual simplex at iteration %8d\n", get_total_iter(lp)); break; } else {
CodecStatus_t Codec_MmeVideoMpeg2_c::DumpDecodeParameters(void *Parameters) { MPEG2_TransformParam_t *FrameParams; // FrameParams = (MPEG2_TransformParam_t *)Parameters; report(severity_info, "AZA - FRAME PARAMS %08x\n", FrameParams); report(severity_info, "AZA - StructSize = %d\n", FrameParams->StructSize); report(severity_info, "AZA - PictureStartAddrCompressedBuffer_p = %08x\n", FrameParams->PictureStartAddrCompressedBuffer_p); report(severity_info, "AZA - PictureStopAddrCompressedBuffer_p = %08x\n", FrameParams->PictureStopAddrCompressedBuffer_p); report(severity_info, "AZA - DecodedBufferAddress\n"); report(severity_info, "AZA - StructSize = %d\n", FrameParams->DecodedBufferAddress.StructSize); report(severity_info, "AZA - DecodedLuma_p = %08x\n", FrameParams->DecodedBufferAddress.DecodedLuma_p); report(severity_info, "AZA - DecodedChroma_p = %08x\n", FrameParams->DecodedBufferAddress.DecodedChroma_p); report(severity_info, "AZA - DecodedTemporalReferenceValue = %d\n", FrameParams->DecodedBufferAddress.DecodedTemporalReferenceValue); report(severity_info, "AZA - DecimatedLuma_p = %08x\n", FrameParams->DecodedBufferAddress.DecimatedLuma_p); report(severity_info, "AZA - DecimatedChroma_p = %08x\n", FrameParams->DecodedBufferAddress.DecimatedChroma_p); report(severity_info, "AZA - MBDescr_p = %08x\n", FrameParams->DecodedBufferAddress.MBDescr_p); report(severity_info, "AZA - RefPicListAddress\n"); report(severity_info, "AZA - StructSize = %d\n", FrameParams->RefPicListAddress.StructSize); report(severity_info, "AZA - BackwardReferenceLuma_p = %08x\n", FrameParams->RefPicListAddress.BackwardReferenceLuma_p); report(severity_info, "AZA - BackwardReferenceChroma_p = %08x\n", FrameParams->RefPicListAddress.BackwardReferenceChroma_p); report(severity_info, "AZA - BackwardTemporalReferenceValue = %d\n", FrameParams->RefPicListAddress.BackwardTemporalReferenceValue); report(severity_info, "AZA - ForwardReferenceLuma_p = %08x\n", FrameParams->RefPicListAddress.ForwardReferenceLuma_p); report(severity_info, "AZA - ForwardReferenceChroma_p = %08x\n", FrameParams->RefPicListAddress.ForwardReferenceChroma_p); report(severity_info, "AZA - ForwardTemporalReferenceValue = %d\n", FrameParams->RefPicListAddress.ForwardTemporalReferenceValue); report(severity_info, "AZA - MainAuxEnable = %08x\n", FrameParams->MainAuxEnable); report(severity_info, "AZA - HorizontalDecimationFactor = %08x\n", FrameParams->HorizontalDecimationFactor); report(severity_info, "AZA - VerticalDecimationFactor = %08x\n", FrameParams->VerticalDecimationFactor); report(severity_info, "AZA - DecodingMode = %d\n", FrameParams->DecodingMode); report(severity_info, "AZA - AdditionalFlags = %08x\n", FrameParams->AdditionalFlags); report(severity_info, "AZA - PictureParameters\n"); report(severity_info, "AZA - StructSize = %d\n", FrameParams->PictureParameters.StructSize); report(severity_info, "AZA - picture_coding_type = %d\n", FrameParams->PictureParameters.picture_coding_type); report(severity_info, "AZA - forward_horizontal_f_code = %d\n", FrameParams->PictureParameters.forward_horizontal_f_code); report(severity_info, "AZA - forward_vertical_f_code = %d\n", FrameParams->PictureParameters.forward_vertical_f_code); report(severity_info, "AZA - backward_horizontal_f_code = %d\n", FrameParams->PictureParameters.backward_horizontal_f_code); report(severity_info, "AZA - backward_vertical_f_code = %d\n", FrameParams->PictureParameters.backward_vertical_f_code); report(severity_info, "AZA - intra_dc_precision = %d\n", FrameParams->PictureParameters.intra_dc_precision); report(severity_info, "AZA - picture_structure = %d\n", FrameParams->PictureParameters.picture_structure); report(severity_info, "AZA - mpeg_decoding_flags = %08x\n", FrameParams->PictureParameters.mpeg_decoding_flags); return CodecNoError; }
int main(int argc, char **argv) { int a, c; int sts; int exitsts = 0; char *source; char *endnum; while ((c = pmGetOptions(argc, argv, &opts)) != EOF) { switch (c) { case 'b': /* batchsize */ batchsize = (int)strtol(opts.optarg, &endnum, 10); if (*endnum != '\0') { pmprintf("%s: -b requires numeric argument\n", pmProgname); opts.errors++; } break; case 'c': /* derived metrics config file */ sts = pmLoadDerivedConfig(opts.optarg); if (sts < 0) { fprintf(stderr, "%s: derived configuration(s) error: %s\n", pmProgname, pmErrStr(sts)); /* errors are not necessarily fatal ... */ } break; case 'd': p_desc = 1; need_context = 1; need_pmid = 1; break; case 'F': p_force = p_value = 1; need_context = 1; need_pmid = 1; break; case 'f': p_value = 1; need_context = 1; need_pmid = 1; break; case 'M': p_fullmid = 1; p_mid = 1; need_pmid = 1; break; case 'm': p_mid = 1; need_pmid = 1; break; case 't': p_oneline = 1; need_context = 1; need_pmid = 1; break; case 'T': p_help = 1; need_context = 1; need_pmid = 1; break; case 'v': verify = 1; need_context = 1; need_pmid = 1; break; case 'x': events = p_value = 1; need_context = 1; need_pmid = 1; break; } } if (opts.errors) { pmUsageMessage(&opts); exit(1); } if (opts.context) need_context = 1; if (opts.context == PM_CONTEXT_ARCHIVE) /* * for archives, one metric per batch and start at beginning of * archive for each batch so metric will be found if it is in * the archive */ batchsize = 1; if (verify) p_desc = p_mid = p_fullmid = p_help = p_oneline = p_value = p_force = 0; if ((namelist = (char **)malloc(batchsize * sizeof(char *))) == NULL) { fprintf(stderr, "%s: namelist malloc: %s\n", pmProgname, osstrerror()); exit(1); } if ((pmidlist = (pmID *)malloc(batchsize * sizeof(pmID))) == NULL) { fprintf(stderr, "%s: pmidlist malloc: %s\n", pmProgname, osstrerror()); exit(1); } if (!opts.nsflag) need_context = 1; /* for distributed PMNS as no PMNS file given */ if (need_context) { int ctxid; if (opts.context == PM_CONTEXT_ARCHIVE) source = opts.archives[0]; else if (opts.context == PM_CONTEXT_HOST) source = opts.hosts[0]; else if (opts.context == PM_CONTEXT_LOCAL) source = NULL; else { opts.context = PM_CONTEXT_HOST; source = "local:"; } if ((sts = pmNewContext(opts.context, source)) < 0) { if (opts.context == PM_CONTEXT_HOST) fprintf(stderr, "%s: Cannot connect to PMCD on host \"%s\": %s\n", pmProgname, source, pmErrStr(sts)); else if (opts.context == PM_CONTEXT_LOCAL) fprintf(stderr, "%s: Cannot make standalone connection on localhost: %s\n", pmProgname, pmErrStr(sts)); else fprintf(stderr, "%s: Cannot open archive \"%s\": %s\n", pmProgname, source, pmErrStr(sts)); exit(1); } ctxid = sts; if (opts.context == PM_CONTEXT_ARCHIVE) { pmTrimNameSpace(); /* complete TZ and time window option (origin) setup */ if (pmGetContextOptions(ctxid, &opts)) { pmflush(); exit(1); } } } if (opts.optind >= argc) { sts = pmTraversePMNS("", dometric); if (sts < 0) { fprintf(stderr, "Error: %s\n", pmErrStr(sts)); exitsts = 1; } } else { for (a = opts.optind; a < argc; a++) { sts = pmTraversePMNS(argv[a], dometric); if (sts < 0) { fprintf(stderr, "Error: %s: %s\n", argv[a], pmErrStr(sts)); exitsts = 1; } } } report(); exit(exitsts); }
static int dofile (lua_State *L, const char *name) { int status = luaL_loadfile(L, name) || docall(L, 0, 1); return report(L, status); }
/* Choose an authentication function for action == LOGIN, service != enable */ static int choose_login(struct authen_data *data, struct authen_type *type) { char *name = data->NAS_id->username; char *cfg_passwd; switch(type->authen_type) { case TAC_PLUS_AUTHEN_TYPE_ASCII: if (session.version != TAC_PLUS_VER_0) { break; } if (!name[0]) { /* request a user name if not already supplied */ return(CHOOSE_GETUSER); } /* Does this user require s/key? */ cfg_passwd = cfg_get_login_secret(name, TAC_PLUS_RECURSE); if (cfg_passwd && STREQ(cfg_passwd, "skey")) { if (debug & DEBUG_PASSWD_FLAG) report(LOG_DEBUG, "%s %s: user %s requires skey", session.peer, session.port, name); #ifdef SKEY type->authen_func = skey_fn; strcpy(type->authen_name, "skey_fn"); return(CHOOSE_OK); #else /* SKEY */ report(LOG_ERR, "%s %s: user %s s/key support has not been compiled in", name ? name : "<unknown>", session.peer, session.port); return(CHOOSE_FAILED); #endif /* SKEY */ } /* Not an skey user. Must be none, des, cleartext or file password */ type->authen_func = default_fn; strcpy(type->authen_name, "default_fn"); return(CHOOSE_OK); case TAC_PLUS_AUTHEN_TYPE_ARAP: #ifndef ARAP_DES /* * If we have no des code we can't do ARAP via SENDAUTH. We'll * have to do it via SENDPASS. Return a down-rev reply * packet and hope the NAS is smart enough to deal with it. */ session.version = TAC_PLUS_VER_0; report(LOG_ERR, "%s %s: user %s DES is unavailable", name ? name : "<unknown>", session.peer, session.port); return(CHOOSE_FAILED); #endif /* ARAP_DES */ /* FALLTHROUGH */ #ifdef MSCHAP case TAC_PLUS_AUTHEN_TYPE_MSCHAP: #ifndef MSCHAP_DES /* * If we have no des code we can't do MSCHAP via LOGIN. We'll * have to do it via SENDPASS. Return a down-rev reply * packet and hope the NAS is smart enough to deal with it. */ session.version = TAC_PLUS_VER_0; report(LOG_ERR, "%s %s: user %s DES is unavailable", name ? name : "<unknown>", session.peer, session.port); return(CHOOSE_FAILED); #endif /* MSCHAP_DES */ /* FALLTHROUGH */ #endif /* MSCHAP */ case TAC_PLUS_AUTHEN_TYPE_PAP: case TAC_PLUS_AUTHEN_TYPE_CHAP: if (session.version == TAC_PLUS_VER_0) { type->authen_func = default_v0_fn; strcpy(type->authen_name, "default_v0_fn"); return(CHOOSE_OK); } /* Version 1 login/[pap|chap|arap]. * The username must in the initial START packet */ if (!name[0]) { report(LOG_ERR, "%s %s: No user in START packet for PAP/CHAP/ARAP", session.peer, session.port); return(CHOOSE_FAILED); } type->authen_func = default_fn; strcpy(type->authen_name, "default_fn"); return(CHOOSE_OK); default: break; } /* Illegal value combination */ report(LOG_ERR, "%s: %s %s Illegal packet ver=%d action=%d type=%d", session.peer, session.port, name ? name : "<unknown>", session.version, data->action, type->authen_type); return(CHOOSE_FAILED); }
static int dolibrary (lua_State *L, const char *name) { lua_getglobal(L, "require"); lua_pushstring(L, name); return report(L, docall(L, 1, 1)); }
void FlightControlCenter::start(string file, double speed) { string line; ifstream myfile(file); Clock::speedOfSimClock = speed; if (myfile) { getline(myfile, line); cityParser->InitCityData((char*)line.c_str()); //initiate city parser with file on 1st line getline(myfile, line); fltParser->InitFlightData((char*)line.c_str()); //initiate flight parser with file on 2nd line }; cityParser->getCitySymbolsArray(&FlightControlCenter::symbols); //get city symbols array from City Parser cityParser->getDistTable(&FlightControlCenter::distances); //get city Distance Table array from City Parser FlightControlCenter::numofCities = cityParser->getCityCount(); // get number of cities for calculating distances fltParser->getStartTime(&Clock::curr_hour, &Clock::curr_min); //get start time buildManifest(); //get info on all flights buildAirplanesList(); // builds airplane list buildCitiesList(); //builds cities list buildFlightsList(); // builds flight list //print sim start time cout << "*** Starting simulation at "<< setfill('0') << setw(2) << Clock::curr_hour << ":" << setfill('0') << setw(2) << Clock::curr_min << " ***" << endl << endl; //timer loop _ftime(&Clock::tStruct); // Get start time Clock::startOfSimClock = Clock::tStruct.time + (((double)(Clock::tStruct.millitm)) / 1000.0); // Convert to double Clock::thisTime = Clock::tStruct.time + (((double)(Clock::tStruct.millitm)) / 1000.0); // Convert to double Clock::outputTime = Clock::thisTime + (5.0/Clock::speedOfSimClock); // Set next (5 second/ simulator speed) interval time while (!done) // Start an eternal loop { _ftime(&Clock::tStruct); // Get the current time Clock::thisTime = Clock::tStruct.time + (((double)(Clock::tStruct.millitm)) / 1000.0); // Convert to double // Check for 5 second interval to print status to screen if (Clock::thisTime >= Clock::outputTime) { Clock::curr_min += 5 * Clock::speedOfSimClock; //keeps up with hours and minutes for display if (Clock::curr_min > 59) { ++Clock::curr_hour; Clock::curr_min %= 60; Clock::startOfSimClock = Clock::thisTime; } else if (Clock::curr_hour > 12) Clock::curr_hour = 1; // Call functions to perform actions at 5 second intervals double t = Clock::curr_hour + ((double)Clock::curr_min / 60); Notify(t, Clock::curr_hour, Clock::curr_min); report(); Clock::outputTime = Clock::thisTime + (5.0/Clock::speedOfSimClock); // Set next (5 second/ simulator speed) interval time } // Do other stuff here if ((Clock::curr_hour == SIM_END_HOUR) && (Clock::curr_min == SIM_END_MINUTE)) done = true; } }
int main(int argc, char **argv) { int i; int exit_code; int index = 0; enum { lookup_mode, list_mode, search_mode, search_all_mode } mode = lookup_mode; setlocale(LC_ALL, ""); for (;;) { int c = getopt_long(argc, argv, "hlsS", options, &index); if (c == -1) break; switch (c) { case 'h': usage(); return EXIT_SUCCESS; case 'l': mode = list_mode; break; case 's': mode = search_mode; break; case 'S': mode = search_all_mode; break; case '?': break; default: fprintf(stderr, "getopt returned 0x%02x\n", c); return EXIT_FAILURE; } } exit_code = EXIT_SUCCESS; switch (mode) { case lookup_mode: for (i = optind; i < argc; ++i) { const char *arg = argv[i]; if (toupper(arg[0]) == 'E') { if (!report_from_name(arg)) exit_code = EXIT_FAILURE; } else if (isdigit(arg[0])) { if (!report_from_code(atoi(arg))) exit_code = EXIT_FAILURE; } else { fprintf(stderr, "ERROR: Not understood: %s\n", arg); exit_code = EXIT_FAILURE; } } break; case list_mode: for (i = 0; i < num_errnos; ++i) report(errnos[i].name, errnos[i].code); break; case search_mode: search(argc - optind, argv + optind); break; case search_all_mode: search_all(argc - optind, argv + optind); break; } return exit_code; }
void sigint(int which) { report(); exit(0); }