sysinfo: Make libpci an optional dependency
This commit is contained in:
parent
47b653cc7c
commit
3e53635dfb
|
@ -19,14 +19,17 @@ if system == 'linux' or system == 'darwin'
|
||||||
]
|
]
|
||||||
|
|
||||||
if system == 'linux'
|
if system == 'linux'
|
||||||
libpci = dependency('libpci')
|
libpci = dependency('libpci', required: false)
|
||||||
sysinfo_deps += libpci
|
if libpci.found()
|
||||||
|
sysinfo_deps += libpci
|
||||||
|
sysinfo_cargs += '-DHAVE_LIBPCI'
|
||||||
|
sysinfo_sources += 'unix/pci.c'
|
||||||
|
endif
|
||||||
sysinfo_includes += 'unix'
|
sysinfo_includes += 'unix'
|
||||||
sysinfo_sources += [
|
sysinfo_sources += [
|
||||||
'unix/backend.c',
|
'unix/backend.c',
|
||||||
'unix/match.c',
|
'unix/match.c',
|
||||||
'unix/parse.c',
|
'unix/parse.c',
|
||||||
'unix/pci.c',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
picidsdir = libpci.get_pkgconfig_variable('idsdir')
|
picidsdir = libpci.get_pkgconfig_variable('idsdir')
|
||||||
|
|
|
@ -132,21 +132,24 @@ gint64 xs_parse_uptime(void)
|
||||||
|
|
||||||
if(fgets(buffer, bsize, fp) != NULL)
|
if(fgets(buffer, bsize, fp) != NULL)
|
||||||
uptime = g_ascii_strtoll(buffer, NULL, 0);
|
uptime = g_ascii_strtoll(buffer, NULL, 0);
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
return uptime;
|
return uptime;
|
||||||
}
|
}
|
||||||
|
|
||||||
int xs_parse_sound(char *snd_card)
|
int xs_parse_sound(char *snd_card)
|
||||||
{
|
{
|
||||||
|
#ifndef HAVE_LIBPCI
|
||||||
|
return 1;
|
||||||
|
#else
|
||||||
char buffer[bsize], cards[bsize] = "\0", vendor[7] = "\0", device[7] = "\0", *pos;
|
char buffer[bsize], cards[bsize] = "\0", vendor[7] = "\0", device[7] = "\0", *pos;
|
||||||
u16 class = PCI_CLASS_MULTIMEDIA_AUDIO;
|
u16 class = PCI_CLASS_MULTIMEDIA_AUDIO;
|
||||||
|
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
if((fp = fopen("/proc/asound/cards", "r"))== NULL)
|
if((fp = fopen("/proc/asound/cards", "r"))== NULL)
|
||||||
{
|
{
|
||||||
if (pci_find_by_class(&class, vendor, device) == 0)
|
if (pci_find_by_class(&class, vendor, device) == 0)
|
||||||
{
|
{
|
||||||
pci_find_fullname(snd_card, vendor, device);
|
pci_find_fullname(snd_card, vendor, device);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -154,8 +157,8 @@ int xs_parse_sound(char *snd_card)
|
||||||
else
|
else
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
while(fgets(buffer, bsize, fp) != NULL)
|
while(fgets(buffer, bsize, fp) != NULL)
|
||||||
{
|
{
|
||||||
if(isdigit(buffer[0]) || isdigit(buffer[1]))
|
if(isdigit(buffer[0]) || isdigit(buffer[1]))
|
||||||
|
@ -175,13 +178,17 @@ int xs_parse_sound(char *snd_card)
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(snd_card, cards);
|
strcpy(snd_card, cards);
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return 0;
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int xs_parse_video(char *vid_card)
|
int xs_parse_video(char *vid_card)
|
||||||
{
|
{
|
||||||
|
#ifndef HAVE_LIBPCI
|
||||||
|
return 1;
|
||||||
|
#else
|
||||||
char vendor[7] = "\0", device[7] = "\0";
|
char vendor[7] = "\0", device[7] = "\0";
|
||||||
u16 class = PCI_CLASS_DISPLAY_VGA;
|
u16 class = PCI_CLASS_DISPLAY_VGA;
|
||||||
if (pci_find_by_class(&class, vendor, device))
|
if (pci_find_by_class(&class, vendor, device))
|
||||||
|
@ -189,10 +196,14 @@ int xs_parse_video(char *vid_card)
|
||||||
else
|
else
|
||||||
pci_find_fullname(vid_card, vendor, device);
|
pci_find_fullname(vid_card, vendor, device);
|
||||||
return 0;
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int xs_parse_ether(char *ethernet_card)
|
int xs_parse_ether(char *ethernet_card)
|
||||||
{
|
{
|
||||||
|
#ifndef HAVE_LIBPCI
|
||||||
|
return 1;
|
||||||
|
#else
|
||||||
char vendor[7] = "\0", device[7] = "\0";
|
char vendor[7] = "\0", device[7] = "\0";
|
||||||
u16 class = PCI_CLASS_NETWORK_ETHERNET;
|
u16 class = PCI_CLASS_NETWORK_ETHERNET;
|
||||||
if (pci_find_by_class(&class, vendor, device))
|
if (pci_find_by_class(&class, vendor, device))
|
||||||
|
@ -200,10 +211,14 @@ int xs_parse_ether(char *ethernet_card)
|
||||||
else
|
else
|
||||||
pci_find_fullname(ethernet_card, vendor, device);
|
pci_find_fullname(ethernet_card, vendor, device);
|
||||||
return 0;
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int xs_parse_agpbridge(char *agp_bridge)
|
int xs_parse_agpbridge(char *agp_bridge)
|
||||||
{
|
{
|
||||||
|
#ifndef HAVE_LIBPCI
|
||||||
|
return 1;
|
||||||
|
#else
|
||||||
char vendor[7] = "\0", device[7] = "\0";
|
char vendor[7] = "\0", device[7] = "\0";
|
||||||
u16 class = PCI_CLASS_BRIDGE_HOST;
|
u16 class = PCI_CLASS_BRIDGE_HOST;
|
||||||
if (pci_find_by_class(&class, vendor, device))
|
if (pci_find_by_class(&class, vendor, device))
|
||||||
|
@ -211,6 +226,7 @@ int xs_parse_agpbridge(char *agp_bridge)
|
||||||
else
|
else
|
||||||
pci_find_fullname(agp_bridge, vendor, device);
|
pci_find_fullname(agp_bridge, vendor, device);
|
||||||
return 0;
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int xs_parse_meminfo(unsigned long long *mem_tot, unsigned long long *mem_free, int swap)
|
int xs_parse_meminfo(unsigned long long *mem_tot, unsigned long long *mem_free, int swap)
|
||||||
|
@ -306,7 +322,7 @@ int xs_parse_distro(char *name)
|
||||||
g_snprintf(buffer, bsize, "Unknown Distro");
|
g_snprintf(buffer, bsize, "Unknown Distro");
|
||||||
if(fp != NULL)
|
if(fp != NULL)
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
pos=strchr(buffer, '\n');
|
pos=strchr(buffer, '\n');
|
||||||
if(pos != NULL)
|
if(pos != NULL)
|
||||||
*pos = '\0';
|
*pos = '\0';
|
||||||
|
|
Loading…
Reference in New Issue