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