FireBirdLib - Topfield TMS PVR TAP Programming Library
GetUptime.c
Go to the documentation of this file.
1
#include <stdio.h>
2
#include <locale.h>
3
#include "
libFireBird.h
"
4
5
dword
GetUptime
(
void
)
6
{
7
TRACEENTER
();
8
9
dword uptime = 0;
10
FILE
*fp;
11
double
upsecs;
12
13
fp = fopen(
"/proc/uptime"
,
"r"
);
14
if
(fp != NULL)
15
{
16
char
buf[BUFSIZ];
17
int
res;
18
char
*b;
19
20
b = fgets(buf, BUFSIZ, fp);
21
if
(b == buf)
22
{
23
/* The following sscanf must use the C locale. */
24
setlocale(LC_NUMERIC,
"C"
);
25
res = sscanf(buf,
"%lf"
, &upsecs);
26
setlocale(LC_NUMERIC,
""
);
27
if
(res == 1) uptime = (dword)(upsecs * 100);
28
}
29
fclose(fp);
30
}
31
32
TRACEEXIT
();
33
return
uptime;
34
}
FILE
struct __STDIO_FILE_STRUCT FILE
Definition:
FBLib_hdd.h:137
GetUptime
dword GetUptime(void)
Definition:
GetUptime.c:5
libFireBird.h
TRACEEXIT
#define TRACEEXIT()
Definition:
libFireBird.h:1244
TRACEENTER
#define TRACEENTER()
Definition:
libFireBird.h:1243
time
GetUptime.c
Generated on Fri Apr 29 2022 13:34:01 for FireBirdLib - Topfield TMS PVR TAP Programming Library by
1.9.3