File: sauter_test.C

package info (click to toggle)
cbflib 0.9.6%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 56,196 kB
  • sloc: ansic: 103,920; python: 4,552; sh: 3,032; makefile: 1,822; yacc: 659; f90: 210; xml: 210; cpp: 58; java: 16
file content (33 lines) | stat: -rw-r--r-- 933 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "cbf.h"
#include "cbf_simple.h"
#include <cstdio>
#include <string>
#include <exception>
#include <iostream>

struct Error : public std::exception {
  std::string s;
  Error(std::string s):s(s){}
  virtual const char* what() const throw() {return s.c_str();}
  virtual ~Error() throw() {}
};

int main() {
  std::string file("adscconverted_flat.cbf");

  for (int cc=0; cc<20000; ++cc) {
    cbf_handle cbf_h;
    FILE* private_file = std::fopen(file.c_str(),"rb");
    if (!private_file) throw Error("cbf file BAD_OPEN");

    cbf_failnez ( cbf_make_handle (&cbf_h) )
    cbf_failnez ( cbf_read_file (cbf_h, private_file, MSG_DIGEST))
      //file handle must be left open & is closed by the cbf library.

    cbf_detector detector1;
    cbf_failnez ( cbf_construct_detector(cbf_h,&detector1,0) )
    cbf_failnez ( cbf_free_detector(detector1) )
    cbf_failnez ( cbf_free_handle (cbf_h))
    //fclose(private_file);
  }
}