cake
/
p7utils
Archived
1
0
Fork 0
This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
p7utils/src/p7/list_devices.c

45 lines
1.3 KiB
C

/* ************************************************************************** */
/* _____ _ */
/* p7/list_devices.c |_ _|__ _ _| |__ ___ _ _ */
/* | Project: libp7 | |/ _ \| | | | '_ \ / _ \ | | | */
/* | | (_) | |_| | | | | __/ |_| | */
/* By: thomas <thomas@touhey.fr> |_|\___/ \__,_|_| |_|\___|\__, |.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);
}