Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 360849 | Differences between
and this patch

Collapse All | Expand All

(-)file_not_specified_in_diff (-11 / +47 lines)
Line  Link Here
0
-- a/extras/usb-db/usb-db.c
0
++ b/extras/usb-db/usb-db.c
Lines 90-108 Link Here
90
#define HEXCHARS "0123456789abcdefABCDEF"
90
#define HEXCHARS "0123456789abcdefABCDEF"
91
#define WHITESPACE " \t\n\r"
91
#define WHITESPACE " \t\n\r"
92
92
93
#ifdef USE_ZLIB
94
95
#include <zlib.h>
96
97
static ssize_t gz_getline(char **lineptr, size_t *n, void *stream)
98
{
99
	if (!*lineptr)
100
		*lineptr = malloc(*n = 4096);
101
	if (!*lineptr)
102
		return -1;
103
	if (gzgets(stream, *lineptr, *n - 1)) {
104
		(*lineptr)[*n - 1] = '\0';
105
		/* should return strlen(*lineptr), but caller doesn't care */
106
		return 0;
107
	}
108
	return -1;
109
}
110
static int gz_fclose(void *stream)
111
{
112
	return gzclose(stream);
113
}
114
115
static ssize_t stdio_getline(char **lineptr, size_t *n, void *stream)
116
{
117
	return getline(lineptr, n, stream);
118
}
119
static int stdio_fclose(void *stream)
120
{
121
	return fclose(stream);
122
}
123
124
#endif
125
93
static int lookup_vid_pid(
126
static int lookup_vid_pid(
94
	uint16_t vid,
127
	uint16_t vid,
95
	uint16_t pid,
128
	uint16_t pid,
96
	char **vendor,
129
	char **vendor,
97
	char **product) {
130
	char **product) {
98
131
99
	FILE *f;
132
	void *f;
100
	int ret = -1;
133
	int ret = -1;
101
	int found_vendor = 0;
134
	int found_vendor = 0;
102
	char *line = NULL;
135
	char *line = NULL;
103
136
104
	*vendor = *product = NULL;
137
	*vendor = *product = NULL;
105
138
139
#ifdef USE_ZLIB
140
	ssize_t (*getline)(char **lineptr, size_t *n, void *stream) = stdio_getline;
141
	int (*fclose)(void *stream) = stdio_fclose;
142
	if ((f = gzopen(DATABASE ".gz", "r"))) {
143
		getline = gz_getline;
144
		fclose = gz_fclose;
145
	} else
146
#endif
106
	if (!(f = fopen(DATABASE, "r"))) {
147
	if (!(f = fopen(DATABASE, "r"))) {
107
		fprintf(stderr, "Failed to open database file "DATABASE": %s\n", strerror(errno));
148
		fprintf(stderr, "Failed to open database file "DATABASE": %s\n", strerror(errno));
108
		return -1;
149
		return -1;
Lines 111-121 Link Here
111
	for (;;) {
152
	for (;;) {
112
		size_t n;
153
		size_t n;
113
154
114
		if (line) {
115
			free(line);
116
			line = NULL;
117
		}
118
119
		if (getline(&line, &n, f) < 0)
155
		if (getline(&line, &n, f) < 0)
120
			break;
156
			break;
121
157
122
-- a/Makefile.in
158
++ b/Makefile.in
Lines 987-993 Link Here
987
# ------------------------------------------------------------------------------
987
# ------------------------------------------------------------------------------
988
@ENABLE_HWDB_TRUE@extras_usb_db_usb_db_SOURCES = extras/usb-db/usb-db.c
988
@ENABLE_HWDB_TRUE@extras_usb_db_usb_db_SOURCES = extras/usb-db/usb-db.c
989
@ENABLE_HWDB_TRUE@extras_usb_db_usb_db_CPPFLAGS = $(AM_CPPFLAGS) -DUSB_DATABASE=\"$(USB_DATABASE)\" -DBUILD_FOR_USB
989
@ENABLE_HWDB_TRUE@extras_usb_db_usb_db_CPPFLAGS = $(AM_CPPFLAGS) -DUSB_DATABASE=\"$(USB_DATABASE)\" -DBUILD_FOR_USB -DUSE_ZLIB
990
@ENABLE_HWDB_TRUE@extras_usb_db_usb_db_LDADD = libudev/libudev-private.la
990
@ENABLE_HWDB_TRUE@extras_usb_db_usb_db_LDADD = libudev/libudev-private.la -lz
991
@ENABLE_HWDB_TRUE@extras_usb_db_pci_db_SOURCES = extras/usb-db/usb-db.c
991
@ENABLE_HWDB_TRUE@extras_usb_db_pci_db_SOURCES = extras/usb-db/usb-db.c
992
@ENABLE_HWDB_TRUE@extras_usb_db_pci_db_CPPFLAGS = $(AM_CPPFLAGS) -DPCI_DATABASE=\"$(PCI_DATABASE)\" -DBUILD_FOR_PCI
992
@ENABLE_HWDB_TRUE@extras_usb_db_pci_db_CPPFLAGS = $(AM_CPPFLAGS) -DPCI_DATABASE=\"$(PCI_DATABASE)\" -DBUILD_FOR_PCI -DUSE_ZLIB
993
@ENABLE_HWDB_TRUE@extras_usb_db_pci_db_LDADD = libudev/libudev-private.la
993
@ENABLE_HWDB_TRUE@extras_usb_db_pci_db_LDADD = libudev/libudev-private.la

Return to bug 360849