[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: EBCDIC slapd



Howard Chu wrote:
-----Original Message-----
From: jean-frederic clere [mailto:jfrederic.clere@fujitsu-siemens.com]


Hi,

I have ported slapd to BS2000. The BS2000 is an EBCDIC mainframe.
The C compiler of the BS2000 supports an option: "-K
literal_encoding_ascii"
that allows to handle strings in ASCII. I have compile
OpenLDAP with the
options: "--without-threads --enable-ldbm --with-ldbm-api=berkeley
--with-ldbm-module=static" and I have used bdb 4.1.24. After
some fightings I
have got a running slapd.

Find enclosed the corresponding patch against the actual HEAD.

Some comments:
clients/tools/ldapsearch.c: That is not BS2000 specific: I
need the same
correction to build on Linux when configure --without-cyrus_sasl.


OK, the ldap_pvt_tls_destroy() call should have been #ifdef HAVE_TLS.


getopt (libraries/liblutil/getopt.c and include/getopt-compat.h).
I have a getopt but it is EBCDIC based I have to redefine the
OpenLDAP getopt to use an ASCII one.


The OpenLDAP getopt() is the one I use for OS/390. It takes care of charset
conversion already, which removes the need for your patch in slapd/main.c.

Ok I will try to use it but I think the OpenLDAP getopt() will collide with the libc getopt().



libraries/liblber/stdio.c: The writting to a pipe is not
working well and I
think writting to /dev/null is faster (and I keep the
/dev/null open to make
sure to have better performances).

libraries/liblunicode/ucdata/ucgendat.c: I think that the IBM
machine also needs
a similar patch because the *.txt should be in EBCDIC (text files).


The fgets function has already been #defined to ber_pvt_fgets, which already
does the translation. This patch in ucgendat.c should not be needed.

No... The BS2000 has already its own ASCII fgets and I have tried to use it.
In ucgendat.c the file is in EBCDIC therefore it is possible to use the EBCDIC fgets and convert the data after reading them.



I also have had to patch the configure:
+++
Index: configure
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/configure,v
retrieving revision 1.508
diff -u -r1.508 configure
--- configure   23 Apr 2003 14:50:56 -0000      1.508
+++ configure   20 May 2003 14:42:31 -0000
@@ -9722,10 +9722,12 @@
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
     builtin and then its argument prototype would still apply.  */
-char regfree();
+#include <sys/types.h>
+#include <regex.h>

 int main() {
-regfree()
+regex_t *preg;
+regfree(preg)
 ; return 0; }
 EOF
 if { (eval echo configure:9732: \"$ac_link\") 1>&5; (eval
$ac_link) 2>&5; } &&
test -s conftest${ac_exeext}; then
+++
But that is to prevent using the system regexp but I think
that makes sense to
#include regex.h before using regfree().

After configure I have modified include/portable.h, because
the configure does
not find that the machine is EBCDIC and __atoe(), __etoa()
and __atoe_l() have
different names in BS2000.


You should find out why the EBCDIC test failed and let us know.


+++
$ diff -u ./include/portable.h.ori ./include/portable.h
--- ./include/portable.h.ori    Mon May 19 17:44:13 2003
+++ ./include/portable.h        Mon May 19 17:47:10 2003
@@ -16,6 +16,13 @@

 /* end of preamble */

+#define OSD_POSIX 1
+#ifdef OSD_POSIX
+#define HAVE_EBCDIC 1
+#define __atoe(x) _a2e(x)
+#define __etoa(x) _e2a(x)
+#define __atoe_l(x,l) _e2a_n(x,l)
+#endif


Your atoe_l definition looks backwards.


 /* Define to empty if the keyword does not work.  */
 /* #undef const */
@@ -1067,7 +1074,7 @@
 #endif
 #endif

-#ifdef HAVE_EBCDIC
+#if defined(HAVE_EBCDIC) && !defined(OSD_POSIX)
 /* ASCII/EBCDIC converting replacements for stdio funcs
  * vsnprintf and snprintf are used too, but they are already
  * checked by the configure script
+++


Why have you disabled these function replacements? That's going to cause a
lot of other conversion issues.

Because the BS2000 has already those ASCII functions, it defines them like: +++ # define fgetc __fgetc_ascii # define fgets __fgets_ascii # define fputs __fputs_ascii # define fputc __fputc_ascii # define fread __fread_ascii # define fwrite __fwrite_ascii # define ungetc __ungetc_ascii # define gets __gets_ascii # define puts __puts_ascii +++



I think the patch to libldbm/ldbm.c is generic, should be HAVE_EBCDIC not OSD_POSIX.

Agreed.

Since I finished porting back-bdb, I no longer use ldbm so this
escaped my notice before. With that said, you should probably be using
back-bdb as well.

I will try.


-- Howard Chu Chief Architect, Symas Corp. Director, Highland Sun http://www.symas.com http://highlandsun.com/hyc Symas: Premier OpenSource Development and Support