view src/nick2ldif.cpp @ 388:292ad0f71fd4

Add operator and quotes to the AX_PYTHON_DEVEL parameter The operator is required and the quotes are needed to protect PYTHON_VERSION. See-also: https://www.gnu.org/software/autoconf-archive/ax_python_devel.html Fixes: checking whether to build the libpst python interface... yes checking for python build information... checking for python3.7... python3.7 checking for main in -lpython3.7... no checking for main in -lpython3.7m... yes results of the Python check: Binary: python3.7 Library: python3.7m Include Dir: /usr/include/python3.7m checking for python3.7... /usr/bin/python3.7 checking for a version of Python >= '2.1.0'... yes checking for a version of Python 3.7... File "<string>", line 1 import sys; ver = sys.version.split ()[0]; print (ver 3.7) ^ SyntaxError: invalid syntax no configure: error: this package requires Python 3.7. If you have it installed, but it isn't the default Python interpreter in your system path, please pass the PYTHON_VERSION variable to configure. See ``configure --help'' for reference.
author Paul Wise <pabs3@bonedaddy.net>
date Sat, 21 Dec 2019 21:25:45 +0800
parents 8ad8fd1c5451
children
line wrap: on
line source

/*

Copyright (c) 2004 Carl Byington - 510 Software Group, released under
the GPL version 2 or any later version at your choice available at
http://www.fsf.org/licenses/gpl.txt

*/

#include <iostream>

extern "C" {
    #include "define.h"
}

char *ldap_base  = NULL;
char *ldap_org	 = NULL;
char *ldap_class = NULL;

using namespace std;

int main(int argc, char* const* argv) {
	char c;
	char *temp;
	while ((c = getopt(argc, argv, "b:c:"))!= -1) {
		switch (c) {
		case 'b':
			ldap_base = optarg;
			temp = strchr(ldap_base, ',');
			if (temp) {
				*temp = '\0';
				ldap_org = strdup(ldap_base);
				*temp = ',';
			}
			break;
		case 'c':
			ldap_class = optarg;
			break;
		default:
			break;
		}
	}

	const int LINE_SIZE = 2000;
	char line[LINE_SIZE];
	while (!cin.eof()) {
		cin.getline(line, LINE_SIZE);
		int n = strlen(line);
		if (!n) continue;
        if (strncmp(line, "alias", 5) != 0) continue;   // not alias
		char *f = line + 6; 	// skip alias keyword
		char *e;
		if (*f == '"') {
			f++;
			e = strchr(f, '"');
		}
		else {
			e = strchr(f, ' ');
		}
		if (!e) continue;
		*e = '\0';
		char *m = e+1;
		while (*m == ' ') m++;
		if (*m != '\0') {
			char cn[1000], givenName[1000], sn[1000];
			snprintf(cn, sizeof(cn), "%s", f);
            char *ff = strchr(f, ' ');
            if (ff) {
                strncpy(givenName, ff+1, sizeof(givenName)-1);
                *ff = '\0';
                strncpy(sn, f, sizeof(sn)-1);
            }
            else {
                strcpy(givenName, cn);
                strcpy(sn, cn);
            }
			printf("dn: cn=%s, %s\n", cn, ldap_base);
			printf("cn: %s\n", cn);
            printf("givenName: %s\n", givenName);
			printf("sn: %s\n", sn);
			printf("mail: %s\n", m);
			printf("objectClass: %s\n\n", ldap_class);
		}
	}
}