Mercurial > libpst
annotate src/nick2ldif.cpp @ 118:0f1492b7fe8b
patch from Fridrich Strba for building on mingw and general cleanup of autoconf files
add processing for pst files of type 0x0f
start adding support for properly building and installing libpst.so and the header files required to use it.
remove version.h since the version number is now in config.h
more const correctness issues regarding getopt()
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Sat, 31 Jan 2009 12:12:36 -0800 |
parents | e5418051878c |
children | ab2a11e72250 |
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 <stdio.h> | |
10 #include <iostream> | |
11 //#include <fstream> | |
12 #include <unistd.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 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
|
14 #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
|
15 } |
16 | 16 |
17 char *ldap_base = NULL; | |
18 char *ldap_org = NULL; | |
19 char *ldap_class = NULL; | |
20 | |
21 using namespace std; | |
22 | |
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
|
23 int main(int argc, const char** argv) { |
16 | 24 char c; |
25 char *temp; | |
26 while ((c = getopt(argc, argv, "b:c:"))!= -1) { | |
27 switch (c) { | |
28 case 'b': | |
29 ldap_base = optarg; | |
30 temp = strchr(ldap_base, ','); | |
31 if (temp) { | |
32 *temp = '\0'; | |
33 ldap_org = strdup(ldap_base); | |
34 *temp = ','; | |
35 } | |
36 break; | |
37 case 'c': | |
38 ldap_class = optarg; | |
39 break; | |
40 default: | |
41 break; | |
42 } | |
43 } | |
44 | |
45 const int LINE_SIZE = 2000; | |
46 char line[LINE_SIZE]; | |
47 while (!cin.eof()) { | |
48 cin.getline(line, LINE_SIZE); | |
49 int n = strlen(line); | |
50 if (!n) continue; | |
51 char *f = line + 6; // skip alias keyword | |
52 char *e; | |
53 if (*f == '"') { | |
54 f++; | |
55 e = strchr(f, '"'); | |
56 } | |
57 else { | |
58 e = strchr(f, ' '); | |
59 } | |
60 if (!e) continue; | |
61 *e = '\0'; | |
62 char *m = e+1; | |
63 while (*m == ' ') m++; | |
64 if (*m != '\0') { | |
65 char cn[1000]; | |
66 snprintf(cn, sizeof(cn), "email %s", f); | |
67 printf("dn: cn=%s, %s\n", cn, ldap_base); | |
68 printf("cn: %s\n", cn); | |
69 printf("sn: %s\n", f); | |
70 printf("mail: %s\n", m); | |
71 printf("objectClass: %s\n\n", ldap_class); | |
72 } | |
73 } | |
74 } |