Have tincd and tincctl use the same method of determining netname.

This commit is contained in:
Guus Sliepen 2012-07-21 15:15:04 +02:00
parent 1d322d2eda
commit 33521eabd4
2 changed files with 20 additions and 8 deletions

View file

@ -187,11 +187,15 @@ static bool parse_options(int argc, char **argv) {
}
}
if(!netname) {
netname = getenv("NETNAME");
if(netname)
netname = xstrdup(netname);
}
if(!netname && (netname = getenv("NETNAME")))
netname = xstrdup(netname);
/* netname "." is special: a "top-level name" */
if(!strcmp(netname, ".")) {
free(netname);
netname = NULL;
}
return true;
}

View file

@ -177,9 +177,7 @@ static bool parse_options(int argc, char **argv) {
break;
case 'n': /* net name given */
/* netname "." is special: a "top-level name" */
netname = strcmp(optarg, ".") != 0 ?
xstrdup(optarg) : NULL;
netname = xstrdup(optarg);
break;
case 'o': /* option */
@ -228,6 +226,16 @@ static bool parse_options(int argc, char **argv) {
}
}
if(!netname && (netname = getenv("NETNAME")))
netname = xstrdup(netname);
/* netname "." is special: a "top-level name" */
if(!strcmp(netname, ".")) {
free(netname);
netname = NULL;
}
return true;
}