devd.cc (215607) | devd.cc (226775) |
---|---|
1/*- 2 * Copyright (c) 2002-2010 M. Warner Losh. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 49 unchanged lines hidden (view full) --- 58 */ 59 60// TODO list: 61// o devd.conf and devd man pages need a lot of help: 62// - devd needs to document the unix domain socket 63// - devd.conf needs more details on the supported statements. 64 65#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2002-2010 M. Warner Losh. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 49 unchanged lines hidden (view full) --- 58 */ 59 60// TODO list: 61// o devd.conf and devd man pages need a lot of help: 62// - devd needs to document the unix domain socket 63// - devd.conf needs more details on the supported statements. 64 65#include <sys/cdefs.h> |
66__FBSDID("$FreeBSD: head/sbin/devd/devd.cc 215607 2010-11-21 04:02:37Z kevlo $"); | 66__FBSDID("$FreeBSD: head/sbin/devd/devd.cc 226775 2011-10-26 02:11:28Z hrs $"); |
67 68#include <sys/param.h> 69#include <sys/socket.h> 70#include <sys/stat.h> 71#include <sys/sysctl.h> 72#include <sys/types.h> 73#include <sys/wait.h> 74#include <sys/un.h> --- 171 unchanged lines hidden (view full) --- 246 my_system(s.c_str()); 247 return (true); 248} 249 250match::match(config &c, const char *var, const char *re) 251 : _var(var) 252{ 253 _re = "^"; | 67 68#include <sys/param.h> 69#include <sys/socket.h> 70#include <sys/stat.h> 71#include <sys/sysctl.h> 72#include <sys/types.h> 73#include <sys/wait.h> 74#include <sys/un.h> --- 171 unchanged lines hidden (view full) --- 246 my_system(s.c_str()); 247 return (true); 248} 249 250match::match(config &c, const char *var, const char *re) 251 : _var(var) 252{ 253 _re = "^"; |
254 _re.append(c.expand_string(string(re))); | 254 if (!c.expand_string(string(re)).empty() && 255 c.expand_string(string(re)).at(0) == '!') { 256 _re.append(c.expand_string(string(re)).substr(1)); 257 _inv = 1; 258 } else { 259 _re.append(c.expand_string(string(re))); 260 _inv = 0; 261 } |
255 _re.append("$"); 256 regcomp(&_regex, _re.c_str(), REG_EXTENDED | REG_NOSUB | REG_ICASE); 257} 258 259match::~match() 260{ 261 regfree(&_regex); 262} 263 264bool 265match::do_match(config &c) 266{ 267 const string &value = c.get_variable(_var); 268 bool retval; 269 270 if (Dflag) | 262 _re.append("$"); 263 regcomp(&_regex, _re.c_str(), REG_EXTENDED | REG_NOSUB | REG_ICASE); 264} 265 266match::~match() 267{ 268 regfree(&_regex); 269} 270 271bool 272match::do_match(config &c) 273{ 274 const string &value = c.get_variable(_var); 275 bool retval; 276 277 if (Dflag) |
271 fprintf(stderr, "Testing %s=%s against %s\n", _var.c_str(), 272 value.c_str(), _re.c_str()); | 278 fprintf(stderr, "Testing %s=%s against %s, invert=%d\n", 279 _var.c_str(), value.c_str(), _re.c_str(), _inv); |
273 274 retval = (regexec(&_regex, value.c_str(), 0, NULL, 0) == 0); | 280 281 retval = (regexec(&_regex, value.c_str(), 0, NULL, 0) == 0); |
282 if (_inv == 1) 283 retval = (retval == 0) ? 1 : 0; 284 |
|
275 return retval; 276} 277 278#include <sys/sockio.h> 279#include <net/if.h> 280#include <net/if_media.h> 281 282media::media(config &, const char *var, const char *type) --- 782 unchanged lines hidden --- | 285 return retval; 286} 287 288#include <sys/sockio.h> 289#include <net/if.h> 290#include <net/if_media.h> 291 292media::media(config &, const char *var, const char *type) --- 782 unchanged lines hidden --- |