diff --git a/src/alt/logging_libqb.c b/src/alt/logging_libqb.c index 34cf97c..e82ff68 100644 --- a/src/alt/logging_libqb.c +++ b/src/alt/logging_libqb.c @@ -1,84 +1,84 @@ /* * Copyright (C) 2016 Jan Pokorny * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * version 2 of the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include #include #include #include "logging_libqb.h" int debug_level = 0; /* ENV_X definitions based on glue/lib/clplumbing/cl_log.c of glue project: http://hg.linux-ha.org/glue */ #define ENV_HADEBUGVAL "HA_debug" #define ENV_LOGFENV "HA_logfile" /* well-formed log file :-) */ #define ENV_DEBUGFENV "HA_debugfile" /* Debug log file */ #define ENV_LOGFACILITY "HA_logfacility"/* Facility to use for logger */ #define ENV_SYSLOGFMT "HA_syslogmsgfmt"/* TRUE if we should use syslog message formatting */ void alt_qb_inherit_logging_environment(void) { char *inherit_env; /* Don't need to free the return pointer from getenv */ inherit_env = getenv(ENV_HADEBUGVAL); if (inherit_env != NULL && atoi(inherit_env) != 0 ) debug_level = atoi(inherit_env); inherit_env = getenv(ENV_LOGFENV); if (inherit_env != NULL && *inherit_env != '\0') { int32_t log_fd = qb_log_file_open(inherit_env); qb_log_ctl(log_fd, QB_LOG_CONF_ENABLED, QB_TRUE); /* do not log debug info even if debug_level non-zero */ qb_log_filter_ctl(log_fd, QB_LOG_FILTER_ADD, QB_LOG_FILTER_FILE, "*", LOG_INFO); } inherit_env = getenv(ENV_DEBUGFENV); if (inherit_env != NULL && *inherit_env != '\0') { int32_t log_fd = qb_log_file_open(inherit_env); qb_log_ctl(log_fd, QB_LOG_CONF_ENABLED, QB_TRUE); } inherit_env = getenv(ENV_LOGFACILITY); if (inherit_env != NULL && *inherit_env != '\0') { int fac = qb_log_facility2int(inherit_env); if (fac > 0) qb_log_ctl(QB_LOG_SYSLOG, QB_LOG_CONF_FACILITY, fac); else qb_log_ctl(QB_LOG_SYSLOG, QB_LOG_CONF_ENABLED, QB_FALSE); } inherit_env = getenv(ENV_SYSLOGFMT); if (inherit_env != NULL && *inherit_env != '\0' && ( !strcasecmp(inherit_env, "false") || !strcasecmp(inherit_env, "off") || !strcasecmp(inherit_env, "no") || !strcasecmp(inherit_env, "n") || !strcasecmp(inherit_env, "0"))){ enum qb_log_target_slot i; for (i = QB_LOG_TARGET_START; i < QB_LOG_TARGET_MAX; i++) { if (i == QB_LOG_SYSLOG || i == QB_LOG_BLACKBOX) continue; qb_log_format_set(i, NULL); } } } diff --git a/src/alt/logging_libqb.h b/src/alt/logging_libqb.h index 76592d4..af5ba83 100644 --- a/src/alt/logging_libqb.h +++ b/src/alt/logging_libqb.h @@ -1,70 +1,70 @@ /* * Copyright (C) 2016 Jan Pokorny * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * version 2 of the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include #include "b_config.h" /* qb logging compat definitions */ #if (!defined LOGGING_LIBQB_MAJOR || (LOGGING_LIBQB_MAJOR < 1)) enum tmp_log_target_slot { TMP_LOG_SYSLOG = QB_LOG_SYSLOG, TMP_LOG_STDERR = QB_LOG_STDERR, TMP_LOG_BLACKBOX = QB_LOG_BLACKBOX, TMP_LOG_TARGET_MAX = QB_LOG_TARGET_MAX, }; #undef QB_LOG_SYSLOG #undef QB_LOG_STDERR #undef QB_LOG_BLACKBOX #undef QB_LOG_TARGET_MAX enum qb_log_target_slot { QB_LOG_TARGET_START, QB_LOG_SYSLOG = TMP_LOG_SYSLOG, QB_LOG_STDERR = TMP_LOG_STDERR, QB_LOG_BLACKBOX = TMP_LOG_BLACKBOX, QB_LOG_TARGET_MAX = TMP_LOG_TARGET_MAX, }; #define QB_LOG_CTL2_S(a) (a) #define qb_log_ctl2(t, s, a) ((void) 0) #endif #ifndef HA_LOG_FACILITY /* based on glue/configure.ac of glue project: http://hg.linux-ha.org/glue */ #define HA_LOG_FACILITY LOG_DAEMON #endif extern int debug_level; #define ANYDEBUG (debug_level) void alt_qb_inherit_logging_environment(void); #define cl_log_set_entity(ent) \ (void) qb_log_ctl2(QB_LOG_SYSLOG, QB_LOG_CONF_IDENT, QB_LOG_CTL2_S(ent)) #define cl_log_enable_stderr(b) \ (void) qb_log_ctl(QB_LOG_STDERR, QB_LOG_CONF_ENABLED, b ? QB_TRUE : QB_FALSE) #define cl_log_set_facility(f) \ (void) qb_log_ctl(QB_LOG_SYSLOG, QB_LOG_CONF_FACILITY, f) #define cl_inherit_logging_environment(logqueuemax) \ alt_qb_inherit_logging_environment() diff --git a/src/alt/nametag_libsystemd.c b/src/alt/nametag_libsystemd.c index 1fb9ffa..26e5009 100644 --- a/src/alt/nametag_libsystemd.c +++ b/src/alt/nametag_libsystemd.c @@ -1,81 +1,81 @@ /* * Copyright (C) 2016 Jan Pokorny * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * version 2 of the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include #include #include #include #include #include "nametag_libsystemd.h" #include "booth.h" #include "log.h" #include "transport.h" /* assume first argument after "fmt" is for DAEMON_NAME, that is really not of interest in our "nametag" function based on sd_notify (that very data point is provided implicitly) */ void sd_notify_wrapper(const char *fmt, ...) { /* assume that first %s in fmt is intended for DAEMON_NAME, i.e., for first argument following fmt in original set_proc_title invocation, which has already been dropped before it boils down here (using the wrapping macro trick); we now simply append the reset after that first %s (with whitespace stripped) to the "Running: " prefix */ int rv; char buffer[255]; char *fmt_iter; char *suffix = NULL; va_list ap; switch (local->type) { case ARBITRATOR: case GEOSTORE: break; default: return; /* not expected to be run as system service */ } fmt_iter = strchr(fmt, '%'); while (fmt_iter) { switch (*++fmt_iter) { case 's': suffix = fmt_iter; /* fall through */ default: fmt_iter = NULL; } } if (!suffix) { log_warn("%s:%d: invalid format: %s", __FILE__, __LINE__, fmt); return; } while (isspace(*++suffix)) /* noop */ ; va_start(ap, fmt); fmt_iter = va_arg(ap, char *); /* just shift by one */ assert(!strcmp(fmt_iter, DAEMON_NAME)); rv = vsnprintf(buffer, sizeof(buffer), suffix, ap); va_end(ap); rv = sd_notifyf(0, "READY=1\n" "STATUS=Running: %s", buffer); if (rv < 0) log_warn("%s:%d: sd_notifyf fail", __FILE__, __LINE__); } diff --git a/src/alt/nametag_libsystemd.h b/src/alt/nametag_libsystemd.h index 2c1dc1e..b2b781f 100644 --- a/src/alt/nametag_libsystemd.h +++ b/src/alt/nametag_libsystemd.h @@ -1,23 +1,23 @@ /* * Copyright (C) 2016 Jan Pokorny * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * version 2 of the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ void sd_notify_wrapper(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); #define init_set_proc_title(c, a, e) /* omitted */ #define set_proc_title sd_notify_wrapper diff --git a/src/alt/range2random_glib.c b/src/alt/range2random_glib.c index 8363559..93c5d39 100644 --- a/src/alt/range2random_glib.c +++ b/src/alt/range2random_glib.c @@ -1,33 +1,33 @@ /* * Copyright (C) 2016 Jan Pokorny * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * version 2 of the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include #include #include #include "range2random_glib.h" #include "ticket.h" int alt_glib_rand_from_interval(int from, int to) { assert(from >= 0 && from < to); assert(sizeof(to) <= sizeof(gint32) || (to < 0x7fffffff)); return (int) g_random_int_range(from, to); } diff --git a/src/alt/range2random_glib.h b/src/alt/range2random_glib.h index 4b87c46..8b73020 100644 --- a/src/alt/range2random_glib.h +++ b/src/alt/range2random_glib.h @@ -1,22 +1,22 @@ /* * Copyright (C) 2016 Jan Pokorny * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * version 2 of the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ int alt_glib_rand_from_interval(int from, int to); #define cl_rand_from_interval(from, to) \ alt_glib_rand_from_interval(from, to)