salmon.h

/* This is free software.  See LICENSE for terms.
 * Copyright 2004 - 2015, Patricia Kirk.
 */

#ifndef SALMON_H
#define SALMON_H

#include <X11/xpm.h>

#include "config.h"

#ifndef WITH_SUID
#define WITH_SUID 0
#endif	/* WITH_SUID */
#ifndef WITH_COMMANDS
#define WITH_COMMANDS 0
#endif	/* WITH_COMMANDS */
#ifndef WITH_GRAPHICS
#define WITH_GRAPHICS 0
#endif	/* WITH_GRAPHICS */
#ifndef WITH_REMEXEC
#define WITH_REMEXEC 0
#endif	/* WITH_REMEXEC */
#ifndef WITH_TIMESYNC
#define WITH_TIMESYNC 0
#endif	/* WITH_TIMESYNC */
#ifndef WITH_STEPEXEC
#define WITH_STEPEXEC 0
#endif	/* WITH_STEPEXEC */
#ifndef WITH_DETACH
#define WITH_DETACH 0
#endif	/* WITH_DETACH */
#ifndef WITH_CONTROL
#define WITH_CONTROL 0
#endif	/* WITH_CONTROL */

#define DATADIR		DATA_ROOT_DIR"/salmon"
#define CFGFILE		CFG_DIR"/salmon.cfg"
#define TEMPDIR		"/tmp"

/* Default helper executables including AUDIOCMD.
 * Any required arguments are separated from the
 * command before the locate database is used to
 * find the executable.
 */
#define UNZIP		"gunzip <"
#define RESIZE		"mogrify -colors 20 -scale"
#define TILER		"montage -geometry"
#define TALKER		"flite"
#if defined(__FreeBSD__)
#define MIXER		"mixer"
#elif defined(__NetBSD__) || defined(__OpenBSD__)
#define MIXER		"mixerctl"
#elif defined(__linux__)
#define MIXER		"aumix"
#endif	/* __FreeBSD__ */

#if defined(__FreeBSD__)
#define AUDIOCMD	"cat"
#define AUDIODEV	"/dev/dsp0"
#define BEEPER		AUDIODEV
#elif defined(__NetBSD__)
#define AUDIOCMD	"cat"
#define AUDIODEV	"/dev/sound"
#define BEEPER		AUDIODEV
#elif defined(__OpenBSD__)
#define AUDIOCMD	"aucat -r 4000 -e s8 -i"
#define AUDIODEV	""
#define BEEPER		"/dev/audio"
#elif defined(__linux__)
#define AUDIOCMD	"cat"
#define AUDIODEV	"/dev/dsp"
#define BEEPER		AUDIODEV
#endif	/* __FreeBSD__ */

#define LODYNAMIC	49152		/* Lowest dynamic/private port. */
#define HIDYNAMIC	65535		/* highest dynamic/private port. */

/* These definitions are the sizes and offsets in the
 * forexpm pixmap.  There are ten characters in
 * each row so the ascii number of the character %10
 * and /10 point to the character in the pixmap.
 */
#define CHARWIDTH	5
#define CHARHEIGHT	7

#define ASCEN		30		/* up arrow, used as an offset into forexpm characters */
#define DSCEN		31		/* down arrow */
#define SPACE		32
#define DASH		45
#define SLASH		47
#define AZERO		48		/* ascii zero, used as an offset into forexpm digits */
#define ANINE		57
#define GIGS		71
#define KEYS		75
#define MEGS		77
#define PIPE		124		/* vertical bar */
#define DEG		127		/* degrees */

/* The default background and foreground colors, the
 * reduction amount for the foreground color and the
 * positions in the colors array.
 */
#define BACKGROUND	"#000000"
#define FOREGROUND	"#ff8c69"
#define SHUTDOWN	"#fFfF01010101"	/* shutdown notice color */
#define LITE		1.00		/* the brighter color in forexpm */
#define DARK		0.55		/* the darker color in forexpm */
#define BACK		0
#define FORE		1

#define FALSE		0
#define TRUE		1

#define ISIZE		64

#define SHOWBUF		20
#define SMALBUF		129
#define BUFSIZE		1025
#define BUFPLUS		BUFSIZE * 2

#define SWAPDEVICES	100		/* maximum number of devices or files */
#define MAXTRIES	1 << 26		/* maximum tries to find a random port 67108864 */
#define CELSIUS		2732		/* Zero degrees Celsius is ~273.16 kelvins */

#if defined(__NetBSD__)
#define GETOPT		getopt_long
#else
#define GETOPT		getopt_long_only
#endif

#define FREE(a)		{ \
			if (a) { \
			    free(a); \
			    (a) = NULL; \
			} \
			}

#define STRDUP(a,b)	{ \
			FREE(a); \
			if (strlen((b)) >= BUFSIZE) \
			    gdayMate("strdup() argument size", NULL); \
			if (!((a) = strdup(b))) \
			    gdayMate("strdup() failed", (b)); \
			}

#define CALLOC(a,b,c,d)	{ \
			if (!(a = calloc(b, c))) \
			    allocFailed(d); \
			}

#define DAEMON		(!g.running || (g.daemonize && getpid() == g.ppid))

#endif	/* SALMON_H */
* * o * *