This is my first experience with C, but a language is a language after the 
3rd or 4th :)
I'm calling C for LDAP queries from Natural (Software AG "4"GL) in batch. And 
it works, sort of.
One FM is IBM Tivoli Directory Server Client Programming for z/OS

  If I use the sequence ldap_init, ldap_simple_bind_s, ldap_search, 
ldap_unbind, it gets overloaded after 5 calls at the speed of batch. If I leave 
out the unbind, it works for thousands of calls, but there is an obvious memory 
leak.
  So, I want to anchor the ldap handle in the main driving program. I made a 
simple C stub:
 
extern int ret2nat (int  *back_value, LDAP *ld, char *msg)
#include <ldap.h>

In ldap.h there is: 
typedef struct ldap LDAP;

The examples use:
LDAP * ld;   
To declare an ldap_handle which according to the listing is an:
ld                  6270-1:1931     Class = parameter, Length = 4           
                                    Type = pointer to incomplete struct ldap
        
I have a function:
LDAP * bind_adlds(char *hostname, char *container, char *msg)
And I call it:  
printf("ld before bind   :%d\n",ld);           /* ld before bind   :286352012   
ld = bind_adlds(hostname, container, msg) ; 
printf("ld after bind    :%d\n",ld);            /* ld after bind    :283317144  
 

but the value is not returned to the caller of ret2nat.
 
Any attempts to use *ld in an assignment or even memcpy() get a complier 
message:
ERROR CCN3285 /u/ldap/test.c:46    The indirection operator cannot be applied 
to a pointer to an incomplete struct or union.                                  
                                                                             
Or
WARNING CCN3068 /u/ldap/test.c:46    Operation between types "int*" and 
"pointer to an incomplete type" is not allowed.

As I said, I am just learning how to spell C. I know I am fighting some kind of 
battle of types. I welcome even derisive comments, if in the end thay help.

Dave Gibney
Information Technology Services
Washington State University

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@bama.ua.edu with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

Reply via email to