2013-06-24 23:17:23 +00:00
|
|
|
/*
|
|
|
|
spacenavd - a free software replacement driver for 6dof space-mice.
|
2019-01-28 03:41:06 +00:00
|
|
|
Copyright (C) 2007-2019 John Tsiombikas <nuclear@member.fsf.org>
|
2013-06-24 23:17:23 +00:00
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2023-04-02 01:53:11 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2013-06-24 23:17:23 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2019-01-28 03:41:06 +00:00
|
|
|
#include <string.h>
|
2013-06-24 23:17:23 +00:00
|
|
|
#include "dev_usb.h"
|
2019-01-28 03:41:06 +00:00
|
|
|
#ifdef HAVE_ALLOCA_H
|
|
|
|
#include <alloca.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_MALLOC_H
|
|
|
|
#include <malloc.h>
|
|
|
|
#endif
|
|
|
|
#include "logger.h"
|
2013-06-24 23:17:23 +00:00
|
|
|
|
|
|
|
|
2022-01-28 18:09:01 +00:00
|
|
|
void free_usb_devices_list(struct usb_dev_info *list)
|
2013-06-24 23:17:23 +00:00
|
|
|
{
|
|
|
|
while(list) {
|
|
|
|
int i;
|
2022-01-28 18:09:01 +00:00
|
|
|
struct usb_dev_info *tmp = list;
|
2013-06-24 23:17:23 +00:00
|
|
|
list = list->next;
|
|
|
|
|
|
|
|
free(tmp->name);
|
|
|
|
for(i=0; i<tmp->num_devfiles; i++) {
|
|
|
|
free(tmp->devfiles[i]);
|
|
|
|
}
|
|
|
|
free(tmp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-28 18:09:01 +00:00
|
|
|
void print_usb_device_info(struct usb_dev_info *devinfo)
|
2013-06-24 23:17:23 +00:00
|
|
|
{
|
2019-01-28 03:41:06 +00:00
|
|
|
int i, sz = 64;
|
|
|
|
char *devname, *buf, *s;
|
2013-06-24 23:17:23 +00:00
|
|
|
|
2019-01-28 03:41:06 +00:00
|
|
|
devname = devinfo->name ? devinfo->name : "unknown";
|
|
|
|
sz += strlen(devname);
|
|
|
|
for(i=0; i<devinfo->num_devfiles; i++) {
|
|
|
|
sz += strlen(devinfo->devfiles[i]) + 1;
|
|
|
|
}
|
2013-06-24 23:17:23 +00:00
|
|
|
|
2019-01-28 03:41:06 +00:00
|
|
|
s = buf = alloca(sz);
|
|
|
|
s += sprintf(s, "[%x:%x]: \"%s\" (", devinfo->vendorid, devinfo->productid,
|
|
|
|
devinfo->name ? devinfo->name : "unknown");
|
2013-06-24 23:17:23 +00:00
|
|
|
for(i=0; i<devinfo->num_devfiles; i++) {
|
2019-01-28 03:41:06 +00:00
|
|
|
s += sprintf(s, "%s ", devinfo->devfiles[i]);
|
2013-06-24 23:17:23 +00:00
|
|
|
}
|
2019-01-28 03:41:06 +00:00
|
|
|
sprintf(s, ")\n");
|
|
|
|
|
|
|
|
logmsg(LOG_INFO, buf);
|
2013-06-24 23:17:23 +00:00
|
|
|
}
|