static char * find_trackpoint_sysfs_path (InputInfoPtr local, const char *base_path) { struct dirent **seriolist; int i = 0, n; char *serio_path = NULL; n = scandir(base_path, &seriolist, serio_filter, alphasort); if (n < 0) return NULL; while (i < n) { char path[4096]; snprintf(path, sizeof(path), "%s/%s", base_path, seriolist[i]->d_name); if (find_sensitivity(path) && check_device_name(local, path)) { serio_path = strdup(path); break; } else { serio_path = find_trackpoint_sysfs_path(local, path); if (serio_path) break; } i++; } while (n--) free(seriolist[n]); free(seriolist); return serio_path; }
int tunemu_open(tunemu_device device) { int ppp_unit_number = -1; if (device[0] != 0) { if (check_device_name(device) < 0) { tun_error("invalid device name \"%s\"", device); return -1; } ppp_unit_number = atoi(device + 3); } int ppp_unit_fd = ppp_new_unit(&ppp_unit_number); if (ppp_unit_fd < 0) return -1; if (ppp_setup_unit(ppp_unit_fd) < 0) { close(ppp_unit_fd); return -1; } if (open_pcap() < 0) { close(ppp_unit_fd); return -1; } make_device_name(device, ppp_unit_number); return ppp_unit_fd; }