1e530e044SWarner Losh %{ 2e530e044SWarner Losh /*- 3e530e044SWarner Losh * DEVD (Device action daemon) 4e530e044SWarner Losh * 5e530e044SWarner Losh * Copyright (c) 2002 M. Warner Losh <imp@freebsd.org>. 6e530e044SWarner Losh * All rights reserved. 7e530e044SWarner Losh * 8e530e044SWarner Losh * Redistribution and use in source and binary forms, with or without 9e530e044SWarner Losh * modification, are permitted provided that the following conditions 10e530e044SWarner Losh * are met: 11e530e044SWarner Losh * 1. Redistributions of source code must retain the above copyright 12e530e044SWarner Losh * notice, this list of conditions and the following disclaimer. 13e530e044SWarner Losh * 2. Redistributions in binary form must reproduce the above copyright 14e530e044SWarner Losh * notice, this list of conditions and the following disclaimer in the 15e530e044SWarner Losh * documentation and/or other materials provided with the distribution. 16e530e044SWarner Losh * 17e530e044SWarner Losh * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18e530e044SWarner Losh * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19e530e044SWarner Losh * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20e530e044SWarner Losh * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21e530e044SWarner Losh * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22e530e044SWarner Losh * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23e530e044SWarner Losh * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24e530e044SWarner Losh * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25e530e044SWarner Losh * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26e530e044SWarner Losh * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27e530e044SWarner Losh * SUCH DAMAGE. 28e530e044SWarner Losh * 29e530e044SWarner Losh * $FreeBSD$ 30e530e044SWarner Losh */ 31e530e044SWarner Losh 32*5e2a209aSBaptiste Daroussin #include <sys/cdefs.h> 33e530e044SWarner Losh #include "devd.h" 34e530e044SWarner Losh #include <stdio.h> 353054f218SWarner Losh #include <string.h> 36e530e044SWarner Losh 37e530e044SWarner Losh %} 38e530e044SWarner Losh 39e530e044SWarner Losh %union { 40e530e044SWarner Losh char *str; 41e530e044SWarner Losh int i; 423054f218SWarner Losh struct eps *eps; /* EventProcStatement */ 433054f218SWarner Losh struct event_proc *eventproc; 44e530e044SWarner Losh } 45e530e044SWarner Losh 46e530e044SWarner Losh %token SEMICOLON BEGINBLOCK ENDBLOCK COMMA 47e530e044SWarner Losh %token <i> NUMBER 48e530e044SWarner Losh %token <str> STRING 49e530e044SWarner Losh %token <str> ID 50e530e044SWarner Losh %token OPTIONS SET DIRECTORY PID_FILE DEVICE_NAME ACTION MATCH 51cd70782bSWarner Losh %token ATTACH DETACH NOMATCH NOTIFY MEDIA_TYPE CLASS SUBDEVICE 52e530e044SWarner Losh 533054f218SWarner Losh %type <eventproc> match_or_action_list 543054f218SWarner Losh %type <eps> match_or_action match action 55e530e044SWarner Losh 56e530e044SWarner Losh %% 57e530e044SWarner Losh 58e530e044SWarner Losh config_file 59e530e044SWarner Losh : config_list 603054f218SWarner Losh | 61e530e044SWarner Losh ; 62e530e044SWarner Losh 63e530e044SWarner Losh config_list 64e530e044SWarner Losh : config 65e530e044SWarner Losh | config_list config 66e530e044SWarner Losh ; 67e530e044SWarner Losh 68e530e044SWarner Losh config 69e530e044SWarner Losh : option_block 70e530e044SWarner Losh | attach_block 71e530e044SWarner Losh | detach_block 72e530e044SWarner Losh | nomatch_block 73842ccec5SWarner Losh | notify_block 74e530e044SWarner Losh ; 75e530e044SWarner Losh 76e530e044SWarner Losh option_block 77e530e044SWarner Losh : OPTIONS BEGINBLOCK options ENDBLOCK SEMICOLON 78e530e044SWarner Losh ; 79e530e044SWarner Losh 80e530e044SWarner Losh options 81e530e044SWarner Losh : option 82e530e044SWarner Losh | options option 83e530e044SWarner Losh 84e530e044SWarner Losh option 85e530e044SWarner Losh : directory_option 86e530e044SWarner Losh | pid_file_option 87e530e044SWarner Losh | set_option 88e530e044SWarner Losh ; 89e530e044SWarner Losh 90e530e044SWarner Losh directory_option 913054f218SWarner Losh : DIRECTORY STRING SEMICOLON { add_directory($2); } 92e530e044SWarner Losh ; 93e530e044SWarner Losh 94e530e044SWarner Losh pid_file_option 953054f218SWarner Losh : PID_FILE STRING SEMICOLON { set_pidfile($2); } 96e530e044SWarner Losh ; 97e530e044SWarner Losh 98e530e044SWarner Losh set_option 993054f218SWarner Losh : SET ID STRING SEMICOLON { set_variable($2, $3); } 100e530e044SWarner Losh ; 101e530e044SWarner Losh 102e530e044SWarner Losh attach_block 1033054f218SWarner Losh : ATTACH NUMBER BEGINBLOCK match_or_action_list ENDBLOCK SEMICOLON 1043054f218SWarner Losh { add_attach($2, $4); } 10518e8d6d7SWarner Losh | ATTACH NUMBER BEGINBLOCK ENDBLOCK SEMICOLON 106e530e044SWarner Losh ; 107e530e044SWarner Losh 108e530e044SWarner Losh detach_block 1093054f218SWarner Losh : DETACH NUMBER BEGINBLOCK match_or_action_list ENDBLOCK SEMICOLON 1103054f218SWarner Losh { add_detach($2, $4); } 11118e8d6d7SWarner Losh | DETACH NUMBER BEGINBLOCK ENDBLOCK SEMICOLON 112e530e044SWarner Losh ; 113e530e044SWarner Losh 114e530e044SWarner Losh nomatch_block 1153054f218SWarner Losh : NOMATCH NUMBER BEGINBLOCK match_or_action_list ENDBLOCK SEMICOLON 1163054f218SWarner Losh { add_nomatch($2, $4); } 11718e8d6d7SWarner Losh | NOMATCH NUMBER BEGINBLOCK ENDBLOCK SEMICOLON 118e530e044SWarner Losh ; 119e530e044SWarner Losh 120842ccec5SWarner Losh notify_block 121842ccec5SWarner Losh : NOTIFY NUMBER BEGINBLOCK match_or_action_list ENDBLOCK SEMICOLON 122842ccec5SWarner Losh { add_notify($2, $4); } 123842ccec5SWarner Losh | NOTIFY NUMBER BEGINBLOCK ENDBLOCK SEMICOLON 124842ccec5SWarner Losh ; 125842ccec5SWarner Losh 126e530e044SWarner Losh match_or_action_list 1273054f218SWarner Losh : match_or_action { $$ = add_to_event_proc( NULL, $1); } 128e530e044SWarner Losh | match_or_action_list match_or_action 1293054f218SWarner Losh { $$ = add_to_event_proc($1, $2); } 130e530e044SWarner Losh ; 131e530e044SWarner Losh 132e530e044SWarner Losh match_or_action 133e530e044SWarner Losh : match 134e530e044SWarner Losh | action 135e530e044SWarner Losh ; 136e530e044SWarner Losh 137e530e044SWarner Losh match 1383054f218SWarner Losh : MATCH STRING STRING SEMICOLON { $$ = new_match($2, $3); } 1393054f218SWarner Losh | DEVICE_NAME STRING SEMICOLON 1403054f218SWarner Losh { $$ = new_match(strdup("device-name"), $2); } 141cd70782bSWarner Losh | MEDIA_TYPE STRING SEMICOLON 142cd70782bSWarner Losh { $$ = new_media(strdup("media-type"), $2); } 143cd70782bSWarner Losh | CLASS STRING SEMICOLON 144cd70782bSWarner Losh { $$ = new_match(strdup("class"), $2); } 145cd70782bSWarner Losh | SUBDEVICE STRING SEMICOLON 146cd70782bSWarner Losh { $$ = new_match(strdup("subdevice"), $2); } 147e530e044SWarner Losh ; 148e530e044SWarner Losh 149e530e044SWarner Losh action 1503054f218SWarner Losh : ACTION STRING SEMICOLON { $$ = new_action($2); } 151e530e044SWarner Losh ; 152e530e044SWarner Losh 153e530e044SWarner Losh %% 154