mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-18 11:05:18 +00:00
1ddb6a88b9
This depends on fopencookie, which is linux-specific. For BSD, there is a similar function called funopen, which can be used as a drop-in replacement.
34 lines
550 B
C
34 lines
550 B
C
#define _GNU_SOURCE
|
|
#include <stdio.h>
|
|
#include <sys/types.h>
|
|
#include "defconfig.h"
|
|
|
|
ssize_t conf_read(void *cookie, char *buf, size_t size)
|
|
{
|
|
static int col = 0, row = 0;
|
|
size_t i = 0;
|
|
const char *conf[] = defconfig;
|
|
|
|
(void)cookie;
|
|
|
|
while (i < size) {
|
|
if (!(conf[row])) /* end of rows */
|
|
break;
|
|
if (!(conf[row][col])) { /* end of line */
|
|
row++;
|
|
col = 0;
|
|
continue;
|
|
}
|
|
buf[i++] = conf[row][col++];
|
|
}
|
|
return i;
|
|
}
|
|
|
|
cookie_io_functions_t conf_cookie = {
|
|
.read = &conf_read,
|
|
.write = NULL,
|
|
.seek = NULL,
|
|
.close = NULL,
|
|
};
|
|
|