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
5dword GetUptime(void)
6{
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}
struct __STDIO_FILE_STRUCT FILE
Definition: FBLib_hdd.h:137
dword GetUptime(void)
Definition: GetUptime.c:5
#define TRACEEXIT()
Definition: libFireBird.h:1244
#define TRACEENTER()
Definition: libFireBird.h:1243