Subject: Conf file for wsmoused(8) - second attempt
To: None <tech-userlevel@netbsd.org>
From: Julio Merino <jmmv@menta.net>
List: tech-userlevel
Date: 02/26/2003 13:50:52
As nobody has replied (might be because the previous tar.gz)...
Let's make things easier for a fast review, and just paste files inside
the mail (I know, this gonna be big).
----------------------------------------------------------------------
The conf file looks like:
# $NetBSD$
#
# wsmoused.conf - multipurpose mouse daemon configuration file.
# See wsmoused(8) and wsmoused.conf(5) # for details.
#
device = /dev/wsmouse;
mode sel {
xconsole = 4;
}
----------------------------------------------------------------------
The patch for the program:
Index: Makefile
===================================================================
RCS file: /cvsroot/src/usr.sbin/wsmoused/Makefile,v
retrieving revision 1.1
diff -u -u -r1.1 Makefile
--- Makefile 2002/06/26 23:13:06 1.1
+++ Makefile 2003/02/23 11:22:21
@@ -2,8 +2,16 @@
#
PROG= wsmoused
-SRCS= wsmoused.c events.c selection.c
+SRCS= wsmoused.c config.c config_yacc.y config_lex.l events.c selection.c
-MAN= wsmoused.8
+MAN= wsmoused.conf.5 wsmoused.8
+
+CPPFLAGS+= -I. -I${.CURDIR}
+
+YHEADER= yes
+
+# XXX Remove me
+CFLAGS+= -g
+LDFLAGS+= -L/usr/pkg/lib -lefence
.include <bsd.prog.mk>
Index: pathnames.h
===================================================================
RCS file: /cvsroot/src/usr.sbin/wsmoused/pathnames.h,v
retrieving revision 1.2
diff -u -u -r1.2 pathnames.h
--- pathnames.h 2002/06/27 15:07:52 1.2
+++ pathnames.h 2003/02/23 11:22:21
@@ -36,5 +36,6 @@
#define _PATH_PID "/var/run/wsmoused.pid"
#define _PATH_TTYPREFIX "/dev/ttyE"
#define _PATH_TTYSTAT "/dev/ttyEstat"
+#define _PATH_CONF "/etc/wsmoused.conf"
#endif /* _WSMOUSED_PATHNAMES_H */
Index: wsmoused.8
===================================================================
RCS file: /cvsroot/src/usr.sbin/wsmoused/wsmoused.8,v
retrieving revision 1.8
diff -u -u -r1.8 wsmoused.8
--- wsmoused.8 2003/01/19 21:25:43 1.8
+++ wsmoused.8 2003/02/23 11:22:22
@@ -1,6 +1,6 @@
.\" $NetBSD: wsmoused.8,v 1.8 2003/01/19 21:25:43 atatat Exp $
.\"
-.\" Copyright (c) 2002 The NetBSD Foundation, Inc.
+.\" Copyright (c) 2002, 2003, The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
@@ -27,90 +27,64 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"/
-.Dd June 26, 2002
+.Dd February 23, 2003
.Dt WSMOUSED 8
.Os
.Sh NAME
.Nm wsmoused
-.Nd mouse console daemon
+.Nd mouse daemon
.Sh SYNOPSIS
.Nm
.Op Fl d Ar device
-.Op Fl f Ar fifo
-.Op Fl ln
-.Op Fl X Ar number
-.Op Fl x Ar number
-.Op Fl y Ar number
+.Op Fl f Ar conf_file
+.Op Fl n
.Sh DESCRIPTION
The
.Nm
daemon provides mouse support in console, allowing copying and pasting
-text. The left mouse button is used to select text when held and you
+text.
+The left mouse button is used to select text when held and you
use the right button to paste it in the active console.
.Pp
Supported options are as follows:
.Bl -tag -width XXXnumberX
.It Fl d Ar device
-specifies which driver to use as the mouse device. It defaults to
+specifies the device file to be used as the
+.Xr wsmouse 4
+device.
+Defaults to
.Pa /dev/wsmouse .
-.It Fl f Ar fifo
-is used to specify an optional fifo where to redirect all mouse events
-(even if they have been processed). By default, no fifo is used.
-.It Fl l
-swaps mouse buttons, specially useful for left handed users.
+.It Fl f Ar conf_file
+specifies the configuration file to be used.
+Defaults to
+.Pa /etc/wsmoused.conf .
.It Fl n
do not fork in the background (for debugging purposes).
-.It Fl X Ar number
-tells
-.Nm
-which virtual console holds the X server (if any). The argument
-specifies the console number (the same found in
-.Pa /dev/ttyE? ,
-where the ? appears).
-.Nm
-will stop processing events when entering this console and will
-continue its job when you return to any other terminal.
-.It Fl x Ar number
-x slowdown. This positive integer specifies how many events in the x
-direction should be ignored before changing the current column. It
-defaults to 0.
-.It Fl y Ar number
-y slowdown. This positive integer specifies how many events in the y
-direction should be ignored before changing the current row. It
-defaults to 3.
.El
+.Pp
+Many other details can be tuned.
+See
+.Xr wsmoused.conf 5
+for more information.
.Sh FILES
-.Bl -tag -width /dev/wsdisplayXXX -compact
+.Bl -tag -width /dev/wsmoused.conf -compact
.It Pa /dev/ttyE[0-n]
tty devices
.It Pa /dev/ttyEstat
wsdisplay status notification device
-.It Pa /dev/wsmouse0
+.It Pa /dev/wsmouse[0-n]
mouse control device
+.It Pa /etc/wsmoused.conf
+default configuration file
.El
-.Sh EXAMPLES
-The following are just a few examples of
-.Nm
-and its functionality.
-.Pp
-.Dl wsmoused -X 4
-.Pp
-Starts the mouse dameon, telling it that ttyE4 holds a X server.
-.Pp
-.Dl wsmoused -d /dev/wsmouse1 -f /tmp/mousefifo
-.Pp
-Uses
-.Pa /dev/wsmouse1
-device as the mouse and
-.Pa /tmp/mousefifo
-as the fifo where all mouse data is redirected.
.Sh SECURITY CONSIDERATIONS
Be ABSOLUTELY sure that
.Pa /dev/ttyE*
devices have restrictive permissions as the mouse uses some functions
that could allow terminal snooping if improperly set.
.Sh NOTES
-The mouse cursor is only visible for a short time. It will disappear
+The mouse cursor is only visible for a short time.
+It will disappear
when you stop moving it to avoid console corruption if there is any
output while it is visible.
.Pp
@@ -119,7 +93,8 @@
order to get mouse console support.
.Pp
When you return from the X screen to another terminal there is a small
-time delay until the mouse works again. The delay is needed to allow X
+time delay until the mouse works again.
+The delay is needed to allow X
to close the mouse device properly.
.Pp
It's needed that you change the getty program which runs in the first
@@ -139,9 +114,14 @@
.Xr wsmouse 4 ,
.Xr ttys 5 ,
.Xr wscons.conf 5 ,
+.Xr wsmoused.conf 5 ,
.Xr moused 8
.Sh HISTORY
The
.Nm
command first appeared in
.Nx 2.0 .
+.Sh AUTHORS
+The
+.Nm
+command was developed by Julio Merino \*[Lt]jmmv@netbsd.org\*[Gt].
Index: wsmoused.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/wsmoused/wsmoused.c,v
retrieving revision 1.6
diff -u -u -r1.6 wsmoused.c
--- wsmoused.c 2002/12/25 19:13:53 1.6
+++ wsmoused.c 2003/02/23 11:22:22
@@ -1,7 +1,7 @@
/* $NetBSD: wsmoused.c,v 1.6 2002/12/25 19:13:53 jmmv Exp $ */
/*
- * Copyright (c) 2002 The NetBSD Foundation, Inc.
+ * Copyright (c) 2002, 2003, The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -63,7 +63,6 @@
static struct mouse mouse;
int XConsole = -1;
-int NoDaemon = 0;
/*
* Show program usage information
@@ -72,8 +71,7 @@
usage(void)
{
(void)fprintf(stderr,
- "Usage: %s [-d device] [-f fifo] [-ln] [-X number] [-x number] "
- "[-y number]\n",
+ "Usage: %s [-d device] [-f config_file] [-n]\n",
getprogname());
exit(EXIT_FAILURE);
}
@@ -85,6 +83,7 @@
signal_terminate(int sig)
{
mouse_cursor_hide(&mouse);
+ config_free();
exit(EXIT_SUCCESS);
}
@@ -104,8 +103,7 @@
m->fd = open(m->device_name,
O_RDONLY | O_NONBLOCK, 0);
if (m->fd == -1) {
- err(EXIT_FAILURE, "cannot open '%s'",
- m->device_name);
+ err(EXIT_FAILURE, "%s", m->device_name);
}
}
@@ -118,7 +116,7 @@
/* Open wsdisplay status device */
mouse.stat_fd = open(_PATH_TTYSTAT, O_RDONLY | O_NONBLOCK, 0);
if (mouse.stat_fd == -1)
- err(EXIT_FAILURE, "Cannot open `%s'", _PATH_TTYSTAT);
+ err(EXIT_FAILURE, "%s", mouse.tstat_name);
mouse.fd = -1;
mouse_open_device(&mouse, 0);
@@ -127,7 +125,7 @@
if (mouse.fifo_name != NULL) {
mouse.fifo_fd = open(mouse.fifo_name, O_RDWR | O_NONBLOCK, 0);
if (mouse.fifo_fd == -1)
- err(EXIT_FAILURE, "Cannot open `%s'", mouse.fifo_name);
+ err(EXIT_FAILURE, "%s", mouse.fifo_name);
}
}
@@ -197,7 +195,7 @@
/* Get terminal size */
if (ioctl(0, TIOCGWINSZ, &ws) < 0)
- err(EXIT_FAILURE, "Cannot get terminal size");
+ err(EXIT_FAILURE, "cannot get terminal size");
/* Open current tty */
ioctl(mouse.stat_fd, WSDISPLAYIO_GETACTIVESCREEN, &i);
@@ -264,7 +262,7 @@
(void)snprintf(buf, sizeof(buf), _PATH_TTYPREFIX "%d", ttyno);
m->tty_fd = open(buf, O_RDONLY | O_NONBLOCK);
if (m->tty_fd < 0)
- errx(EXIT_FAILURE, "Cannot open `%s'", buf);
+ errx(EXIT_FAILURE, "%s", buf);
m->disabled = 0;
}
@@ -299,56 +297,61 @@
int
main(int argc, char **argv)
{
- int opt;
+ int opt, nodaemon = -1;
+ char *conffile;
+ struct block *mode;
setprogname(argv[0]);
- /* Setup mouse default data */
memset(&mouse, 0, sizeof(struct mouse));
- mouse.fifo_fd = -1;
- mouse.device_name = _PATH_DEFAULT_MOUSE;
- mouse.fifo_name = NULL;
-
- /* Defaults that can be overriden by options. If you change
- * these, update wsmoused.8 accordingly. */
- mouse.slowdown_x = 0;
- mouse.slowdown_y = 3;
-
- /* Right handed by default */
- mouse.but_select = 0;
- mouse.but_paste = 2;
+ conffile = _PATH_CONF;
/* Parse command line options */
- while ((opt = getopt(argc, argv, "d:f:lny:X:x:")) != -1) {
+ while ((opt = getopt(argc, argv, "d:f:n")) != -1) {
switch (opt) {
case 'd': /* Mouse device name */
- mouse.device_name = strdup(optarg);
+ mouse.device_name = optarg;
break;
- case 'f': /* FIFO file name */
- mouse.fifo_name = strdup(optarg);
+ case 'f': /* Configuration file name */
+ conffile = optarg;
break;
- case 'l': /* Left handed */
- mouse.but_select = 2;
- mouse.but_paste = 0;
- break;
case 'n': /* No daemon */
- NoDaemon = 1;
- break;
- case 'X': /* X console number */
- XConsole = atoi(optarg);
- break;
- case 'x': /* x slowdown */
- mouse.slowdown_x = atoi(optarg);
+ nodaemon = 1;
break;
- case 'y': /* y slowdown */
- mouse.slowdown_y = atoi(optarg);
- break;
default:
usage();
/* NOTREACHED */
}
}
+ /* Read the configuration file and get our mode configuration */
+ config_read(conffile);
+ mode = config_get_mode("sel");
+ if (mode == NULL)
+ errx(EXIT_FAILURE,
+ "`sel' mode not defined in configuration file");
+
+ /* Set values according to the configuration file */
+ if (mouse.device_name == NULL)
+ mouse.device_name = block_get_propval(mode, "device",
+ _PATH_DEFAULT_MOUSE);
+
+ if (nodaemon == -1)
+ nodaemon = block_get_propval_int(mode, "nodaemon", 0);
+
+ mouse.slowdown_x = block_get_propval_int(mode, "slowdown_x", 0);
+ mouse.slowdown_y = block_get_propval_int(mode, "slowdown_y", 3);
+ mouse.tstat_name = block_get_propval(mode, "ttystat", _PATH_TTYSTAT);
+ XConsole = block_get_propval_int(mode, "xconsole", -1);
+
+ if (block_get_propval_int(mode, "lefthanded", 0)) {
+ mouse.but_select = 2;
+ mouse.but_paste = 0;
+ } else {
+ mouse.but_select = 0;
+ mouse.but_paste = 2;
+ }
+
open_files();
mouse_init();
mouse_sel_init();
@@ -359,8 +362,10 @@
(void)signal(SIGQUIT, signal_terminate);
(void)signal(SIGTERM, signal_terminate);
- if (!NoDaemon) daemon(0, 0);
+ if (!nodaemon)
+ daemon(0, 0);
event_loop();
+ /* NOTREACHED */
return EXIT_SUCCESS;
}
Index: wsmoused.h
===================================================================
RCS file: /cvsroot/src/usr.sbin/wsmoused/wsmoused.h,v
retrieving revision 1.2
diff -u -u -r1.2 wsmoused.h
--- wsmoused.h 2002/12/25 19:13:53 1.2
+++ wsmoused.h 2003/02/23 11:22:23
@@ -40,6 +40,7 @@
int fifo_fd;
char *device_name;
char *fifo_name;
+ char *tstat_name;
/* Screen coordinates */
size_t row, col;
@@ -58,11 +59,45 @@
int but_paste;
};
+struct prop {
+ char *p_name;
+ char *p_value;
+};
+
+#define MAX_EVENTS 10
+#define MAX_BLOCKS 10
+#define MAX_PROPS 100
+#define BLOCK_GLOBAL 1
+#define BLOCK_MODE 2
+#define BLOCK_EVENT 3
+struct block {
+ char *b_name;
+ int b_type;
+ int b_prop_count;
+ int b_child_count;
+ struct prop *b_prop[MAX_BLOCKS];
+ struct block *b_child[MAX_BLOCKS];
+ struct block *b_parent;
+};
+
/* Prototypes for wsmoused.c */
void char_invert(struct mouse *, size_t, size_t);
void mouse_cursor_show(struct mouse *);
void mouse_cursor_hide(struct mouse *);
void mouse_open_tty(struct mouse *, int);
+
+/* Prototypes for config.c */
+struct prop *prop_new(void);
+void prop_free(struct prop *);
+struct block *block_new(int);
+void block_free(struct block *);
+void block_add_prop(struct block *, struct prop *);
+void block_add_child(struct block *, struct block *);
+char *block_get_propval(struct block *, char *, char *);
+int block_get_propval_int(struct block *, char *, int);
+struct block *config_get_mode(char *);
+void config_read(char *);
+void config_free(void);
/* Prototypes for event.c */
void mouse_motion_event(struct mouse *, struct wscons_event *);
----------------------------------------------------------------------
The config file lexer:
/* $NetBSD$ */
/*
* Copyright (c) 2003, The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Julio Merino.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. The name authors may not be used to endorse or promote products
* derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
%{
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: wsmoused.c,v 1.6 2002/12/25 19:13:53 jmmv Exp $");
#endif /* not lint */
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <dev/wscons/wsconsio.h>
#include "wsmoused.h"
#include "config_yacc.h"
extern int yyline;
extern int yyerror(const char *fmt, ...);
int yylex(void);
%}
%option noyywrap
STRING [\$A-Za-z\.\/_\-0-9]*
MODE_PROPS device|fifo|lefthanded|nodaemon|slowdown_x|slowdown_y|ttystat|xconsole
EVENT_PROPS button|do
%%
#.*$ /* Eat up comments */
[ \t]+ /* Eat up whitespace */
\n { yyline++; }
= { return TK_EQUAL; }
; { return TK_EOL; }
"{" { return TK_LBRACE; }
"}" { return TK_RBRACE; }
event { return TK_EVENT; }
mode { return TK_MODE; }
{EVENT_PROPS} { yylval.string = strdup(yytext); return TK_EVENTPROP; }
{MODE_PROPS} { yylval.string = strdup(yytext); return TK_MODEPROP; }
{STRING} { yylval.string = strdup(yytext); return TK_STRING; }
. { yyerror("illegal token `%s'", yytext); }
----------------------------------------------------------------------
The config file grammar analyer:
/* $NetBSD$ */
/*
* Copyright (c) 2003, The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Julio Merino.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. The name authors may not be used to endorse or promote products
* derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
%{
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD$");
#endif /* not lint */
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <sys/time.h>
#include <dev/wscons/wsconsio.h>
#include "err.h"
#include "wsmoused.h"
int yylex(void);
int yyparse(void);
int yyerror(const char *, ...);
void yyrestart(FILE *);
struct block *config_parse(char *);
int yyline;
static struct block *Conf;
%}
%token TK_EOL
%token TK_EQUAL TK_LBRACE TK_RBRACE
%token TK_STRING TK_EVENT TK_EVENTPROP TK_MODE TK_MODEPROP
%type <string> TK_STRING TK_EVENTPROP TK_MODEPROP
%type <prop> eventprop modeprop
%type <block> main outermode mode outerevent event
%union {
char *string;
struct prop *prop;
struct block *block;
}
%%
Config :
main { Conf = $1;
Conf->b_name = strdup("global"); }
;
/* Matches the whole configuration file and constructs a block defining it.
Can contain mode properties (common to all modes) and mode definitions. */
main :
modeprop { struct block *b = block_new(BLOCK_GLOBAL);
block_add_prop(b, $1);
$$ = b; }
| main modeprop { block_add_prop($1, $2); }
| outermode { struct block *b = block_new(BLOCK_GLOBAL);
block_add_child(b, $1);
$$ = b; }
| main outermode { block_add_child($1, $2); }
| error TK_EOL { yyerrok; }
;
/* Defines the aspect of a mode definition. Returns the block given by the
mode definition itself. */
outermode :
TK_MODE TK_STRING TK_LBRACE mode TK_RBRACE
{ $4->b_name = strdup($2);
$$ = $4; }
| TK_MODE TK_STRING TK_LBRACE TK_RBRACE
{ $$ = block_new(BLOCK_MODE);
$$->b_name = strdup($2); }
;
/* Matches a mode and returns a block defining it. Can contain properties
and event definitions. */
mode :
modeprop { struct block *b = block_new(BLOCK_MODE);
block_add_prop(b, $1);
$$ = b; }
| mode modeprop { block_add_prop($1, $2); }
| outerevent { struct block *b = block_new(BLOCK_MODE);
block_add_child(b, $1);
$$ = b; }
| mode outerevent { block_add_child($1, $2); }
| error TK_EOL { yyerrok; }
;
/* Defines the aspect of an event definition. Returns the block given by the
event definition itself. */
outerevent :
TK_EVENT TK_LBRACE event TK_RBRACE
{ $$ = $3; }
TK_EVENT TK_LBRACE TK_RBRACE
{ $$ = block_new(BLOCK_EVENT); }
;
/* Matches an event and returns a block defining it. Contains properties. */
event :
eventprop { struct block *b = block_new(BLOCK_EVENT);
block_add_prop(b, $1);
$$ = b; }
| event eventprop { block_add_prop($1, $2); }
| error TK_EOL { yyerrok; }
| error { yyerrok; }
;
/* Matches a mode property and returns a prop defining it. */
modeprop :
TK_MODEPROP TK_EQUAL TK_STRING TK_EOL
{ struct prop *p = prop_new();
p->p_name = strdup($1);
p->p_value = strdup($3);
$$ = p; }
;
/* Matches an event property and returns a prop defining it. */
eventprop :
TK_EVENTPROP TK_EQUAL TK_STRING TK_EOL
{ struct prop *p = prop_new();
p->p_name = strdup($1);
p->p_value = strdup($3);
$$ = p; }
;
%%
int
yyerror(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
fprintf(stderr, "%s: ", getprogname());
vfprintf(stderr, fmt, ap);
fprintf(stderr, " in line %d\n", yyline);
va_end(ap);
return (0);
}
struct block *
config_parse(char *filename)
{
FILE *fd;
fd = fopen(filename, "r");
if (fd == NULL)
err(EXIT_FAILURE, "%s", filename);
yyrestart(fd);
Conf = NULL;
yyline = 1;
yyparse();
return Conf;
}
----------------------------------------------------------------------
And the manpage for config file syntax. Read it to learn how the whole
thing works.
.\" $NetBSD$
.\"
.\" Copyright (c) 2003, The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
.\" by Julio Merino.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Neither the name of The NetBSD Foundation nor the names of its
.\" contributors may be used to endorse or promote products derived
.\" from this software without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"/
.Dd February 23, 2003
.Dt WSMOUSED.CONF 5
.Os
.Sh NAME
.Nm wsmoused.conf
.Nd mouse daemon configuration
.Sh SYNOPSIS
.Nm
.Sh DESCRIPTION
The
.Nm
file configures all the features provided by the
.Xr wsmoused 8
daemon.
It is composed by a series of
.Em blocks ,
each of which defines a group of
.Em properties .
The file format is free-form: new line markers are ignored as well as
indentation.
Comments start with the
.Ql #
sign and extend until the end of line.
.Pp
A
.Em property
is like a variable assignment.
It has a name, which goes to the left of the equal sign, and a value,
which goes to the right.
The assignment ends with a semicolon.
It looks like:
.Pp
.Dl name = value;
.Pp
There is no difference between string or integer values when defining them.
Booleans are specified as integers, where
.Ql 0
means false and
.Ql 1
stands for true.
Even though, the program cares about this and will emit a warning if you
have done an incorrect assignment.
Note that it will not accept unrecognized names.
.Pp
A
.Em mode
is a type of block that defines how the program behaves when run in a
specific mode.
A mode inherits properties defined in the global scope.
It has the following syntax:
.Pp
.Bd -literal -offset indent
mode mode_name {
property1 = value1;
...
propertyN = valueN;
}
.Ed
.Pp
In order to run
.Xr wsmoused 8
in a specific mode, it must be defined in the configuration file, even
if empty.
Actually, there is only one recognized mode, the
.Ql sel
mode.
.Ss Properties common to all modes
The following properties can be defined in the global scope, thus
affecting all modes, or inside the mode definition, to override global
values.
.Bl -tag -width indent
.It device = pathname;
The
.Xr wsmouse 4
device name to use.
Defaults to
.Pa /dev/wsmouse .
.It nodaemon = boolean;
Set to 1 to not fork in the background.
.El
.Pp
.Ss Properties specific to the sel mode
The following properties are only useful when running in the
.Em sel
mode:
.Bl -tag -width indent
.It fifo = pathname;
Specify an optional fifo where to redirect all mouse events, no matter
if they have been processed.
By default, no fifo is used.
.It lefthanded = boolean;
Set to 1 to swap mouse buttons, specially useful for left handed users.
.It slowdown_x = integer;
X axis slowdown. This positive integer specifies how many events in
the vertical direction should be ignored before changing the current
column.
It defaults to 0.
.It slowdown_y = integer;
Y axis slowdown. This positive integer specifies how many events in
the horizontal direction should be ignored before changing the current row.
It defaults to 3.
.It ttystat = pathname;
.Xr wsdisplay 4 's
notification device.
Defaults to
.Pa /dev/ttyEstat .
You will not want to change this.
.It xconsole = integer;
Virtual console number which holds the X server (if any).
The argument specifies the console number (the same found in
.Pa /dev/ttyE? ,
where the ? appears).
Unset by default.
.El
.Pp
.Sh FILES
.Bl -tag -width /dev/wsmoused.conf -compact
.It Pa /etc/wsmoused.conf
.El
.Pp
.Sh EXAMPLES
Here is a sample configuration file:
.Bd -literal -offset indent
# Set the default mouse device
device = /dev/wsmouse1
mode sel {
# Override the mouse device in this mode
device = /dev/wsmouse0
# X runs in ttyE4
xconsole = 4;
# Make pointer movements slower
slowdown_x = 5; slowdown_y = 5;
}
.Ed
.Pp
.Sh SEE ALSO
.Xr wsdisplay 4 ,
.Xr wsmouse 4 ,
.Xr wsmoused 8
.Sh HISTORY
The
.Nm
configuration file first appeared in
.Nx 2.0 .
--
Julio M. Merino Vidal <jmmv@menta.net>
The NetBSD Project - http://www.NetBSD.org/