#include <stdlib.h>#include <stdio.h>#include <time.h>#include <ctype.h>#include <math.h>#include <assert.h>#include <errno.h>#include <unistd.h>#include <string.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <stdarg.h>#include <dirent.h>#include "common.h"
Go to the source code of this file.
Functions | |
| void | ResetCacheCounters (void) |
| reset all the counters | |
| int | CacheFileSelect (const struct dirent *t) |
| filter for SN T1 T2 | |
| void | OpenCacheFileWrite (int wr) |
| Open the cache file. | |
| char * | CacheRead (char *line) |
| read a line in the cache file | |
| void | RewindCache (void) |
| rewind the cache file is open for read | |
| int | OpenCacheFileRead (char *SN, time_t t) |
| look for the cache file corresponding to the current data stream | |
| int | CompareCacheLines (const void *p1, const void *p2) |
| comparison method for qsort | |
| void | SortCacheFile (char *fn) |
| sort the cache file | |
| void | CloseCacheFile (int cancel) |
| Close the cache file, if open. | |
| void | CachePrint (const char *format,...) |
| print a formatted line in the cache file, open it if neccessary | |
| void | CachePrintCST (void) |
| issue a #CST message (continuous segment tag) | |
| void | CachePrintTIME (void) |
| issue a #TIME message | |
| void | CacheCallBack (void) |
| Build the cache for the current input. | |
| void | InitCache (void) |
| initialize the cache directory This function should cleanup the cache by removing the oldest files | |
Variables | |
| struct dirent ** | cacheFileList = NULL |
| FILE * | cacheFile = NULL |
| char | cacheFileName [128] |
| char | cacheDir [128] |
| time_t | lastCacheTime = 0 |
| int64_t | lastCacheOffset = 0 |
| int | cacheOutput = -1 |
| int | startCacheTime = 0 |
| char | testForSN [128] |
| time_t | testForTime |
| int | nTimesInCache = 0 |
| void CacheCallBack | ( | void | ) |
Build the cache for the current input.
Definition at line 508 of file cache.c.
References beginWindow, cacheOutput, CachePrintTIME(), currentTime, HWConfig, lastCacheOffset, lastCacheTime, noCache, OpenCacheFileRead(), HWConfigType::serialNumber, totalFrameProcessed, and Titan2TimeType::usecond.
Referenced by ProcessTimeFrame().
| int CacheFileSelect | ( | const struct dirent * | t | ) |
filter for SN T1 T2
Definition at line 74 of file cache.c.
References cacheDir, testForSN, and testForTime.
Referenced by OpenCacheFileRead().
| void CachePrint | ( | const char * | format, | |
| ... | ||||
| ) |
print a formatted line in the cache file, open it if neccessary
| format,... | the same format and arguments as for *printf |
Definition at line 454 of file cache.c.
References cacheFile, currentTime, noCache, OpenCacheFileWrite(), startCacheTime, and Titan2TimeType::usecond.
Referenced by CachePrintTIME().
| void CachePrintCST | ( | void | ) |
issue a #CST message (continuous segment tag)
Definition at line 478 of file cache.c.
References cacheOutput.
Referenced by EndSuperFrame(), and ProcessTimeFrame().
| void CachePrintTIME | ( | void | ) |
issue a #TIME message
Definition at line 489 of file cache.c.
References cacheFile, cacheOutput, CachePrint(), currentFile, currentTime, nTimesInCache, titan2File, and Titan2TimeType::usecond.
Referenced by CacheCallBack().
| char* CacheRead | ( | char * | line | ) |
read a line in the cache file
| line | the output char buffer |
Definition at line 180 of file cache.c.
References cacheFile, and cacheOutput.
Referenced by SeekTime().
| void CloseCacheFile | ( | int | cancel | ) |
Close the cache file, if open.
| cancel | juste close and unlink the cache file if 1 |
Definition at line 402 of file cache.c.
References cacheDir, cacheFile, cacheFileName, cacheOutput, currentTime, HWConfig, localCache, nTimesInCache, PrintDebug, Rename(), ResetCacheCounters(), HWConfigType::serialNumber, SortCacheFile(), startCacheTime, and Titan2TimeType::usecond.
Referenced by FlushNonDataFiles(), and MainCleanUp().
| int CompareCacheLines | ( | const void * | p1, | |
| const void * | p2 | |||
| ) |
comparison method for qsort
| p1 | first element | |
| p2 | second element |
Definition at line 305 of file cache.c.
Referenced by SortCacheFile().
| void InitCache | ( | void | ) |
initialize the cache directory This function should cleanup the cache by removing the oldest files
Definition at line 555 of file cache.c.
References cacheDir, noCache, OpenCacheFileWrite(), and PrintDebug.
Referenced by main().
| int OpenCacheFileRead | ( | char * | SN, | |
| time_t | t | |||
| ) |
look for the cache file corresponding to the current data stream
| SN | the serial number to look for | |
| t | the time to look for If SN is NULL and t is -2, then the cache is cleared |
Definition at line 205 of file cache.c.
References __alphasort(), __scandir(), cacheDir, cacheFile, cacheFileList, cacheFileName, CacheFileSelect(), cacheOutput, localCache, OpenCacheFileWrite(), PrintDebug, PrintLog, PrintWarning, testForSN, and testForTime.
Referenced by CacheCallBack(), ParseOptions(), and SeekTime().
| void OpenCacheFileWrite | ( | int | wr | ) |
Open the cache file.
| wr | do the job if 1 else just set and create cacheDir |
Definition at line 121 of file cache.c.
References baseDir, cacheDir, cacheFile, cacheFileName, cacheOutput, currentTime, localCache, nTimesInCache, OpenTempFile(), PrintDebug, startCacheTime, and Titan2TimeType::usecond.
Referenced by CachePrint(), InitCache(), and OpenCacheFileRead().
| void ResetCacheCounters | ( | void | ) |
reset all the counters
Definition at line 66 of file cache.c.
References cacheOutput, lastCacheOffset, and lastCacheTime.
Referenced by CloseCacheFile().
| void RewindCache | ( | void | ) |
rewind the cache file is open for read
Definition at line 190 of file cache.c.
References cacheFile, and cacheOutput.
Referenced by SeekTime().
| void SortCacheFile | ( | char * | fn | ) |
sort the cache file
| fn | the filename of the cache file to sort |
Definition at line 329 of file cache.c.
References CompareCacheLines(), and PrintDebug.
Referenced by CloseCacheFile().
| char cacheDir[128] |
Definition at line 50 of file cache.c.
Referenced by CacheFileSelect(), CloseCacheFile(), InitCache(), OpenCacheFileRead(), and OpenCacheFileWrite().
| FILE* cacheFile = NULL |
Definition at line 48 of file cache.c.
Referenced by CachePrint(), CachePrintTIME(), CacheRead(), CloseCacheFile(), OpenCacheFileRead(), OpenCacheFileWrite(), and RewindCache().
| struct dirent** cacheFileList = NULL |
| char cacheFileName[128] |
Definition at line 49 of file cache.c.
Referenced by CloseCacheFile(), OpenCacheFileRead(), and OpenCacheFileWrite().
| int cacheOutput = -1 |
Definition at line 56 of file cache.c.
Referenced by CacheCallBack(), CachePrintCST(), CachePrintTIME(), CacheRead(), CloseCacheFile(), OpenCacheFileRead(), OpenCacheFileWrite(), ResetCacheCounters(), and RewindCache().
| int64_t lastCacheOffset = 0 |
| time_t lastCacheTime = 0 |
| int nTimesInCache = 0 |
Definition at line 63 of file cache.c.
Referenced by CachePrintTIME(), CloseCacheFile(), and OpenCacheFileWrite().
| int startCacheTime = 0 |
Definition at line 58 of file cache.c.
Referenced by CachePrint(), CloseCacheFile(), and OpenCacheFileWrite().
| char testForSN[128] |
| time_t testForTime |
1.5.6