kee

Offline IOU signer with QR as transport
git clone https://holbrook.no/src/kee
Info | Log | Files | Refs | README | LICENSE

commit 72622792a915772e966930afec67527f5f9eb3ac
parent 61c2d914e23bba50107a3d78db1c5124d5b79f7b
Author: lash <dev@holbrook.no>
Date:   Tue, 30 Apr 2024 19:04:04 +0100

Use dir scanning to handle gaps in vid dev names

Diffstat:
Msrc/camera.c | 20+++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/camera.c b/src/camera.c @@ -4,6 +4,8 @@ #include <fcntl.h> #include <sys/ioctl.h> #include <linux/videodev2.h> +#include <dirent.h> +#include <sys/types.h> #include "err.h" #include "debug.h" @@ -19,13 +21,28 @@ int kee_camera_scan(struct kee_camera_devices *devices) { struct kee_camera_devices *p; struct v4l2_capability video_cap; char s[1024]; + struct dirent *de; + DIR *d; p = devices; memset(p, 0, sizeof(struct kee_camera_devices)); devnum = 0; + d = opendir("/dev"); while (1) { + strcpy(p->path, "/dev/"); + de = readdir(d); + if (de == NULL) { + break; + } + if (strlen(de->d_name) < 6) { + continue; + } + if (memcmp(de->d_name, "video", 5)) { + continue; + } //sprintf(dev.path, KEE_VIDEO_DEVICE_TEMPLATE, devnum); - sprintf(p->path, "/dev/video%d", devnum); + //sprintf(p->path, "/dev/video%d", devnum); + strcpy(p->path + 5, de->d_name); fd = open(p->path, O_RDONLY); if (fd < 0) { p->path[0] = 0; @@ -55,6 +72,7 @@ int kee_camera_scan(struct kee_camera_devices *devices) { p = p->next; devnum++; } + closedir(d); return ERR_OK; }