summaryrefslogtreecommitdiffstats
path: root/common.h
blob: e6f927db874faabe9f88de2bace8ac737f2953b0 (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
41
42
43
44
45
46
47
#ifndef LIBLDETECT_COMMON
#define LIBLDETECT_COMMON

#include "libldetect.h"
#include <zlib.h>

#define NON_EXPORTED __attribute__((visibility("hidden")))

#pragma GCC visibility push(hidden) 

#define GZIP_BIN "/bin/gzip"

extern char *table_name_to_file(const char *name);

typedef enum {
     LOAD,
     DO_NOT_LOAD,
} descr_lookup;

extern int pciusb_find_modules(struct pciusb_entries *entries, const char *fpciusbtable, const descr_lookup, int is_pci) NON_EXPORTED;
extern void pciusb_initialize(struct pciusb_entry *e) NON_EXPORTED;
extern char *modalias_resolve_module(const char *modalias) NON_EXPORTED;
extern void modalias_cleanup(void) NON_EXPORTED;

#define MAX_DEVICES 100
#define BUF_SIZE 512

typedef struct {
	enum { ZLIB, GZIP } gztype;
	union {
		struct {
			FILE *f;
			pid_t pid;
		} gzip_fh;
		gzFile zlib_fh;
	} u;
} fh;

#define psizeof(a) (sizeof(a) / sizeof(*(a)))
#define ifree(p) do { if (p) { free(p); p = NULL; } } while (0)

extern fh fh_open(const char *name) NON_EXPORTED;
extern char* fh_gets(char *line, int size, fh *f) NON_EXPORTED;
extern int fh_close(fh *f) NON_EXPORTED;
#pragma GCC visibility pop

#endif