Trisurf Monte Carlo simulator
mihaf
2014-05-13 0f9d229fb830435d92cfc73c85aa7771a420286c
commit | author | age
d7639a 1 #include<stdio.h>
SP 2 #include<stdlib.h>
3 #include "general.h"
4 #include<stdarg.h>
5
1ab449 6 #include <sys/time.h>
SP 7 #include <unistd.h>
8 #include <time.h>
9
10
a10dd5 11 ts_uint ts_fprintf(FILE *fd, char *fmt, ...){
d7639a 12 if(quiet) return TS_SUCCESS;
1ab449 13     va_list ap;
SP 14     va_start(ap,fmt);
15     char tmbuf[255];
16     struct timeval now;
17       gettimeofday(&now, 0);
18     strftime(tmbuf, sizeof tmbuf, "%Y-%m-%d %H:%M:%S", localtime(&now.tv_sec));
19 fprintf(fd, "[%s] ",tmbuf); 
a10dd5 20 vfprintf(fd, fmt, ap); /* Call vfprintf */
d7639a 21 va_end(ap); /* Cleanup the va_list */
SP 22 return TS_SUCCESS;
23 }
24
25 void err(char *text){
26     ts_fprintf(stderr,"Err: %s\n", text);
27 }
28
29 void fatal(char *text, ts_int errcode){
30     ts_fprintf(stderr,"Fatal: %s. TERMINATED!\n", text);
31     exit(errcode);
32 }
33
34