/** * This routine reads an single token from the specified * text file and interprets it as a prototype specification. * @param File open text file to read prototype style from * @return Prototype style read from text file * @note Globals: None * @note Exceptions: ILLEGALSTYLESPEC illegal prototype style specification * @note History: 6/8/89, DSJ, Created. */ PROTOSTYLE ReadProtoStyle(FILE *File) { char Token[TOKENSIZE]; PROTOSTYLE Style; if (tfscanf(File, "%s", Token) != 1) DoError (ILLEGALSTYLESPEC, "Illegal prototype style specification"); switch (Token[0]) { case 's': Style = spherical; break; case 'e': Style = elliptical; break; case 'm': Style = mixed; break; case 'a': Style = automatic; break; default: Style = elliptical; DoError (ILLEGALSTYLESPEC, "Illegal prototype style specification"); } return (Style); }
/*---------------------------------------------------------------------------*/ void *Emalloc(int Size) { /* ** Parameters: ** Size number of bytes of memory to be allocated ** Globals: none ** Operation: ** This routine attempts to allocate the specified number of ** bytes. If the memory can be allocated, a pointer to the ** memory is returned. If the memory cannot be allocated, or ** if the allocation request is negative or zero, ** an error is trapped. ** Return: Pointer to allocated memory. ** Exceptions: NOTENOUGHMEMORY unable to allocate Size bytes ** ILLEGALMALLOCREQUEST negative or zero request size ** History: 4/3/89, DSJ, Created. */ void *Buffer; if (Size <= 0) DoError (ILLEGALMALLOCREQUEST, "Illegal malloc request size"); Buffer = (void *) malloc (Size); if (Buffer == NULL) { DoError (NOTENOUGHMEMORY, "Not enough memory"); return (NULL); } else return (Buffer); } /* Emalloc */
/** * This routine reads textual descriptions of sets of parameters * which describe the characteristics of feature dimensions. * * Exceptions: * - ILLEGALCIRCULARSPEC * - ILLEGALESSENTIALSPEC * - ILLEGALMINMAXSPEC * @param File open text file to read N parameter descriptions from * @param N number of parameter descriptions to read * @return Pointer to an array of parameter descriptors. * @note Globals: None * @note History: 6/6/89, DSJ, Created. */ PARAM_DESC *ReadParamDesc(FILE *File, uinT16 N) { int i; PARAM_DESC *ParamDesc; char Token[TOKENSIZE]; ParamDesc = (PARAM_DESC *) Emalloc (N * sizeof (PARAM_DESC)); for (i = 0; i < N; i++) { if (tfscanf(File, "%s", Token) != 1) DoError (ILLEGALCIRCULARSPEC, "Illegal circular/linear specification"); if (Token[0] == 'c') ParamDesc[i].Circular = TRUE; else ParamDesc[i].Circular = FALSE; if (tfscanf(File, "%s", Token) != 1) DoError (ILLEGALESSENTIALSPEC, "Illegal essential/non-essential spec"); if (Token[0] == 'e') ParamDesc[i].NonEssential = FALSE; else ParamDesc[i].NonEssential = TRUE; if (tfscanf(File, "%f%f", &(ParamDesc[i].Min), &(ParamDesc[i].Max)) != 2) DoError (ILLEGALMINMAXSPEC, "Illegal min or max specification"); ParamDesc[i].Range = ParamDesc[i].Max - ParamDesc[i].Min; ParamDesc[i].HalfRange = ParamDesc[i].Range / 2; ParamDesc[i].MidRange = (ParamDesc[i].Max + ParamDesc[i].Min) / 2; } return (ParamDesc); }
/*---------------------------------------------------------------------------*/ void *Erealloc(void *ptr, int size) { void *Buffer; if (size < 0 || (size == 0 && ptr == NULL)) DoError (ILLEGALMALLOCREQUEST, "Illegal realloc request size"); Buffer = (void *) realloc (ptr, size); if (Buffer == NULL && size != 0) DoError (NOTENOUGHMEMORY, "Not enough memory"); return (Buffer); } /* Erealloc */
/*---------------------------------------------------------------------------*/ jmp_buf &PushErrorTrap(VOID_PROC Procedure) { /* ** Parameters: ** Procedure trap procedure to execute ** Globals: ** ErrorTrapStack stack of error traps ** CurrentTrapDepth number of traps on the stack ** Operation: ** This routine pushes a new error trap onto the top of ** the error trap stack. This new error trap can then be ** used in a call to setjmp. This trap is then in effect ** until ReleaseErrorTrap is called. WARNING: a procedure ** that calls PushErrorTrap should never exit before calling ** ReleaseErrorTrap. ** Return: ** Pointer to a new error trap buffer ** Exceptions: ** Traps an error if the error trap stack is already full ** History: ** 3/17/89, DSJ, Created. ** 9/12/90, DSJ, Added trap procedure parameter. */ if (CurrentTrapDepth >= MAXTRAPDEPTH) DoError (ERRORTRAPDEPTH, "Error trap depth exceeded"); ProcTrapStack[CurrentTrapDepth] = Procedure; return ErrorTrapStack[CurrentTrapDepth++]; } /* PushErrorTrap */
void CMainFrame::OnSelectMenu(UINT nID) { int nMenu=nID-MENU_START_ID; if(nMenu<0||nMenu>=aAllMenuItems.GetSize()) { Message(String("ќшибка: идентификатор обработки меню не найден")); return; } try { CMyMenuItem element=aAllMenuItems[nMenu]; if(element.nType==MENU_FUNCTION) { if(element.pRun) { int nRes=element.pRun->FindFunction(element.sFunction,0); if(nRes>=0) element.pRun->CallFunction(element.sFunction,element.vData); else OpenFormExt(element.sFunction,CValue()); } } else if(element.nType==MENU_OBJECT) element.vObject.CallFunction(element.sFunction,&element.vData); } catch(CTranslateError *) { DoError(); }; }
/** * This routine reads N floats from the specified text file * and places them into Buffer. If Buffer is NULL, a buffer * is created and passed back to the caller. If EOF is * encountered before any floats can be read, NULL is * returned. * @param File open text file to read floats from * @param N number of floats to read * @param Buffer pointer to buffer to place floats into * @return Pointer to buffer holding floats or NULL if EOF * @note Globals: None * @note Exceptions: ILLEGALFLOAT * @note History: 6/6/89, DSJ, Created. */ FLOAT32* ReadNFloats(FILE * File, uinT16 N, FLOAT32 Buffer[]) { bool needs_free = false; int i; int NumFloatsRead; if (Buffer == NULL) { Buffer = reinterpret_cast<FLOAT32*>(Emalloc(N * sizeof(FLOAT32))); needs_free = true; } for (i = 0; i < N; i++) { NumFloatsRead = tfscanf(File, "%f", &(Buffer[i])); if (NumFloatsRead != 1) { if ((NumFloatsRead == EOF) && (i == 0)) { if (needs_free) { Efree(Buffer); } return NULL; } else { DoError(ILLEGALFLOAT, "Illegal float specification"); } } } return Buffer; }
/*---------------------------------------------------------------------------*/ CLASS_ID NameToChar ( char CharName[]) /* ** Parameters: ** CharName character name to convert to a character ** Globals: ** NameList lookup table for name to char mapping ** Operation: ** This routine converts the specified character name to ** an ascii character. ** Return: Ascii character that corresponds to the character name. ** Exceptions: ILLEGALCHARNAME ** History: Sat Aug 26 12:26:54 1989, DSJ, Created. */ { int i; // look for name in table and return character if found for ( i = 0; NameList[i] != NULL; i++ ) if ( strcmp (CharName, &NameList[i][1]) == 0) return (NameList[i][0]); if ( strlen (CharName) == 1 ) return (CharName[0]); //name is not in table but is a single character else //illegal character { DoError (ILLEGALCHARNAME, "Illegal character name"); return 0; } } /* NameToChar */
/*---------------------------------------------------------------------------*/ CHAR_DESC ReadCharDescription(FILE *File) { /* ** Parameters: ** File open text file to read character description from ** Globals: none ** Operation: Read a character description from File, and return ** a data structure containing this information. The data ** is formatted as follows: ** NumberOfSets ** ShortNameForSet1 Set1 ** ShortNameForSet2 Set2 ** ... ** Return: Character description read from File. ** Exceptions: ILLEGAL_NUM_SETS ** History: Wed May 23 17:32:48 1990, DSJ, Created. */ int NumSetsToRead; char ShortName[FEAT_NAME_SIZE]; CHAR_DESC CharDesc; int Type; if (fscanf (File, "%d", &NumSetsToRead) != 1 || NumSetsToRead < 0 || NumSetsToRead > NumFeaturesDefined ()) DoError (ILLEGAL_NUM_SETS, "Illegal number of feature sets"); CharDesc = NewCharDescription (); for (; NumSetsToRead > 0; NumSetsToRead--) { fscanf (File, "%s", ShortName); Type = ShortNameToFeatureType (ShortName); FeaturesOfType (CharDesc, Type) = ReadFeatureSet (File, DefinitionOf (Type)); } return (CharDesc); } // ReadCharDescription
VbError_t VbExTpmOpen(void) { char* device_path; struct timespec delay; int retries, saved_errno; if (tpm_fd >= 0) return VBERROR_SUCCESS; /* Already open */ device_path = getenv("TPM_DEVICE_PATH"); if (device_path == NULL) { device_path = TPM_DEVICE_PATH; } /* Retry TPM opens on EBUSY failures. */ for (retries = 0; retries < OPEN_RETRY_MAX_NUM; ++ retries) { errno = 0; tpm_fd = open(device_path, O_RDWR | O_CLOEXEC); saved_errno = errno; if (tpm_fd >= 0) return VBERROR_SUCCESS; if (saved_errno != EBUSY) break; VB2_DEBUG("TPM: retrying %s: %s\n", device_path, strerror(errno)); /* Stall until TPM comes back. */ delay.tv_sec = 0; delay.tv_nsec = OPEN_RETRY_DELAY_NS; nanosleep(&delay, NULL); } return DoError(TPM_E_NO_DEVICE, "TPM: Cannot open TPM device %s: %s\n", device_path, strerror(saved_errno)); }
/*---------------------------------------------------------------------------*/ FEATURE_SET ReadFeatureSet(FILE *File, const FEATURE_DESC_STRUCT* FeatureDesc) { /* ** Parameters: ** File open text file to read new feature set from ** FeatureDesc specifies type of feature to read from File ** Globals: none ** Operation: Create a new feature set of the specified type and read in ** the features from File. The correct text representation ** for a feature set is an integer which specifies the number (N) ** of features in a set followed by a list of N feature ** descriptions. ** Return: New feature set read from File. ** Exceptions: none ** History: Wed May 23 09:17:31 1990, DSJ, Created. */ FEATURE_SET FeatureSet; int NumFeatures; int i; if (fscanf (File, "%d", &NumFeatures) != 1 || NumFeatures < 0) DoError (ILLEGAL_NUM_FEATURES, "Illegal number of features in set"); FeatureSet = NewFeatureSet (NumFeatures); for (i = 0; i < NumFeatures; i++) AddFeature (FeatureSet, ReadFeature (File, FeatureDesc)); return (FeatureSet); } /* ReadFeatureSet */
/*---------------------------------------------------------------------------*/ FEATURE ReadFeature(FILE *File, const FEATURE_DESC_STRUCT* FeatureDesc) { /* ** Parameters: ** File open text file to read feature from ** FeatureDesc specifies type of feature to read from File ** Globals: none ** Operation: Create a new feature of the specified type and read in ** the value of its parameters from File. The extra penalty ** for the feature is also computed by calling the appropriate ** function for the specified feature type. The correct text ** representation for a feature is a list of N floats where ** N is the number of parameters in the feature. ** Return: New feature read from File. ** Exceptions: ILLEGAL_FEATURE_PARAM if text file doesn't match expected format ** History: Wed May 23 08:53:16 1990, DSJ, Created. */ FEATURE Feature; int i; Feature = NewFeature (FeatureDesc); for (i = 0; i < Feature->Type->NumParams; i++) { if (fscanf (File, "%f", &(Feature->Params[i])) != 1) DoError (ILLEGAL_FEATURE_PARAM, "Illegal feature parameter spec"); #ifndef WIN32 assert (!isnan(Feature->Params[i])); #endif } return (Feature); } /* ReadFeature */
/*---------------------------------------------------------------------------*/ void Efree(void *ptr) { if (ptr == NULL) DoError (ILLEGALMALLOCREQUEST, "Attempted to free NULL ptr"); free(ptr); } /* Efree */
bool GetNewDinoName(char *dinoName) { char line[kMaxLineLength]; int i, nameLen; printf("Enter new name: "); if (fgets(line, kMaxLineLength, stdin)) { DoError("Bad fgets."); } line[strlen(line) - 1] = '\0'; for (i = 0; i < kDinoRecordSize; i++) { dinoName[i] = ' '; } nameLen = (int)strlen(line); if (nameLen > kDinoRecordSize) { nameLen = kDinoRecordSize; } for (i = 0; i <nameLen; i++) { dinoName[i] = line[i]; } return true; }
void C4ConsoleQtLocalizeStringDlg::AddLanguagePressed() { bool lang_ok = false; QRegExpValidator validator(QRegExp("^[a-zA-Z][a-zA-Z]$"), this); QString lang_id; while (!lang_ok) { bool ok; int q = 0; lang_id = QInputDialog::getText(this, LoadResStr("IDS_CNS_ADDLANGUAGE"), LoadResStr("IDS_CNS_ADDLANGUAGEID"), QLineEdit::Normal, QString(), &ok); if (!ok) return; lang_ok = (validator.validate(lang_id, q) == QValidator::Acceptable); if (!lang_ok) { DoError(LoadResStr("IDS_ERR_INVALIDLANGUAGEID")); } } // Either add or just focus existing editor QLineEdit *editor = GetEditorByLanguage(lang_id.toUtf8()); if (!editor) { editor = AddEditor(lang_id.toUtf8(), nullptr); adjustSize(); setMinimumSize(size()); } editor->setFocus(); }
void CSocketEngine::RunL(){ switch(iSocketStatus){ case EDns: { iHostResolver.Close(); if(iStatus==KErrNone){ DnsComplete(); }else DoError(EDns); } break; case EConnecting: {//正在连接状态完成后,发送请求信息 if(iStatus==KErrNone){ if(iType){ TRAPD(err,SendDataPost(1,iPostType,iData->Des())); if(err) Log(_L8("SendDataPost Exception")); }else{ TRAPD(err,SendDataGet(1)); if(err) Log(_L8("SendDataGet Exception")); } }else{ DoError(EConnecting); } } break; case EWritting: {//发送请求状态完成后,开始读取返回数据 if(iStatus==KErrNone){ TRAPD(err,ReceiveData()); if(err) Log(_L8("ReceiveData Exception")); }else DoError(EWritting); } break; case EReading: {//如果数据没有接收完,则继续读取数据 if(iStatus==KErrNone){ TRAPD(err,GetData()); if(err) Log(_L8("GetData Exception")); }else DoError(EReading); } break; case EWrittingPost: case EWaiting: case EConnected: case ESending: case ENotConnected: default: break; } }
/** * This routine reads a single integer from the specified * file and checks to ensure that it is between 0 and * MAXSAMPLESIZE. * @param File open text file to read sample size from * @return Sample size * @note Globals: None * @note Exceptions: ILLEGALSAMPLESIZE illegal format or range * @note History: 6/6/89, DSJ, Created. */ uinT16 ReadSampleSize(FILE *File) { int SampleSize; if ((tfscanf(File, "%d", &SampleSize) != 1) || (SampleSize < 0) || (SampleSize > MAXSAMPLESIZE)) DoError (ILLEGALSAMPLESIZE, "Illegal sample size"); return (SampleSize); }
void WriteDinoName(int number, char *dinoName) { FILE *fp; long bytesToSkip; if ((fp = fopen(kDinoFileName, "r")) == NULL) { DoError("Could not open the file."); } bytesToSkip = (long)((number - 1) * kDinoRecordSize); if (fseek(fp, bytesToSkip, SEEK_SET) != 0) { DoError("Could not seek in the file."); } if (fwrite(dinoName, (size_t)kDinoRecordSize, (size_t)1, fp) != 1) { DoError("Bad fread."); } }
int GetNumberOfDinos(void) { FILE *fp; long fileLength; if ((fp = fopen(kDinoFileName, "r")) == NULL) { DoError("Couldn't open the file."); } if (fseek(fp, 0L, SEEK_END) != 0) { DoError("Could not seek to the end of the file."); } if ((fileLength = ftell(fp)) == -1L) { DoError("ftell() failed."); } return (int)(fileLength / kDinoRecordSize); }
/********************************************************************** * memfree * * Memory allocator with protection. **********************************************************************/ void memfree(void *element) { if (element) { free_mem(element); mem_alloc_counter--; } else { tprintf ("%d MEM_ALLOC's used\n", mem_alloc_counter); DoError (0, "Memfree of NULL pointer"); } }
//______________________________________________________________________________ void MainWindow::DoConvert(){ // gettimeofday(&start, 0); t1.restart(); ui_progressbar->setValue(0); AnalysisWidget = new Analysis(this); AnalysisWidget->Emax = ui_EmaxSpinBox->value(); AnalysisWidget->binning = ui_BinSizeSpinBox->value(); AnalysisWidget->spin = ui_SpinParitySpinBox->value(); AnalysisWidget->parity = ui_SpinParitySpinBox_2->value(); AnalysisWidget->CTorBSFG = ui_DensityEnergyComboBox->currentIndex(); AnalysisWidget->param1 = ui_TorASpinBox_1->value(); AnalysisWidget->param2 = ui_TorASpinBox_2->value(); AnalysisWidget->A = ui_ASpinBox->value(); AnalysisWidget->Z = ui_ZSpinBox->value(); AnalysisWidget->Pair = ui_PairSpinBox->value(); AnalysisWidget->Parity_average = ui_ParityBox->value(); AnalysisWidget->spin_ex = ui_SpinParitySpinBox_n1->value(); AnalysisWidget->parity_ex = ui_SpinParitySpinBox_n2->value(); AnalysisWidget->Calculate(); AnalysisWidget->SetStrength(ui_E1StrengthComboBox->currentIndex(),ui_M1StrengthComboBox->currentIndex()); if (ui_Levellabel->text().isEmpty()==false) {AnalysisWidget->ReplaceLevels(ui_Levellabel->text());} if(ui_ReactionComboBox->currentIndex()==0){ AnalysisWidget->Decay(); } if((ui_ReactionComboBox->currentIndex()==1)&&(ui_Spectrumlabel->text().isEmpty()==false)){ ui_SpinParitySpinBox_n1->setValue(ui_SpinParitySpinBox->value()); AnalysisWidget->LoadSpectrum(ui_Spectrumlabel->text()); AnalysisWidget->GammaGamma(); } if((ui_ReactionComboBox->currentIndex()==1)&&(ui_Spectrumlabel->text().isEmpty()==true)){ DoError("No Gamma Spectrum given"); } gettimeofday(&end, 0); int a = t1.elapsed()/1000; QString s ; s = "time needed : "; s += QString::number(a); s += " s"; if (a>5){ ui_OutputLabel->setText(s); } //cout <<" Time needed: "<< end.tv_sec-start.tv_sec<<"s "<< t2< endl; }
/** * Search thru all features currently defined and return * the feature type for the feature with the specified short * name. Trap an error if the specified name is not found. * * Globals: * - none * * @param FeatureDefs definitions of feature types/extractors * @param ShortName short name of a feature type * @return Feature type which corresponds to ShortName. * @note Exceptions: * - ILLEGAL_SHORT_NAME * @note History: Wed May 23 15:36:05 1990, DSJ, Created. */ int ShortNameToFeatureType(const FEATURE_DEFS_STRUCT &FeatureDefs, const char *ShortName) { int i; for (i = 0; i < FeatureDefs.NumFeatureTypes; i++) if (!strcmp ((FeatureDefs.FeatureDesc[i]->ShortName), ShortName)) return (i); DoError (ILLEGAL_SHORT_NAME, "Illegal short name for a feature"); return 0; } // ShortNameToFeatureType
nsresult RasterImage::OnImageDataComplete(nsIRequest*, nsISupports*, nsresult aStatus, bool aLastPart) { MOZ_ASSERT(NS_IsMainThread()); // Record that we have all the data we're going to get now. mHasSourceData = true; // Let decoders know that there won't be any more data coming. mSourceBuffer->Complete(aStatus); // Allow a synchronous metadata decode if mSyncLoad was set, or if we're // running on a single thread (in which case waiting for the async metadata // decoder could delay this image's load event quite a bit), or if this image // is transient. bool canSyncDecodeMetadata = mSyncLoad || mTransient || DecodePool::NumberOfCores() < 2; if (canSyncDecodeMetadata && !mHasSize) { // We're loading this image synchronously, so it needs to be usable after // this call returns. Since we haven't gotten our size yet, we need to do a // synchronous metadata decode here. DecodeMetadata(FLAG_SYNC_DECODE); } // Determine our final status, giving precedence to Necko failure codes. We // check after running the metadata decode in case it triggered an error. nsresult finalStatus = mError ? NS_ERROR_FAILURE : NS_OK; if (NS_FAILED(aStatus)) { finalStatus = aStatus; } // If loading failed, report an error. if (NS_FAILED(finalStatus)) { DoError(); } Progress loadProgress = LoadCompleteProgress(aLastPart, mError, finalStatus); if (!mHasSize && !mError) { // We don't have our size yet, so we'll fire the load event in SetSize(). MOZ_ASSERT(!canSyncDecodeMetadata, "Firing load async after metadata sync decode?"); NotifyProgress(FLAG_ONLOAD_BLOCKED); mLoadProgress = Some(loadProgress); return finalStatus; } NotifyForLoadEvent(loadProgress); return finalStatus; }
/*---------------------------------------------------------------------------*/ void ExtractorStub () /** * This routine is used to stub out feature extractors * that are no longer used. It simply calls DoError. * * @note Exceptions: none * @note History: Wed Jan 2 14:16:49 1991, DSJ, Created. */ #define DUMMY_ERROR 1 { DoError (DUMMY_ERROR, "Selected feature extractor has been stubbed out!"); } /* ExtractorStub */
nsresult RasterImage::OnImageDataAvailable(nsIRequest*, nsISupports*, nsIInputStream* aInputStream, uint64_t, uint32_t aCount) { nsresult rv = mSourceBuffer->AppendFromInputStream(aInputStream, aCount); if (NS_FAILED(rv)) { DoError(); } return rv; }
/** * This routine converts the specified character name to * an ascii character. * * @param CharName character name to convert to a character * * Globals: * - NameList lookup table for name to char mapping * * @return Ascii character that corresponds to the character name. * @note Exceptions: ILLEGALCHARNAME * @note History: Sat Aug 26 12:26:54 1989, DSJ, Created. */ CLASS_ID NameToChar (char CharName[]) { int i; // look for name in table and return character if found for ( i = 0; NameList[i] != NULL; i++ ) if ( strcmp (CharName, &NameList[i][1]) == 0) return (NameList[i][0]); if ( strlen (CharName) == 1 ) return (CharName[0]); //name is not in table but is a single character else //illegal character { DoError (ILLEGALCHARNAME, "Illegal character name"); return 0; } } /* NameToChar */
nsresult RasterImage::OnImageDataAvailable(nsIRequest*, nsISupports*, nsIInputStream* aInputStream, uint64_t, uint32_t aCount) { nsresult rv = mSourceBuffer->AppendFromInputStream(aInputStream, aCount); MOZ_ASSERT(rv == NS_OK || rv == NS_ERROR_OUT_OF_MEMORY); if (MOZ_UNLIKELY(rv == NS_ERROR_OUT_OF_MEMORY)) { DoError(); } return rv; }
/*---------------------------------------------------------------------------*/ int ShortNameToFeatureType(const char *ShortName) { /* ** Parameters: ** ShortName short name of a feature type ** Globals: none ** Operation: Search thru all features currently defined and return ** the feature type for the feature with the specified short ** name. Trap an error if the specified name is not found. ** Return: Feature type which corresponds to ShortName. ** Exceptions: ILLEGAL_SHORT_NAME ** History: Wed May 23 15:36:05 1990, DSJ, Created. */ int i; for (i = 0; i < NumFeaturesDefined (); i++) if (!strcmp (ShortNameOf (DefinitionOf (i)), ShortName)) return (i); DoError (ILLEGAL_SHORT_NAME, "Illegal short name for a feature"); return 0; } // ShortNameToFeatureType
/** * Read a character description from File, and return * a data structure containing this information. The data * is formatted as follows: * @verbatim NumberOfSets ShortNameForSet1 Set1 ShortNameForSet2 Set2 ... @endverbatim * * Globals: * - none * * @param FeatureDefs definitions of feature types/extractors * @param File open text file to read character description from * @return Character description read from File. * @note Exceptions: * - ILLEGAL_NUM_SETS * @note History: Wed May 23 17:32:48 1990, DSJ, Created. */ CHAR_DESC ReadCharDescription(const FEATURE_DEFS_STRUCT &FeatureDefs, FILE *File) { int NumSetsToRead; char ShortName[FEAT_NAME_SIZE]; CHAR_DESC CharDesc; int Type; if (fscanf (File, "%d", &NumSetsToRead) != 1 || NumSetsToRead < 0 || NumSetsToRead > FeatureDefs.NumFeatureTypes) DoError (ILLEGAL_NUM_SETS, "Illegal number of feature sets"); CharDesc = NewCharDescription(FeatureDefs); for (; NumSetsToRead > 0; NumSetsToRead--) { fscanf (File, "%s", ShortName); Type = ShortNameToFeatureType(FeatureDefs, ShortName); CharDesc->FeatureSets[Type] = ReadFeatureSet (File, FeatureDefs.FeatureDesc[Type]); } return (CharDesc); } // ReadCharDescription
/** * This routine stores Entry into Heap. The heap is * maintained in such a way that the item with the lowest key * is always at the top of the heap. * * Globals: * - None * * @param Heap ptr to heap to store new item in * @param Entry ptr to item to be stored in Heap * @note Exceptions: * - HEAPFULL error if heap size is exceeded * @note History: 3/13/89, DSJ, Created. */ void HeapStore(HEAP *Heap, HEAPENTRY *Entry) { inT32 Item; inT32 Father; if (Heap->FirstFree > Heap->Size) DoError (HEAPFULL, "Heap size exceeded"); Item = Heap->FirstFree; Heap->FirstFree++; while (Item != 1) { Father = FATHER (Item); if (Heap->Entry[Father].Key > Entry->Key) { Heap->Entry[Item].Key = Heap->Entry[Father].Key; Heap->Entry[Item].Data = Heap->Entry[Father].Data; Item = Father; } else break; } Heap->Entry[Item].Key = Entry->Key; Heap->Entry[Item].Data = Entry->Data; } /* HeapStore */