return;
client_close(stat_task->pcd);
stat_task->pcd = NULL;
- for (i = 0; i < NUM_STAT_ITEMS; i++) {
+ FOR_EACH_STATUS_ITEM(i) {
free(stat_task->stat_item_values[i]);
stat_task->stat_item_values[i] = NULL;
}
goto out;
free(df);
}
-
- for (i = 0; i < NUM_STAT_ITEMS; i++) {
+ FOR_EACH_STATUS_ITEM(i) {
char *tmp, *v;
if (!((1 << i) & mask))
continue;
{
int i;
- FOR_EACH_STAT_ITEM(i) {
+ FOR_EACH_STATUS_ITEM(i) {
char *tmp = make_message("%s:\n", status_item_list[i]);
stat_client_write(tmp, i);
free(tmp);
if (!curses_active)
return;
- for (i = 0; i < NUM_STAT_ITEMS; i++)
+ FOR_EACH_STATUS_ITEM(i)
print_stat_item(i);
}
+
static void clear_all_items(void)
{
int i;
- for (i = 0; i < NUM_STAT_ITEMS; i++) {
+ FOR_EACH_STATUS_ITEM(i) {
free(stat_content[i]);
stat_content[i] = para_strdup("");
}
if (!has_colors())
msg_n_exit(EXIT_FAILURE, "Error: No color term\n");
start_color();
- for (i = 0; i < NUM_STAT_ITEMS; i++)
+ FOR_EACH_STATUS_ITEM(i)
if (theme.data[i].len)
init_pair(i + 1, theme.data[i].fg, theme.data[i].bg);
init_pair(COLOR_STATUSBAR, theme.sb_fg, theme.sb_bg);
void init_theme(int num, struct gui_theme *t)
{
int i;
-
- for (i = 0; i < NUM_STAT_ITEMS; i++)
+ FOR_EACH_STATUS_ITEM(i)
t->data[i].len = 0;
current_theme_num = num;
struct timeval *result);
void ms2tv(const long unsigned n, struct timeval *tv);
+/** The enum of all status items. */
enum status_items {STATUS_ITEM_ENUM NUM_STAT_ITEMS};
extern const char *status_item_list[];
-
+/** Loop over each status item. */
+#define FOR_EACH_STATUS_ITEM(i) for (i = 0; i < NUM_STAT_ITEMS; i++)
int stat_item_valid(const char *item);
int stat_line_valid(const char *);
void stat_client_write(const char *msg, int itemnum);
int stat_client_add(int fd, long unsigned mask);
-/** Loop over each status item. */
-#define FOR_EACH_STAT_ITEM(i) for (i = 0; i < NUM_STAT_ITEMS; i++)
__printf_2_3 void para_log(int, const char*, ...);
PARA_ERROR_LOG("%s\n", "no item");
return -E_UNKNOWN_STAT_ITEM;
}
- FOR_EACH_STAT_ITEM(i)
+ FOR_EACH_STATUS_ITEM(i)
if (!strcmp(status_item_list[i], item))
return i;
PARA_ERROR_LOG("invalid stat item: %s\n", item);
if (!line || !*line)
return -E_UNKNOWN_STAT_ITEM;
line_len = strlen(line);
- FOR_EACH_STAT_ITEM(i) {
+ FOR_EACH_STATUS_ITEM(i) {
const char *s = status_item_list[i];
size_t item_len = strlen(s);