Project

General

Profile

« Previous | Next » 

Revision f0a067e9

Added by Pierre-Loïc Garoche almost 3 years ago

Better production of trace files.
By default traces are not produced. Requires the option -t to produce them

View differences:

include/io_frontend.hpp
8 8
int ISATTY;
9 9

  
10 10
/* Standard Input procedures **************/
11
bool _get_bool(FILE* file, char* n){
11
bool _get_bool(char* n){
12 12
   char b[512];
13 13
   bool r = 0;
14 14
   int s = 1;
......
24 24
      if((c == '0') || (c == 'f') || (c == 'F')) r = 0;
25 25
      if((c == '1') || (c == 't') || (c == 'T')) r = 1;
26 26
   } while((s != 1) || (r == -1));
27
   fprintf(file, "%i\n",r);
28 27
   return r;
29 28
}
30 29

  
31
int _get_int(FILE* file, char* n){
30
int _get_int(char* n){
32 31
   char b[512];
33 32
   int r;
34 33
   int s = 1;
......
40 39
      if(scanf("%s", b)==EOF) exit(0);
41 40
      s = sscanf(b, "%d", &r);
42 41
   } while(s != 1);
43
   fprintf(file, "%d\n", r);
44 42
   return r;
45 43
}
46 44

  
47
double _get_double(FILE* file, char* n){
45
double _get_double(char* n){
48 46
   char b[512];
49 47
   double r;
50 48
   int s = 1;
......
56 54
      if(scanf("%s", b)==EOF) exit(0);
57 55
      s = sscanf(b, "%lf", &r);
58 56
   } while(s != 1);
59
   fprintf(file, "%f\n", r);
60 57
   return r;
61 58
}
62 59
/* Standard Output procedures **************/
63
void _put_bool(FILE* file, char* n, bool _V){
60
void _put_bool(char* n, bool _V){
64 61
  if(ISATTY) {
65 62
    printf("%s = ", n);
66 63
  } else {
67 64
    printf("'%s': ", n);
68 65
  };
69 66
  printf("'%i' ", (_V)? 1 : 0);
70
  printf("\n");
71
  fprintf(file, "%i\n", _V);
72 67
}
73
void _put_int(FILE* file, char* n, int _V){
68
void _put_int(char* n, int _V){
74 69
  if(ISATTY) {
75 70
    printf("%s = ", n);
76 71
  } else {
77 72
    printf("'%s': ", n);
78 73
  };
79 74
  printf("'%d' ", _V);
80
  printf("\n");
81
  fprintf(file, "%d\n", _V);
82 75
}
83 76

  
84
void _put_float(FILE* file, char* n, float _V, int PREC){
77
void _put_float(char* n, float _V, int PREC){
85 78
  if(ISATTY) {
86 79
    printf("%s = ", n);
87 80
  } else {
......
89 82
  };
90 83
  printf("'%.*f' ", PREC, _V);
91 84
  printf("\n");
92
  fprintf(file, "%.*f\n", PREC, _V);
93
  fflush(file);
94 85
}
95 86

  
96
void _put_double(FILE* file, char* n, double _V, int PREC){
87
void _put_double(char* n, double _V, int PREC){
97 88
  if(ISATTY) {
98 89
    printf("%s = ", n);
99 90
  } else {
......
101 92
  };
102 93
  printf("'%.*f' ", PREC, _V);
103 94
  printf("\n");
104
  fprintf(file, "%.*f\n", PREC, _V);
105
  fflush(file);
106 95
}
107 96

  
108 97

  

Also available in: Unified diff