Xinqi Bao's Git
projects
/
slstatus.git
/ commitdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
patch
|
inline
| side by side (parent:
efa26f4
)
Consistent paramter naming for components
author
Aaron Marcher <
[email protected]
>
Fri, 6 Jul 2018 06:08:48 +0000
(08:08 +0200)
committer
Aaron Marcher <
[email protected]
>
Fri, 6 Jul 2018 06:08:48 +0000
(08:08 +0200)
components/disk.c
patch
|
blob
|
history
components/ip.c
patch
|
blob
|
history
components/num_files.c
patch
|
blob
|
history
components/wifi.c
patch
|
blob
|
history
slstatus.h
patch
|
blob
|
history
diff --git
a/components/disk.c
b/components/disk.c
index
9d2284e
..
15a221b
100644
(file)
--- a/
components/disk.c
+++ b/
components/disk.c
@@
-5,12
+5,12
@@
#include "../util.h"
const char *
#include "../util.h"
const char *
-disk_free(const char *
mnt
)
+disk_free(const char *
path
)
{
struct statvfs fs;
{
struct statvfs fs;
- if (statvfs(
mnt
, &fs) < 0) {
- warn("statvfs '%s':",
mnt
);
+ if (statvfs(
path
, &fs) < 0) {
+ warn("statvfs '%s':",
path
);
return NULL;
}
return NULL;
}
@@
-18,12
+18,12
@@
disk_free(const char *mnt)
}
const char *
}
const char *
-disk_perc(const char *
mnt
)
+disk_perc(const char *
path
)
{
struct statvfs fs;
{
struct statvfs fs;
- if (statvfs(
mnt
, &fs) < 0) {
- warn("statvfs '%s':",
mnt
);
+ if (statvfs(
path
, &fs) < 0) {
+ warn("statvfs '%s':",
path
);
return NULL;
}
return NULL;
}
@@
-32,12
+32,12
@@
disk_perc(const char *mnt)
}
const char *
}
const char *
-disk_total(const char *
mnt
)
+disk_total(const char *
path
)
{
struct statvfs fs;
{
struct statvfs fs;
- if (statvfs(
mnt
, &fs) < 0) {
- warn("statvfs '%s':",
mnt
);
+ if (statvfs(
path
, &fs) < 0) {
+ warn("statvfs '%s':",
path
);
return NULL;
}
return NULL;
}
@@
-45,12
+45,12
@@
disk_total(const char *mnt)
}
const char *
}
const char *
-disk_used(const char *
mnt
)
+disk_used(const char *
path
)
{
struct statvfs fs;
{
struct statvfs fs;
- if (statvfs(
mnt
, &fs) < 0) {
- warn("statvfs '%s':",
mnt
);
+ if (statvfs(
path
, &fs) < 0) {
+ warn("statvfs '%s':",
path
);
return NULL;
}
return NULL;
}
diff --git
a/components/ip.c
b/components/ip.c
index
f26e49a
..
a7b1bfd
100644
(file)
--- a/
components/ip.c
+++ b/
components/ip.c
@@
-11,7
+11,7
@@
#include "../util.h"
static const char *
#include "../util.h"
static const char *
-ip(const char *iface, unsigned short sa_family)
+ip(const char *i
nter
face, unsigned short sa_family)
{
struct ifaddrs *ifaddr, *ifa;
int s;
{
struct ifaddrs *ifaddr, *ifa;
int s;
@@
-28,7
+28,7
@@
ip(const char *iface, unsigned short sa_family)
}
s = getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in6),
host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
}
s = getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in6),
host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
- if (!strcmp(ifa->ifa_name, iface) &&
+ if (!strcmp(ifa->ifa_name, i
nter
face) &&
(ifa->ifa_addr->sa_family == sa_family)) {
freeifaddrs(ifaddr);
if (s != 0) {
(ifa->ifa_addr->sa_family == sa_family)) {
freeifaddrs(ifaddr);
if (s != 0) {
@@
-45,13
+45,13
@@
ip(const char *iface, unsigned short sa_family)
}
const char *
}
const char *
-ipv4(const char *iface)
+ipv4(const char *i
nter
face)
{
{
- return ip(iface, AF_INET);
+ return ip(i
nter
face, AF_INET);
}
const char *
}
const char *
-ipv6(const char *iface)
+ipv6(const char *i
nter
face)
{
{
- return ip(iface, AF_INET6);
+ return ip(i
nter
face, AF_INET6);
}
}
diff --git
a/components/num_files.c
b/components/num_files.c
index
86ea064
..
fb55df9
100644
(file)
--- a/
components/num_files.c
+++ b/
components/num_files.c
@@
-6,14
+6,14
@@
#include "../util.h"
const char *
#include "../util.h"
const char *
-num_files(const char *
dir
)
+num_files(const char *
path
)
{
struct dirent *dp;
DIR *fd;
int num;
{
struct dirent *dp;
DIR *fd;
int num;
- if (!(fd = opendir(
dir
))) {
- warn("opendir '%s':",
dir
);
+ if (!(fd = opendir(
path
))) {
+ warn("opendir '%s':",
path
);
return NULL;
}
return NULL;
}
diff --git
a/components/wifi.c
b/components/wifi.c
index
3751ae3
..
9de543b
100644
(file)
--- a/
components/wifi.c
+++ b/
components/wifi.c
@@
-13,7
+13,7
@@
#include <linux/wireless.h>
const char *
#include <linux/wireless.h>
const char *
- wifi_perc(const char *iface)
+ wifi_perc(const char *i
nter
face)
{
int i, cur;
int total = 70; /* the max of /proc/net/wireless */
{
int i, cur;
int total = 70; /* the max of /proc/net/wireless */
@@
-24,7
+24,7
@@
if (esnprintf(path, sizeof(path),
"/sys/class/net/%s/operstate",
if (esnprintf(path, sizeof(path),
"/sys/class/net/%s/operstate",
- iface) < 0) {
+ i
nter
face) < 0) {
return NULL;
}
if (!(fp = fopen(path, "r"))) {
return NULL;
}
if (!(fp = fopen(path, "r"))) {
@@
-51,11
+51,11
@@
return NULL;
}
return NULL;
}
- if (!(datastart = strstr(buf, iface))) {
+ if (!(datastart = strstr(buf, i
nter
face))) {
return NULL;
}
return NULL;
}
- datastart = (datastart+(strlen(iface)+1));
+ datastart = (datastart+(strlen(i
nter
face)+1));
sscanf(datastart + 1, " %*d %d %*d %*d\t\t %*d\t "
"%*d\t\t%*d\t\t %*d\t %*d\t\t %*d", &cur);
sscanf(datastart + 1, " %*d %d %*d %*d\t\t %*d\t "
"%*d\t\t%*d\t\t %*d\t %*d\t\t %*d", &cur);
@@
-63,7
+63,7
@@
}
const char *
}
const char *
- wifi_essid(const char *iface)
+ wifi_essid(const char *i
nter
face)
{
static char id[IW_ESSID_MAX_SIZE+1];
int sockfd;
{
static char id[IW_ESSID_MAX_SIZE+1];
int sockfd;
@@
-72,7
+72,7
@@
memset(&wreq, 0, sizeof(struct iwreq));
wreq.u.essid.length = IW_ESSID_MAX_SIZE+1;
if (esnprintf(wreq.ifr_name, sizeof(wreq.ifr_name),
memset(&wreq, 0, sizeof(struct iwreq));
wreq.u.essid.length = IW_ESSID_MAX_SIZE+1;
if (esnprintf(wreq.ifr_name, sizeof(wreq.ifr_name),
- "%s", iface) < 0) {
+ "%s", i
nter
face) < 0) {
return NULL;
}
return NULL;
}
@@
-105,7
+105,7
@@
#include <sys/types.h>
static int
#include <sys/types.h>
static int
- load_ieee80211_nodereq(const char *iface, struct ieee80211_nodereq *nr)
+ load_ieee80211_nodereq(const char *i
nter
face, struct ieee80211_nodereq *nr)
{
struct ieee80211_bssid bssid;
int sockfd;
{
struct ieee80211_bssid bssid;
int sockfd;
@@
-117,7
+117,7
@@
warn("socket 'AF_INET':");
return 0;
}
warn("socket 'AF_INET':");
return 0;
}
- strlcpy(bssid.i_name, iface, sizeof(bssid.i_name));
+ strlcpy(bssid.i_name, i
nter
face, sizeof(bssid.i_name));
if ((ioctl(sockfd, SIOCG80211BSSID, &bssid)) < 0) {
warn("ioctl 'SIOCG80211BSSID':");
close(sockfd);
if ((ioctl(sockfd, SIOCG80211BSSID, &bssid)) < 0) {
warn("ioctl 'SIOCG80211BSSID':");
close(sockfd);
@@
-129,7
+129,7
@@
close(sockfd);
return 0;
}
close(sockfd);
return 0;
}
- strlcpy(nr->nr_ifname, iface, sizeof(nr->nr_ifname));
+ strlcpy(nr->nr_ifname, i
nter
face, sizeof(nr->nr_ifname));
memcpy(&nr->nr_macaddr, bssid.i_bssid, sizeof(nr->nr_macaddr));
if ((ioctl(sockfd, SIOCG80211NODE, nr)) < 0 && nr->nr_rssi) {
warn("ioctl 'SIOCG80211NODE':");
memcpy(&nr->nr_macaddr, bssid.i_bssid, sizeof(nr->nr_macaddr));
if ((ioctl(sockfd, SIOCG80211NODE, nr)) < 0 && nr->nr_rssi) {
warn("ioctl 'SIOCG80211NODE':");
@@
-141,12
+141,12
@@
}
const char *
}
const char *
- wifi_perc(const char *iface)
+ wifi_perc(const char *i
nter
face)
{
struct ieee80211_nodereq nr;
int q;
{
struct ieee80211_nodereq nr;
int q;
- if (load_ieee80211_nodereq(iface, &nr)) {
+ if (load_ieee80211_nodereq(i
nter
face, &nr)) {
if (nr.nr_max_rssi) {
q = IEEE80211_NODEREQ_RSSI(&nr);
} else {
if (nr.nr_max_rssi) {
q = IEEE80211_NODEREQ_RSSI(&nr);
} else {
@@
-160,11
+160,11
@@
}
const char *
}
const char *
- wifi_essid(const char *iface)
+ wifi_essid(const char *i
nter
face)
{
struct ieee80211_nodereq nr;
{
struct ieee80211_nodereq nr;
- if (load_ieee80211_nodereq(iface, &nr)) {
+ if (load_ieee80211_nodereq(i
nter
face, &nr)) {
return bprintf("%s", nr.nr_nwid);
}
return bprintf("%s", nr.nr_nwid);
}
diff --git
a/slstatus.h
b/slstatus.h
index
342d191
..
08f610a
100644
(file)
--- a/
slstatus.h
+++ b/
slstatus.h
@@
-13,10
+13,10
@@
const char *cpu_perc(void);
const char *datetime(const char *fmt);
/* disk */
const char *datetime(const char *fmt);
/* disk */
-const char *disk_free(const char *
mnt
);
-const char *disk_perc(const char *
mnt
);
-const char *disk_total(const char *
mnt
);
-const char *disk_used(const char *
mnt
);
+const char *disk_free(const char *
path
);
+const char *disk_perc(const char *
path
);
+const char *disk_total(const char *
path
);
+const char *disk_used(const char *
path
);
/* entropy */
const char *entropy(void);
/* entropy */
const char *entropy(void);
@@
-25,8
+25,8
@@
const char *entropy(void);
const char *hostname(void);
/* ip */
const char *hostname(void);
/* ip */
-const char *ipv4(const char *iface);
-const char *ipv6(const char *iface);
+const char *ipv4(const char *i
nter
face);
+const char *ipv6(const char *i
nter
face);
/* kernel_release */
const char *kernel_release(void);
/* kernel_release */
const char *kernel_release(void);
@@
-45,7
+45,7
@@
const char *netspeed_rx(const char *interface);
const char *netspeed_tx(const char *interface);
/* num_files */
const char *netspeed_tx(const char *interface);
/* num_files */
-const char *num_files(const char *
dir
);
+const char *num_files(const char *
path
);
/* ram */
const char *ram_free(void);
/* ram */
const char *ram_free(void);
@@
-77,5
+77,5
@@
const char *uid(void);
const char *vol_perc(const char *card);
/* wifi */
const char *vol_perc(const char *card);
/* wifi */
-const char *wifi_perc(const char *iface);
-const char *wifi_essid(const char *iface);
+const char *wifi_perc(const char *i
nter
face);
+const char *wifi_essid(const char *i
nter
face);