6 #define cio_set_log_filename cio_set_log_filename_
7 #define cio_prints cio_prints_
8 #define cio_printf cio_printf_
9 #define cio_printi cio_printi_
11 #ifdef _DOUBLEUNDERSCORE
12 #define cio_set_log_filename cio_set_log_filename__
13 #define cio_prints cio_prints__
14 #define cio_printf cio_printf__
15 #define cio_printi cio_printi__
18 char * logfilename
= 0;
21 void cio_set_log_filename(char * s
, int * n
)
23 /* Allow changes to the log filename so long as
24 * we haven't actually opened the file (and written
27 if (!cio_out
&& logfilename
)
35 logfilename
= (char *)malloc(*n
+1);
36 strncpy(logfilename
, s
, *n
);
37 logfilename
[*n
] = '\0';
41 void cio_printf(int * fd
, float * f
)
43 if (!logfilename
) return;
47 if (!cio_out
) cio_out
= fopen(logfilename
,"w");
48 fprintf(cio_out
, "%f", *f
);
53 fprintf(stdout
, "%f", *f
);
58 void cio_printi(int * fd
, int * i
)
60 if (!logfilename
) return;
64 if (!cio_out
) cio_out
= fopen(logfilename
,"w");
65 fprintf(cio_out
, "%i", *i
);
70 fprintf(stdout
, "%i", *i
);
75 void cio_prints(int * fd
, char * s
, int * n
)
77 if (!logfilename
) return;
82 if (!cio_out
) cio_out
= fopen(logfilename
,"w");
83 fprintf(cio_out
, "%s", s
);
89 fprintf(stdout
, "%s", s
);