annotate src/nick2ldif.cpp @ 120:6395ced2b8b2

disable building pst2dii on cygwin consistent ordering of our include files all system includes protected by ifdef HAVE_ from autoconf
author Carl Byington <carl@five-ten-sg.com>
date Sun, 01 Feb 2009 11:24:22 -0800
parents 0f1492b7fe8b
children ab2a11e72250
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 <stdio.h>
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
10 #include <iostream>
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
11 //#include <fstream>
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
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
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
16
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
17 char *ldap_base = NULL;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
18 char *ldap_org = NULL;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
19 char *ldap_class = NULL;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
20
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
21 using namespace std;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
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
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
24 char c;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
25 char *temp;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
26 while ((c = getopt(argc, argv, "b:c:"))!= -1) {
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
27 switch (c) {
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
28 case 'b':
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
29 ldap_base = optarg;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
30 temp = strchr(ldap_base, ',');
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
31 if (temp) {
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
32 *temp = '\0';
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
33 ldap_org = strdup(ldap_base);
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
34 *temp = ',';
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
35 }
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
36 break;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
37 case 'c':
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
38 ldap_class = optarg;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
39 break;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
40 default:
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
41 break;
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
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
45 const int LINE_SIZE = 2000;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
46 char line[LINE_SIZE];
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
47 while (!cin.eof()) {
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
48 cin.getline(line, LINE_SIZE);
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
49 int n = strlen(line);
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
50 if (!n) continue;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
51 char *f = line + 6; // skip alias keyword
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
52 char *e;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
53 if (*f == '"') {
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
54 f++;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
55 e = strchr(f, '"');
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
56 }
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
57 else {
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
58 e = strchr(f, ' ');
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
59 }
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
60 if (!e) continue;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
61 *e = '\0';
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
62 char *m = e+1;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
63 while (*m == ' ') m++;
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
64 if (*m != '\0') {
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
65 char cn[1000];
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
66 snprintf(cn, sizeof(cn), "email %s", f);
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
67 printf("dn: cn=%s, %s\n", cn, ldap_base);
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
68 printf("cn: %s\n", cn);
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
69 printf("sn: %s\n", f);
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
70 printf("mail: %s\n", m);
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
71 printf("objectClass: %s\n\n", ldap_class);
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
72 }
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
73 }
c508ee15dfca switch to automake/autoconf
carl
parents:
diff changeset
74 }