1e530e044SWarner Losh %{ 2e530e044SWarner Losh /*- 3e530e044SWarner Losh * DEVD (Device action daemon) 4e530e044SWarner Losh * 5*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 61de7b4b8SPedro F. Giffuni * 7f86e6000SWarner Losh * Copyright (c) 2002 M. Warner Losh <imp@FreeBSD.org> 8e530e044SWarner Losh * 9e530e044SWarner Losh * Redistribution and use in source and binary forms, with or without 10e530e044SWarner Losh * modification, are permitted provided that the following conditions 11e530e044SWarner Losh * are met: 12e530e044SWarner Losh * 1. Redistributions of source code must retain the above copyright 13e530e044SWarner Losh * notice, this list of conditions and the following disclaimer. 14e530e044SWarner Losh * 2. Redistributions in binary form must reproduce the above copyright 15e530e044SWarner Losh * notice, this list of conditions and the following disclaimer in the 16e530e044SWarner Losh * documentation and/or other materials provided with the distribution. 17e530e044SWarner Losh * 18e530e044SWarner Losh * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19e530e044SWarner Losh * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20e530e044SWarner Losh * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21e530e044SWarner Losh * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22e530e044SWarner Losh * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23e530e044SWarner Losh * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24e530e044SWarner Losh * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25e530e044SWarner Losh * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26e530e044SWarner Losh * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27e530e044SWarner Losh * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28e530e044SWarner Losh * SUCH DAMAGE. 29e530e044SWarner Losh */ 30e530e044SWarner Losh 315e2a209aSBaptiste Daroussin #include <sys/cdefs.h> 32e530e044SWarner Losh #include "devd.h" 33e530e044SWarner Losh #include <stdio.h> 343054f218SWarner Losh #include <string.h> 35e530e044SWarner Losh 36e530e044SWarner Losh %} 37e530e044SWarner Losh 38e530e044SWarner Losh %union { 39e530e044SWarner Losh char *str; 40e530e044SWarner Losh int i; 413054f218SWarner Losh struct eps *eps; /* EventProcStatement */ 423054f218SWarner Losh struct event_proc *eventproc; 43e530e044SWarner Losh } 44e530e044SWarner Losh 45e530e044SWarner Losh %token SEMICOLON BEGINBLOCK ENDBLOCK COMMA 46e530e044SWarner Losh %token <i> NUMBER 47e530e044SWarner Losh %token <str> STRING 48e530e044SWarner Losh %token <str> ID 49e530e044SWarner Losh %token OPTIONS SET DIRECTORY PID_FILE DEVICE_NAME ACTION MATCH 50cd70782bSWarner Losh %token ATTACH DETACH NOMATCH NOTIFY MEDIA_TYPE CLASS SUBDEVICE 51e530e044SWarner Losh 523054f218SWarner Losh %type <eventproc> match_or_action_list 533054f218SWarner Losh %type <eps> match_or_action match action 54e530e044SWarner Losh 55e530e044SWarner Losh %% 56e530e044SWarner Losh 57e530e044SWarner Losh config_file 58e530e044SWarner Losh : config_list 593054f218SWarner Losh | 60e530e044SWarner Losh ; 61e530e044SWarner Losh 62e530e044SWarner Losh config_list 63e530e044SWarner Losh : config 64e530e044SWarner Losh | config_list config 65e530e044SWarner Losh ; 66e530e044SWarner Losh 67e530e044SWarner Losh config 68e530e044SWarner Losh : option_block 69e530e044SWarner Losh | attach_block 70e530e044SWarner Losh | detach_block 71e530e044SWarner Losh | nomatch_block 72842ccec5SWarner Losh | notify_block 73e530e044SWarner Losh ; 74e530e044SWarner Losh 75e530e044SWarner Losh option_block 76e530e044SWarner Losh : OPTIONS BEGINBLOCK options ENDBLOCK SEMICOLON 77e530e044SWarner Losh ; 78e530e044SWarner Losh 79e530e044SWarner Losh options 80e530e044SWarner Losh : option 81e530e044SWarner Losh | options option 82e530e044SWarner Losh 83e530e044SWarner Losh option 84e530e044SWarner Losh : directory_option 85e530e044SWarner Losh | pid_file_option 86e530e044SWarner Losh | set_option 87e530e044SWarner Losh ; 88e530e044SWarner Losh 89e530e044SWarner Losh directory_option 903054f218SWarner Losh : DIRECTORY STRING SEMICOLON { add_directory($2); } 91e530e044SWarner Losh ; 92e530e044SWarner Losh 93e530e044SWarner Losh pid_file_option 943054f218SWarner Losh : PID_FILE STRING SEMICOLON { set_pidfile($2); } 95e530e044SWarner Losh ; 96e530e044SWarner Losh 97e530e044SWarner Losh set_option 983054f218SWarner Losh : SET ID STRING SEMICOLON { set_variable($2, $3); } 99e530e044SWarner Losh ; 100e530e044SWarner Losh 101e530e044SWarner Losh attach_block 1023054f218SWarner Losh : ATTACH NUMBER BEGINBLOCK match_or_action_list ENDBLOCK SEMICOLON 1033054f218SWarner Losh { add_attach($2, $4); } 10418e8d6d7SWarner Losh | ATTACH NUMBER BEGINBLOCK ENDBLOCK SEMICOLON 105e530e044SWarner Losh ; 106e530e044SWarner Losh 107e530e044SWarner Losh detach_block 1083054f218SWarner Losh : DETACH NUMBER BEGINBLOCK match_or_action_list ENDBLOCK SEMICOLON 1093054f218SWarner Losh { add_detach($2, $4); } 11018e8d6d7SWarner Losh | DETACH NUMBER BEGINBLOCK ENDBLOCK SEMICOLON 111e530e044SWarner Losh ; 112e530e044SWarner Losh 113e530e044SWarner Losh nomatch_block 1143054f218SWarner Losh : NOMATCH NUMBER BEGINBLOCK match_or_action_list ENDBLOCK SEMICOLON 1153054f218SWarner Losh { add_nomatch($2, $4); } 11618e8d6d7SWarner Losh | NOMATCH NUMBER BEGINBLOCK ENDBLOCK SEMICOLON 117e530e044SWarner Losh ; 118e530e044SWarner Losh 119842ccec5SWarner Losh notify_block 120842ccec5SWarner Losh : NOTIFY NUMBER BEGINBLOCK match_or_action_list ENDBLOCK SEMICOLON 121842ccec5SWarner Losh { add_notify($2, $4); } 122842ccec5SWarner Losh | NOTIFY NUMBER BEGINBLOCK ENDBLOCK SEMICOLON 123842ccec5SWarner Losh ; 124842ccec5SWarner Losh 125e530e044SWarner Losh match_or_action_list 1263054f218SWarner Losh : match_or_action { $$ = add_to_event_proc( NULL, $1); } 127e530e044SWarner Losh | match_or_action_list match_or_action 1283054f218SWarner Losh { $$ = add_to_event_proc($1, $2); } 129e530e044SWarner Losh ; 130e530e044SWarner Losh 131e530e044SWarner Losh match_or_action 132e530e044SWarner Losh : match 133e530e044SWarner Losh | action 134e530e044SWarner Losh ; 135e530e044SWarner Losh 136e530e044SWarner Losh match 1373054f218SWarner Losh : MATCH STRING STRING SEMICOLON { $$ = new_match($2, $3); } 1383054f218SWarner Losh | DEVICE_NAME STRING SEMICOLON 1393054f218SWarner Losh { $$ = new_match(strdup("device-name"), $2); } 140cd70782bSWarner Losh | MEDIA_TYPE STRING SEMICOLON 141cd70782bSWarner Losh { $$ = new_media(strdup("media-type"), $2); } 142cd70782bSWarner Losh | CLASS STRING SEMICOLON 143cd70782bSWarner Losh { $$ = new_match(strdup("class"), $2); } 144cd70782bSWarner Losh | SUBDEVICE STRING SEMICOLON 145cd70782bSWarner Losh { $$ = new_match(strdup("subdevice"), $2); } 146e530e044SWarner Losh ; 147e530e044SWarner Losh 148e530e044SWarner Losh action 1493054f218SWarner Losh : ACTION STRING SEMICOLON { $$ = new_action($2); } 150e530e044SWarner Losh ; 151e530e044SWarner Losh 152e530e044SWarner Losh %% 153