blob: e296d7f2b041d60ba5566196b9e3d3feabe27e1f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include "common.h"
char *table_name_to_file(const char *name) {
char *share_path = getenv("SHARE_PATH");
char *fname;
if (!share_path || !*share_path) share_path = "/usr/share";
asprintf(&fname, "%s/ldetect-lst/%s", share_path, name);
return fname;
}
fh fh_open(const char *name) {
char *fname = table_name_to_file(name);
if (access(fname, R_OK) != 0) {
char *fname_gz;
asprintf(&fname_gz, "%s.gz", fname);
free(fname);
fname = fname_gz;
}
fh f = gzopen(fname, "r");
if (!f) {
perror("pciusb");
exit(1);
}
free(fname);
return f;
}
|