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
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" {
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
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
15
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
16 char *ldap_base = NULL;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
17 char *ldap_org = NULL;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
18 char *ldap_class = NULL;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
19
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
20 using namespace std;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
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
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
23 char c;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
24 char *temp;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
25 while ((c = getopt(argc, argv, "b:c:"))!= -1) {
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
26 switch (c) {
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
27 case 'b':
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
28 ldap_base = optarg;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
29 temp = strchr(ldap_base, ',');
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
30 if (temp) {
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
31 *temp = '\0';
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
32 ldap_org = strdup(ldap_base);
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
33 *temp = ',';
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
34 }
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
35 break;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
36 case 'c':
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
37 ldap_class = optarg;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
38 break;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
39 default:
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
40 break;
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
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
44 const int LINE_SIZE = 2000;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
45 char line[LINE_SIZE];
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
46 while (!cin.eof()) {
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
47 cin.getline(line, LINE_SIZE);
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
48 int n = strlen(line);
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
49 if (!n) continue;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
50 char *f = line + 6; // skip alias keyword
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
51 char *e;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
52 if (*f == '"') {
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
53 f++;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
54 e = strchr(f, '"');
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
55 }
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
56 else {
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
57 e = strchr(f, ' ');
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
58 }
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
59 if (!e) continue;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
60 *e = '\0';
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
61 char *m = e+1;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
62 while (*m == ' ') m++;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
63 if (*m != '\0') {
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
64 char cn[1000];
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
65 snprintf(cn, sizeof(cn), "email %s", f);
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
66 printf("dn: cn=%s, %s\n", cn, ldap_base);
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
67 printf("cn: %s\n", cn);
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
68 printf("sn: %s\n", f);
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
69 printf("mail: %s\n", m);
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
70 printf("objectClass: %s\n\n", ldap_class);
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
71 }
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
72 }
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
73 }