/* Sample client program using libargus. */ #include #include #include "libargus/libargus.h" /* Ideas: * * > Ncurses mode: * - Multicolumn display. * - SIGWINCH. * - Colors. :^) * - Minimum and maximum values. * - Jitter factor. (Running average of differential?) * - User input, such as reset, quit, and remove sensor. * - Activity meter, based on time of last update. * * > Command-line mode: * - Parameter to specify name of argusd socket. * - Option to suppress sensor names. * - List of sensor names on command line. * */ int main(int argc, char** argv) { int i, width; int ret = EXIT_SUCCESS; argus_t ctx; /* Connect to the argusd server. */ if (argus_connect(&ctx, NULL, "/tmp/argusd") < 0) { perror("argus_connect"); return EXIT_FAILURE; } /* Monitor all sensors. */ if (argus_listen(&ctx, ctx.sensor_names_all, ctx.sensor_count_all, NULL) < 0) { perror("argus_listen"); ret = EXIT_FAILURE; goto error; } /* Determine the width of the longest sensor name. */ for (i = width = 0; i < ctx.sensor_count; ++i) { int len = strlen(ctx.sensor_names[i]); if (width < len) width = len; } /* Get current values for sensors. */ if (argus_loop_next(&ctx, -1) < 0) { perror("argus_loop_next"); ret = EXIT_FAILURE; goto error; } /* Display current values for all sensors. */ for (i = 0; i < ctx.sensor_count; ++i) { printf("%-*s : %3d\n", width, ctx.sensor_names[i], ctx.sensor_values[i]); } error: /* Disconnect from the argusd server. */ if (argus_disconnect(&ctx) < 0) { perror("argus_disconnect"); ret = EXIT_FAILURE; } return ret; } /* vim: set ts=4 sts=4 sw=4 tw=80 et: */