]> infiniteadaptability.org Git - cold/commitdiff
...
authoralex <[email protected]>
Thu, 12 May 2022 06:04:58 +0000 (23:04 -0700)
committeralex <[email protected]>
Thu, 12 May 2022 06:04:58 +0000 (23:04 -0700)
Makefile.am
configure.ac
inc/main.h
src/main.c

index c69add98e9457955d8dfc8d2afeefd3bc921ea1b..1634c27894950e310d996d20d14a307121a2ed7e 100644 (file)
@@ -2,6 +2,12 @@ AM_CPPFLAGS = \
        -Wall \
        -Werror
 
+if ENABLE_DEBUG
+else
+AM_CPPFLAGS += \
+       -DNDEBUG
+endif
+
 bin_PROGRAMS = cold
 
 cold_SOURCES = \
index c486633d732c85e34dfbb247d1ef85e0c87c0f28..82d2bd2fa2767693a32b17bb9eb97c0e31ec9946 100644 (file)
@@ -9,6 +9,47 @@ AM_INIT_AUTOMAKE([foreign subdir-objects -Wall -Werror])
 AC_CONFIG_SRCDIR([src/main.c])
 AC_CONFIG_HEADERS([inc/config.h])
 
+AC_ARG_ENABLE([debug],
+  [AS_HELP_STRING([--enable-debug],
+  [enable debugging])],
+  [enable_debug=$enableval],
+  [enable_debug=no])
+
+AC_ARG_ENABLE([memcheck],
+  [AS_HELP_STRING([--disable-memcheck],
+  [disable memcheck with valgrind (enabled by default)])],
+  [enable_memcheck=$enableval],
+  [enable_memcheck=yes])
+
+AC_PATH_PROG([VALGRIND], [valgrind])
+AM_CONDITIONAL([HAVE_VALGRIND], [test -n "$VALGRIND"])
+
+AC_MSG_CHECKING([if debugging])
+if test x$enable_debug != xno; then
+       AC_MSG_RESULT(yes)
+       CFLAGS="-ggdb3 -O0"
+else
+       AC_MSG_RESULT(no)
+fi
+
+AM_CONDITIONAL([ENABLE_DEBUG],[test x$enable_debug != xno])
+
+dnl disable memcheck if valgrind not found
+if test "x$enable_memcheck" != "xno"; then
+  if test -z "$VALGRIND"; then
+    enable_memcheck=no
+  fi
+fi
+
+AC_MSG_CHECKING([if memcheck should be enabled])
+if test x$enable_memcheck != xno; then
+  AC_MSG_RESULT(yes)
+else
+  AC_MSG_RESULT(no)
+fi
+
+AM_CONDITIONAL([ENABLE_MEMCHECK],[test x$enable_memcheck = xyes])
+
 # Checks for programs.
 AC_PROG_CC
 
index b073e2dd84225cb03a01498b4801a435b8a028be..b3ec90b8aa7f5c800aff587f0323b0843d0a89ab 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef __MAIN_H_
 #define __MAIN_H_
 
+#include<stdio.h>
 #include<stdlib.h>
 
 #include<libudev.h>
index c38e52ad09b6cf156b441cba339e1dc10bf5f787..3eeea7ed4e66d7024ff2f2267b6379184d3a5c10 100644 (file)
@@ -1,10 +1,29 @@
 #include<main.h>
 
 int main(int argc, char **argv) {
-       struct udev *monitor;
+       struct udev *monitor; //, *dev;
+       struct udev_enumerate *enumerate;
+       struct udev_list_entry *devices, *dev_list_entry;
+       const char *path;
 
        monitor = udev_new();
        if(NULL==monitor) { return EXIT_FAILURE; }
+       
+       enumerate = udev_enumerate_new(monitor);
+
+       udev_enumerate_add_match_subsystem(enumerate, "usb");
+       udev_enumerate_add_nomatch_sysattr(enumerate, "bDeviceClass", "09");
+       udev_enumerate_add_nomatch_sysattr(enumerate, "bInterfaceNumber", NULL);
+       udev_enumerate_scan_devices(enumerate);
+       
+       devices = udev_enumerate_get_list_entry(enumerate);
+       
+       udev_list_entry_foreach(dev_list_entry, devices) {
+               path = udev_list_entry_get_name(dev_list_entry);
+//             dev = udev_device_new_from_syspath(monitor, path);
+
+               printf("found: %s\n",path);
+       }
 
        udev_unref(monitor);