annotate src/nick2ldif.cpp @ 144:c0bf3cb16524

Added tag stable-0-6-28 for changeset fdc58ad2c758
author Carl Byington <carl@five-ten-sg.com>
date Tue, 24 Feb 2009 12:41:04 -0800
parents fc11b1d1ad34
children 8ad8fd1c5451
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
1 /*
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
2
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
3 Copyright (c) 2004 Carl Byington - 510 Software Group, released under
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
4 the GPL version 2 or any later version at your choice available at
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
5 http://www.fsf.org/licenses/gpl.txt
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
6
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
7 */
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
8
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
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
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
14
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
15 char *ldap_base = NULL;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
16 char *ldap_org = NULL;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
17 char *ldap_class = NULL;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
18
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
19 using namespace std;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
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
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
22 char c;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
23 char *temp;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
24 while ((c = getopt(argc, argv, "b:c:"))!= -1) {
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
25 switch (c) {
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
26 case 'b':
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
27 ldap_base = optarg;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
28 temp = strchr(ldap_base, ',');
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
29 if (temp) {
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
30 *temp = '\0';
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
31 ldap_org = strdup(ldap_base);
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
32 *temp = ',';
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
33 }
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
34 break;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
35 case 'c':
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
36 ldap_class = optarg;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
37 break;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
38 default:
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
39 break;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
40 }
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
41 }
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
42
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
43 const int LINE_SIZE = 2000;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
44 char line[LINE_SIZE];
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
45 while (!cin.eof()) {
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
46 cin.getline(line, LINE_SIZE);
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
47 int n = strlen(line);
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
48 if (!n) continue;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
49 char *f = line + 6; // skip alias keyword
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
50 char *e;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
51 if (*f == '"') {
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
52 f++;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
53 e = strchr(f, '"');
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
54 }
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
55 else {
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
56 e = strchr(f, ' ');
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
57 }
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
58 if (!e) continue;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
59 *e = '\0';
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
60 char *m = e+1;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
61 while (*m == ' ') m++;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
62 if (*m != '\0') {
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
63 char cn[1000];
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
64 snprintf(cn, sizeof(cn), "email %s", f);
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
65 printf("dn: cn=%s, %s\n", cn, ldap_base);
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
66 printf("cn: %s\n", cn);
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
67 printf("sn: %s\n", f);
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
68 printf("mail: %s\n", m);
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
69 printf("objectClass: %s\n\n", ldap_class);
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
70 }
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
71 }
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
72 }