mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	Remove info() and die()
This commit is contained in:
		
							parent
							
								
									22f5073ebd
								
							
						
					
					
						commit
						20fd8f59a7
					
				
					 11 changed files with 26 additions and 51 deletions
				
			
		| 
						 | 
					@ -1,19 +1,9 @@
 | 
				
			||||||
#ifndef __LABWC_LOG_H
 | 
					#ifndef __LABWC_LOG_H
 | 
				
			||||||
#define __LABWC_LOG_H
 | 
					#define __LABWC_LOG_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * info - print info message
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
void info(const char *msg, ...);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * warn - print warning
 | 
					 * warn - print warning
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
void warn(const char *err, ...);
 | 
					void warn(const char *err, ...);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * die - print fatal message and exit()
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
void die(const char *err, ...);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif /* __LABWC_LOG_H */
 | 
					#endif /* __LABWC_LOG_H */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -85,7 +85,7 @@ find_dir(struct ctx *ctx)
 | 
				
			||||||
			/* handle /etc/xdg... */
 | 
								/* handle /etc/xdg... */
 | 
				
			||||||
			ctx->build_path_fn(ctx, NULL, d.path);
 | 
								ctx->build_path_fn(ctx, NULL, d.path);
 | 
				
			||||||
			if (debug) {
 | 
								if (debug) {
 | 
				
			||||||
				info("%s", ctx->buf);
 | 
									fprintf(stderr, "%s\n", ctx->buf);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			if (isdir(ctx->buf)) {
 | 
								if (isdir(ctx->buf)) {
 | 
				
			||||||
				return ctx->buf;
 | 
									return ctx->buf;
 | 
				
			||||||
| 
						 | 
					@ -100,7 +100,7 @@ find_dir(struct ctx *ctx)
 | 
				
			||||||
			for (gchar **p = prefixes; *p; p++) {
 | 
								for (gchar **p = prefixes; *p; p++) {
 | 
				
			||||||
				ctx->build_path_fn(ctx, *p, d.path);
 | 
									ctx->build_path_fn(ctx, *p, d.path);
 | 
				
			||||||
				if (debug) {
 | 
									if (debug) {
 | 
				
			||||||
					info("%s", ctx->buf);
 | 
										fprintf(stderr, "%s\n", ctx->buf);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				if (isdir(ctx->buf)) {
 | 
									if (isdir(ctx->buf)) {
 | 
				
			||||||
					g_strfreev(prefixes);
 | 
										g_strfreev(prefixes);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,17 +3,6 @@
 | 
				
			||||||
#include <stdlib.h>
 | 
					#include <stdlib.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					 | 
				
			||||||
info(const char *msg, ...)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	va_list params;
 | 
					 | 
				
			||||||
	fprintf(stderr, "[labwc] info: ");
 | 
					 | 
				
			||||||
	va_start(params, msg);
 | 
					 | 
				
			||||||
	vfprintf(stderr, msg, params);
 | 
					 | 
				
			||||||
	va_end(params);
 | 
					 | 
				
			||||||
	fprintf(stderr, "\n");
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
warn(const char *err, ...)
 | 
					warn(const char *err, ...)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -25,14 +14,3 @@ warn(const char *err, ...)
 | 
				
			||||||
	fprintf(stderr, "\n");
 | 
						fprintf(stderr, "\n");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					 | 
				
			||||||
die(const char *err, ...)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	va_list params;
 | 
					 | 
				
			||||||
	fprintf(stderr, "[labwc] fatal: ");
 | 
					 | 
				
			||||||
	va_start(params, err);
 | 
					 | 
				
			||||||
	vfprintf(stderr, err, params);
 | 
					 | 
				
			||||||
	va_end(params);
 | 
					 | 
				
			||||||
	fprintf(stderr, "\n");
 | 
					 | 
				
			||||||
	exit(EXIT_FAILURE);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,7 +10,7 @@
 | 
				
			||||||
#include <strings.h>
 | 
					#include <strings.h>
 | 
				
			||||||
#include <unistd.h>
 | 
					#include <unistd.h>
 | 
				
			||||||
#include <wayland-server-core.h>
 | 
					#include <wayland-server-core.h>
 | 
				
			||||||
 | 
					#include <wlr/util/log.h>
 | 
				
			||||||
#include "common/dir.h"
 | 
					#include "common/dir.h"
 | 
				
			||||||
#include "common/log.h"
 | 
					#include "common/log.h"
 | 
				
			||||||
#include "common/nodename.h"
 | 
					#include "common/nodename.h"
 | 
				
			||||||
| 
						 | 
					@ -273,7 +273,7 @@ static void
 | 
				
			||||||
post_processing(void)
 | 
					post_processing(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (!wl_list_length(&rc.keybinds)) {
 | 
						if (!wl_list_length(&rc.keybinds)) {
 | 
				
			||||||
		info("load default key bindings");
 | 
							wlr_log(WLR_INFO, "load default key bindings");
 | 
				
			||||||
		bind("A-Escape", "Exit", NULL);
 | 
							bind("A-Escape", "Exit", NULL);
 | 
				
			||||||
		bind("A-Tab", "NextWindow", NULL);
 | 
							bind("A-Tab", "NextWindow", NULL);
 | 
				
			||||||
		bind("A-F3", "Execute", "bemenu-run");
 | 
							bind("A-F3", "Execute", "bemenu-run");
 | 
				
			||||||
| 
						 | 
					@ -323,7 +323,7 @@ rcxml_read(const char *filename)
 | 
				
			||||||
		find_config_file(rcxml, sizeof(rcxml), filename);
 | 
							find_config_file(rcxml, sizeof(rcxml), filename);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (rcxml[0] == '\0') {
 | 
						if (rcxml[0] == '\0') {
 | 
				
			||||||
		info("cannot find rc.xml config file; using defaults");
 | 
							wlr_log(WLR_INFO, "cannot find rc.xml config file");
 | 
				
			||||||
		goto no_config;
 | 
							goto no_config;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -333,7 +333,7 @@ rcxml_read(const char *filename)
 | 
				
			||||||
		warn("cannot read (%s)", rcxml);
 | 
							warn("cannot read (%s)", rcxml);
 | 
				
			||||||
		goto no_config;
 | 
							goto no_config;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	info("read config file (%s)", rcxml);
 | 
						wlr_log(WLR_INFO, "read config file %s", rcxml);
 | 
				
			||||||
	buf_init(&b);
 | 
						buf_init(&b);
 | 
				
			||||||
	while (getline(&line, &len, stream) != -1) {
 | 
						while (getline(&line, &len, stream) != -1) {
 | 
				
			||||||
		char *p = strrchr(line, '\n');
 | 
							char *p = strrchr(line, '\n');
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,6 +5,7 @@
 | 
				
			||||||
#include <stdlib.h>
 | 
					#include <stdlib.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
#include <sys/stat.h>
 | 
					#include <sys/stat.h>
 | 
				
			||||||
 | 
					#include <wlr/util/log.h>
 | 
				
			||||||
#include "common/dir.h"
 | 
					#include "common/dir.h"
 | 
				
			||||||
#include "common/log.h"
 | 
					#include "common/log.h"
 | 
				
			||||||
#include "common/spawn.h"
 | 
					#include "common/spawn.h"
 | 
				
			||||||
| 
						 | 
					@ -52,7 +53,7 @@ read_environment_file(const char *filename)
 | 
				
			||||||
	if (!stream) {
 | 
						if (!stream) {
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	info("read environment file (%s)", filename);
 | 
						wlr_log(WLR_INFO, "read environment file %s", filename);
 | 
				
			||||||
	while (getline(&line, &len, stream) != -1) {
 | 
						while (getline(&line, &len, stream) != -1) {
 | 
				
			||||||
		char *p = strrchr(line, '\n');
 | 
							char *p = strrchr(line, '\n');
 | 
				
			||||||
		if (p) {
 | 
							if (p) {
 | 
				
			||||||
| 
						 | 
					@ -101,7 +102,7 @@ session_autostart_init(void)
 | 
				
			||||||
		warn("no autostart file");
 | 
							warn("no autostart file");
 | 
				
			||||||
		goto out;
 | 
							goto out;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	info("run autostart file (%s)", autostart);
 | 
						wlr_log(WLR_INFO, "run autostart file %s", autostart);
 | 
				
			||||||
	int len = strlen(autostart) + 4;
 | 
						int len = strlen(autostart) + 4;
 | 
				
			||||||
	char *cmd = calloc(len, 1);
 | 
						char *cmd = calloc(len, 1);
 | 
				
			||||||
	strcat(cmd, "sh ");
 | 
						strcat(cmd, "sh ");
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -59,7 +59,8 @@ main(int argc, char *argv[])
 | 
				
			||||||
	rcxml_read(config_file);
 | 
						rcxml_read(config_file);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!getenv("XDG_RUNTIME_DIR")) {
 | 
						if (!getenv("XDG_RUNTIME_DIR")) {
 | 
				
			||||||
		die("XDG_RUNTIME_DIR is unset");
 | 
							wlr_log(WLR_ERROR, "XDG_RUNTIME_DIR is unset");
 | 
				
			||||||
 | 
							exit(EXIT_FAILURE);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct server server = { 0 };
 | 
						struct server server = { 0 };
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,6 +10,7 @@
 | 
				
			||||||
#include <stdlib.h>
 | 
					#include <stdlib.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
#include <strings.h>
 | 
					#include <strings.h>
 | 
				
			||||||
 | 
					#include <wlr/util/log.h>
 | 
				
			||||||
#include "common/buf.h"
 | 
					#include "common/buf.h"
 | 
				
			||||||
#include "common/dir.h"
 | 
					#include "common/dir.h"
 | 
				
			||||||
#include "common/font.h"
 | 
					#include "common/font.h"
 | 
				
			||||||
| 
						 | 
					@ -209,7 +210,7 @@ parse_xml(const char *filename, struct menu *menu)
 | 
				
			||||||
		warn("cannot read (%s)", menuxml);
 | 
							warn("cannot read (%s)", menuxml);
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	info("read menu file (%s)", menuxml);
 | 
						wlr_log(WLR_INFO, "read menu file %s", menuxml);
 | 
				
			||||||
	buf_init(&b);
 | 
						buf_init(&b);
 | 
				
			||||||
	while (getline(&line, &len, stream) != -1) {
 | 
						while (getline(&line, &len, stream) != -1) {
 | 
				
			||||||
		char *p = strrchr(line, '\n');
 | 
							char *p = strrchr(line, '\n');
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -834,7 +834,7 @@ new_output_notify(struct wl_listener *listener, void *data)
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (getenv("LABWC_ADAPTIVE_SYNC")) {
 | 
						if (getenv("LABWC_ADAPTIVE_SYNC")) {
 | 
				
			||||||
		info("Set %s adaptive sync to 'true'", wlr_output->name);
 | 
							wlr_log(WLR_INFO, "enable adaptive sync on %s", wlr_output->name);
 | 
				
			||||||
		wlr_output_enable_adaptive_sync(wlr_output, true);
 | 
							wlr_output_enable_adaptive_sync(wlr_output, true);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	wlr_output_layout_add_auto(server->output_layout, wlr_output);
 | 
						wlr_output_layout_add_auto(server->output_layout, wlr_output);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -31,7 +31,7 @@ configure_libinput(struct wlr_input_device *wlr_input_device)
 | 
				
			||||||
	if (libinput_device_config_tap_get_finger_count(libinput_dev) <= 0) {
 | 
						if (libinput_device_config_tap_get_finger_count(libinput_dev) <= 0) {
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	info("tap enabled for libinput device");
 | 
						wlr_log(WLR_INFO, "tap enabled");
 | 
				
			||||||
	libinput_device_config_tap_set_enabled(libinput_dev,
 | 
						libinput_device_config_tap_set_enabled(libinput_dev,
 | 
				
			||||||
		LIBINPUT_CONFIG_TAP_ENABLED);
 | 
							LIBINPUT_CONFIG_TAP_ENABLED);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										12
									
								
								src/server.c
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								src/server.c
									
										
									
									
									
								
							| 
						 | 
					@ -24,13 +24,14 @@ static struct server *g_server;
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
reload_config_and_theme(void)
 | 
					reload_config_and_theme(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						damage_all_outputs(g_server);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* TODO: use rc.config_path */
 | 
						/* TODO: use rc.config_path */
 | 
				
			||||||
	rcxml_finish();
 | 
						rcxml_finish();
 | 
				
			||||||
	rcxml_read(NULL);
 | 
						rcxml_read(NULL);
 | 
				
			||||||
	theme_finish(g_server->theme);
 | 
						theme_finish(g_server->theme);
 | 
				
			||||||
	theme_init(g_server->theme, g_server->renderer, rc.theme_name);
 | 
						theme_init(g_server->theme, g_server->renderer, rc.theme_name);
 | 
				
			||||||
	menu_reconfigure(g_server, g_server->rootmenu);
 | 
						menu_reconfigure(g_server, g_server->rootmenu);
 | 
				
			||||||
	damage_all_outputs(g_server);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int
 | 
					static int
 | 
				
			||||||
| 
						 | 
					@ -54,14 +55,17 @@ drop_permissions(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (getuid() != geteuid() || getgid() != getegid()) {
 | 
						if (getuid() != geteuid() || getgid() != getegid()) {
 | 
				
			||||||
		if (setgid(getgid())) {
 | 
							if (setgid(getgid())) {
 | 
				
			||||||
			die("unable to drop root group");
 | 
								wlr_log(WLR_ERROR, "unable to drop root group");
 | 
				
			||||||
 | 
								exit(EXIT_FAILURE);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (setuid(getuid())) {
 | 
							if (setuid(getuid())) {
 | 
				
			||||||
			die("unable to drop root user");
 | 
								wlr_log(WLR_ERROR, "unable to drop root user");
 | 
				
			||||||
 | 
								exit(EXIT_FAILURE);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (setgid(0) != -1 || setuid(0) != -1) {
 | 
						if (setgid(0) != -1 || setuid(0) != -1) {
 | 
				
			||||||
		die("unable to drop root");
 | 
							wlr_log(WLR_ERROR, "unable to drop root");
 | 
				
			||||||
 | 
							exit(EXIT_FAILURE);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -15,6 +15,7 @@
 | 
				
			||||||
#include <stdlib.h>
 | 
					#include <stdlib.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
#include <wlr/util/box.h>
 | 
					#include <wlr/util/box.h>
 | 
				
			||||||
 | 
					#include <wlr/util/log.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "common/dir.h"
 | 
					#include "common/dir.h"
 | 
				
			||||||
#include "common/font.h"
 | 
					#include "common/font.h"
 | 
				
			||||||
| 
						 | 
					@ -191,12 +192,11 @@ theme_read(struct theme *theme, const char *theme_name)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (!stream) {
 | 
						if (!stream) {
 | 
				
			||||||
		if (theme_name) {
 | 
							if (theme_name) {
 | 
				
			||||||
			info("cannot find theme (%s), using built-in",
 | 
								wlr_log(WLR_INFO, "cannot find theme %s", theme_name);
 | 
				
			||||||
			     theme_name);
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	info("read themerc (%s)", themerc);
 | 
						wlr_log(WLR_INFO, "read theme %s", themerc);
 | 
				
			||||||
	while (getline(&line, &len, stream) != -1) {
 | 
						while (getline(&line, &len, stream) != -1) {
 | 
				
			||||||
		char *p = strrchr(line, '\n');
 | 
							char *p = strrchr(line, '\n');
 | 
				
			||||||
		if (p) {
 | 
							if (p) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue