bar.c (462B)
1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 #include <unistd.h> 5 6 #include "config.h" 7 #define LEN(x) sizeof(x) / sizeof(x[0]) 8 9 char * 10 update_bar() { 11 static char bar[MAXBAR] = { 0 }; 12 int off = 0; 13 for (int i = 0; i < LEN(entrys); i++) 14 off += snprintf(bar + off, MAXBAR - off, "%s%s%s", 15 (i == 0) ? "" : SEP, 16 entrys[i].func(), 17 (i != LEN(entrys)) ? "" : SEP 18 ); 19 return bar; 20 } 21 22 int 23 main() { 24 printf("%s\n", update_bar()); 25 }