Mercurial > libpst
annotate src/nick2ldif.cpp @ 250:c47bba52460f stable-0-6-47
Subpackage Licensing
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Wed, 07 Jul 2010 16:04:17 -0700 |
parents | fc11b1d1ad34 |
children | 8ad8fd1c5451 |
rev | line source |
---|---|
16 | 1 /* |
2 | |
3 Copyright (c) 2004 Carl Byington - 510 Software Group, released under | |
4 the GPL version 2 or any later version at your choice available at | |
5 http://www.fsf.org/licenses/gpl.txt | |
6 | |
7 */ | |
8 | |
9 #include <iostream> | |
123
ab2a11e72250
more cleanup of #include files.
Carl Byington <carl@five-ten-sg.com>
parents:
118
diff
changeset
|
10 |
118
0f1492b7fe8b
patch from Fridrich Strba for building on mingw and general cleanup of autoconf files
Carl Byington <carl@five-ten-sg.com>
parents:
21
diff
changeset
|
11 extern "C" { |
0f1492b7fe8b
patch from Fridrich Strba for building on mingw and general cleanup of autoconf files
Carl Byington <carl@five-ten-sg.com>
parents:
21
diff
changeset
|
12 #include "define.h" |
0f1492b7fe8b
patch from Fridrich Strba for building on mingw and general cleanup of autoconf files
Carl Byington <carl@five-ten-sg.com>
parents:
21
diff
changeset
|
13 } |
16 | 14 |
15 char *ldap_base = NULL; | |
16 char *ldap_org = NULL; | |
17 char *ldap_class = NULL; | |
18 | |
19 using namespace std; | |
20 | |
118
0f1492b7fe8b
patch from Fridrich Strba for building on mingw and general cleanup of autoconf files
Carl Byington <carl@five-ten-sg.com>
parents:
21
diff
changeset
|
21 int main(int argc, const char** argv) { |
16 | 22 char c; |
23 char *temp; | |
24 while ((c = getopt(argc, argv, "b:c:"))!= -1) { | |
25 switch (c) { | |
26 case 'b': | |
27 ldap_base = optarg; | |
28 temp = strchr(ldap_base, ','); | |
29 if (temp) { | |
30 *temp = '\0'; | |
31 ldap_org = strdup(ldap_base); | |
32 *temp = ','; | |
33 } | |
34 break; | |
35 case 'c': | |
36 ldap_class = optarg; | |
37 break; | |
38 default: | |
39 break; | |
40 } | |
41 } | |
42 | |
43 const int LINE_SIZE = 2000; | |
44 char line[LINE_SIZE]; | |
45 while (!cin.eof()) { | |
46 cin.getline(line, LINE_SIZE); | |
47 int n = strlen(line); | |
48 if (!n) continue; | |
49 char *f = line + 6; // skip alias keyword | |
50 char *e; | |
51 if (*f == '"') { | |
52 f++; | |
53 e = strchr(f, '"'); | |
54 } | |
55 else { | |
56 e = strchr(f, ' '); | |
57 } | |
58 if (!e) continue; | |
59 *e = '\0'; | |
60 char *m = e+1; | |
61 while (*m == ' ') m++; | |
62 if (*m != '\0') { | |
63 char cn[1000]; | |
64 snprintf(cn, sizeof(cn), "email %s", f); | |
65 printf("dn: cn=%s, %s\n", cn, ldap_base); | |
66 printf("cn: %s\n", cn); | |
67 printf("sn: %s\n", f); | |
68 printf("mail: %s\n", m); | |
69 printf("objectClass: %s\n\n", ldap_class); | |
70 } | |
71 } | |
72 } |