FireBirdLib - Topfield TMS PVR TAP Programming Library
LogEntryFBLibPrintf.c
Go to the documentation of this file.
1
#include <stdio.h>
2
#include <fcntl.h>
3
#include <sys/stat.h>
4
#include <string.h>
5
#include <stdarg.h>
6
#include <sys/types.h>
7
#include <utime.h>
8
#define FB_LOG_ENTRY_LIB_PRINTF
9
#include "
libFireBird.h
"
10
11
int
vsnprintf
(
char
*str,
size_t
size,
const
char
*format, va_list ap);
//define missing prototype
12
13
void
LogEntryFBLibPrintf
(
bool
Console,
char
*format, ...)
14
{
15
TRACEENTER
();
16
17
char
Text[512];
18
FILE
*File;
19
char
TimeResult[40];
20
byte
Sec;
21
char
CRLF[] = {
'\r'
,
'\n'
};
22
struct
utimbuf times;
23
24
#define FILENAME "/mnt/hd/ProgramFiles/Settings/FBLib.log"
25
26
if
(!format)
27
{
28
TRACEEXIT
();
29
return
;
30
}
31
32
va_list args;
33
va_start(args, format);
34
vsnprintf
(Text,
sizeof
(Text), format, args);
35
va_end(args);
36
37
mkdir(
"/mnt/hd/ProgramFiles/Settings"
, 0777);
38
39
TimeFormat
(
Now
(&Sec), Sec,
TIMESTAMP_YMDHMS
, TimeResult);
40
strcat(TimeResult,
" "
);
41
42
if
((File = fopen(
FILENAME
,
"r+"
)) != NULL)
43
{
44
fseek(File, 0,
SEEK_END
);
45
fwrite(TimeResult, strlen(TimeResult), 1, File);
46
fwrite(Text, strlen(Text), 1, File);
47
fwrite(CRLF, 2, 1, File);
48
fclose(File);
49
50
//As the log would receive the Linux time stamp (01.01.2000), adjust to the PVR's time
51
times.actime =
PvrTimeToLinux
(
Now
(NULL));
52
times.modtime = times.actime;
53
utime(
FILENAME
, ×);
54
}
55
56
if
(Console)
57
{
58
TAP_Print
(
"%s FBLIB - %s\n"
, TimeResult, Text);
59
}
60
61
TRACEEXIT
();
62
}
FILE
struct __STDIO_FILE_STRUCT FILE
Definition:
FBLib_hdd.h:137
LogEntryFBLibPrintf
void LogEntryFBLibPrintf(bool Console, char *format,...)
Definition:
LogEntryFBLibPrintf.c:13
vsnprintf
int vsnprintf(char *str, size_t size, const char *format, va_list ap)
FILENAME
#define FILENAME
PvrTimeToLinux
dword PvrTimeToLinux(dword PVRTime)
Definition:
PvrTimeToLinux.c:3
libFireBird.h
TAP_Print
#define TAP_Print
Definition:
libFireBird.h:181
TimeFormat
char * TimeFormat(dword DateTime, byte Sec, eTimeStampFormat TimeStampFormat, char *Result)
Definition:
TimeFormat.c:4
TRACEEXIT
#define TRACEEXIT()
Definition:
libFireBird.h:1244
TIMESTAMP_YMDHMS
@ TIMESTAMP_YMDHMS
Definition:
libFireBird.h:100
TRACEENTER
#define TRACEENTER()
Definition:
libFireBird.h:1243
SEEK_END
#define SEEK_END
Definition:
libFireBird.h:1883
Now
dword Now(byte *Sec)
Definition:
Now.c:3
debug
LogEntryFBLibPrintf.c
Generated on Fri Apr 29 2022 13:34:01 for FireBirdLib - Topfield TMS PVR TAP Programming Library by
1.9.3