-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.h
105 lines (95 loc) · 3.43 KB
/
util.h
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
* Copyright © 2008-2011 Kristian Høgsberg
* Copyright © 2011 Intel Corporation
* Copyright © 2013-2015 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#pragma once
#define versionsort alphasort
#define LIBINPUT_ATTRIBUTE_PRINTF(_format, _args) \
__attribute__ ((format (printf, _format, _args)))
#define bit(x_) (1UL << (x_))
#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
/* Recognized device types */
enum device_type {
DEVICE_TYPE_UNKNOWN = -1,
DEVICE_TYPE_MOUSE = 0,
DEVICE_TYPE_POINTINGSTICK,
DEVICE_TYPE_TOUCHPAD,
DEVICE_TYPE_TOUCHSCREEN,
DEVICE_TYPE_TABLET,
DEVICE_TYPE_TABLET_PAD,
DEVICE_TYPE_KEYBOARD,
DEVICE_TYPE_JOYSTICK,
};
struct device {
const char *path;
enum device_type type;
char name[80];
char uniq[80];
struct input_id id;
};
struct input_prop {
unsigned int prop;
bool enabled;
};
/**
* @ingroup base
*
* Log handler type for custom logging.
*
* @param priority The priority of the current message
* @param format Message format in printf-style
* @param args Message arguments
*/
typedef void moused_log_handler(int priority, int errnum,
const char *format, va_list args);
bool streq(const char *str1, const char *str2);
bool strneq(const char *str1, const char *str2, int n);
void * zalloc(size_t size);
char* safe_strdup(const char *str);
__attribute__ ((format (printf, 2, 3)))
int xasprintf(char **strp, const char *fmt, ...);
bool safe_atoi_base(const char *str, int *val, int base);
static inline bool
safe_atoi(const char *str, int *val)
{
return (safe_atoi_base(str, val, 10));
}
bool safe_atou_base(const char *str, unsigned int *val, int base);
static inline bool
safe_atou(const char *str, unsigned int *val)
{
return (safe_atou_base(str, val, 10));
}
bool safe_atod(const char *str, double *val);
void strv_free(char **strv);
const char *next_word(const char **state, size_t *len, const char *separators);
char ** strv_from_string(const char *in, const char *separators,
size_t *num_elements);
bool strendswith(const char *str, const char *suffix);
bool parse_dimension_property(const char *prop, size_t *w, size_t *h);
bool parse_range_property(const char *prop, int *hi, int *lo);
bool parse_boolean_property(const char *prop, bool *b);
bool parse_evcode_property(const char *prop, struct input_event *events,
size_t *nevents);
bool parse_input_prop_property(const char *prop,
struct input_prop *props_out, size_t *nprops);