unsigned int i;
for (i = 0; i < sizeof(longopts) / sizeof(longopts[0]); i++) {
- if (strcmp(longopts[i].name, opt) != 0)
+ if (!longopts[i].name ||
+ strcmp(longopts[i].name, opt) != 0)
continue;
if (longopts[i].has_arg == required_argument && !line) {
int pidfd = -1;
int sig = 0;
int retval = EXIT_FAILURE;
- char *line, *option, *p, *buffer = NULL;
+ char *line, *option, *p, *lp, *buffer = NULL;
+ char lt = '\\';
size_t len = 0;
FILE *f;
r = 1;
while ((get_line(&buffer, &len, f))) {
line = buffer;
- option = strsep(&line, " ");
+ while ((option = strsep(&line, " \t")))
+ if (*option != '\0')
+ break;
if (!option || *option == '\0' || *option == '#')
continue;
/* Trim leading whitespace */
/* Trim trailing whitespace */
if (line && *line) {
p = line + strlen(line) - 1;
- while (p != line && (*p == ' ' || *p == '\t'))
+ while (p != line && (*p == ' ' || *p == '\t')) {
+ /* Remember the last char trimmed */
+ lt = *p;
*p-- = '\0';
+ }
+ }
+ /* Process escapes */
+ lp = p = line;
+ while (p && *p) {
+ if (*p == '\\')
+ p++;
+ /* EOL? */
+ if (*p == '\0') {
+ /* Restore the last char trimmed */
+ *lp++ = lt;
+ break;
+ }
+ *lp++ = *p++;
}
+ if (lp)
+ *lp = '\0';
r = parse_config_line(option, line, options);
if (r != 1)
break;
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd Apr 18, 2008
+.Dd Apr 24, 2008
.Dt DHCPCD.CONF 5 SMM
.Sh NAME
.Nm dhcpcd.conf
to do it once in a configuration file. Most of the options found in
.Xr dhcpcd 8
can be used here. The first word on the line is the option and the rest of the
-line is the value. Blank lines and lines starting with # are ignored.
+line is the value. Leading and trailing whitespace for the option and value
+are trimmed. You can escape characters in the value using the \ character.
+.Pp
+Blank lines and lines starting with # are ignored.
.Pp
Here's a list of available options:
.Bl -tag -width indent