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

Re: EBCDIC API



Kurt D. Zeilenga wrote:
At 08:53 PM 7/30/2003, jean-frederic clere wrote:

I have started to write an EBCDIC API for OpenLDAP. On EBCDIC machines
OpenLDAP is compiled with all strings in ASCII. The side effect is that the
client API is not usable in programs that have strings in EBCDIC (that is
most of the existing code on such machines).

I am converting all the attributes values from ASCII to EBCDIC because I am
not yet able to find whether an attribute is binary or a string.


There isn't a good, general way for the API to determine this on its own.

That is why I am thinking of a file containing the name of attribut that should not be converted.




Find enclosed the patch for ldap.h and the source file that contains the
code to  do the conversions.


I wouldn't rename the existing routines... better to have a new .h file which
provided prototypes for new routines to which one can document exactly when
and where they do transcoding.

But that means changing code of application that use the OpenLDAP API when porting them to EBCDIC machine.



One of the interesting things I see relevant to previous discussions about transcoding callbacks is the need to transcode protocol tokens (e.g., attribute descriptions) as well as protocol values (e.g., attribute values). The other place one sees this need is in localization of protocol tokens (e.g., transforming "CN" to "common name" or local equivalent).

Without reading schema?



Before expanding the API I would like to have some comments about my code. Could someone make comments or give hints?

Cheers

Jean-Frederic


Index: ./include/ldap.h =================================================================== RCS
file: /repo/OpenLDAP/pkg/ldap/include/ldap.h,v retrieving revision 1.208 diff -u -r1.208 ldap.h --- ./include/ldap.h 1 May 2003 21:39:29 -0000
1.208 +++ ./include/ldap.h 31 Jul 2003 12:29:58 -0000 @@ -602,6 +602,24
@@ #define LDAP_URL_ERR_BADFILTER 0x09 /* bad or missing filter */ #define LDAP_URL_ERR_BADEXTS 0x0a /* bad or missing extensions */


+#if defined(_OSD_POSIX) && ('A' == '\xC1') +#define USE_EBCDIC_API +#endif
+ +/* ebcdic API (in ldap_ebcdic.c) */ +#ifdef USE_EBCDIC_API +#define
ldap_init ldap_init_ebcdic +#define ldap_initialize ldap_initialize_ebcdic +#define ldap_simple_bind ldap_simple_bind_ebcdic +#define
ldap_simple_bind_s ldap_simple_bind_s_ebcdic +#define ldap_err2string
ldap_err2string_ebcdic +#define ldap_search_ext ldap_search_ext_ebcdic +#define ldap_search_ext_s ldap_search_ext_s_ebcdic +#define
ldap_first_attribute ldap_first_attribute_ebcdic +#define
ldap_next_attribute ldap_next_attribute_ebcdic +#define ldap_get_values
ldap_get_values_ebcdic +#endif + /* * The API draft spec says we should
declare (or cause to be declared) * 'struct timeval'. We don't. See IETF
LDAPext discussions. #include <stdio.h> #include <stdlib.h> #include
"ldap.h"


#ifdef ldap_init #undef ldap_init #endif #ifdef ldap_initialize #undef
ldap_initialize #endif #ifdef ldap_simple_bind #undef ldap_simple_bind #endif #ifdef ldap_simple_bind_s #undef ldap_simple_bind_s #endif #ifdef
ldap_err2string #undef ldap_err2string #endif #ifdef ldap_search_ext #undef
ldap_search_ext #endif #ifdef ldap_search_ext_s #undef ldap_search_ext_s #endif #ifdef ldap_first_attribute #undef ldap_first_attribute #endif #ifdef ldap_next_attribute #undef ldap_next_attribute #endif #ifdef
ldap_get_values #undef ldap_get_values #endif


/* Alloc a buffer, copy and convert the input string into it */ static char
*malloc2ebcdic(LDAP_CONST char *string) { char *newstring; if (string ==
NULL) return(NULL);

newstring = (char *) malloc(strlen(string)); if (newstring == NULL) return(NULL); strcpy(newstring,string); _e2a(newstring); return(newstring);
} static void safefree(char *string) { if (string!=NULL) free(string); }



/* From open.c */ LDAP * ldap_init_ebcdic ( LDAP_CONST char *host, int port
) { LDAP *ptr; char *new; new = malloc2ebcdic(host); if (new == NULL) return ((LDAP *)NULL); ptr = ldap_init(new,port); free(new); return(ptr); }
int ldap_initialize_ebcdic ( LDAP **ldp, LDAP_CONST char *url ) { int i; char *new; new = malloc2ebcdic(url); if (new == NULL) return (-1); i =
ldap_initialize(ldp,new); free(new); return(i); }


/* From sbind.c */ int ldap_simple_bind_ebcdic ( LDAP *ld, LDAP_CONST char
*who, LDAP_CONST char *passwd ) { char *newwho; char *newpasswd; int ret; newwho = malloc2ebcdic(who); newpasswd = malloc2ebcdic(passwd); ret =
ldap_simple_bind(ld,newwho,newpasswd); safefree(newwho); safefree(newpasswd); return(ret); } int ldap_simple_bind_s_ebcdic ( LDAP
*ld, LDAP_CONST char *who, LDAP_CONST char *passwd ) { char *newwho; char
*newpasswd; int ret; newwho = malloc2ebcdic(who); newpasswd =
malloc2ebcdic(passwd); ret = ldap_simple_bind_s(ld,newwho,newpasswd); safefree(newwho); safefree(newpasswd); return(ret); }


/* From error.c: */ char * ldap_err2string_ebcdic ( int err ) { static char
ebcdic_err[80]; strcpy(ebcdic_err,ldap_err2string(err)); _a2e(ebcdic_err); return(ebcdic_err); }


/* From search.c */ int ldap_search_ext_ebcdic ( LDAP
*ld, LDAP_CONST char *base, int scope, LDAP_CONST char *filter, char **attrs, int
attrsonly, LDAPControl **serverctrls, LDAPControl
**clientctrls, struct timeval *timeout, int
sizelimit, int *msgidp ) { char *newbase; char
*newfilter; char **newattrs; int i,j,ret; newbase = malloc2ebcdic(base); newfilter = malloc2ebcdic(filter); if (attrs == NULL) newattrs = NULL; else { i = 0; newattrs = attrs; while (newattrs[i]!=NULL) i++; newattrs =
malloc(sizeof(char *)*i); j = i; for (i=0;i<j;i++) newattrs[i] =
malloc2ebcdic(attrs[i]); }


ret = ldap_search_ext (ld, newbase, scope, newfilter, newattrs, attrsonly,
serverctrls, clientctrls, timeout, sizelimit, msgidp);

safefree(newbase); safefree(newfilter); if (newattrs!=NULL) { for
(i=0;i<j;i++) safefree(newattrs[i]); free(newattrs); } return (ret); }

int ldap_search_ext_s_ebcdic ( LDAP *ld, LDAP_CONST char
*base, int scope, LDAP_CONST char *filter, char
**attrs, int attrsonly, LDAPControl
**serverctrls, LDAPControl **clientctrls, struct timeval
*timeout, int sizelimit, LDAPMessage
**res ) { char *newbase; char *newfilter; char **newattrs; int i,j,ret; newbase = malloc2ebcdic(base); newfilter = malloc2ebcdic(filter); if
(attrs == NULL) newattrs = NULL; else { i = 0; newattrs = attrs; while
(newattrs[i]!=NULL) i++; newattrs = malloc(sizeof(char *)*i); j = i; for
(i=0;i<j;i++) newattrs[i] = malloc2ebcdic(attrs[i]); }


ret = ldap_search_ext_s (ld, newbase, scope, newfilter, newattrs,
attrsonly, serverctrls, clientctrls, timeout, sizelimit, res);

safefree(newbase); safefree(newfilter); if (newattrs!=NULL) { for
(i=0;i<j;i++) safefree(newattrs[i]); free(newattrs); } return (ret); }

/* From getattr.c */ char * ldap_first_attribute_ebcdic ( LDAP *ld, LDAPMessage *entry, BerElement **ber ) { char *ptr; ptr =
ldap_first_attribute(ld,entry,ber); if (ptr!=NULL) _a2e(ptr); return(ptr); }


char * ldap_next_attribute_ebcdic ( LDAP *ld, LDAPMessage *entry, BerElement *ber ) { char *ptr; ptr = ldap_next_attribute(ld,entry,ber); if
(ptr!=NULL) _a2e(ptr); return(ptr); } /* From getvalues.c */ char ** ldap_get_values_ebcdic ( /* deprecated */ LDAP *ld, LDAPMessage
*entry, LDAP_CONST char *target ) { char **ptr; char *newtarget; int i=0; newtarget = malloc2ebcdic(target); ptr =
ldap_get_values(ld,entry,newtarget); safefree(newtarget); /* I am
converting all the values... that sounds wrong! */ if (ptr!=NULL) { while(ptr[i]!=NULL) { _a2e(ptr[i]); i++; } } return(ptr); }




jpegPhoto
userSMIMECertificate
userPKCS12
javaSerializedData
userCertificate
cACertificate
authorityRevocationList
certificateRevocationList
crossCertificatePair
supportedAlgorithms
deltaRevocationList
krb5Key
krb5RealmName
photo
personalSignature
audio
nadfSearchGuide
multiMediaInformation
marshalledInterface
replUpToDateVector
securityIdentifier
groupMembershipSAM
requiredCategories
upgradeProductCode
trustAuthOutgoing
trustAuthIncoming
fRSReplicaSetGUID
machineWidePolicy
foreignIdentifier
logonWorkstation
pKIOverlapPeriod
winsockAddresses
serviceClassInfo
domainWidePolicy
currentLocation
publicKeyPolicy
volTableIdxGUID
linkTrackSecret
mS-DS-CreatorSID
mSMQEncryptKey
terminalServer
nTGroupMembers
fRSVersionGUID
mSMQDigestsMig
lDAPIPDenyList
dhcpProperties
assocNTAccount
auditingPolicy
serviceClassID
mSMQQueueType
fRSExtensions
addressSyntax
moveTreeState
birthLocation
oMObjectClass
currMachineId
ntPwdHistory
lmPwdHistory
currentValue
dSASignature
invocationId
volTableGUID
schemaIDGUID
tokenGroups
syncWithSID
dNSProperty
oMTIndxGuid
mSMQUserSid
mSMQSignKey
netbootGUID
mSMQOwnerID
mSMQDigests
dhcpOptions
pKIKeyUsage
productCode
dhcpClasses
meetingBlob
sIDHistory
logonHours
priorValue
unicodePwd
privateKey
mSMQSiteID
addressEntryDisplayTableMSDOS
parentGUID
categoryId
objectGUID
schemaInfo
mSMQSites
msiScript
cRLPartitionedRevocationList
partialAttributeDeletionList
eFSPolicy
prefixMap
dnsRecord
objectSid
ipsecData
helpData16
helpData32
userCert
mSMQQMID
siteGUID
schedule
pekList
oMTGuid
pKTGuid
moniker
dBCSPwd
perRecipDialogDisplayTable
originalDisplayTableMSDOS
tokenGroupsNoGCAcceptable
tokenGroupsGlobalAndUniversal
retiredReplDSASignatures
addressEntryDisplayTable
perMsgDialogDisplayTable
parentCACertificateChain
supplementalCredentials
mSMQSignCertificatesMig
pKT
serviceInstanceVersion
previousCACertificates
attributeSecurityGUID
implementedCategories
pendingCACertificates
replPropertyMetaData
mS-DS-ConsistencyGuid
mSMQSignCertificates
originalDisplayTable
partialAttributeSet
pKIExpirationPeriod
controlAccessRights
userPassword
thumbnailPhoto
thumbnailLogo