readability++

This commit is contained in:
Doug MacEachern 2005-12-21 04:58:02 +00:00
parent 70f18204dd
commit 55a1c28a1a
1 changed files with 22 additions and 21 deletions

View File

@ -226,7 +226,7 @@ static sigar_psapi_t sigar_winsta = {
}; };
#define DLLMOD_COPY(name) \ #define DLLMOD_COPY(name) \
memcpy(&(*sigar)->##name, &sigar_##name, sizeof(sigar_##name)) memcpy(&(sigar->##name), &sigar_##name, sizeof(sigar_##name))
#define DLLMOD_INIT(name, all) \ #define DLLMOD_INIT(name, all) \
sigar_dllmod_init(sigar, (sigar_dll_module_t *)&(sigar->##name), all) sigar_dllmod_init(sigar, (sigar_dll_module_t *)&(sigar->##name), all)
@ -304,19 +304,20 @@ static int sigar_dllmod_init(sigar_t *sigar,
return SIGAR_OK; return SIGAR_OK;
} }
int sigar_os_open(sigar_t **sigar) int sigar_os_open(sigar_t **sigar_ptr)
{ {
LONG result; LONG result;
HINSTANCE h; HINSTANCE h;
OSVERSIONINFO version; OSVERSIONINFO version;
int i; int i;
sigar_t *sigar;
*sigar = malloc(sizeof(**sigar)); *sigar_ptr = sigar = malloc(sizeof(*sigar));
(*sigar)->machine = ""; /* local machine */ sigar->machine = ""; /* local machine */
(*sigar)->using_wide = 0; /*XXX*/ sigar->using_wide = 0; /*XXX*/
(*sigar)->perfbuf = NULL; sigar->perfbuf = NULL;
(*sigar)->perfbuf_size = 0; sigar->perfbuf_size = 0;
version.dwOSVersionInfoSize = sizeof(version); version.dwOSVersionInfoSize = sizeof(version);
GetVersionEx(&version); GetVersionEx(&version);
@ -325,24 +326,24 @@ int sigar_os_open(sigar_t **sigar)
* 4 == NT 4.0 * 4 == NT 4.0
* 5 == 2000, XP, 2003 Server * 5 == 2000, XP, 2003 Server
*/ */
(*sigar)->winnt = (version.dwMajorVersion == 4); sigar->winnt = (version.dwMajorVersion == 4);
if (USING_WIDE_S(*sigar)) { if (USING_WIDE_S(sigar)) {
WCHAR wmachine[MAX_PATH+1]; WCHAR wmachine[MAX_PATH+1];
SIGAR_A2W((*sigar)->machine, wmachine, sizeof(wmachine)); SIGAR_A2W(sigar->machine, wmachine, sizeof(wmachine));
result = RegConnectRegistryW(wmachine, result = RegConnectRegistryW(wmachine,
HKEY_PERFORMANCE_DATA, HKEY_PERFORMANCE_DATA,
&(*sigar)->handle); &sigar->handle);
} }
else { else {
result = RegConnectRegistryA((*sigar)->machine, result = RegConnectRegistryA(sigar->machine,
HKEY_PERFORMANCE_DATA, HKEY_PERFORMANCE_DATA,
&(*sigar)->handle); &sigar->handle);
} }
get_sysinfo(*sigar); get_sysinfo(sigar);
DLLMOD_COPY(wtsapi); DLLMOD_COPY(wtsapi);
DLLMOD_COPY(iphlpapi); DLLMOD_COPY(iphlpapi);
@ -351,16 +352,16 @@ int sigar_os_open(sigar_t **sigar)
DLLMOD_COPY(psapi); DLLMOD_COPY(psapi);
DLLMOD_COPY(winsta); DLLMOD_COPY(winsta);
(*sigar)->log_level = -1; /* else below segfaults */ sigar->log_level = -1; /* else below segfaults */
/* XXX init early for use by javasigar.c */ /* XXX init early for use by javasigar.c */
sigar_dllmod_init(*sigar, sigar_dllmod_init(sigar,
(sigar_dll_module_t *)&(*sigar)->advapi, (sigar_dll_module_t *)&sigar->advapi,
FALSE); FALSE);
(*sigar)->pinfo.pid = -1; sigar->pinfo.pid = -1;
(*sigar)->ws_version = 0; sigar->ws_version = 0;
(*sigar)->ncpu = 0; sigar->ncpu = 0;
(*sigar)->peb = NULL; sigar->peb = NULL;
return result; return result;
} }