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
|
/* See LICENSE file for copyright and license details. */
#include "common.h"
/**
* Return the capabilities of an adjustment method
*
* @param this The data structure to fill with the method's capabilities
* @param size Should be `sizeof(*this)`, used to let the library know which version
* of the structure is used so that it does not write outside of it
* @param method The adjustment method (display server and protocol)
* @return Zero on success, otherwise (negative) the value of an
* error identifier provided by this library
*/
int
libgamma_method_capabilities(struct libgamma_method_capabilities *restrict this, size_t size, int method)
{
struct libgamma_method_capabilities caps_;
void (*func)(struct libgamma_method_capabilities *restrict);
memset(this, 0, sizeof(*this));
switch (method) {
#define X(CONST, CNAME, ...)\
case CONST:\
func = libgamma_##CNAME##_method_capabilities;\
break;
LIST_AVAILABLE_METHODS(X)
#undef X
default:
return LIBGAMMA_NO_SUCH_ADJUSTMENT_METHOD;
}
if (size == sizeof(caps_)) {
func(this);
this->struct_version = LIBGAMMA_METHOD_CAPABILITIES_STRUCT_VERSION;
} else {
func(&caps_);
caps_.struct_version = LIBGAMMA_METHOD_CAPABILITIES_STRUCT_VERSION;
if (size < sizeof(caps_)) {
memcpy(this, &caps_, size);
} else {
memcpy(this, &caps_, sizeof(caps_));
memset(&((char *)this)[size], 0, size - sizeof(caps_));
}
}
this->crtc_information__old = (int32_t)this->crtc_information;
return 0;
}
|