mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-02-12 00:48:49 +00:00
* Fix issues https://github.com/brndnmtthws/conky/issues/439 , https://github.com/brndnmtthws/conky/issues/303 * core.cc: Add missing header file * core.cc: Check if we build for x11 and add the locks functions * read_tcpip.cc: Fix for https://github.com/brndnmtthws/conky/issues/306 * read_tcpip.cc: Missing string format specifier for "snprintf()" * read_tcpip.cc: Wrong signed int format specifier for "snprintf()" * Missing many string format specifiers to "snprintf()"
This commit is contained in:
parent
71cfbff645
commit
7bca0ca881
@ -147,7 +147,7 @@ enum arg_type get_arg_type(const char *arg) {
|
||||
p++;
|
||||
}
|
||||
while (p <= e) {
|
||||
if (isdigit(*p) == 0) {
|
||||
if (isdigit((unsigned char)*p) == 0) {
|
||||
break;
|
||||
}
|
||||
p++;
|
||||
@ -158,7 +158,7 @@ enum arg_type get_arg_type(const char *arg) {
|
||||
if (*p == '.') {
|
||||
p++;
|
||||
while (p <= e) {
|
||||
if (isdigit(*p) == 0) {
|
||||
if (isdigit((unsigned char)*p) == 0) {
|
||||
return ARG_BAD;
|
||||
}
|
||||
p++;
|
||||
|
@ -74,13 +74,13 @@ void print_apm_adapter(struct text_object *obj, char *p, int p_max_size) {
|
||||
|
||||
fd = open(APMDEV, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
snprintf(p, p_max_size, "ERR");
|
||||
snprintf(p, p_max_size, "%s", "ERR");
|
||||
return;
|
||||
}
|
||||
|
||||
if (apm_getinfo(fd, &a_info) != 0) {
|
||||
close(fd);
|
||||
snprintf(p, p_max_size, "ERR");
|
||||
snprintf(p, p_max_size, "%s", "ERR");
|
||||
return;
|
||||
}
|
||||
close(fd);
|
||||
@ -123,13 +123,13 @@ void print_apm_battery_life(struct text_object *obj, char *p, int p_max_size) {
|
||||
|
||||
fd = open(APMDEV, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
snprintf(p, p_max_size, "ERR");
|
||||
snprintf(p, p_max_size, "%s", "ERR");
|
||||
return;
|
||||
}
|
||||
|
||||
if (apm_getinfo(fd, &a_info) != 0) {
|
||||
close(fd);
|
||||
snprintf(p, p_max_size, "ERR");
|
||||
snprintf(p, p_max_size, "%s", "ERR");
|
||||
return;
|
||||
}
|
||||
close(fd);
|
||||
@ -165,13 +165,13 @@ void print_apm_battery_time(struct text_object *obj, char *p, int p_max_size) {
|
||||
|
||||
fd = open(APMDEV, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
snprintf(p, p_max_size, "ERR");
|
||||
snprintf(p, p_max_size, "%s", "ERR");
|
||||
return;
|
||||
}
|
||||
|
||||
if (apm_getinfo(fd, &a_info) != 0) {
|
||||
close(fd);
|
||||
snprintf(p, p_max_size, "ERR");
|
||||
snprintf(p, p_max_size, "%s", "ERR");
|
||||
return;
|
||||
}
|
||||
close(fd);
|
||||
@ -182,7 +182,7 @@ void print_apm_battery_time(struct text_object *obj, char *p, int p_max_size) {
|
||||
batt_time = a_info.ai_batt_time;
|
||||
|
||||
if (batt_time == -1) {
|
||||
snprintf(p, p_max_size, "unknown");
|
||||
snprintf(p, p_max_size, "%s", "unknown");
|
||||
} else
|
||||
#ifdef __OpenBSD__
|
||||
{
|
||||
|
@ -192,9 +192,9 @@ std::string variable_substitute(std::string s) {
|
||||
std::string var;
|
||||
std::string::size_type l = 0;
|
||||
|
||||
if (isalpha(s[pos + 1]) != 0) {
|
||||
if (isalpha((unsigned char)s[pos + 1]) != 0) {
|
||||
l = 1;
|
||||
while (pos + l < s.size() && (isalnum(s[pos + l]) != 0)) {
|
||||
while (pos + l < s.size() && (isalnum((unsigned char)s[pos + l]) != 0)) {
|
||||
++l;
|
||||
}
|
||||
var = s.substr(pos + 1, l - 1);
|
||||
@ -323,7 +323,7 @@ unsigned int round_to_int(float f) {
|
||||
|
||||
void scan_loadavg_arg(struct text_object *obj, const char *arg) {
|
||||
obj->data.i = 0;
|
||||
if ((arg != nullptr) && (arg[1] == 0) && (isdigit(arg[0]) != 0)) {
|
||||
if ((arg != nullptr) && (arg[1] == 0) && (isdigit((unsigned char)arg[0]) != 0)) {
|
||||
obj->data.i = atoi(arg);
|
||||
if (obj->data.i > 3 || obj->data.i < 1) {
|
||||
NORM_ERR("loadavg arg needs to be in range (1,3)");
|
||||
|
22
src/core.cc
22
src/core.cc
@ -425,7 +425,7 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
|
||||
obj->callbacks.free = &gen_free_opaque;
|
||||
#endif /* !__OpenBSD__ */
|
||||
END OBJ(freq, nullptr) get_cpu_count();
|
||||
if ((arg == nullptr) || (isdigit(arg[0]) == 0) || strlen(arg) >= 3 ||
|
||||
if ((arg == nullptr) || (isdigit((unsigned char)arg[0]) == 0) || strlen(arg) >= 3 ||
|
||||
atoi(&arg[0]) == 0 || atoi(&arg[0]) > info.cpu_count) {
|
||||
obj->data.i = 1;
|
||||
/* NORM_ERR("freq: Invalid CPU number or you don't have that many CPUs! "
|
||||
@ -435,7 +435,7 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
|
||||
}
|
||||
obj->callbacks.print = &print_freq;
|
||||
END OBJ(freq_g, nullptr) get_cpu_count();
|
||||
if ((arg == nullptr) || (isdigit(arg[0]) == 0) || strlen(arg) >= 3 ||
|
||||
if ((arg == nullptr) || (isdigit((unsigned char)arg[0]) == 0) || strlen(arg) >= 3 ||
|
||||
atoi(&arg[0]) == 0 || atoi(&arg[0]) > info.cpu_count) {
|
||||
obj->data.i = 1;
|
||||
/* NORM_ERR("freq_g: Invalid CPU number or you don't have that many "
|
||||
@ -461,7 +461,7 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
|
||||
obj->callbacks.free = &free_tcp_ping;
|
||||
#if defined(__linux__)
|
||||
END OBJ(voltage_mv, 0) get_cpu_count();
|
||||
if (!arg || !isdigit(arg[0]) || strlen(arg) >= 3 || atoi(&arg[0]) == 0 ||
|
||||
if (!arg || !isdigit((unsigned char)arg[0]) || strlen(arg) >= 3 || atoi(&arg[0]) == 0 ||
|
||||
atoi(&arg[0]) > info.cpu_count) {
|
||||
obj->data.i = 1;
|
||||
/* NORM_ERR("voltage_mv: Invalid CPU number or you don't have that many "
|
||||
@ -471,7 +471,7 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
|
||||
}
|
||||
obj->callbacks.print = &print_voltage_mv;
|
||||
END OBJ(voltage_v, 0) get_cpu_count();
|
||||
if (!arg || !isdigit(arg[0]) || strlen(arg) >= 3 || atoi(&arg[0]) == 0 ||
|
||||
if (!arg || !isdigit((unsigned char)arg[0]) || strlen(arg) >= 3 || atoi(&arg[0]) == 0 ||
|
||||
atoi(&arg[0]) > info.cpu_count) {
|
||||
obj->data.i = 1;
|
||||
/* NORM_ERR("voltage_v: Invalid CPU number or you don't have that many "
|
||||
@ -815,6 +815,16 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
|
||||
obj->data.s = strndup(arg ? arg : "", text_buffer_size.get(*state));
|
||||
obj->callbacks.print = &print_cat;
|
||||
obj->callbacks.free = &gen_free_opaque;
|
||||
|
||||
#ifdef BUILD_X11
|
||||
END OBJ(num_led, 0)
|
||||
obj->callbacks.print = &print_num_led;
|
||||
END OBJ(caps_led, 0)
|
||||
obj->callbacks.print = &print_caps_led;
|
||||
END OBJ(scroll_led, 0)
|
||||
obj->callbacks.print = &print_scroll_led;
|
||||
#endif /* BUILD_X11 */
|
||||
|
||||
END OBJ(catp, 0)
|
||||
obj->data.s = strndup(arg ? arg : "", text_buffer_size.get(*state));
|
||||
obj->callbacks.print = &print_catp;
|
||||
@ -1997,7 +2007,7 @@ int extract_variable_text_internal(struct text_object *retval,
|
||||
s = p;
|
||||
if (*p == '#') { p++; }
|
||||
while ((*p != 0) &&
|
||||
((isalnum(static_cast<int>(*p)) != 0) || *p == '_')) {
|
||||
((isalnum((unsigned char)(*p)) != 0) || *p == '_')) {
|
||||
p++;
|
||||
}
|
||||
}
|
||||
@ -2031,7 +2041,7 @@ int extract_variable_text_internal(struct text_object *retval,
|
||||
arg = strchr(buf, ' ');
|
||||
*arg = '\0';
|
||||
arg++;
|
||||
while (isspace(static_cast<int>(*arg)) != 0) { arg++; }
|
||||
while (isspace((unsigned char)(*arg)) != 0) { arg++; }
|
||||
if (*arg == 0) { arg = nullptr; }
|
||||
}
|
||||
|
||||
|
@ -210,7 +210,7 @@ void get_fs_type(const char *path, char *result) {
|
||||
void init_fs_bar(struct text_object *obj, const char *arg) {
|
||||
arg = scan_bar(obj, arg, 1);
|
||||
if (arg != nullptr) {
|
||||
while (isspace(*arg) != 0) { arg++; }
|
||||
while (isspace((unsigned char)*arg) != 0) { arg++; }
|
||||
if (*arg == '\0') { arg = "/"; }
|
||||
} else {
|
||||
arg = "/";
|
||||
|
@ -225,7 +225,7 @@ void print_hddtemp(struct text_object *obj, char *p, int p_max_size) {
|
||||
char unit;
|
||||
|
||||
if (get_hddtemp_info(obj->data.s, &val, &unit)) {
|
||||
snprintf(p, p_max_size, "N/A");
|
||||
snprintf(p, p_max_size, "%s", "N/A");
|
||||
} else {
|
||||
temp_print(p, p_max_size, (double)val,
|
||||
(unit == 'C' ? TEMP_CELSIUS : TEMP_FAHRENHEIT));
|
||||
|
@ -129,13 +129,13 @@ void print_i8k_ac_status(struct text_object *obj, char *p, int p_max_size) {
|
||||
|
||||
sscanf(i8k.ac_status, "%d", &ac_status);
|
||||
if (ac_status == -1) {
|
||||
snprintf(p, p_max_size, "disabled (read i8k docs)");
|
||||
snprintf(p, p_max_size, "%s", "disabled (read i8k docs)");
|
||||
}
|
||||
if (ac_status == 0) {
|
||||
snprintf(p, p_max_size, "off");
|
||||
snprintf(p, p_max_size, "%s", "off");
|
||||
}
|
||||
if (ac_status == 1) {
|
||||
snprintf(p, p_max_size, "on");
|
||||
snprintf(p, p_max_size, "%s", "on");
|
||||
}
|
||||
}
|
||||
|
||||
|
48
src/linux.cc
48
src/linux.cc
@ -253,7 +253,7 @@ void print_ioscheduler(struct text_object *obj, char *p, int p_max_size) {
|
||||
}
|
||||
fclose(fp);
|
||||
out_fail:
|
||||
snprintf(p, p_max_size, "n/a");
|
||||
snprintf(p, p_max_size, "%s", "n/a");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -410,7 +410,7 @@ int update_net_stats(void) {
|
||||
p = buf;
|
||||
/* change char * p to first non-space character, which is the beginning
|
||||
* of the interface name */
|
||||
while (*p != '\0' && isspace((int)*p)) { p++; }
|
||||
while (*p != '\0' && isspace((unsigned char)*p)) { p++; }
|
||||
|
||||
s = p;
|
||||
|
||||
@ -573,7 +573,7 @@ int update_net_stats(void) {
|
||||
if (winfo->b.essid_on) {
|
||||
snprintf(ns->essid, 32, "%s", winfo->b.essid);
|
||||
} else {
|
||||
snprintf(ns->essid, 32, "off/any");
|
||||
snprintf(ns->essid, 32, "%s", "off/any");
|
||||
}
|
||||
}
|
||||
// get channel and freq
|
||||
@ -864,7 +864,7 @@ int update_stat(void) {
|
||||
sscanf(buf, "%*s %hu", &info.run_threads);
|
||||
} else if (strncmp(buf, "cpu", 3) == 0) {
|
||||
double delta;
|
||||
if (isdigit(buf[3])) {
|
||||
if (isdigit((unsigned char)buf[3])) {
|
||||
idx++; // just increment here since the CPU index can skip numbers
|
||||
} else {
|
||||
idx = 0;
|
||||
@ -1426,7 +1426,7 @@ void get_acpi_fan(char *p_client_buffer, size_t client_buffer_size) {
|
||||
|
||||
/* yeah, slow... :/ */
|
||||
if (!get_first_file_in_a_directory(ACPI_FAN_DIR, buf, &rep)) {
|
||||
snprintf(p_client_buffer, client_buffer_size, "no fans?");
|
||||
snprintf(p_client_buffer, client_buffer_size, "%s", "no fans?");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1434,7 +1434,7 @@ void get_acpi_fan(char *p_client_buffer, size_t client_buffer_size) {
|
||||
|
||||
fp = open_file(buf2, &rep);
|
||||
if (!fp) {
|
||||
snprintf(p_client_buffer, client_buffer_size,
|
||||
snprintf(p_client_buffer, client_buffer_size, "%s",
|
||||
"can't open fan's state file");
|
||||
return;
|
||||
}
|
||||
@ -1504,7 +1504,7 @@ void get_acpi_ac_adapter(char *p_client_buffer, size_t client_buffer_size,
|
||||
} else {
|
||||
/* yeah, slow... :/ */
|
||||
if (!get_first_file_in_a_directory(ACPI_AC_ADAPTER_DIR, buf, &rep)) {
|
||||
snprintf(p_client_buffer, client_buffer_size, "no ac_adapters?");
|
||||
snprintf(p_client_buffer, client_buffer_size, "%s", "no ac_adapters?");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1512,7 +1512,7 @@ void get_acpi_ac_adapter(char *p_client_buffer, size_t client_buffer_size,
|
||||
|
||||
fp = open_file(buf2, &rep);
|
||||
if (!fp) {
|
||||
snprintf(p_client_buffer, client_buffer_size,
|
||||
snprintf(p_client_buffer, client_buffer_size, "%s",
|
||||
"No ac adapter found.... where is it?");
|
||||
return;
|
||||
}
|
||||
@ -1821,12 +1821,12 @@ void get_battery_stuff(char *buffer, unsigned int n, const char *bat,
|
||||
"charging %d%%",
|
||||
(int)(((float)remaining_capacity / acpi_last_full[idx]) * 100));
|
||||
snprintf(last_battery_time_str[idx],
|
||||
sizeof(last_battery_time_str[idx]) - 1, "unknown");
|
||||
sizeof(last_battery_time_str[idx]) - 1, "%s", "unknown");
|
||||
} else {
|
||||
strncpy(last_battery_str[idx], "charging",
|
||||
sizeof(last_battery_str[idx]) - 1);
|
||||
snprintf(last_battery_time_str[idx],
|
||||
sizeof(last_battery_time_str[idx]) - 1, "unknown");
|
||||
sizeof(last_battery_time_str[idx]) - 1, "%s", "unknown");
|
||||
}
|
||||
}
|
||||
/* discharging */
|
||||
@ -1845,14 +1845,14 @@ void get_battery_stuff(char *buffer, unsigned int n, const char *bat,
|
||||
snprintf(last_battery_str[idx], sizeof(last_battery_str[idx]) - 1,
|
||||
"full");
|
||||
snprintf(last_battery_time_str[idx],
|
||||
sizeof(last_battery_time_str[idx]) - 1, "unknown");
|
||||
sizeof(last_battery_time_str[idx]) - 1, "%s", "unknown");
|
||||
} else {
|
||||
snprintf(
|
||||
last_battery_str[idx], sizeof(last_battery_str[idx]) - 1,
|
||||
"discharging %d%%",
|
||||
(int)(((float)remaining_capacity / acpi_last_full[idx]) * 100));
|
||||
snprintf(last_battery_time_str[idx],
|
||||
sizeof(last_battery_time_str[idx]) - 1, "unknown");
|
||||
sizeof(last_battery_time_str[idx]) - 1, "%s", "unknown");
|
||||
}
|
||||
}
|
||||
/* charged */
|
||||
@ -1951,12 +1951,12 @@ void get_battery_stuff(char *buffer, unsigned int n, const char *bat,
|
||||
"charging %d%%",
|
||||
(int)((remaining_capacity * 100) / acpi_last_full[idx]));
|
||||
snprintf(last_battery_time_str[idx],
|
||||
sizeof(last_battery_time_str[idx]) - 1, "unknown");
|
||||
sizeof(last_battery_time_str[idx]) - 1, "%s", "unknown");
|
||||
} else {
|
||||
strncpy(last_battery_str[idx], "charging",
|
||||
sizeof(last_battery_str[idx]) - 1);
|
||||
snprintf(last_battery_time_str[idx],
|
||||
sizeof(last_battery_time_str[idx]) - 1, "unknown");
|
||||
sizeof(last_battery_time_str[idx]) - 1, "%s", "unknown");
|
||||
}
|
||||
/* discharging */
|
||||
} else if (strncmp(charging_state, "discharging", 64) == 0) {
|
||||
@ -1973,13 +1973,13 @@ void get_battery_stuff(char *buffer, unsigned int n, const char *bat,
|
||||
snprintf(last_battery_str[idx], sizeof(last_battery_str[idx]) - 1,
|
||||
"charged");
|
||||
snprintf(last_battery_time_str[idx],
|
||||
sizeof(last_battery_time_str[idx]) - 1, "unknown");
|
||||
sizeof(last_battery_time_str[idx]) - 1, "%s", "unknown");
|
||||
} else {
|
||||
snprintf(last_battery_str[idx], sizeof(last_battery_str[idx]) - 1,
|
||||
"discharging %d%%",
|
||||
(int)((remaining_capacity * 100) / acpi_last_full[idx]));
|
||||
snprintf(last_battery_time_str[idx],
|
||||
sizeof(last_battery_time_str[idx]) - 1, "unknown");
|
||||
sizeof(last_battery_time_str[idx]) - 1, "%s", "unknown");
|
||||
}
|
||||
/* charged */
|
||||
} else if (strncmp(charging_state, "charged", 64) == 0) {
|
||||
@ -2021,7 +2021,7 @@ void get_battery_stuff(char *buffer, unsigned int n, const char *bat,
|
||||
|
||||
if (life == -1) {
|
||||
/* could check now that there is ac */
|
||||
snprintf(last_battery_str[idx], 64, "not present");
|
||||
snprintf(last_battery_str[idx], 64, "%s", "not present");
|
||||
|
||||
/* could check that status == 3 here? */
|
||||
} else if (ac && life != 100) {
|
||||
@ -2307,10 +2307,10 @@ void get_powerbook_batt_info(struct text_object *obj, char *buffer, int n) {
|
||||
if (timeval == 0 && ac && (flags & PMU_BATT_PRESENT) &&
|
||||
!(flags & PMU_BATT_CHARGING)) {
|
||||
snprintf(pb_battery_info[PB_BATT_PERCENT],
|
||||
sizeof(pb_battery_info[PB_BATT_PERCENT]), "100%%");
|
||||
sizeof(pb_battery_info[PB_BATT_PERCENT]), "%s", "100%%");
|
||||
} else if (timeval == 0) {
|
||||
snprintf(pb_battery_info[PB_BATT_PERCENT],
|
||||
sizeof(pb_battery_info[PB_BATT_PERCENT]), "unknown");
|
||||
sizeof(pb_battery_info[PB_BATT_PERCENT]), "%s", "unknown");
|
||||
} else {
|
||||
snprintf(pb_battery_info[PB_BATT_PERCENT],
|
||||
sizeof(pb_battery_info[PB_BATT_PERCENT]), "%d%%",
|
||||
@ -2320,7 +2320,7 @@ void get_powerbook_batt_info(struct text_object *obj, char *buffer, int n) {
|
||||
/* update time string */
|
||||
if (timeval == 0) { /* fully charged or battery not present */
|
||||
snprintf(pb_battery_info[PB_BATT_TIME],
|
||||
sizeof(pb_battery_info[PB_BATT_TIME]), "unknown");
|
||||
sizeof(pb_battery_info[PB_BATT_TIME]), "%s", "unknown");
|
||||
} else if (timeval < 60 * 60) { /* don't show secs */
|
||||
format_seconds_short(pb_battery_info[PB_BATT_TIME],
|
||||
sizeof(pb_battery_info[PB_BATT_TIME]), timeval);
|
||||
@ -2371,16 +2371,16 @@ void print_disk_protect_queue(struct text_object *obj, char *p,
|
||||
snprintf(path, 127, "/sys/block/%s/queue/protect", obj->data.s);
|
||||
}
|
||||
if ((fp = fopen(path, "r")) == nullptr) {
|
||||
snprintf(p, p_max_size, "n/a ");
|
||||
snprintf(p, p_max_size, "%s", "n/a ");
|
||||
return;
|
||||
}
|
||||
if (fscanf(fp, "%d\n", &state) != 1) {
|
||||
fclose(fp);
|
||||
snprintf(p, p_max_size, "failed");
|
||||
snprintf(p, p_max_size, "%s", "failed");
|
||||
return;
|
||||
}
|
||||
fclose(fp);
|
||||
snprintf(p, p_max_size, (state > 0) ? "frozen" : "free ");
|
||||
snprintf(p, p_max_size, "%s", (state > 0) ? "frozen" : "free ");
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, bool> dev_list;
|
||||
@ -2454,7 +2454,7 @@ void print_distribution(struct text_object *obj, char *p, int p_max_size) {
|
||||
struct stat sb;
|
||||
|
||||
if (stat("/etc/arch-release", &sb) == 0) {
|
||||
snprintf(p, p_max_size, "Arch Linux");
|
||||
snprintf(p, p_max_size, "%s", "Arch Linux");
|
||||
return;
|
||||
}
|
||||
snprintf(p, p_max_size, "Unknown");
|
||||
|
@ -216,11 +216,11 @@ void llua_load(const char *script) {
|
||||
static const char *tokenize(const char *str, size_t *len) {
|
||||
str += *len;
|
||||
*len = 0;
|
||||
while ((str != nullptr) && (isspace(*str) != 0)) { ++str; }
|
||||
while ((str != nullptr) && (isspace((unsigned char)*str) != 0)) { ++str; }
|
||||
|
||||
size_t level = 0;
|
||||
while ((str != nullptr) && (str[*len] != 0) &&
|
||||
(level > 0 || (isspace(str[*len]) == 0))) {
|
||||
(level > 0 || (isspace((unsigned char)str[*len]) == 0))) {
|
||||
switch (str[*len]) {
|
||||
case '{':
|
||||
++level;
|
||||
|
@ -362,7 +362,7 @@ static void mbox_scan(char *args, char *output, size_t max_len) {
|
||||
from_width, curr->from, subject_width, curr->subject);
|
||||
}
|
||||
} else {
|
||||
snprintf(buf, text_buffer_size.get(*state), "\n");
|
||||
snprintf(buf, text_buffer_size.get(*state), "%s", "\n");
|
||||
}
|
||||
strncat(output, buf, max_len - strlen(output));
|
||||
|
||||
|
@ -131,7 +131,7 @@ void parse_net_stat_arg(struct text_object *obj, const char *arg,
|
||||
netstat = get_net_stat(nextarg, obj, free_at_crash);
|
||||
}
|
||||
i += strlen(nextarg); // skip this arg
|
||||
while (!((isspace(arg[i]) != 0) || arg[i] == 0)) {
|
||||
while (!((isspace((unsigned char)arg[i]) != 0) || arg[i] == 0)) {
|
||||
i++; // and skip the spaces in front of it
|
||||
}
|
||||
}
|
||||
@ -214,7 +214,7 @@ void print_addr(struct text_object *obj, char *p, int p_max_size) {
|
||||
|
||||
if ((ns->addr.sa_data[2] & 255) == 0 && (ns->addr.sa_data[3] & 255) == 0 &&
|
||||
(ns->addr.sa_data[4] & 255) == 0 && (ns->addr.sa_data[5] & 255) == 0) {
|
||||
snprintf(p, p_max_size, "No Address");
|
||||
snprintf(p, p_max_size, "%s", "No Address");
|
||||
} else {
|
||||
snprintf(p, p_max_size, "%u.%u.%u.%u", ns->addr.sa_data[2] & 255,
|
||||
ns->addr.sa_data[3] & 255, ns->addr.sa_data[4] & 255,
|
||||
@ -244,7 +244,7 @@ void print_v6addrs(struct text_object *obj, char *p, int p_max_size) {
|
||||
|
||||
if (p_max_size == 0) return;
|
||||
if (!ns->v6addrs) {
|
||||
snprintf(p, p_max_size, "No Address");
|
||||
snprintf(p, p_max_size, "%s", "No Address");
|
||||
return;
|
||||
}
|
||||
*p = 0;
|
||||
@ -348,7 +348,7 @@ void print_wireless_channel(struct text_object *obj, char *p, int p_max_size) {
|
||||
if (ns->channel != 0) {
|
||||
snprintf(p, p_max_size, "%i", ns->channel);
|
||||
} else {
|
||||
snprintf(p, p_max_size, "/");
|
||||
snprintf(p, p_max_size, "%s", "/");
|
||||
}
|
||||
}
|
||||
void print_wireless_frequency(struct text_object *obj, char *p,
|
||||
|
@ -950,7 +950,7 @@ void print_nvidia_value(struct text_object *obj, char *p, int p_max_size) {
|
||||
snprintf(p, p_max_size, "%s", str);
|
||||
free(str);
|
||||
} else {
|
||||
snprintf(p, p_max_size, "N/A");
|
||||
snprintf(p, p_max_size, "%s", "N/A");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -477,7 +477,7 @@ void update_obsd_sensors() {
|
||||
}
|
||||
|
||||
void parse_obsd_sensor(struct text_object *obj, const char *arg) {
|
||||
if (!isdigit(arg[0]) || atoi(&arg[0]) < 0 ||
|
||||
if (!isdigit((unsigned char)arg[0]) || atoi(&arg[0]) < 0 ||
|
||||
atoi(&arg[0]) > OBSD_MAX_SENSORS - 1) {
|
||||
obj->data.l = 0;
|
||||
NORM_ERR("Invalid sensor number!");
|
||||
@ -520,7 +520,7 @@ void get_obsd_vendor(struct text_object *obj, char *buf,
|
||||
|
||||
if (sysctl(mib, 2, vendor, &size, nullptr, 0) == -1) {
|
||||
NORM_ERR("error reading vendor");
|
||||
snprintf(buf, client_buffer_size, "unknown");
|
||||
snprintf(buf, client_buffer_size, "%s", "unknown");
|
||||
} else {
|
||||
snprintf(buf, client_buffer_size, "%s", vendor);
|
||||
}
|
||||
@ -540,7 +540,7 @@ void get_obsd_product(struct text_object *obj, char *buf,
|
||||
|
||||
if (sysctl(mib, 2, product, &size, nullptr, 0) == -1) {
|
||||
NORM_ERR("error reading product");
|
||||
snprintf(buf, client_buffer_size, "unknown");
|
||||
snprintf(buf, client_buffer_size, "%s", "unknown");
|
||||
} else {
|
||||
snprintf(buf, client_buffer_size, "%s", product);
|
||||
}
|
||||
|
@ -135,10 +135,10 @@ void print_tcp_ping(struct text_object *obj, char *p, int p_max_size) {
|
||||
usecdiff =
|
||||
((tv2.tv_sec - tv1.tv_sec) * 1000000) + tv2.tv_usec - tv1.tv_usec;
|
||||
if (usecdiff <= TCP_PING_TIMEOUT * 1000000) {
|
||||
snprintf(p, p_max_size, "%llu", usecdiff);
|
||||
snprintf(p, p_max_size, "%llu", (usecdiff / 1000U));
|
||||
} else {
|
||||
#define TCP_PING_FAILED "down"
|
||||
snprintf(p, p_max_size, TCP_PING_FAILED);
|
||||
snprintf(p, p_max_size, "%s", TCP_PING_FAILED);
|
||||
}
|
||||
} else {
|
||||
NORM_ERR("tcp_ping: Couldn't wait on the 'pong'");
|
||||
@ -169,7 +169,7 @@ void print_read_tcpip(struct text_object *obj, char *p, int p_max_size,
|
||||
hints.ai_socktype = protocol == IPPROTO_TCP ? SOCK_STREAM : SOCK_DGRAM;
|
||||
hints.ai_flags = 0;
|
||||
hints.ai_protocol = protocol;
|
||||
snprintf(portbuf, 8, "%d", rtd->port);
|
||||
snprintf(portbuf, 8, "%u", rtd->port);
|
||||
if (getaddrinfo(rtd->host, portbuf, &hints, &airesult) != 0) {
|
||||
NORM_ERR("%s: Problem with resolving the hostname",
|
||||
protocol == IPPROTO_TCP ? "read_tcp" : "read_udp");
|
||||
|
@ -212,7 +212,7 @@ void print_lines(struct text_object *obj, char *p, int p_max_size) {
|
||||
int j, lines;
|
||||
|
||||
if (fp == nullptr) {
|
||||
snprintf(p, p_max_size, "File Unreadable");
|
||||
snprintf(p, p_max_size, "%s", "File Unreadable");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -236,14 +236,14 @@ void print_words(struct text_object *obj, char *p, int p_max_size) {
|
||||
char inword = 0;
|
||||
|
||||
if (fp == nullptr) {
|
||||
snprintf(p, p_max_size, "File Unreadable");
|
||||
snprintf(p, p_max_size, "%s", "File Unreadable");
|
||||
return;
|
||||
}
|
||||
|
||||
words = 0;
|
||||
while (fgets(buf, BUFSZ, fp) != nullptr) {
|
||||
for (j = 0; buf[j] != 0; j++) {
|
||||
if (isspace(buf[j]) == 0) {
|
||||
if (isspace((unsigned char)buf[j]) == 0) {
|
||||
if (inword == 0) {
|
||||
words++;
|
||||
inword = 1;
|
||||
|
@ -133,14 +133,14 @@ void tcp_portmon_action(struct text_object *obj, char *p, int p_max_size) {
|
||||
find_tcp_port_monitor(pmc, pmd->port_range_begin, pmd->port_range_end);
|
||||
|
||||
if (!p_monitor) {
|
||||
snprintf(p, p_max_size, "monitor not found");
|
||||
snprintf(p, p_max_size, "%s", "monitor not found");
|
||||
return;
|
||||
}
|
||||
|
||||
/* now grab the text of interest */
|
||||
if (peek_tcp_port_monitor(p_monitor, pmd->item, pmd->connection_index, p,
|
||||
p_max_size) != 0) {
|
||||
snprintf(p, p_max_size, "monitor peek error");
|
||||
snprintf(p, p_max_size, "%s", "monitor peek error");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -184,7 +184,7 @@ char *find_and_replace_templates(const char *inbuf) {
|
||||
if (*(p + 1) == '{') {
|
||||
p += 2;
|
||||
templ = p;
|
||||
while ((*p != 0) && (isspace(*p) == 0) && *p != '{' && *p != '}') { p++; }
|
||||
while ((*p != 0) && (isspace((unsigned char)*p) == 0) && *p != '{' && *p != '}') { p++; }
|
||||
if (*p == '}') {
|
||||
args = nullptr;
|
||||
} else {
|
||||
@ -211,7 +211,7 @@ char *find_and_replace_templates(const char *inbuf) {
|
||||
} else {
|
||||
templ = p + 1;
|
||||
p += strlen("$template");
|
||||
while ((*p != 0) && (isdigit(*p) != 0)) { p++; }
|
||||
while ((*p != 0) && (isdigit((unsigned char)*p) != 0)) { p++; }
|
||||
args = nullptr;
|
||||
}
|
||||
tmpl_out = handle_template(templ, args);
|
||||
|
@ -343,7 +343,7 @@ void weather::parse_token(const char *token) {
|
||||
|
||||
// Check if token is a weather condition
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (!isalpha(token[i])) break;
|
||||
if (!isalpha((unsigned char)token[i])) break;
|
||||
}
|
||||
if (i == 2) {
|
||||
for (i = 0; i < NUM_WC_CODES; i++) {
|
||||
@ -369,7 +369,7 @@ void weather::parse_token(const char *token) {
|
||||
// Check if token is a modified weather condition
|
||||
if ((token[0] == '+') || (token[0] == '-')) {
|
||||
for (i = 1; i < 3; i++) {
|
||||
if (!isalpha(token[i])) break;
|
||||
if (!isalpha((unsigned char)token[i])) break;
|
||||
}
|
||||
if (i == 3) {
|
||||
for (i = 0; i < NUM_WC_CODES; i++) {
|
||||
@ -425,11 +425,11 @@ void weather::parse_token(const char *token) {
|
||||
|
||||
// Check if token is the temperature
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (!isdigit(token[i])) break;
|
||||
if (!isdigit((unsigned char)token[i])) break;
|
||||
}
|
||||
if ((i == 2) && (token[2] == '/')) {
|
||||
for (i = 3; i < 5; i++) {
|
||||
if (!isdigit(token[i])) break;
|
||||
if (!isdigit((unsigned char)token[i])) break;
|
||||
}
|
||||
if (i == 5) {
|
||||
// First 2 digits gives the air temperature
|
||||
@ -448,7 +448,7 @@ void weather::parse_token(const char *token) {
|
||||
// Check if token is the pressure
|
||||
if ((token[0] == 'Q') || (token[0] == 'A')) {
|
||||
for (i = 1; i < 5; i++) {
|
||||
if (!isdigit(token[i])) break;
|
||||
if (!isdigit((unsigned char)token[i])) break;
|
||||
}
|
||||
if (i == 5) {
|
||||
if (token[0] == 'A') {
|
||||
@ -484,11 +484,11 @@ void weather::parse_token(const char *token) {
|
||||
|
||||
// Check if token is the cloud cover
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (!isalpha(token[i])) break;
|
||||
if (!isalpha((unsigned char)token[i])) break;
|
||||
}
|
||||
if (i == 3) {
|
||||
for (i = 3; i < 6; i++) {
|
||||
if (!isdigit(token[i])) break;
|
||||
if (!isdigit((unsigned char)token[i])) break;
|
||||
}
|
||||
if (i == 6) {
|
||||
// Check if first 3 digits gives the cloud cover condition
|
||||
@ -504,11 +504,11 @@ void weather::parse_token(const char *token) {
|
||||
|
||||
// Check if token is positive temp and negative dew
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (!isdigit(token[i])) break;
|
||||
if (!isdigit((unsigned char)token[i])) break;
|
||||
}
|
||||
if ((i == 2) && (token[2] == '/') && (token[3] == 'M')) {
|
||||
for (i = 4; i < 6; i++) {
|
||||
if (!isdigit(token[i])) break;
|
||||
if (!isdigit((unsigned char)token[i])) break;
|
||||
}
|
||||
if (i == 6) {
|
||||
// 1st and 2nd digits gives the temperature
|
||||
@ -531,13 +531,13 @@ void weather::parse_token(const char *token) {
|
||||
|
||||
// Check if token is the observation time
|
||||
for (i = 0; i < 6; i++) {
|
||||
if (!isdigit(token[i])) break;
|
||||
if (!isdigit((unsigned char)token[i])) break;
|
||||
}
|
||||
if ((i == 6) && (token[6] == 'Z')) return;
|
||||
|
||||
// Check if token is the wind speed/direction in knots
|
||||
for (i = 0; i < 5; i++) {
|
||||
if (!isdigit(token[i])) break;
|
||||
if (!isdigit((unsigned char)token[i])) break;
|
||||
}
|
||||
if ((i == 5) && (token[5] == 'K') && (token[6] == 'T')) {
|
||||
// First 3 digits are wind direction
|
||||
@ -554,11 +554,11 @@ void weather::parse_token(const char *token) {
|
||||
// Check if token is negative temperature
|
||||
if ((token[0] == 'M') && (token[4] == 'M')) {
|
||||
for (i = 1; i < 3; i++) {
|
||||
if (!isdigit(token[i])) break;
|
||||
if (!isdigit((unsigned char)token[i])) break;
|
||||
}
|
||||
if ((i == 3) && (token[3] == '/')) {
|
||||
for (i = 5; i < 7; i++) {
|
||||
if (!isdigit(token[i])) break;
|
||||
if (!isdigit((unsigned char)token[i])) break;
|
||||
}
|
||||
if (i == 7) {
|
||||
// 2nd and 3rd digits gives the temperature
|
||||
@ -577,11 +577,11 @@ void weather::parse_token(const char *token) {
|
||||
|
||||
// Check if token is wind variability
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (!isdigit(token[i])) break;
|
||||
if (!isdigit((unsigned char)token[i])) break;
|
||||
}
|
||||
if ((i == 3) && (token[3] == 'V')) {
|
||||
for (i = 4; i < 7; i++) {
|
||||
if (!isdigit(token[i])) break;
|
||||
if (!isdigit((unsigned char)token[i])) break;
|
||||
}
|
||||
if (i == 7) return;
|
||||
}
|
||||
@ -593,7 +593,7 @@ void weather::parse_token(const char *token) {
|
||||
|
||||
// Check if token is the wind speed/direction in m/s
|
||||
for (i = 0; i < 5; i++) {
|
||||
if (!isdigit(token[i])) break;
|
||||
if (!isdigit((unsigned char)token[i])) break;
|
||||
}
|
||||
if ((i == 5) && (token[5] == 'M') && (token[6] == 'P') &&
|
||||
(token[7] == 'S')) {
|
||||
|
13
src/x11.cc
13
src/x11.cc
@ -1300,3 +1300,16 @@ void xpmdb_swap_buffers(void) {
|
||||
}
|
||||
}
|
||||
#endif /* BUILD_XDBE */
|
||||
|
||||
#define LOCK_TEMPLATE(func, num) \
|
||||
void print_##func(struct text_object *obj, char *p, int p_max_size) { \
|
||||
(void)obj; \
|
||||
XKeyboardState x; \
|
||||
XGetKeyboardControl(display, &x); \
|
||||
snprintf(p, p_max_size, "%s", (x.led_mask & num ? "On" : "Off")); \
|
||||
return; \
|
||||
}
|
||||
|
||||
LOCK_TEMPLATE(num_led, 2)
|
||||
LOCK_TEMPLATE(caps_led, 1)
|
||||
LOCK_TEMPLATE(scroll_led, 4)
|
||||
|
@ -115,6 +115,11 @@ void print_desktop(struct text_object *, char *, int);
|
||||
void print_desktop_number(struct text_object *, char *, int);
|
||||
void print_desktop_name(struct text_object *, char *, int);
|
||||
|
||||
/* Num lock, Scroll lock, Caps Lock */
|
||||
void print_num_led(struct text_object *, char *, int);
|
||||
void print_caps_led(struct text_object *, char *, int);
|
||||
void print_scroll_led(struct text_object *, char *, int);
|
||||
|
||||
#ifdef BUILD_XDBE
|
||||
void xdbe_swap_buffers(void);
|
||||
#else
|
||||
|
Loading…
x
Reference in New Issue
Block a user