blob: 12a4df873780e5fd61bc745a9e15d5650e33614a (
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
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <assert.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);
}
|