00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <stdlib.h>
00024 #include <stdio.h>
00025 #include <time.h>
00026 #include <ctype.h>
00027 #include <math.h>
00028 #include <errno.h>
00029 #include <unistd.h>
00030 #include <string.h>
00031 #include <sys/types.h>
00032 #include <sys/stat.h>
00033 #include <fcntl.h>
00034 #include <dirent.h>
00035 #include <signal.h>
00036 #include <unistd.h>
00037 #include <sys/time.h>
00038 #include <sys/resource.h>
00039
00040 #include "common.h"
00041
00042
00043 char *MaskToList(int64_t mask)
00044 {
00045 static char list[128];
00046 int i;
00047 list[0]=0;
00048 for (i=0; i<64; i++)
00049 {
00050 if (mask&(1LL<<i))
00051 {
00052 sprintf(list+strlen(list),"%s%d",
00053 strlen(list)?",":"",
00054 i);
00055 }
00056 }
00057 return(list);
00058 }
00059
00060
00064 int DumpTriggerEvents(char *file)
00065 {
00066 FILE *f;
00067 char type[32],line[255];
00068 int trigger, end;
00069 int mask;
00070
00071 printf("#mode\tdate and time \t[channel|end]\n");
00072 f=fopen(file,"rt");
00073 if (f!=NULL)
00074 {
00075
00076 while (fgets(line,254,f)!=NULL)
00077 {
00078 sscanf(line,"%s %d",type,&trigger);
00079 if (strcmp(type,"stalta")==0)
00080 {
00081 sscanf(line,"%*s %*d %d",&mask);
00082 printf("%-6s\t%.19s\t%s\n",
00083 type,
00084 time2str((double)trigger),
00085 MaskToList(mask));
00086 }
00087 if (strcmp(type,"extern")==0)
00088 {
00089 printf("%-6s\t%.19s\n",
00090 type,
00091 time2str((double)trigger));
00092 }
00093 if (strcmp(type,"window")==0)
00094 {
00095 sscanf(line,"%*s %*d %d",&end);
00096 printf("%-6s\t%.19s\t",
00097 type,
00098 time2str((double)trigger));
00099 printf("%.19s\n",time2str((double)end));
00100 }
00101 if (strcmp(type,"custom")==0)
00102 {
00103 printf("%-6s\t%.19s\n",
00104 type,
00105 time2str((double)trigger));
00106 }
00107 if (strcmp(type,"end")==0)
00108 {
00109 printf("%-6s\t%.19s\n",
00110 type,
00111 time2str((double)trigger));
00112 }
00113 }
00114 }
00115
00116 else
00117 {
00118 PrintError("could not open %s: %m\n",file);
00119 }
00120 return(0);
00121 }