37#include <lal/SFTReferenceLibrary.h>
45void modify_checksum(
const char *
filename,
unsigned long long newchecksumle,
unsigned long long newchecksumbe );
51 char *tmp = (
char * )&
i;
57 FILE *
fp = fopen(
name,
"w" );
60 perror(
"Unable to open file for writing" );
62 fprintf( stderr,
"Unable to open file %s for writing\n",
name );
71 fprintf( stderr,
"WriteSFT failed with return value %d\n",
err );
79 int returnval = system( command );
81 fprintf( stderr,
"Unable to execute the command: %s (exit status %d)\n", command, returnval );
90 fprintf( stderr,
"modify_byes() called with null pointer for new data!\n" );
95 perror(
"Unable to open file for writing" );
97 fprintf( stderr,
"Unable to open file %s for reading/writing\n",
filename );
100 if ( fseek(
fp, byte_offset, SEEK_SET ) ) {
102 perror(
"Failed fseek()" );
107 if ( 1 != fwrite( (
const void * )new_value, nbytes, 1,
fp ) ) {
109 perror(
"Failed fwrite()" );
137 float data[] = {1.0, 0.0, 2.0, -1.0, 3.0, -2.0, 4.0, -3.0};
156 dosystem(
"cat SFT-test[123] > SFT-good" );
158 dosystem(
"cat SFT-test[123] SFT-test3 > SFT-bad1" );
160 dosystem(
"cat SFT-test[124] > SFT-bad2" );
162 dosystem(
"cat SFT-test[125] > SFT-bad3" );
164 dosystem(
"cat SFT-test[126] > SFT-bad4" );
166 dosystem(
"cat SFT-test[127] > SFT-bad5" );
168 dosystem(
"cat SFT-test1 > SFT-bad6" );
171 dosystem(
"cat SFT-test1 > SFT-bad7" );
173 modify_checksum(
"SFT-bad7", 2594301065140926588ULL, 1040429337927860515ULL );
175 dosystem(
"cat SFT-test1 > SFT-bad8" );
177 modify_checksum(
"SFT-bad8", 9546122005026447583ULL, 12540893872916896128ULL );
182 modify_checksum(
"SFT-bad9", 8104828364422822013ULL, 6488197905334075682ULL );
185 dosystem(
"cat SFT-test1 > SFT-bad10" );
187 modify_checksum(
"SFT-bad10", 14553276594141125530ULL, 13919267759677155442ULL );
189 dosystem(
"cat SFT-test1 > SFT-bad11" );
191 modify_checksum(
"SFT-bad11", 9905878389211410491ULL, 12381252028459463649ULL );
194 dosystem(
"cat SFT-test1 > SFT-bad12" );
196 modify_checksum(
"SFT-bad12", 5605290681458522985ULL, 7307622666058252853ULL );
199 dosystem(
"cat SFT-test1 > SFT-bad13" );
201 modify_checksum(
"SFT-bad13", 14214363586458317283ULL, 6130423751169108856ULL );
204 dosystem(
"cat SFT-test1 > SFT-bad14" );
206 modify_checksum(
"SFT-bad14", 9944972421627148413ULL, 15720824585133081082ULL );
208 for (
size_t i = 0;
i < 8;
i += 2 ) {
211 for (
size_t i = 1;
i < 8;
i += 2 ) {
217 printf(
"Wrote good SFTs: SFT-test[12345678] SFT-good\n" );
218 printf(
"Wrote bad SFTs: SFT-bad[123456789] SFT-bad1[0-4]\n" );
void dosystem(const char *command)
void modify_checksum(const char *filename, unsigned long long newchecksumle, unsigned long long newchecksumbe)
void modify_bytes(const char *filename, int byte_offset, const char *new_value, int nbytes)
FILE * openfile(const char *name)
int WriteSFT(FILE *fp, int gps_sec, int gps_nsec, double tbase, int firstfreqindex, int nsamples, const char *detector, unsigned short windowspec, const char *comment, float *data)