/* ************************************************************************** */ /* _____ _ */ /* p7/list_devices.c |_ _|__ _ _| |__ ___ _ _ */ /* | Project: libp7 | |/ _ \| | | | '_ \ / _ \ | | | */ /* | | (_) | |_| | | | | __/ |_| | */ /* By: thomas |_|\___/ \__,_|_| |_|\___|\__, |.fr */ /* Last updated: 2017/02/09 17:55:40 |___/ */ /* */ /* ************************************************************************** */ #include "main.h" /** * list_a_device: * List one serial device. * * @arg cookie the cookie (unused) * @arg path the path. */ static int initialized = 0; static void list_a_device(void *cookie, const char *path) { (void)cookie; if (!initialized) { printf("Available devices:\n"); initialized = 1; } printf("- %s\n", path); } /** * list_devices: * List serial devices. * * @return the program return code. */ int list_devices(void) { p7_comlist(list_a_device, NULL); if (!initialized) fprintf(stderr, "Could not find any devices.\n"); return (0); }