diff options
Diffstat (limited to 'sbin/devd/devd.cc')
-rw-r--r-- | sbin/devd/devd.cc | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/sbin/devd/devd.cc b/sbin/devd/devd.cc index 203d750..b2aea19 100644 --- a/sbin/devd/devd.cc +++ b/sbin/devd/devd.cc @@ -648,8 +648,8 @@ config::expand_one(const char *&src, string &dst) return; } - // $[^A-Za-z] -> $\1 - if (!isalpha(*src)) { + // $[^-A-Za-z_*] -> $\1 + if (!isalpha(*src) && *src != '_' && *src != '-' && *src != '*') { dst += '$'; dst += *src++; return; @@ -788,15 +788,30 @@ process_event(char *buffer) { char type; char *sp; + struct timeval tv; + char *timestr; sp = buffer + 1; devdlog(LOG_INFO, "Processing event '%s'\n", buffer); type = *buffer++; cfg.push_var_table(); - // No match doesn't have a device, and the format is a little + // $* is the entire line + cfg.set_variable("*", buffer - 1); + // $_ is the entire line without the initial character + cfg.set_variable("_", buffer); + + // Save the time this happened (as approximated by when we got + // around to processing it). + gettimeofday(&tv, NULL); + asprintf(×tr, "%jd.%06ld", (uintmax_t)tv.tv_sec, tv.tv_usec); + cfg.set_variable("timestamp", timestr); + free(timestr); + + // Match doesn't have a device, and the format is a little // different, so handle it separately. switch (type) { case notify: + //! (k=v)* sp = cfg.set_vars(sp); break; case nomatch: |