Note: borrowed (and mangled) code for reading some /proc entries
Go to the source code of this file.
Defines | |
| #define | PROC_FILE_TO_BUF(buf, bufsize, FILE, logger) |
|
|
Value: { \
int32_t i, n, fd; \
if ( (fd = open(FILE, O_RDONLY)) == -1) { \
aw_log(logger, AW_ERROR_LOG_LEVEL, "Cannot open %s: %s",\
FILE, strerror(errno)); \
n=0; \
goto _done_f2b; \
} \
if ((n = read(fd, buf, bufsize - 1)) < 0) { \
aw_log(logger, AW_ERROR_LOG_LEVEL, "Cannot read %s: %s",\
FILE, strerror(errno)); \
n=0; \
goto _done_f2b; \
} \
_done_f2b:; \
buf[n] = '\0'; \
/* in case file has more than 1 string nulls */ \
for(i=0; i<n; i++) { if ( buf[i] == '\0' ) buf[i] = ' ' ; } \
close(fd); \
}
|