blob: 7ff58c7c9aa35f8f97651c02659f41a965566ec3 (
plain)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <assert.h>
#include "main.h"
typedef struct logFile_struct
{
char *name;
FILE *file;
} logFile_t;
logFile_t* newLogFile(char *s)
{
logFile_t *new;
assert( s != NULL );
new = malloc( sizeof(logFile_t) );
memset(new, 0, sizeof(logFile_t) );
new->name = strdup(s);
new->file = fopen(new->name, "a+");
assert( new->file != NULL );
return new;
}
int writeLog(logFile_t *p, char *s)
{
assert( p != NULL );
assert( s != NULL );
return fprintf(p->file, s);
}
void destroyLogFile(logFile_t *p)
{
assert( p != NULL );
free(p->name);
fclose(p->file);
free(p);
}
|