aboutsummaryrefslogblamecommitdiffstats
path: root/libenv_get_complete_list.c
blob: 9a542c9caed2f76a21b11b2c9a1e27b175914f4a (plain) (tree)


















































































































































































































                                                                                                  
/* See LICENSE file for copyright and license details. */
#include "common.h"

#define NCLASSWORDS  1U


#define _(E) ((uint64_t)1 << (E))

#define SU_SAFE _(LIBENV_SU_SAFE)
#define SU_UNSAFE _(LIBENV_SU_UNSAFE)
#define LOGIN_SAFE _(LIBENV_LOGIN_SAFE)
#define LOGIN_UNSAFE _(LIBENV_LOGIN_UNSAFE)
#define REMOTE_SAFE _(LIBENV_REMOTE_SAFE)
#define REMOTE_UNSAFE _(LIBENV_REMOTE_UNSAFE)
#define PATH (_(LIBENV_PATH) | REMOTE_UNSAFE)

#define DECLARE(VAR, ENUMS_)\
	static const uint64_t VAR[NCLASSWORDS] = {ENUMS_}

DECLARE(classes__display, _(LIBENV_DISPLAY) | SU_SAFE | LOGIN_SAFE | REMOTE_UNSAFE);
DECLARE(classes__display_config, _(LIBENV_DISPLAY_CONFIG) | SU_SAFE | LOGIN_SAFE | REMOTE_UNSAFE);
DECLARE(classes__desktop, _(LIBENV_DESKTOP) | SU_SAFE | LOGIN_SAFE | REMOTE_SAFE);
DECLARE(classes__terminal_caps, _(LIBENV_TERMINAL_CAPS) | SU_SAFE | LOGIN_SAFE | REMOTE_SAFE);
DECLARE(classes__local_terminal, _(LIBENV_LOCAL_TERMINAL) | SU_SAFE | LOGIN_SAFE | REMOTE_UNSAFE);
DECLARE(classes__locale, _(LIBENV_LOCALE) | SU_SAFE | LOGIN_UNSAFE | REMOTE_UNSAFE);
DECLARE(classes__locale__path, _(LIBENV_LOCALE) | SU_SAFE | LOGIN_UNSAFE | PATH);
DECLARE(classes__timezone, _(LIBENV_TIMEZONE) | SU_SAFE | LOGIN_UNSAFE | REMOTE_UNSAFE);
DECLARE(classes__timezone__path, _(LIBENV_TIMEZONE) | SU_SAFE | LOGIN_UNSAFE | PATH);
DECLARE(classes__session, _(LIBENV_SESSION) | SU_SAFE | LOGIN_SAFE | REMOTE_UNSAFE);
DECLARE(classes__theme_config, _(LIBENV_THEME_CONFIG) | SU_SAFE | LOGIN_UNSAFE | REMOTE_SAFE);
DECLARE(classes__theme_plugin, _(LIBENV_THEME_PLUGIN) | SU_UNSAFE | LOGIN_UNSAFE | REMOTE_UNSAFE);
DECLARE(classes__internet, _(LIBENV_INTERNET) | SU_SAFE | LOGIN_UNSAFE | REMOTE_UNSAFE);
DECLARE(classes__audio, _(LIBENV_AUDIO) | SU_SAFE | LOGIN_SAFE | REMOTE_UNSAFE);
DECLARE(classes__user, _(LIBENV_USER) | SU_UNSAFE | LOGIN_UNSAFE | REMOTE_UNSAFE);
DECLARE(classes__applications, _(LIBENV_APPLICATIONS) | SU_SAFE | LOGIN_UNSAFE | REMOTE_UNSAFE);
DECLARE(classes__preferences, _(LIBENV_PREFERENCES) | SU_SAFE | LOGIN_UNSAFE | REMOTE_SAFE);
DECLARE(classes__system_paths, _(LIBENV_SYSTEM_PATHS) | SU_SAFE | LOGIN_UNSAFE | PATH);
DECLARE(classes__user_paths, _(LIBENV_USER_PATHS) | SU_SAFE | LOGIN_UNSAFE | PATH);
DECLARE(classes__pwd, _(LIBENV_PWD) | SU_SAFE | LOGIN_UNSAFE | PATH);
DECLARE(classes__exec__path, _(LIBENV_EXEC) | SU_SAFE | LOGIN_UNSAFE | PATH);

#undef _
#undef SU_SAFE
#undef SU_UNSAFE
#undef LOGIN_SAFE
#undef LOGIN_UNSAFE
#undef REMOTE_SAFE
#undef REMOTE_UNSAFE
#undef PATH
#undef DECLARE
#define V(S) {S, CLASSES}


static struct libenv_variable list[] = {

#define CLASSES classes__display
	V("DISPLAY"),
	V("WAYLAND_DISPLAY"),
	V("XAUTHORITY"),
	V("XDG_SEAT"),
	V("XDG_SEAT_PATH"),
	V("XDG_VTNR"),
#undef CLASSES

#define CLASSES classes__display_config
	V("SDL_VIDEO_FULLSCREEN_DISPLAY"),
	V("XMODIFIERS"),
#undef CLASSES

#define CLASSES classes__desktop
	V("DESKTOP_SESSION"),
	V("GTK_CSD"),
	V("XDG_SESSION_PATH"),
	V("XDG_SESSION_DESKTOP"),
	V("XDG_SESSION_TYPE"),
	V("XDG_SESSION_CLASS"),
	V("XDG_SESSION_ID"),
	V("_JAVA_AWT_WM_NOREPARENTING"),
#undef CLASSES

#define CLASSES classes__terminal_caps
	V("TERM"),
	V("COLORTERM"),
	V("VTE_VERSION"),
#undef CLASSES

#define CLASSES classes__local_terminal
	V("TERMINATOR_UUID"),
#undef CLASSES

#define CLASSES classes__locale
	V("LANG"),
	V("LANGUAGE"),
	V("LOCALE"),
	V("LC_CTYPE"),
	V("LC_NUMERIC"),
	V("LC_TIME"),
	V("LC_COLLATE"),
	V("LC_MONETARY"),
	V("LC_MESSAGES"),
	V("LC_PAPER"),
	V("LC_NAME"),
	V("LC_ADDRESS"),
	V("LC_TELEPHONE"),
	V("LC_MEASUREMENT"),
	V("LC_IDENTIFICATION"),
	V("LC_ALL"),
#undef CLASSES

#define CLASSES classes__locale__path
	V("LOCPATH"),
	V("NLSPATH"),
#undef CLASSES

#define CLASSES classes__timezone
	V("TZ"),
#undef CLASSES

#define CLASSES classes__timezone__path
	V("TZDIR"),
#undef CLASSES

#define CLASSES classes__session
	V("SSH_CLIENT"),
	V("SSH_CONNECTION"),
	V("SSH_TTY"),
#undef CLASSES

#define CLASSES classes__theme_config
	V("LS_COLORS"),
#undef CLASSES

#define CLASSES classes__theme_plugin
	V("GTK_THEME"),
	V("QT_STYLE_OVERRIDE"),
	V("QT_QPA_PLATFORMTHEME"),
#undef CLASSES

#define CLASSES classes__internet
	V("ftp_proxy"),
	V("http_proxy"),
#undef CLASSES

#define CLASSES classes__audio
	V("MAIN_ALSA_MIXER"),
	V("MAIN_ALSA_CARD"),
#undef CLASSES

#define CLASSES classes__user
	V("LOGNAME"),
	V("HOME"),
	V("SHELL"),
#undef CLASSES

#define CLASSES classes__applications
	V("EDITOR"),
	V("VISUAL"),
	V("BROWSER"),
	V("PAGER"),
#undef CLASSES

#define CLASSES classes__preferences
	V("MANSECT"),
	V("_JAVA_OPTIONS"),
#undef CLASSES

#define CLASSES classes__system_paths
	V("PATH"),
	V("XDG_DATA_DIRS"),
	V("XDG_CONFIG_DIRS"),
	V("MANPATH"),
	V("INFODIR"),
	V("JAVA_HOME"),
#undef CLASSES

#define CLASSES classes__user_paths
	V("XDG_SPOOL_HOME"),
	V("XDG_CACHE_HOME"),
	V("XDG_STATE_HOME"),
	V("XDG_RUNTIME_DIR"),
	V("XDG_DATA_HOME"),
	V("XDG_CONFIG_HOME"),
	V("GNUPGHOME"),
	V("MPLAYER_HOME"),
#undef CLASSES

#define CLASSES classes__pwd
	V("PWD"),
	V("OLDPWD"),
#undef CLASSES

#define CLASSES classes__exec__path
	V("_"),
#undef CLASSES

	{NULL, NULL}
};


#undef V


const struct libenv_variable *
libenv_get_complete_list(size_t *nclasswords_out, size_t *count_out) /* TODO test */
{
	if (nclasswords_out)
		*nclasswords_out = NCLASSWORDS;
	if (count_out)
		*count_out = sizeof(list) / sizeof(*list) - 1U;
	return list;
}