/* Sample client program using libargus. */ #include #include #include "libargus/libargus.h" 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; } /* Set up the shm. */ if (argus_shm_open(&ctx) < 0) { perror("argus_shm_open"); return EXIT_FAILURE; } /* 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; } /* 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]); } /* Close the shm. */ if (argus_shm_close(&ctx) < 0) { perror("argus_shm_close"); ret = EXIT_FAILURE; } return ret; } /* vim: set ts=4 sts=4 sw=4 tw=80 et: */