Project

General

Profile

Revision 86ae18b7 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(FILE* file, char* n){
9
_Bool _get_bool(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);
26 25
   return r;
27 26
}
28

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

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

Also available in: Unified diff