Mercurial > libpst
annotate src/nick2ldif.cpp @ 123:ab2a11e72250
more cleanup of #include files.
common.h is the only file allowed to include system .h files
unprotected by autoconf HAVE_ symbols. define.h is the only other file
allowed to include system .h files. define.h is never installed;
common.h is installed if we are building the shared library.
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Tue, 03 Feb 2009 10:59:10 -0800 |
parents | 0f1492b7fe8b |
children | fc11b1d1ad34 |
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" { |
123
ab2a11e72250
more cleanup of #include files.
Carl Byington <carl@five-ten-sg.com>
parents:
118
diff
changeset
|
12 #include "common.h" |
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
|
13 #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
|
14 } |
16 | 15 |
16 char *ldap_base = NULL; | |
17 char *ldap_org = NULL; | |
18 char *ldap_class = NULL; | |
19 | |
20 using namespace std; | |
21 | |
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
|
22 int main(int argc, const char** argv) { |
16 | 23 char c; |
24 char *temp; | |
25 while ((c = getopt(argc, argv, "b:c:"))!= -1) { | |
26 switch (c) { | |
27 case 'b': | |
28 ldap_base = optarg; | |
29 temp = strchr(ldap_base, ','); | |
30 if (temp) { | |
31 *temp = '\0'; | |
32 ldap_org = strdup(ldap_base); | |
33 *temp = ','; | |
34 } | |
35 break; | |
36 case 'c': | |
37 ldap_class = optarg; | |
38 break; | |
39 default: | |
40 break; | |
41 } | |
42 } | |
43 | |
44 const int LINE_SIZE = 2000; | |
45 char line[LINE_SIZE]; | |
46 while (!cin.eof()) { | |
47 cin.getline(line, LINE_SIZE); | |
48 int n = strlen(line); | |
49 if (!n) continue; | |
50 char *f = line + 6; // skip alias keyword | |
51 char *e; | |
52 if (*f == '"') { | |
53 f++; | |
54 e = strchr(f, '"'); | |
55 } | |
56 else { | |
57 e = strchr(f, ' '); | |
58 } | |
59 if (!e) continue; | |
60 *e = '\0'; | |
61 char *m = e+1; | |
62 while (*m == ' ') m++; | |
63 if (*m != '\0') { | |
64 char cn[1000]; | |
65 snprintf(cn, sizeof(cn), "email %s", f); | |
66 printf("dn: cn=%s, %s\n", cn, ldap_base); | |
67 printf("cn: %s\n", cn); | |
68 printf("sn: %s\n", f); | |
69 printf("mail: %s\n", m); | |
70 printf("objectClass: %s\n\n", ldap_class); | |
71 } | |
72 } | |
73 } |