Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

sysinfo.h File Reference


Detailed Description

System info (e.g., /proc formats, etc.) oriented os depenedent headers/macros are #included in this file.

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)


Define Documentation

#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);                                                  \
}

Aware 0.11.1 Copyright (C) 1998-2005 Russell Leighton (russ@elegant-software.com)