[PC-BSD Commits] r18313 - pcbsd/current/src-sh/pc-adctl/nssldap
svn at pcbsd.org
svn at pcbsd.org
Tue Aug 7 13:28:05 PDT 2012
Author: johnh
Date: 2012-08-07 20:28:05 +0000 (Tue, 07 Aug 2012)
New Revision: 18313
Modified:
pcbsd/current/src-sh/pc-adctl/nssldap/nssldapconf.c
Log:
distinguish between pairs and triplets
Modified: pcbsd/current/src-sh/pc-adctl/nssldap/nssldapconf.c
===================================================================
--- pcbsd/current/src-sh/pc-adctl/nssldap/nssldapconf.c 2012-08-07 20:24:41 UTC (rev 18312)
+++ pcbsd/current/src-sh/pc-adctl/nssldap/nssldapconf.c 2012-08-07 20:28:05 UTC (rev 18313)
@@ -77,8 +77,12 @@
return (str);
}
+
+#define add_pair(m,c) add_modification(m, 'p', c)
+#define add_triplet(m,c) add_modification(m, 't', c)
+
static int
-add_modification(const char *m, int create)
+add_modification(const char *m, int mt, int create)
{
char *tmp, *save, *ptr;
struct nssldap_modification *nm;
@@ -125,13 +129,18 @@
if (tmp != NULL)
nm->name = xstrdup(clean(tmp));
if (ptr != NULL) {
- tmp = strsep(&ptr, "=");
- if (ptr != NULL) {
- nm->attr = xstrdup(clean(tmp));
- nm->value = xstrdup(clean(ptr));
+ switch (mt) {
+ case 't': {
+ tmp = strsep(&ptr, "=");
+ if (ptr != NULL) {
+ nm->attr = xstrdup(clean(tmp));
+ nm->value = xstrdup(clean(ptr));
+ }
+ }
- } else {
- nm->value = xstrdup(clean(tmp));
+ case 'p':
+ default:
+ nm->value = xstrdup(clean(ptr));
}
}
@@ -365,7 +374,8 @@
"Where options in:\n\n"
"\t-f <input file>\n"
"\t-o <output file>\n"
- "\t-m <(+|-|^)name=(value|attr=value)>\n\n"
+ "\t-p <(+|-|^)name=value>\n\n"
+ "\t-t <(+|-|^)name=attr=value>\n\n"
);
exit (1);
@@ -382,7 +392,7 @@
create = 0;
infile = outfile = NULL;
- while ((ch = getopt(argc, argv, "f:m:co:")) != -1) {
+ while ((ch = getopt(argc, argv, "f:m:p:t:co:")) != -1) {
switch (ch) {
case 'f':
xfree(&infile);
@@ -394,10 +404,16 @@
break;
case 'm':
- add_modification(optarg, create);
+ case 'p':
+ add_pair(optarg, create);
create = 0;
break;
+ case 't':
+ add_triplet(optarg, create);
+ create = 0;
+ break;
+
case 'o':
xfree(&outfile);
outfile = xstrdup(optarg);
More information about the Commits
mailing list