ARA ROOT v3.9 Software

utilities/Atri/fileWriterUtil.h

00001 /* 
00002    Utility functions, mostly file I/O and file handling
00003 
00004    M2 Consulting, July 2010
00005    ped@m2-consult.com
00006 */
00007 
00008 #ifndef ARA_UTIL_H
00009 #define ARA_UTIL_H
00010 
00011 #include "araAtriStructures.h"
00012 #include <stdio.h>
00013 #include <syslog.h>
00014 #include <stdint.h>
00015 #include <zlib.h>
00016 #include <sys/time.h>
00017 
00018 typedef struct {
00019   gzFile         currentFilePtr;
00020   int            maxEvents;  // Number of events per file
00021   int            maxFiles;   // Number of files per subdir
00022   int            writeCount; // Events written to current file
00023   int            fileCount;  // Files written to current subdir
00024   int            dirCount;   // Subdirs written to current dir
00025   char           compressionLevel[10]; 
00026   char           filePrefix[FILENAME_MAX];
00027   char           currentFileName[FILENAME_MAX];
00028   char           currentDirName[FILENAME_MAX];
00029   char           currentSubDirName[FILENAME_MAX];
00030   const char*    linkDir;
00031   int            currentRunNumber;
00032   struct timeval startTime;
00033 } ARAWriterStruct_t;
00034 
00035 void initWriter(ARAWriterStruct_t* writer, 
00036                 int runNumber,
00037                 int compression, 
00038                 int maxFiles, int maxEvents, const char* filePrefix,
00039                 const char* topDir, const char* linkDir);
00040 
00041 void closeWriter(ARAWriterStruct_t* writer);
00042 int newWriterFile(ARAWriterStruct_t* writer);
00043 int newWriterSubDir(ARAWriterStruct_t* writer);
00044 int writeBuffer(ARAWriterStruct_t* writer, char* buffer, int len, int *new_file_flag );
00045 
00046 int makeDirectories(const char *theTmpDir);
00047 int is_dir(const char *path);
00048 int makeLink(const char *theFile, const char *theLinkDir);
00049 int moveFile(const char *theFile, const char *theDir);
00050 int copyFile(const char *theFile, const char *theDir);
00051 int copyFileToFile(const char *theFile, const char *newFile);
00052 char *readFile(const char *theFile, unsigned int *numBytes);
00053 int removeFile(const char *theFile);
00054 
00055 int checkPidFile(const char *fileName);
00056 int writePidFile(const char *fileName);
00057 void sigUsr1Handler(int sig);
00058 void sigUsr2Handler(int sig);
00059 
00060 void setNextTime(struct timeval* nextTime, const struct timeval* lastTime, 
00061                  const struct timeval* timeInterval );
00062 void setTimeInterval(struct timeval* timeInterval, double step);
00063 void getFileStartTime( ARAWriterStruct_t* writer , unsigned int *second , unsigned int *usec );
00064 
00065 uint32_t getRunNumber();
00066 
00067 //Generic Header Stuff
00068 void fillGenericHeader(void *thePtr, AraDataStructureType_t type, unsigned int numBytes);
00069 int checkPacket(void *thePtr);
00070 unsigned int simpleIntCrc(unsigned int *p, unsigned int n);
00071 const char *araDataTypeAsString(AraDataStructureType_t type);
00072 
00073 unsigned int grayToBinary(unsigned int gray);
00074 
00075 #endif // ARA_UTIL_H

Generated on Mon Jun 3 16:10:05 2013 for ARA ROOT v3.9 Software by doxygen 1.4.7