void printOrSkipEntry(RawTemplightTraceEntry &Entry) { if ( IgnoreSystemFlag && !Entry.PointOfInstantiation.isInvalid() && TheSema.getSourceManager() .isInSystemHeader(Entry.PointOfInstantiation) ) { skipRawEntry(Entry); // recursively skip all entries until end of this one. } else { if ( Entry.IsTemplateBegin ) { printEntry(rawToPrintableBegin(TheSema, Entry)); } else { printEntry(rawToPrintableEnd(TheSema, Entry)); } } };
unsigned int Keywords::printBucket (const unsigned int i) { hashEntry **const table = getHashTable (); hashEntry *entry = table [i]; unsigned int measure = 1; boolean first = true; printf ("%2d:", i); if (entry == NULL) printf ("\n"); else while (entry != NULL) { if (! first) printf (" "); else { printf (" "); first = false; } printEntry (entry); entry = entry->next; measure = 2 * measure; } return measure - 1; }
void printEntry(FILE* file, ProfileEntry* entry) { int64 ticks = 0; if (entry->numSamples > 0) { ticks = entry->profileSum / entry->numSamples; } float ms; int64 freq = getFrequencies(); ms = ticks * 1000.0f; ms /= freq; fprintf(file, "%*s %-*s: avrg ms: %7.3f ( %7d ticks )\n", 2 * entry->level, "", 30 - 2 * entry->level, entry->name, ms, ticks); for (int i = 0; i < g_numEntries; ++i) { ProfileEntry* _entry = g_entries[i]; if (_entry->parent == entry) { printEntry(file, _entry); } } }
void Settings::writeLines(std::ostream &os, u32 tab_depth) const { MutexAutoLock lock(m_mutex); for (SettingEntries::const_iterator it = m_settings.begin(); it != m_settings.end(); ++it) printEntry(os, it->first, it->second, tab_depth); }
void findTable(Table *table, char *key) { TableEntry entry; initialize(&entry, key, 0); TableEntry *found = retrieveEntry(table, &entry); if (!found) { printf("%s not found\n", key); } else printEntry(found); }
static void printFileArg(FILE * fp, tOptDesc * pOD, tOptions* pOpts) { /* * If the cookie is not NULL, then it has the file name, period. * Otherwise, if we have a non-NULL string argument, then.... */ if (pOD->optCookie != NULL) printEntry(fp, pOD, pOD->optCookie); else if (HAS_originalOptArgArray(pOpts)) { char const * orig = pOpts->originalOptArgArray[pOD->optIndex].argString; if (pOD->optArg.argString == orig) return; printEntry(fp, pOD, pOD->optArg.argString); } }
Node findKey(Node cursor, char *buffer){ while(cursor != NULL){ if(strcmp(buffer, cursor->key) == 0){ printEntry("found entry:", cursor); return cursor; }else{ cursor = cursor->next; } } return NULL; }
static void printStringArg(FILE * fp, tOptDesc * pOD) { if (pOD->fOptState & OPTST_STACKED) { tArgList* pAL = (tArgList*)pOD->optCookie; int uct = pAL->useCt; tCC** ppz = pAL->apzArgs; /* * un-disable multiple copies of disabled options. */ if (uct > 1) pOD->fOptState &= ~OPTST_DISABLED; while (uct-- > 0) printEntry( fp, pOD, *(ppz++) ); } else { printEntry( fp, pOD, pOD->optArg.argString ); } }
/* * Function: * writeEntryFile * * Description: * Writes the entries from a linked list to a file. * * Arguments: * Pointer to the first node of the linked list: * LinkedList * lp * Pointer to the file stream: * FILE * fp * * Return value: * None. */ void writeEntryFile(LinkedList * lp, FILE *fp) { LinkedList * aux; aux = lp; while(aux != NULL) { printEntry((Entry *) getItemLinkedList(aux), fp); aux = getNextNodeLinkedList(aux); } }
void ICACHE_FLASH_ATTR nextEntry(void) { // 500mS int idx; for (idx = 0; idx < MAX_ENTRY; idx++) { if (++startTemp >= MAX_ENTRY) startTemp = 0; if (strlen(valueEntries[startTemp].type) > 0) { printEntry(startTemp); return; } } }
void printProfile(FILE* file) { for (int i = 0; i < g_numEntries; ++i) { ProfileEntry* entry = g_entries[i]; if (entry->parent == 0) { printEntry(file, entry); } } }
static void printEnumArg(FILE * fp, tOptDesc * pOD) { uintptr_t val = pOD->optArg.argEnum; /* * This is a magic incantation that will convert the * bit flag values back into a string suitable for printing. */ (*(pOD->pOptProc))(OPTPROC_RETURN_VALNAME, pOD); printEntry( fp, pOD, (const void*)(pOD->optArg.argString)); pOD->optArg.argEnum = val; }
Error Dumper::printData() { auto EntryPtrOrErr = WinRes->getHeadEntry(); if (!EntryPtrOrErr) return EntryPtrOrErr.takeError(); auto EntryPtr = *EntryPtrOrErr; bool IsEnd = false; while (!IsEnd) { printEntry(EntryPtr); if (auto Err = EntryPtr.moveNext(IsEnd)) return Err; } return Error::success(); }
static void printSetMemberArg(FILE * fp, tOptDesc * pOD) { uintptr_t val = pOD->optArg.argEnum; /* * This is a magic incantation that will convert the * bit flag values back into a string suitable for printing. */ (*(pOD->pOptProc))(OPTPROC_RETURN_VALNAME, pOD); printEntry( fp, pOD, (const void*)(pOD->optArg.argString)); if (pOD->optArg.argString != NULL) { /* * set membership strings get allocated */ AGFREE( pOD->optArg.argString ); pOD->fOptState &= ~OPTST_ALLOC_ARG; } pOD->optArg.argEnum = val; }
int blogatom_main() { char userid[IDLEN + 1]; struct Blog blog; int n, i; printf("Content-type: text/xml; charset=utf-8\r\n\r\n"); printf("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" "<feed xmlns=\"http://www.w3.org/2005/Atom\" xml:lang=\"zh-CN\">"); strsncpy(userid, getparm2("U", "userid"), sizeof (userid)); if (openBlog(&blog, userid) < 0) { printf("<title>该 Blog 尚不存在</title>"); printf("<link href=\"http://" MY_BBS_DOMAIN "\" />"); goto END; } printf("<id>%s</id>", makeTag(&blog, NULL)); printf("<title>%s</title>", nohtml(blog.config->title)); printf("<link href=\"blog?U=%s\" />", blog.config->useridEN); printf("<link rel=\"self\" href=\"blogatom?U=%s\" />", blog.config->useridEN); printf("<author><name>%s</name></author>", blog.config->useridUTF8); printf("<updated>%s</updated>", atomctime(&blog.indexFile.mtime)); //tagline... //id... //generator... for (i = blog.nIndex - 1, n = 0; i >= 0 && n < 30; i--) { if (now_t - blog.index[i].fileTime > 7 * 24 * 3600 && n > 10) break; printEntry(&blog, i); } closeBlog(&blog); END: printf("</feed>"); return 0; }
void rewriteLog(char *log_path) { dmtcp::SynchronizationLog log; /* Only need enough room for the metadata. */ log.initialize(log_path, LOG_OFFSET_FROM_START); size_t logSize = log.getDataSize(); log.destroy(SYNC_IS_RECORD); sync_logging_branch = SYNC_REPLAY; log.initialize(log_path, logSize + LOG_OFFSET_FROM_START + 1); printf("Metadata: dataSize=%zu, numEntries=%zu\n", log.getDataSize(), log.numEntries()); log_entry_t entry = EMPTY_LOG_ENTRY; for (size_t i = 0; i < log.numEntries(); i++) { if (log.isEndOfLog()) { printf("Error reading log file. numEntries: %zu, entriesRead: %zu\n", log.numEntries(), i); exit(1); } entry = log.getCurrentEntry(); printEntry(i, &entry); log.advanceToNextEntry(); } }
void ICACHE_FLASH_ATTR printAll(void) { int idx; for (idx = 0; idx < MAX_ENTRY; idx++) { printEntry(idx); } }
int main(int argc, char *argv[]) { struct Device *hd; struct Volume *vol; struct File *file; unsigned char buf[600]; long n; FILE *out; long len; struct List *list; adfEnvInitDefault(); /* create and mount one device */ hd = adfCreateDumpDevice("newdev", 80, 11, 2); if (!hd) { fprintf(stderr, "can't mount device\n"); adfEnvCleanUp(); exit(1); } adfCreateFlop( hd, "empty", FSMASK_FFS|FSMASK_DIRCACHE ); vol = adfMount(hd, 0, FALSE); if (!vol) { adfUnMountDev(hd); fprintf(stderr, "can't mount volume\n"); adfEnvCleanUp(); exit(1); } adfVolumeInfo(vol); /* the directory */ list = adfGetDirEnt(vol,vol->curDirPtr); while(list) { printEntry(list->content); adfFreeEntry(list->content); list = list->next; } freeList(list); /* write one file */ file = adfOpenFile(vol, "moon_gif","w"); if (!file) return 1; out = fopen("Check/MOON.GIF","rb"); if (!out) return 1; len = 600; n = fread(buf,sizeof(unsigned char),len,out); while(!feof(out)) { adfWriteFile(file, n, buf); n = fread(buf,sizeof(unsigned char),len,out); } if (n>0) adfWriteFile(file, n, buf); fclose(out); adfCloseFile(file); /* the directory */ list = adfGetDirEnt(vol,vol->curDirPtr); while(list) { printEntry(list->content); adfFreeEntry(list->content); list = list->next; } freeList(list); adfUnMount(vol); adfUnMountDev(hd); adfEnvCleanUp(); return 0; }
int main(int argc, char *argv[]) { struct Device *hd; struct Volume *vol; struct List *list, *cell; BOOL boolPr; adfEnvInitDefault(); // adfSetEnvFct(0,0,MyVer,0); /* mount existing device */ hd = adfMountDev( argv[1],FALSE ); if (!hd) { fprintf(stderr, "can't mount device\n"); adfEnvCleanUp(); exit(1); } vol = adfMount(hd, 0, FALSE); if (!vol) { adfUnMountDev(hd); fprintf(stderr, "can't mount volume\n"); adfEnvCleanUp(); exit(1); } adfVolumeInfo(vol); cell = list = adfGetDirEnt(vol,vol->curDirPtr); while(cell) { printEntry(cell->content); cell = cell->next; } adfFreeDirList(list); putchar('\n'); /* not empty */ adfRemoveEntry(vol, vol->curDirPtr, "dir_2"); /* cd dir_2 */ boolPr = TRUE; adfChgEnvProp(PR_USEDIRC, (void*)&boolPr); cell = list = adfGetDirEnt(vol,vol->curDirPtr); while(cell) { printEntry(cell->content); cell = cell->next; } adfFreeDirList(list); putchar('\n'); adfUnMount(vol); adfUnMountDev(hd); adfEnvCleanUp(); return 0; }
int main(int argc, char *argv[]) { struct Device *hd; struct Volume *vol; struct File *fic; unsigned char buf[1]; struct List *list, *cell; struct GenBlock *block; BOOL true = TRUE; adfEnvInitDefault(); adfChgEnvProp(PR_USEDIRC,&true); /* display or not the physical / logical blocks and W or R */ adfChgEnvProp(PR_USE_RWACCESS,&true); /* create and mount one device */ hd = adfCreateDumpDevice("newdev", 80, 2, 11); if (!hd) { fprintf(stderr, "can't mount device\n"); adfEnvCleanUp(); exit(1); } adfDeviceInfo(hd); if (adfCreateFlop( hd, "empty", FSMASK_FFS|FSMASK_DIRCACHE )!=RC_OK) { fprintf(stderr, "can't create floppy\n"); adfUnMountDev(hd); adfEnvCleanUp(); exit(1); } vol = adfMount(hd, 0, FALSE); if (!vol) { adfUnMountDev(hd); fprintf(stderr, "can't mount volume\n"); adfEnvCleanUp(); exit(1); } fic = adfOpenFile(vol, "file_1a","w"); if (!fic) { adfUnMount(vol); adfUnMountDev(hd); adfEnvCleanUp(); exit(1); } adfWriteFile(fic,1,buf); adfCloseFile(fic); puts("\ncreate file_1a"); adfVolumeInfo(vol); adfCreateDir(vol,vol->curDirPtr,"dir_5u"); puts("\ncreate dir_5u"); adfVolumeInfo(vol); cell = list = adfGetDirEnt(vol, vol->curDirPtr); while(cell) { printEntry(cell->content); cell = cell->next; } adfFreeDirList(list); puts("\nremove file_1a"); adfRemoveEntry(vol,vol->curDirPtr,"file_1a"); adfVolumeInfo(vol); adfRemoveEntry(vol,vol->curDirPtr,"dir_5u"); puts("\nremove dir_5u"); adfVolumeInfo(vol); cell = list = adfGetDelEnt(vol); while(cell) { block =(struct GenBlock*) cell->content; printf("%s %d %d %ld\n",block->name,block->type,block->secType, block->sect); cell = cell->next; } adfFreeDelList(list); adfUndelEntry(vol,vol->curDirPtr,883); // file_1a puts("\nundel file_1a"); adfVolumeInfo(vol); adfUndelEntry(vol,vol->curDirPtr,885); // dir_5u puts("\nundel dir_5u"); adfVolumeInfo(vol); cell = list = adfGetDirEnt(vol, vol->curDirPtr); while(cell) { printEntry(cell->content); cell = cell->next; } adfFreeDirList(list); adfUnMount(vol); adfUnMountDev(hd); adfEnvCleanUp(); return 0; }
int main(int argc, char *argv[]) { struct Device *hd; struct Volume *vol; struct File *file; unsigned char buf[600]; long n; FILE *out; long len; struct List *list; adfEnvInitDefault(); // adfSetEnvFct(0,0,MyVer,0); /* mount existing device : OFS */ hd = adfMountDev( argv[1],FALSE ); vol = adfMount(hd, 0, FALSE); adfVolumeInfo(vol); /* write one file */ file = adfOpenFile(vol, "moon_gif","w"); if (!file) return 1; out = fopen( argv[2],"rb"); if (!out) return 1; len = 600; n = fread(buf,sizeof(unsigned char),len,out); while(!feof(out)) { adfWriteFile(file, n, buf); n = fread(buf,sizeof(unsigned char),len,out); } if (n>0) adfWriteFile(file, n, buf); fclose(out); adfCloseFile(file); /* the directory */ list = adfGetDirEnt(vol,vol->curDirPtr); while(list) { printEntry(list->content); adfFreeEntry(list->content); list = list->next; } freeList(list); /* re read this file */ file = adfOpenFile(vol, "moon_gif","r"); if (!file) return 1; out = fopen("moon__gif","wb"); if (!out) return 1; len = 300; n = adfReadFile(file, len, buf); while(!adfEndOfFile(file)) { fwrite(buf,sizeof(unsigned char),n,out); n = adfReadFile(file, len, buf); } if (n>0) fwrite(buf,sizeof(unsigned char),n,out); fclose(out); adfCloseFile(file); adfUnMount(vol); adfUnMountDev(hd); adfEnvCleanUp(); return 0; }
bool Settings::updateConfigObject(std::istream &is, std::ostream &os, const std::string &end, u32 tab_depth) { std::map<std::string, SettingsEntry>::const_iterator it; std::set<std::string> present_entries; std::string line, name, value; bool was_modified = false; bool end_found = false; // Add any settings that exist in the config file with the current value // in the object if existing while (is.good() && !end_found) { std::getline(is, line); SettingsParseEvent event = parseConfigObject(line, end, name, value); switch (event) { case SPE_END: os << line << (is.eof() ? "" : "\n"); end_found = true; break; case SPE_MULTILINE: value = getMultiline(is); /* FALLTHROUGH */ case SPE_KVPAIR: it = m_settings.find(name); if (it != m_settings.end() && (it->second.is_group || it->second.value != value)) { printEntry(os, name, it->second, tab_depth); was_modified = true; } else { os << line << "\n"; if (event == SPE_MULTILINE) os << value << "\n\"\"\"\n"; } present_entries.insert(name); break; case SPE_GROUP: it = m_settings.find(name); if (it != m_settings.end() && it->second.is_group) { os << line << "\n"; sanity_check(it->second.group != NULL); was_modified |= it->second.group->updateConfigObject(is, os, "}", tab_depth + 1); } else { printEntry(os, name, it->second, tab_depth); was_modified = true; } present_entries.insert(name); break; default: os << line << (is.eof() ? "" : "\n"); break; } } // Add any settings in the object that don't exist in the config file yet for (it = m_settings.begin(); it != m_settings.end(); ++it) { if (present_entries.find(it->first) != present_entries.end()) continue; printEntry(os, it->first, it->second, tab_depth); was_modified = true; } return was_modified; }
int main(int argc, char *argv[]) { struct Device *hd; struct Volume *vol; struct List *list, *cell; SECTNUM nSect; adfEnvInitDefault(); // adfSetEnvFct(0,0,MyVer,0); /* mount existing device */ /* testffs.adf */ hd = adfMountDev( argv[1],FALSE ); if (!hd) { fprintf(stderr, "can't mount device\n"); adfEnvCleanUp(); exit(1); } vol = adfMount(hd, 0, FALSE); if (!vol) { adfUnMountDev(hd); fprintf(stderr, "can't mount volume\n"); adfEnvCleanUp(); exit(1); } adfVolumeInfo(vol); cell = list = adfGetDirEnt(vol,vol->curDirPtr); while(cell) { printEntry(cell->content); cell = cell->next; } adfFreeDirList(list); putchar('\n'); /* cd dir_2 */ nSect = adfChangeDir(vol, "dir_2"); cell = list = adfGetDirEnt(vol,vol->curDirPtr); while(cell) { printEntry(cell->content); cell = cell->next; } adfFreeDirList(list); putchar('\n'); /* cd .. */ adfParentDir(vol); list = adfGetDirEnt(vol,vol->curDirPtr); while(list) { printEntry(list->content); adfFreeEntry(list->content); list = list->next; } freeList(list); adfUnMount(vol); adfUnMountDev(hd); adfEnvCleanUp(); return 0; }
/*=export_func optionSaveFile * * what: saves the option state to a file * * arg: tOptions*, pOpts, program options descriptor * * doc: * * This routine will save the state of option processing to a file. The name * of that file can be specified with the argument to the @code{--save-opts} * option, or by appending the @code{rcfile} attribute to the last * @code{homerc} attribute. If no @code{rcfile} attribute was specified, it * will default to @code{.@i{programname}rc}. If you wish to specify another * file, you should invoke the @code{SET_OPT_SAVE_OPTS( @i{filename} )} macro. * * The recommend usage is as follows: * @example * optionProcess(&progOptions, argc, argv); * if (i_want_a_non_standard_place_for_this) * SET_OPT_SAVE_OPTS("myfilename"); * optionSaveFile(&progOptions); * @end example * * err: * * If no @code{homerc} file was specified, this routine will silently return * and do nothing. If the output file cannot be created or updated, a message * will be printed to @code{stderr} and the routine will return. =*/ void optionSaveFile( tOptions* pOpts ) { tOptDesc* pOD; int ct; FILE* fp = openSaveFile(pOpts); if (fp == NULL) return; /* * FOR each of the defined options, ... */ ct = pOpts->presetOptCt; pOD = pOpts->pOptDesc; do { tOptDesc* p; /* * IF the option has not been defined * OR it does not take an initialization value * OR it is equivalenced to another option * THEN continue (ignore it) * * Equivalenced options get picked up when the equivalenced-to * option is processed. */ if (UNUSED_OPT( pOD )) continue; if ((pOD->fOptState & OPTST_DO_NOT_SAVE_MASK) != 0) continue; if ( (pOD->optEquivIndex != NO_EQUIVALENT) && (pOD->optEquivIndex != pOD->optIndex)) continue; /* * The option argument data are found at the equivalenced-to option, * but the actual option argument type comes from the original * option descriptor. Be careful! */ p = ((pOD->fOptState & OPTST_EQUIVALENCE) != 0) ? (pOpts->pOptDesc + pOD->optActualIndex) : pOD; switch (OPTST_GET_ARGTYPE(pOD->fOptState)) { case OPARG_TYPE_NONE: printNoArgOpt(fp, p, pOD); break; case OPARG_TYPE_NUMERIC: printEntry( fp, p, (void*)(p->optArg.argInt)); break; case OPARG_TYPE_STRING: printStringArg(fp, p); break; case OPARG_TYPE_ENUMERATION: printEnumArg(fp, p); break; case OPARG_TYPE_MEMBERSHIP: printSetMemberArg(fp, p); break; case OPARG_TYPE_BOOLEAN: printEntry( fp, p, p->optArg.argBool ? "true" : "false" ); break; case OPARG_TYPE_HIERARCHY: printHierarchy(fp, p); break; case OPARG_TYPE_FILE: printFileArg(fp, p, pOpts); break; default: break; /* cannot handle - skip it */ } } while ( (pOD++), (--ct > 0)); fclose( fp ); }
int main(int argc, char *argv[]) { struct Device *hd; struct Volume *vol; struct List *list; SECTNUM nSect; adfEnvInitDefault(); /* mount existing device */ hd = adfMountDev( argv[1], FALSE ); if (!hd) { fprintf(stderr, "can't mount device\n"); adfEnvCleanUp(); exit(1); } vol = adfMount(hd, 0, FALSE); if (!vol) { adfUnMountDev(hd); fprintf(stderr, "can't mount volume\n"); adfEnvCleanUp(); exit(1); } adfVolumeInfo(vol); list = adfGetDirEnt(vol,vol->curDirPtr); while(list) { printEntry(list->content); adfFreeEntry(list->content); list = list->next; } freeList(list); putchar('\n'); adfCreateDir(vol,vol->curDirPtr,"newdir"); /* cd dir_2 */ nSect = adfChangeDir(vol, "same_hash"); list = adfGetDirEnt(vol,vol->curDirPtr); while(list) { printEntry(list->content); adfFreeEntry(list->content); list = list->next; } freeList(list); putchar('\n'); /* not empty */ adfRemoveEntry(vol, vol->curDirPtr, "mon.paradox"); /* first in same hash linked list */ adfRemoveEntry(vol, vol->curDirPtr, "file_3a"); /* second */ adfRemoveEntry(vol, vol->curDirPtr, "dir_3"); /* last */ adfRemoveEntry(vol, vol->curDirPtr, "dir_1a"); list = adfGetDirEnt(vol,vol->curDirPtr); while(list) { printEntry(list->content); adfFreeEntry(list->content); list = list->next; } freeList(list); putchar('\n'); adfParentDir(vol); adfRemoveEntry(vol, vol->curDirPtr, "mod.And.DistantCall"); list = adfGetDirEnt(vol,vol->curDirPtr); while(list) { printEntry(list->content); adfFreeEntry(list->content); list = list->next; } freeList(list); putchar('\n'); adfVolumeInfo(vol); adfUnMount(vol); adfUnMountDev(hd); adfEnvCleanUp(); return 0; }
void TfdAnomalyDetector::calculateExpectationMaximation() { float subspace[OD_PAIRS*4]; // vector containing the principal component (subspace) float normal[OD_PAIRS*4]; // vector for normal variation float abnormal[OD_PAIRS*4]; // vector for abnormal variation (anomalous) float t[OD_PAIRS*4]; // temp vector float row[OD_PAIRS*4]; float t_abs_last = 0.0; float anom_val; // anomaly value float x_1, x_2, x_3; // temp variables for projection: // init vectors for (int i=0; i<(OD_PAIRS*4); i++) { subspace[i] = 1.0; // random normal[i] = 0.0; abnormal[i] = 0.0; } // ********************** // Calculate Subspace // ********************** for (int iter=0; iter < 10; iter++) { // max. number of iterations needed for value to convergate float xp_temp = 0.0; // row of singleWayMatrix x * randomVector subspace float t_abs = 0.0; for (int i=0; i<(OD_PAIRS*4); i++) { // init p and t t[i] = 0.0; // zero } // for each row x in singleWayMatrix for (int n=0; n<TIMEBINS; n++) { // (x * p) for(int i=0; i < (OD_PAIRS*4); i++) { xp_temp += singleWayMatrix[n][i] * subspace[i]; } // (x * p) * x for(int i=0; i < (OD_PAIRS*4); i++) { row[i] = singleWayMatrix[n][i] * xp_temp; } xp_temp = 0.0; // t + (x * p) * x for(int i=0; i < (OD_PAIRS*4); i++) { t[i] += row[i]; } } // end for each row x in singleWayMatrix // |t| for(int i=0; i < (OD_PAIRS*4); i++) { t_abs += t[i]*t[i]; } t_abs = sqrt(t_abs); // p = t / |t| for(int i=0; i < (OD_PAIRS*4); i++) { subspace[i] = t[i] / t_abs; } if ((t_abs - t_abs_last) == 0) { break; } t_abs_last = t_abs; } // end of subspace calculation // ********************************************* // Project data on subspace and detect anomaly // ********************************************* // for each timebin for (int i=0; i<TIMEBINS; i++) { x_1 = 0.0; x_2 = 0.0; x_3 = 0.0; anom_val = 0.0; // project data onto subspace for(int j=0; j < (OD_PAIRS*4); j++) { x_1 += subspace[j] * singleWayMatrix[i][j]; // subspace * data_line x_2 += subspace[j] * subspace[j]; // |subspace|_2 } x_3 = x_1/x_2; for(int j=0; j < (OD_PAIRS*4); j++) { normal[j] = x_3 * subspace[j]; // get abnormal vector: data_line = normal + abnormal abnormal[j] = singleWayMatrix[i][j] - normal[j]; anom_val += abnormal[j] * abnormal[j]; // squared norm of abnormal vector } // detect anomaly if (anom_val > tfdThreshold) { // error within timebin detected printEntry(); } } // end: for each timebin }
int main(int argc, char *argv[]) { struct Device *hd; struct Volume *vol; struct File *file; unsigned char buf[600]; long n; FILE *in; long len; struct List *list; adfEnvInitDefault(); // adfSetEnvFct(0,0,MyVer,0); /* mount existing device : FFS */ hd = adfMountDev( "testffs.bak",FALSE ); if (!hd) { fprintf(stderr, "can't mount device\n"); adfEnvCleanUp(); exit(1); } vol = adfMount(hd, 0, FALSE); if (!vol) { adfUnMountDev(hd); fprintf(stderr, "can't mount volume\n"); adfEnvCleanUp(); exit(1); } adfVolumeInfo(vol); list = adfGetDirEnt(vol, vol->curDirPtr); while(list) { printEntry(list->content); adfFreeEntry(list->content); list = list->next; } freeList(list); // adfCreateDir(vol,vol->curDirPtr,"dir_1a"); adfCreateDir(vol,vol->curDirPtr,"dir_1b"); file = adfOpenFile(vol, "newfile","w"); adfCloseFile(file); file = adfOpenFile(vol, "moon_gif","w"); if (!file) return 1; in = fopen("Check/MOON.GIF","rb"); if (!in) return 1; len = 600; n = fread(buf,sizeof(unsigned char),len,in); while(!feof(in)) { adfWriteFile(file, n, buf); n = fread(buf,sizeof(unsigned char),len,in); } if (n>0) adfWriteFile(file, n, buf); // adfFlushFile(file); adfCloseFile(file); fclose(in); adfRemoveEntry(vol,vol->curDirPtr, "dir_1b"); list = adfGetDirEnt(vol, vol->curDirPtr); while(list) { printEntry(list->content); adfFreeEntry(list->content); list = list->next; } freeList(list); adfUnMount(vol); adfUnMountDev(hd); adfEnvCleanUp(); return 0; }
/*=export_func optionSaveFile * * what: saves the option state to a file * * arg: tOptions*, pOpts, program options descriptor * * doc: * * This routine will save the state of option processing to a file. The name * of that file can be specified with the argument to the @code{--save-opts} * option, or by appending the @code{rcfile} attribute to the last * @code{homerc} attribute. If no @code{rcfile} attribute was specified, it * will default to @code{.@i{programname}rc}. If you wish to specify another * file, you should invoke the @code{SET_OPT_SAVE_OPTS( @i{filename} )} macro. * * err: * * If no @code{homerc} file was specified, this routine will silently return * and do nothing. If the output file cannot be created or updated, a message * will be printed to @code{stderr} and the routine will return. =*/ void optionSaveFile( tOptions* pOpts ) { tOptDesc* pOD; int ct; FILE* fp; { int free_name = 0; tCC* pzFName = findFileName( pOpts, &free_name ); if (pzFName == NULL) return; fp = fopen( pzFName, "w" FOPEN_BINARY_FLAG ); if (fp == NULL) { fprintf( stderr, zWarn, pOpts->pzProgName ); fprintf( stderr, zNoCreat, errno, strerror( errno ), pzFName ); if (free_name) AGFREE((void*) pzFName ); return; } if (free_name) AGFREE( (void*)pzFName ); } { char const* pz = pOpts->pzUsageTitle; fputs( "# ", fp ); do { fputc( *pz, fp ); } while (*(pz++) != '\n'); } { time_t timeVal = time( NULL ); char* pzTime = ctime( &timeVal ); fprintf( fp, zPresetFile, pzTime ); #ifdef HAVE_ALLOCATED_CTIME /* * The return values for ctime(), localtime(), and gmtime() * normally point to static data that is overwritten by each call. * The test to detect allocated ctime, so we leak the memory. */ AGFREE( (void*)pzTime ); #endif } /* * FOR each of the defined options, ... */ ct = pOpts->presetOptCt; pOD = pOpts->pOptDesc; do { int arg_state; tOptDesc* p; /* * IF the option has not been defined * OR it does not take an initialization value * OR it is equivalenced to another option * THEN continue (ignore it) */ if (UNUSED_OPT( pOD )) continue; if ((pOD->fOptState & (OPTST_NO_INIT|OPTST_DOCUMENT|OPTST_OMITTED)) != 0) continue; if ( (pOD->optEquivIndex != NO_EQUIVALENT) && (pOD->optEquivIndex != pOD->optIndex)) continue; /* * Set a temporary pointer to the real option description * (i.e. account for equivalencing) */ p = ((pOD->fOptState & OPTST_EQUIVALENCE) != 0) ? (pOpts->pOptDesc + pOD->optActualIndex) : pOD; /* * IF no arguments are allowed * THEN just print the name and continue */ if (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_NONE) { char const * pznm = (DISABLED_OPT( p )) ? p->pz_DisableName : p->pz_Name; /* * If the option was disabled and the disablement name is NULL, * then the disablement was caused by aliasing. * Use the name as the string to emit. */ if (pznm == NULL) pznm = p->pz_Name; fprintf(fp, "%s\n", pznm); continue; } arg_state = OPTST_GET_ARGTYPE(p->fOptState); switch (arg_state) { case 0: case OPARG_TYPE_NUMERIC: printEntry( fp, p, (void*)(p->optArg.argInt)); break; case OPARG_TYPE_STRING: if (p->fOptState & OPTST_STACKED) { tArgList* pAL = (tArgList*)p->optCookie; int uct = pAL->useCt; tCC** ppz = pAL->apzArgs; /* * Disallow multiple copies of disabled options. */ if (uct > 1) p->fOptState &= ~OPTST_DISABLED; while (uct-- > 0) printEntry( fp, p, *(ppz++) ); } else { printEntry( fp, p, p->optArg.argString ); } break; case OPARG_TYPE_ENUMERATION: case OPARG_TYPE_MEMBERSHIP: { uintptr_t val = p->optArg.argEnum; /* * This is a magic incantation that will convert the * bit flag values back into a string suitable for printing. */ (*(p->pOptProc))( (tOptions*)2UL, p ); printEntry( fp, p, (void*)(p->optArg.argString)); if ( (p->optArg.argString != NULL) && (arg_state != OPARG_TYPE_ENUMERATION)) { /* * set membership strings get allocated */ AGFREE( (void*)p->optArg.argString ); p->fOptState &= ~OPTST_ALLOC_ARG; } p->optArg.argEnum = val; break; } case OPARG_TYPE_BOOLEAN: printEntry( fp, p, p->optArg.argBool ? "true" : "false" ); break; default: break; /* cannot handle - skip it */ } } while ( (pOD++), (--ct > 0)); fclose( fp ); }