Lines Matching +full:re +full:- +full:config

1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause AND BSD-2-Clause
4 * Copyright (c) 2002-2010 M. Warner Losh <imp@FreeBSD.org>
63 // - devd needs to document the unix domain socket
64 // - devd.conf needs more details on the supported statements.
122 * The kernel sets it to the minimum of a hard-coded maximum value and sbcc *
143 static const char detach = '-';
171 static config cfg;
175 event_proc::event_proc() : _prio(-1) in event_proc()
192 event_proc::matches(config &c) const in matches()
197 if (!(*i)->do_match(c)) in matches()
203 event_proc::run(config &c) const in run()
208 if (!(*i)->do_action(c)) in run()
248 case -1: /* error */ in my_system()
263 ::execl(_PATH_BSHELL, "sh", "-c", command, (char *)NULL); in my_system()
269 } while (pid == -1 && errno == EINTR); in my_system()
275 return (pid == -1 ? -1 : pstat); in my_system()
279 action::do_action(config &c) in do_action()
287 match::match(config &c, const char *var, const char *re) : in match() argument
288 _inv(re[0] == '!'), in match()
290 _re(c.expand_string(_inv ? re + 1 : re, "^", "$")) in match()
301 match::do_match(config &c) in do_match()
310 * log when we're in -d mode. in do_match()
328 media::media(config &, const char *var, const char *type) in media() argument
329 : _var(var), _type(-1) in media()
335 { -1, "unknown" }, in media()
350 media::do_match(config &c) in do_match()
358 // context where device-name is defined and what we want, in do_match()
360 // the name of interest, first try device-name and fall back in do_match()
362 value = c.get_variable("device-name"); in do_match()
380 } else if (_type == -1) { in do_match()
402 return (i->second); in get_variable()
436 * log when we're in -d mode. in set_variable()
444 config::reset(void) in reset()
461 config::parse_one_file(const char *fn) in parse_one_file()
470 err(1, "Cannot open config file %s", fn); in parse_one_file()
479 config::parse_files_in_dir(const char *dirname) in parse_files_in_dir()
492 if (strcmp(dp->d_name + dp->d_namlen - 5, ".conf") == 0) { in parse_files_in_dir()
494 dirname, dp->d_name); in parse_files_in_dir()
505 return (l1->get_priority() > l2->get_priority()); in operator ()()
510 config::sort_vector(vector<event_proc *> &v) in sort_vector()
516 config::parse(void) in parse()
530 config::open_pidfile() in open_pidfile()
545 config::write_pidfile() in write_pidfile()
552 config::close_pidfile() in close_pidfile()
559 config::remove_pidfile() in remove_pidfile()
566 config::add_attach(int prio, event_proc *p) in add_attach()
568 p->set_priority(prio); in add_attach()
573 config::add_detach(int prio, event_proc *p) in add_detach()
575 p->set_priority(prio); in add_detach()
580 config::add_directory(const char *dir) in add_directory()
586 config::add_nomatch(int prio, event_proc *p) in add_nomatch()
588 p->set_priority(prio); in add_nomatch()
593 config::add_notify(int prio, event_proc *p) in add_notify()
595 p->set_priority(prio); in add_notify()
600 config::set_pidfile(const char *fn) in set_pidfile()
606 config::push_var_table() in push_var_table()
616 config::pop_var_table() in pop_var_table()
624 config::set_variable(const char *var, const char *val) in set_variable()
626 _var_list_table.back()->set_variable(var, val); in set_variable()
630 config::get_variable(const string &var) in get_variable()
635 if ((*i)->is_set(var)) in get_variable()
636 return ((*i)->get_variable(var)); in get_variable()
642 config::is_id_char(char ch) const in is_id_char()
645 ch == '-')); in is_id_char()
649 config::shell_quote(const string &s) in shell_quote()
678 config::expand_one(const char *&src, string &dst, bool is_shell) in expand_one()
684 // $$ -> $ in expand_one()
690 // $(foo) -> $(foo) in expand_one()
698 count--; in expand_one()
706 // $[^-A-Za-z_*] -> $\1 in expand_one()
707 if (!isalpha(*src) && *src != '_' && *src != '-' && *src != '*') { in expand_one()
713 // $var -> replace with value in expand_one()
721 config::expand_string(const char *src, const char *prepend, const char *append) in expand_string()
728 * while parsing config files, as tested on 2013-01-30. in expand_string()
741 dst.append(src, var_at - src); in expand_string()
753 config::chop_var(char *&buffer, char *&lhs, char *&rhs) const in chop_var()
777 rhs[-2] = '\0'; in chop_var()
785 rhs[-1] = '\0'; in chop_var()
795 config::set_vars(char *buffer) in set_vars()
809 config::find_and_execute(char type) in find_and_execute()
836 for (i = l->begin(); i != l->end(); ++i) { in find_and_execute()
837 if ((*i)->matches(*this)) { in find_and_execute()
838 (*i)->run(*this); in find_and_execute()
859 cfg.set_variable("*", buffer - 1); in process_event()
878 //? at location pnp-info on bus in process_event()
899 cfg.set_variable("device-name", buffer); in process_event()
934 if (chown(name, 0, 0)) /* XXX - root.wheel */ in create_socket()
960 if (i->socktype == SOCK_SEQPACKET) in notify_clients()
965 if (send(i->fd, data, len, flags) != len) { in notify_clients()
966 --num_clients; in notify_clients()
967 close(i->fd); in notify_clients()
986 * event. This check eliminates the problem of an ever-growing list of in check_clients()
987 * zombie clients because we're never writing to them on a system in check_clients()
988 * without frequent device-change activity. in check_clients()
992 pfd.fd = i->fd; in check_clients()
996 --num_clients; in check_clients()
997 close(i->fd); in check_clients()
1020 if (s.fd != -1) { in new_client()
1045 if (fd == -1) in event_loop()
1059 // No events -> we've processed all pending events in event_loop()
1104 if (rv == -1) { in event_loop()
1111 rv = read(fd, buffer, sizeof(buffer) - 1); in event_loop()
1114 if (rv == sizeof(buffer) - 1) { in event_loop()
1121 while (buffer[--rv] == '\n') in event_loop()
1192 ep->add(eps); in add_to_event_proc()
1205 new_match(const char *var, const char *re) in new_match() argument
1228 eps *e = new match(cfg, var, re); in new_match()
1230 free(const_cast<char *>(re)); in new_match()
1235 new_media(const char *var, const char *re) in new_media() argument
1237 eps *e = new media(cfg, var, re); in new_media()
1239 free(const_cast<char *>(re)); in new_media()
1277 * Local logging function. Prints to syslog if we're daemonized; stderr
1296 fprintf(stderr, "usage: %s [-dnq] [-l connlimit] [-f file]\n", in usage()
1327 while ((ch = getopt(argc, argv, "df:l:nq")) != -1) { in main()