File: sauter_test.C

package info (click to toggle)
cbflib 0.9.7%2Bdfsg1-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 65,272 kB
  • sloc: ansic: 131,361; python: 22,780; sh: 3,108; makefile: 2,088; yacc: 659; java: 223; f90: 214; xml: 210; cpp: 58
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);
  }
}