Skip to content

Commit bc5edf5

Browse files
committed
v1.1
1 parent 6bfe1ee commit bc5edf5

20 files changed

Lines changed: 2636 additions & 2469 deletions

CHANGELOG

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Author: ColumPaget <colums.projects@gmail.com>
2+
Date: Sun Mar 16 16:21:32 2025 +0000
3+
4+
v1.1 (2025-03-17)
5+
* Added LICENSE
6+
* Fix issue with building without system wide libUseful
7+
* Add support for displaying inputXX devices
8+
9+
v1.0 (2025-03-16)
10+
*¬nitial release
11+

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
OBJ=common.o command-line.o display.o usb.o scsi.o pci.o pci_id.o
2-
FLAGS=-g -DPACKAGE_NAME=\"devlist\" -DPACKAGE_TARNAME=\"devlist\" -DPACKAGE_VERSION=\"1.0\" -DPACKAGE_STRING=\"devlist\ 1.0\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -D_FILE_OFFSET_BITS=64 -DHAVE_LIBZ=1 -DHAVE_LIBCAP=1 -DHAVE_LIBCRYPTO=1 -DHAVE_LIBSSL=1 -DHAVE_PROMPT_HISTORY=\"Y\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_LIBUSEFUL_5_LIBUSEFUL_H=1 -DHAVE_LIBUSEFUL_5=1 -DHAVE_LIBUSEFUL_5=1
2+
FLAGS=-g -DPACKAGE_NAME=\"devlist\" -DPACKAGE_TARNAME=\"devlist\" -DPACKAGE_VERSION=\"1.0\" -DPACKAGE_STRING=\"devlist\ 1.0\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -D_FILE_OFFSET_BITS=64 -DHAVE_LIBZ=1 -DHAVE_LIBCAP=1 -DHAVE_LIBCRYPTO=1 -DHAVE_LIBSSL=1 -DHAVE_PROMPT_HISTORY=\"Y\" -DHAVE_STDIO_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_UNISTD_H=1 -DSTDC_HEADERS=1 -DHAVE_LIBUSEFUL_5_LIBUSEFUL_H=1 -DHAVE_LIBUSEFUL_5=1 -DHAVE_LIBUSEFUL_5=1
33
LIBS=-lUseful-5 -lUseful-5 -lssl -lcrypto -lcap -lz
44
LIBUSEFUL_BUNDLED=
55

66
all: $(OBJ)
7-
gcc $(FLAGS) -o devlist main.c $(OBJ) $(LIBS) $(LIBUSEFUL_BUNDLED)
7+
gcc $(FLAGS) -o devlist main.c $(OBJ) $(LIBUSEFUL_BUNDLED) $(LIBS)
88

99
libUseful-bundled/libUseful.a:
1010
$(MAKE) -C libUseful-bundled

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,8 @@ The pci.ids file is required to look up pci device names. It should be preinstal
6767

6868
If your pci.ids file is stored in an unusual place then you can use the '-I' flag to provide the path to it.
6969

70+
71+
SCREENSHOT
72+
==========
73+
74+
![devlist screenshot](devlist.png)

command-line.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@
33

44
void PrintHelp()
55
{
6-
printf("usage: devlist <options>\n");
7-
printf("options:\n");
8-
printf(" -pci - print PCI devices only\n");
9-
printf(" -usb - print USB devices only\n");
10-
printf(" -scsi - print SCSI devices only\n");
11-
printf(" -I <path> - path to pci.ids file if not in standard places\n");
12-
printf(" -? - print this help\n");
13-
printf(" -help - print this help\n");
14-
printf(" --help - print this help\n");
15-
printf(" --version - print version\n");
16-
printf("the default behavior is to print all device types\n");
17-
18-
exit(0);
6+
printf("usage: devlist <options>\n");
7+
printf("options:\n");
8+
printf(" -pci - print PCI devices only\n");
9+
printf(" -usb - print USB devices only\n");
10+
printf(" -scsi - print SCSI devices only\n");
11+
printf(" -I <path> - path to pci.ids file if not in standard places\n");
12+
printf(" -? - print this help\n");
13+
printf(" -help - print this help\n");
14+
printf(" --help - print this help\n");
15+
printf(" --version - print version\n");
16+
printf("the default behavior is to print all device types\n");
17+
18+
exit(0);
1919
}
2020

2121
void PrintVersion()
2222
{
23-
printf("devlist version: %s\n\n", VERSION);
24-
exit(0);
23+
printf("devlist version: %s\n\n", VERSION);
24+
exit(0);
2525
}
2626

2727
int ParseCommandLine(int argc, char *argv[])
@@ -37,7 +37,7 @@ int ParseCommandLine(int argc, char *argv[])
3737
if (strcasecmp(ptr, "-pci")==0) Flags |= SHOW_BUS_PCI;
3838
else if (strcasecmp(ptr, "-usb")==0) Flags |= SHOW_BUS_USB;
3939
else if (strcasecmp(ptr, "-scsi")==0) Flags |= SHOW_BUS_SCSI;
40-
else if (strcasecmp(ptr, "-I")==0) PciIDsFile=CopyStr(PciIDsFile, CommandLineNext(Cmd));
40+
else if (strcasecmp(ptr, "-I")==0) PciIDsFile=CopyStr(PciIDsFile, CommandLineNext(Cmd));
4141
else if (strcasecmp(ptr, "-?")==0) PrintHelp();
4242
else if (strcasecmp(ptr, "-help")==0) PrintHelp();
4343
else if (strcasecmp(ptr, "--help")==0) PrintHelp();
@@ -46,9 +46,9 @@ int ParseCommandLine(int argc, char *argv[])
4646
ptr=CommandLineNext(Cmd);
4747
}
4848

49-
//SHOW_BUS_ALL includes all the 'SHOW_BUS' flags, so
50-
//this will only happen if none of them are set, which
49+
//SHOW_BUS_ALL includes all the 'SHOW_BUS' flags, so
50+
//this will only happen if none of them are set, which
5151
//is the default 'show all' condition
52-
if (! (Flags & SHOW_BUS_ALL)) Flags |= SHOW_BUS_ALL;
52+
if (! (Flags & SHOW_BUS_ALL)) Flags |= SHOW_BUS_ALL;
5353
return(Flags);
5454
}

common.c

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -52,37 +52,46 @@ uint64_t ReadUint64File(const char *Dir, const char *File)
5252
}
5353

5454

55-
char *LookupDevNode(char *RetStr, const char *Path, const char *SubDir)
55+
char *LookupDevNode(char *RetStr, const char *Path, const char *SubDir, const char *PostFix)
5656
{
57-
char *Tempstr=NULL;
58-
glob_t Glob;
57+
char *Tempstr=NULL;
58+
glob_t Glob;
5959

60-
RetStr=CopyStr(RetStr, "");
61-
Tempstr=MCopyStr(Tempstr, Path, "/", SubDir, "/*", NULL);
60+
RetStr=CopyStr(RetStr, "");
61+
Tempstr=MCopyStr(Tempstr, Path, "/", SubDir, "/", PostFix, NULL);
6262
glob(Tempstr, 0, 0, &Glob);
6363
if (Glob.gl_pathc > 0)
6464
{
65-
RetStr=CopyStr(RetStr, GetBasename(Glob.gl_pathv[0]));
66-
StripTrailingWhitespace(RetStr);
67-
globfree(&Glob);
65+
RetStr=CopyStr(RetStr, GetBasename(Glob.gl_pathv[0]));
66+
StripTrailingWhitespace(RetStr);
67+
globfree(&Glob);
6868
}
6969

70-
Destroy(Tempstr);
70+
Destroy(Tempstr);
7171

72-
return(RetStr);
72+
return(RetStr);
7373
}
7474

7575

7676
void LookupAnyDevNode(TDevice *dev, const char *Path)
7777
{
78-
if (! StrValid(dev->DevNode)) dev->DevNode=LookupDevNode(dev->DevNode, Path, "block");
79-
if (! StrValid(dev->DevNode)) dev->DevNode=LookupDevNode(dev->DevNode, Path, "net");
80-
if (! StrValid(dev->DevNode)) dev->DevNode=LookupDevNode(dev->DevNode, Path, "bluetooth");
81-
if (! StrValid(dev->DevNode)) dev->DevNode=LookupDevNode(dev->DevNode, Path, "tty");
82-
if (! StrValid(dev->DevNode)) dev->DevNode=LookupDevNode(dev->DevNode, Path, "input");
83-
if (! StrValid(dev->DevNode)) dev->DevNode=LookupDevNode(dev->DevNode, Path, "sound");
84-
if (! StrValid(dev->DevNode)) dev->DevNode=LookupDevNode(dev->DevNode, Path, "graphics");
85-
if (! StrValid(dev->DevNode)) dev->DevNode=LookupDevNode(dev->DevNode, Path, "hwmon");
78+
char *Tempstr=NULL;
79+
80+
if (! StrValid(dev->DevNode)) dev->DevNode=LookupDevNode(dev->DevNode, Path, "block","*");
81+
if (! StrValid(dev->DevNode)) dev->DevNode=LookupDevNode(dev->DevNode, Path, "net","*");
82+
if (! StrValid(dev->DevNode)) dev->DevNode=LookupDevNode(dev->DevNode, Path, "bluetooth","*");
83+
if (! StrValid(dev->DevNode)) dev->DevNode=LookupDevNode(dev->DevNode, Path, "tty","*");
84+
if (! StrValid(dev->DevNode)) dev->DevNode=LookupDevNode(dev->DevNode, Path, "sound","*");
85+
if (! StrValid(dev->DevNode)) dev->DevNode=LookupDevNode(dev->DevNode, Path, "graphics","*");
86+
if (! StrValid(dev->DevNode)) dev->DevNode=LookupDevNode(dev->DevNode, Path, "hwmon","*");
87+
if (! StrValid(dev->DevNode)) dev->DevNode=LookupDevNode(dev->DevNode, Path, "input", "*/event*");
88+
if (! StrValid(dev->DevNode))
89+
{
90+
Tempstr=MCopyStr(Tempstr, Path, "/*/*/", NULL);
91+
dev->DevNode=LookupDevNode(dev->DevNode, Tempstr, "input", "*/event*");
92+
}
93+
94+
Destroy(Tempstr);
8695
}
8796

8897

common.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
#ifndef DEVLIST_COMMON_H
22
#define DEVLIST_COMMON_H
33

4+
#ifdef USE_LIBUSEFUL_BUNDLED
5+
#include "libUseful-bundled/libUseful.h"
6+
#else
47
#include "libUseful-5/libUseful.h"
8+
#endif
9+
10+
511
#include <glob.h>
612

713

814
#define FLAG_REMOVABLE 1
915
#define FLAG_READONLY 2
1016

11-
#define VERSION "1.0"
17+
#define VERSION "1.1"
1218

1319
extern char *PciIDsFile;
1420
extern char *PciIDsDirs;
@@ -37,7 +43,7 @@ typedef struct
3743
char *ReadFile(char *RetStr, const char *Dir, const char *File);
3844
int ReadIntegerFile(const char *Dir, const char *File);
3945
uint64_t ReadUint64File(const char *Dir, const char *File);
40-
char *LookupDevNode(char *RetStr, const char *Path, const char *SubDir);
46+
char *LookupDevNode(char *RetStr, const char *Path, const char *SubDir, const char *PostFix);
4147
void LookupAnyDevNode(TDevice *dev, const char *Path);
4248
void TDeviceDestroy(void *p_Dev);
4349

0 commit comments

Comments
 (0)