use larger string heap
[rrq/fuse_xattrs.git] / utils.h
1 /*
2   fuse_xattrs - Add xattrs support using sidecar files
3
4   Copyright (C) 2016  Felipe Barriga Richards <felipe {at} felipebarriga.cl>
5
6   This program can be distributed under the terms of the GNU GPL.
7   See the file COPYING.
8 */
9
10
11 #ifndef FUSE_XATTRS_UTILS_H
12 #define FUSE_XATTRS_UTILS_H
13
14 #define DEBUG 1
15
16 #include <string.h>
17 #include <stdio.h>
18
19 #define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
20
21 #define debug_print(fmt, ...) \
22         do { \
23             if (DEBUG) fprintf(stderr, "%s:%d:%s(): " fmt, __FILENAME__, __LINE__, __func__, ##__VA_ARGS__); \
24         } while (0)
25
26 #define error_print(fmt, ...) \
27         do { if (DEBUG) fprintf(stderr, "%s:%d:%s(): " fmt, __FILENAME__, \
28                                 __LINE__, __func__, ##__VA_ARGS__); } while (0)
29
30 enum namespace {
31     SECURITY,
32     SYSTEM,
33     TRUSTED,
34     USER,
35     ERROR
36 };
37
38 extern enum namespace get_namespace(const char *name);
39 extern char *get_sidecar_path(const char *path);
40 extern char *sanitize_value(const char *value, size_t value_size);
41 extern char *prepend_source_directory(const char *b);
42
43 extern const size_t BINARY_SIDECAR_EXT_SIZE;
44 extern const int filename_is_sidecar(const char *string);
45
46 extern int is_directory(const char *path);
47 extern int is_regular_file(const char *path);
48
49 #endif //FUSE_XATTRS_UTILS_H