move FileTimeToTime from sigar_os.h to win32_sigar.c

This commit is contained in:
Doug MacEachern 2008-05-30 03:54:37 +00:00
parent 31dcf1bc48
commit 35a3672c31
3 changed files with 24 additions and 18 deletions

View File

@ -45,17 +45,6 @@
#define SIGAR_CMDLINE_MAX 4096 #define SIGAR_CMDLINE_MAX 4096
static __inline sigar_uint64_t FileTimeToTime(FILETIME *ft)
{
sigar_uint64_t time;
time = ft->dwHighDateTime;
time = time << 32;
time |= ft->dwLowDateTime;
time /= 10;
time -= EPOCH_DELTA;
return time;
}
/* XXX: support CP_UTF8 ? */ /* XXX: support CP_UTF8 ? */
#define SIGAR_A2W(lpa, lpw, bytes) \ #define SIGAR_A2W(lpa, lpw, bytes) \
@ -569,6 +558,8 @@ struct sigar_t {
extern "C" { extern "C" {
#endif #endif
sigar_uint64_t sigar_FileTimeToTime(FILETIME *ft);
int sigar_wsa_init(sigar_t *sigar); int sigar_wsa_init(sigar_t *sigar);
int sigar_proc_exe_peb_get(sigar_t *sigar, HANDLE proc, int sigar_proc_exe_peb_get(sigar_t *sigar, HANDLE proc,

View File

@ -122,6 +122,17 @@ typedef enum {
#define MS_LOOPBACK_ADAPTER "Microsoft Loopback Adapter" #define MS_LOOPBACK_ADAPTER "Microsoft Loopback Adapter"
#define NETIF_LA "la" #define NETIF_LA "la"
sigar_uint64_t sigar_FileTimeToTime(FILETIME *ft)
{
sigar_uint64_t time;
time = ft->dwHighDateTime;
time = time << 32;
time |= ft->dwLowDateTime;
time /= 10;
time -= EPOCH_DELTA;
return time;
}
static DWORD perfbuf_init(sigar_t *sigar) static DWORD perfbuf_init(sigar_t *sigar)
{ {
if (!sigar->perfbuf) { if (!sigar->perfbuf) {
@ -1244,7 +1255,8 @@ SIGAR_DECLARE(int) sigar_proc_time_get(sigar_t *sigar, sigar_pid_t pid,
} }
if (start_time.dwHighDateTime) { if (start_time.dwHighDateTime) {
proctime->start_time = FileTimeToTime(&start_time) / 1000; proctime->start_time =
sigar_FileTimeToTime(&start_time) / 1000;
} }
else { else {
proctime->start_time = 0; proctime->start_time = 0;
@ -3126,7 +3138,7 @@ static int get_logon_info(HKEY users,
if (status == ERROR_SUCCESS) { if (status == ERROR_SUCCESS) {
FileTimeToLocalFileTime(&wtime, &wtime); FileTimeToLocalFileTime(&wtime, &wtime);
who->time = FileTimeToTime(&wtime) / 1000000; who->time = sigar_FileTimeToTime(&wtime) / 1000000;
} }
size = sizeof(value); size = sizeof(value);
@ -3334,7 +3346,7 @@ static int sigar_who_wts(sigar_t *sigar,
&bytes)) &bytes))
{ {
who->time = who->time =
FileTimeToTime(&station_info.ConnectTime) / 1000000; sigar_FileTimeToTime(&station_info.ConnectTime) / 1000000;
} }
else { else {
who->time = 0; who->time = 0;

View File

@ -67,7 +67,10 @@
memset(s, '\0', sizeof(*(s))) memset(s, '\0', sizeof(*(s)))
#endif #endif
#ifndef WIN32 #ifdef WIN32
#include <windows.h>
sigar_uint64_t sigar_FileTimeToTime(FILETIME *ft);
#else
#include <string.h> #include <string.h>
#endif #endif
@ -192,9 +195,9 @@ static void fillin_fileattrs(sigar_file_attrs_t *finfo,
{ {
DWORD *sizes = &wininfo->nFileSizeHigh; DWORD *sizes = &wininfo->nFileSizeHigh;
finfo->atime = FileTimeToTime(&wininfo->ftLastAccessTime) / 1000; finfo->atime = sigar_FileTimeToTime(&wininfo->ftLastAccessTime) / 1000;
finfo->ctime = FileTimeToTime(&wininfo->ftCreationTime) / 1000; finfo->ctime = sigar_FileTimeToTime(&wininfo->ftCreationTime) / 1000;
finfo->mtime = FileTimeToTime(&wininfo->ftLastWriteTime) / 1000; finfo->mtime = sigar_FileTimeToTime(&wininfo->ftLastWriteTime) / 1000;
finfo->size = (sigar_uint64_t)sizes[1]; finfo->size = (sigar_uint64_t)sizes[1];
if (finfo->size < 0 || sizes[0]) { if (finfo->size < 0 || sizes[0]) {