- foutput = stderr;
- dpy = XOpenDisplay(0x0);
-
- ARGBEGIN {
- case 'd':
- dflag = 1;
- break;
- case 'l':
- strlcpy(logpath, EARGF(usage()), sizeof(logpath)-1);
- logpath[strlen(logpath)+1] = '\0';
- foutput = fopen(logpath, "a");
- if (foutput == NULL) {
- fprintf(stderr, "failed to open log file at %s: %s\n",
- logpath, strerror(errno));
- return (1);
- }
- lflag = 1;
- break;
- default:
- usage();
- } ARGEND
-
- if (dflag && !lflag) {
- ccat(2, getenv("HOME"), "/.slstatus_log");
- foutput = fopen(concat, "a");
- if (foutput == NULL) {
- fprintf(stderr, "failed to open log file at %s: %s\n",
- logpath, strerror(errno));
- return (1);
+ stderr = stderr;
+ dpy = XOpenDisplay(NULL);
+
+ memset(status_string, 0, sizeof(status_string));
+ for (i = 0; i < sizeof(args) / sizeof(args[0]); ++i) {
+ argument = args[i];
+ if (argument.args == NULL)
+ res = argument.func();
+ else
+ res = argument.func(argument.args);
+ element = smprintf(argument.format, res);
+ if (element == NULL) {
+ element = smprintf(UNKNOWN_STR);
+ fprintf(stderr, "Failed to format output.\n");