Subject: Re: Macros defined in the makefile
From: Nathan Kinder
Date: Tue, 07 Nov 2006 19:25:02 -0800
To: Noriko Hosoi
CC: ldap-devel-list@redhat.com

Noriko Hosoi wrote:
To move the macros into config.h, I did a quick research for each macro.  It looks some are completely obsolete and it's time to clean up...  What do you think?  My thoughts are written starting with "noriko>".
I eliminated a bunch of macros from being defined on the command-line because they weren't used at all, but as you noticed there are quite a few that we should just get rid of.  My comments on each of your suggestions are below.
Thanks,
--noriko
------------------------------------------------------------------------
NS_DS -- switch error codes and prints between external and internal formats (note: external is not supported for long time)
Files:
./ldap/servers/slapd/errormap.c
./lib/libsi18n/makstrdb.c
Code:
#ifdef NS_DS
#include "dberrstrs.h"
#include "sslerrstrs.h"
#include "secerrstrs.h"
#include "prerrstrs.h"
#include "disconnect_error_strings.h"
#else /* NS_DS */
#include "SSLerrs.h"
#include "SECerrs.h"
#include "NSPRerrs.h"
#endif /* NS_DS */
...
#ifdef NS_DS
        LDAPDebug( LDAP_DEBUG_ANY,
            "sequence error in error strings at item %d\n"
            "error %d (%s)\n",
            i, lastNum, errStrings[i-1].errString );
        LDAPDebug( LDAP_DEBUG_ANY,
            "should come after \n"
            "error %d (%s)\n",
            num, errStrings[i].errString, 0 );
#else /* NS_DS */
            fprintf(stderr,
"sequence error in error strings at item %d\n"
"error %d (%s)\n"
"should come after \n"
"error %d (%s)\n",
                i, lastNum, errStrings[i-1].errString,
            num, errStrings[i].errString);
#endif /* NS_DS */
noriko> can we eliminate the macro NS_DS and support just NS_DS code?
Yes, I think we should remove this macro.
------------------------------------------------------------------------
NET_SSL -- support SSL
Files:
./httpd/src/ntnsapi.c
./ldap/admin/lib/dsalib_pw.c
./ldap/clients/dsgw/dsgw.h
./ldap/include/proto-ntutil.h
./ldap/libraries/libutil/ntstubs.c
./ldap/servers/plugins/pwdstorage/pwdstorage.h
./ldap/servers/plugins/pwdstorage/sha_pwd.c
./ldap/servers/plugins/pwdstorage/ssha_pwd.c
./ldap/servers/slapd/daemon.c
./ldap/servers/slapd/globals.c
./ldap/servers/slapd/libglobs.c
./ldap/servers/slapd/localhost.c
./ldap/servers/slapd/main.c
./ldap/servers/slapd/ntuserpin.c
./ldap/servers/slapd/plugin_internal_op.c
./ldap/servers/slapd/pw.c
./ldap/servers/slapd/result.c
./ldap/servers/slapd/slap.h
./ldap/servers/slapd/ssl.c
noriko> can we eliminate the macro NET_SSL and support just NET_SSL code?
Yes, I think we should remove this macro.
------------------------------------------------------------------------
LDAP_DEBUG -- debug code
Files:
./ldap/include/ldaplog.h
./ldap/libraries/libutil/ntdebug.c
./ldap/servers/plugins/acl/acldllmain.c
./ldap/servers/plugins/chainingdb/cbdllmain.c
./ldap/servers/plugins/collation/dllmain.c
./ldap/servers/plugins/pam_passthru/pam_ptdllmain.c
./ldap/servers/plugins/passthru/ptdllmain.c
./ldap/servers/plugins/shared/plugin-utils.h
./ldap/servers/plugins/syntaxes/dllmain.c
./ldap/servers/plugins/uiduniq/7bit.c
./ldap/servers/plugins/uiduniq/uid.c
./ldap/servers/slapd/back-ldbm/dllmain.c
./ldap/servers/slapd/back-ldbm/filterindex.c
./ldap/servers/slapd/back-ldbm/index.c
./ldap/servers/slapd/daemon.c
./ldap/servers/slapd/fe.h
./ldap/servers/slapd/main.c
./ldap/servers/slapd/modify.c
./ldap/servers/slapd/back-ldif/dllmain.c
noriko> I guess we want to keep this macro.
Yes, we should keep this.
------------------------------------------------------------------------
LDAP_DONT_USE_SMARTHEAP -- Don't use smartheap. :)
Files:
./ldap/servers/slapd/globals.c
./ldap/servers/slapd/main.c
noriko> This is needed by HP?
I don't think they use this, but I will check with them.  For now, we could just change the logic so we don't use smartheap unless we define USE_SMARTHEAP.
------------------------------------------------------------------------
UPGRADEDB -- upgrade db code, db2index all also uses it.
Files:
./ldap/admin/src/create_instance.c
./ldap/servers/slapd/back-ldbm/dblayer.c
./ldap/servers/slapd/back-ldbm/import-threads.c
./ldap/servers/slapd/back-ldbm/import.c
./ldap/servers/slapd/back-ldbm/import.h
./ldap/servers/slapd/back-ldbm/init.c
./ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
./ldap/servers/slapd/back-ldbm/upgrade.c
./ldap/servers/slapd/back-ldbm/ldif2ldbm.c
./ldap/servers/slapd/main.c
./ldap/servers/slapd/pblock.c
./ldap/servers/slapd/protect_db.c
./ldap/servers/slapd/protect_db.h
./ldap/servers/slapd/slap.h
./ldap/servers/slapd/task.c
./ldap/servers/slapd/slapi-private.h
noriko> can we eliminate the macro UPGRADEDB and support just UPGRADEDB code?
I'm not sure what this macro does.  Is it just for using calls supported by "newer" versions of db?
------------------------------------------------------------------------
NSPR20 -- use NSPR code newer than NSPR20???
Files:
./include/libaccess/usrcache.h
./ldap/servers/slapd/detach.c
./lib/ldaputil/ldapdb.c
Codes:
#if defined( sunos5 ) && ( defined( THREAD_SUNOS5_LWP ) || defined( NSPR20 ))
            switch ( fork1() ) {
#else             switch ( fork() ) {
#endif
...
For example,
#ifdef NSPR20
    if (!(le = (struct ldap_error *) PR_GetThreadPrivate(tsdindex))) {
        le = (struct ldap_error *) malloc(sizeof(struct ldap_error));
        memset((void *)le, 0, sizeof(struct ldap_error));
        PR_SetThreadPrivate(tsdindex, (void *)le);
    }
#else
    le = (struct ldap_error *) PR_GetThreadPrivate( PR_CurrentThread(), tsdindex );
#endif
noriko> can we eliminate the macro NSPR20 and support just NSPR20 code?
Yes, I think we should remove this macro.
------------------------------------------------------------------------
LDAPDB_THREAD_SAFE -- ???
Files:
./include/ldaputil/ldapdb.h
./lib/ldaputil/ldapdb.c
Codes:
#ifdef LDAPDB_THREAD_SAFE
#include <nspr.h>
#include <prthread.h>
#include <prmon.h>
/* removed for new ns security integration
#include <xp_error.h>
*/
#endif /* LDAPDB_THREAD_SAFE */
...
#ifndef LDAPDB_THREAD_SAFE
#define ldb_crit_init(x)
#define ldb_crit_enter(x)
#define ldb_crit_exit(x)
#else
#ifdef NSPR20
uintn           tsdindex;
#else
int32           tsdindex;
#endif
...
noriko> can we eliminate the macro LDAPDB_THREAD_SAFE and support just LDAPDB_THREAD_SAFE code? (plus are we using ldapdb.c?)
Yes, I think we should remove this macro.  I'm not sure about ldapdb.c.  It's compiled into libldaputil, so we would need to check if we call any functions defined from it.
------------------------------------------------------------------------
CLIENT_AUTH -- ???
Files:
./include/libaccess/nsauth.h
./include/libaccess/nsautherr.h
Codes:
#ifdef CLIENT_AUTH
#include "ssl.h"
#if 0
/* Removed for new ns security */
#include "sec.h"                /* SECCertificate */
#endif
#include "cert.h"               /* CERTCertificate for new ns security bin */
#endif /* CLIENT_AUTH */
...
#ifdef CLIENT_AUTH
#if 0
  /* Removed for new ns security  */
    SECCertificate * cla_cert;  /* certificate from SSL client auth */
#endif
    CERTCertificate * cla_cert; /* certificate from SSL client auth */
#endif /* CLIENT_AUTH */
noriko> can we eliminate the macro CLIENT_AUTH and support just CLIENT_AUTH code?
Yes, I think we should remove this macro.
------------------------------------------------------------------------
MCC_HTTPD -- ???
Files:
./include/base/systems.h
Codes:
/* NS_MAIL builds sec-key.c which calls systhread_init, which requires */
/* that USE_NSPR is defined when systhr.c is compiled.  --lachman */
/* MCC_PROXY does the same thing now --nbreslow -- LIKE HELL --ari */
#if (defined(MCC_HTTPD) || defined(MCC_ADMSERV) || defined(MCC_PROXY) || defined(NS_MAIL)) && defined(XP_UNIX)
#define USE_NSPR
/* XXXrobm This is UNIX-only for the moment */
#define LOG_BUFFERING
#ifdef SW_THREADS
#define THREAD_NSPR_USER
#else
#define THREAD_NSPR_KERNEL
#ifdef IRIX
#undef SEM_FLOCK
#define SEM_IRIX
#endif
#endif
#define THREAD_ANY
#endif
noriko> If we need these defines, can we remove "(defined(MCC_HTTPD) || defined(MCC_ADMSERV) || defined(MCC_PROXY) || defined(NS_MAIL))" from #if?
At a minimum, we can remove those so we don't need to add "-DMCC_HTTPD" at compile time.  Without setting it, we run into build issues right now.
------------------------------------------------------------------------
NS_DOMESTIC -- security export restriction (still needed???)
Files:
./ldap/servers/slapd/ssl.c
Codes:
#ifdef NS_DOMESTIC
        s = NSS_SetDomesticPolicy();
#else
        s = NSS_SetExportPolicy();
#endif
noriko> Do we still need to build the less secure version for exporting to abroad???
I'm pretty sure we can remove this, but Bob has stated to never assume anything about export controls, so I'd like to ask him about it before doing anything.
------------------------------------------------------------------------
SPAPI20 -- ???
Files: not found
noriko> Can we eliminate the macro SPAPI20?
I think these may be used in include files from components that we use.  We should check first.
------------------------------------------------------------------------
SERVER_BUILD -- ???
Files: not found
noriko> Can we eliminate the macro SERVER_BUILD?
I think these may be used in include files from components that we use.  We should check first.

-NGK