Project

General

Profile

Revision 6fa45cb6 include/io_frontend.c

View differences:

include/io_frontend.c
6 6
int ISATTY;
7 7

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

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

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

Also available in: Unified diff