Mercurial > libpst
comparison nick2ldif.cpp @ 10:a818f3c2e589
fix tree walk, we now use the item counts in the node blocks
author | carl |
---|---|
date | Fri, 17 Feb 2006 15:48:38 -0800 |
parents | 8dd68d722fa8 |
children |
comparison
equal
deleted
inserted
replaced
9:8c724896a28a | 10:a818f3c2e589 |
---|---|
10 #include <iostream> | 10 #include <iostream> |
11 //#include <fstream> | 11 //#include <fstream> |
12 #include <unistd.h> | 12 #include <unistd.h> |
13 | 13 |
14 char *ldap_base = NULL; | 14 char *ldap_base = NULL; |
15 char *ldap_org = NULL; | 15 char *ldap_org = NULL; |
16 char *ldap_class = NULL; | 16 char *ldap_class = NULL; |
17 | 17 |
18 using namespace std; | 18 using namespace std; |
19 | 19 |
20 int main(int argc, char** argv) { | 20 int main(int argc, char** argv) { |
21 char c; | 21 char c; |
22 char *temp; | 22 char *temp; |
23 while ((c = getopt(argc, argv, "b:c:"))!= -1) { | 23 while ((c = getopt(argc, argv, "b:c:"))!= -1) { |
24 switch (c) { | 24 switch (c) { |
25 case 'b': | 25 case 'b': |
26 ldap_base = optarg; | 26 ldap_base = optarg; |
27 temp = strchr(ldap_base, ','); | 27 temp = strchr(ldap_base, ','); |
28 if (temp) { | 28 if (temp) { |
29 *temp = '\0'; | 29 *temp = '\0'; |
30 ldap_org = strdup(ldap_base); | 30 ldap_org = strdup(ldap_base); |
31 *temp = ','; | 31 *temp = ','; |
32 } | 32 } |
33 break; | 33 break; |
34 case 'c': | 34 case 'c': |
35 ldap_class = optarg; | 35 ldap_class = optarg; |
36 break; | 36 break; |
37 default: | 37 default: |
38 break; | 38 break; |
39 } | 39 } |
40 } | 40 } |
41 | 41 |
42 char *delim = " \t"; | 42 const int LINE_SIZE = 2000; |
43 const int LINE_SIZE = 2000; | 43 char line[LINE_SIZE]; |
44 char line[LINE_SIZE]; | 44 while (!cin.eof()) { |
45 while (!cin.eof()) { | 45 cin.getline(line, LINE_SIZE); |
46 cin.getline(line, LINE_SIZE); | 46 int n = strlen(line); |
47 int n = strlen(line); | 47 if (!n) continue; |
48 if (!n) continue; | 48 char *f = line + 6; // skip alias keyword |
49 char *f = line + 6; // skip alias keyword | 49 char *e; |
50 char *e; | 50 if (*f == '"') { |
51 if (*f == '"') { | 51 f++; |
52 f++; | 52 e = strchr(f, '"'); |
53 e = strchr(f, '"'); | 53 } |
54 } | 54 else { |
55 else { | 55 e = strchr(f, ' '); |
56 e = strchr(f, ' '); | 56 } |
57 } | 57 if (!e) continue; |
58 if (!e) continue; | 58 *e = '\0'; |
59 *e = '\0'; | 59 char *m = e+1; |
60 char *m = e+1; | 60 while (*m == ' ') m++; |
61 while (*m == ' ') m++; | 61 if (*m != '\0') { |
62 if (*m != '\0') { | 62 char cn[1000]; |
63 char cn[1000]; | 63 snprintf(cn, sizeof(cn), "email %s", f); |
64 snprintf(cn, sizeof(cn), "email %s", f); | 64 printf("dn: cn=%s, %s\n", cn, ldap_base); |
65 printf("dn: cn=%s, %s\n", cn, ldap_base); | 65 printf("cn: %s\n", cn); |
66 printf("cn: %s\n", cn); | 66 printf("sn: %s\n", f); |
67 printf("sn: %s\n", f); | 67 printf("mail: %s\n", m); |
68 printf("mail: %s\n", m); | 68 printf("objectClass: %s\n\n", ldap_class); |
69 printf("objectClass: %s\n\n", ldap_class); | 69 } |
70 } | 70 } |
71 } | |
72 } | 71 } |