aboutsummaryrefslogtreecommitdiffstats
path: root/libgamma_method_default_site.c
blob: 5da2c72e01bf85144fa9dfdfd825ce604b237675 (plain) (blame)
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
/* See LICENSE file for copyright and license details. */
#include "common.h"


/**
 * Return the default site for an adjustment method
 * 
 * @param   method  The adjustment method (display server and protocol)
 * @return          The default site, `NULL` if it cannot be determined or
 *                  if multiple sites are not supported by the adjustment
 *                  method
 */
const char *
libgamma_method_default_site(int method)
{
	const char *restrict var = libgamma_method_default_site_variable(method);
	const char *restrict env;

	/* Return `NULL` if there is no variable to read */
	if (!var)
		return NULL;

	/* Read the variable */
	env = getenv(var);
	/* Return `NULL` if it does not exist (or is empty) */
	if (!env || !*env)
		return NULL;

	/* Return the variable's value */
	return env;
}