diff --git a/include/sigar.h b/include/sigar.h index 5da3e46c..cdb03c1b 100644 --- a/include/sigar.h +++ b/include/sigar.h @@ -493,6 +493,25 @@ sigar_net_connection_list_destroy(sigar_t *sigar, SIGAR_DECLARE(const char *)sigar_net_connection_type_get(int type); +typedef struct { + char user[32]; + char device[32]; + char host[256]; + sigar_uint64_t time; +} sigar_who_t; + +typedef struct { + unsigned long number; + unsigned long size; + sigar_who_t *data; +} sigar_who_list_t; + +SIGAR_DECLARE(int) sigar_who_list_get(sigar_t *sigar, + sigar_who_list_t *wholist); + +SIGAR_DECLARE(int) sigar_who_list_destroy(sigar_t *sigar, + sigar_who_list_t *wholist); + SIGAR_DECLARE(int) sigar_proc_port_get(sigar_t *sigar, unsigned long port, sigar_pid_t *pid); diff --git a/include/sigar_private.h b/include/sigar_private.h index b967a9c7..2159f676 100644 --- a/include/sigar_private.h +++ b/include/sigar_private.h @@ -81,6 +81,8 @@ #define SIGAR_NET_CONNLIST_MAX 20 +#define SIGAR_WHO_LIST_MAX 12 + int sigar_os_open(sigar_t **sigar); int sigar_os_close(sigar_t *sigar); @@ -168,6 +170,15 @@ int sigar_net_connection_list_grow(sigar_net_connection_list_t *connlist); sigar_net_connection_list_grow(connlist); \ } +int sigar_who_list_create(sigar_who_list_t *wholist); + +int sigar_who_list_grow(sigar_who_list_t *wholist); + +#define SIGAR_WHO_LIST_GROW(wholist) \ + if (wholist->number >= wholist->size) { \ + sigar_who_list_grow(wholist); \ + } + void sigar_hwaddr_format(char *buff, unsigned char *ptr); #define sigar_hwaddr_set_null(ifconfig) \