Hello! :D

I have probably a question to Mr Sam. I'm not a proffesional C programmer,
so please forgive me if I say the stupid things.

I know that the SqWebmail runs the ldapsearch script, it queries a LDAP
server and returns the results to SqWebmail, but I can't understand your
method of parsing ldapsearch result.

For example, I have the following situation:

This is my filter:

//
// a fragment of doldapsearch() function
//
if (ptr && (f=getfilter()) != 0)
{
  // printf ("f=%s<br>", f) displays "f=(&(sn=Name))"
}

My local OpenLDAP server returns the result and the SqWebmail saves it in
temporary file (fp is a pointer to the file descriptor):

//
// a fragment of doldapsearch() function
//
fd=ldapabook_search(ptr, LDAPSEARCH, f, 1);
// printf ("fd=%d<br>", fd) displays "fd=4"
...
if (fpw)
{
  parsesearch(fp, fpw);
  // printf ("fp=%d<br>") displays "fp=134818896"
}

I can display a body of that file on the screen and I know that its size is
689 bytes (exactly 2 LDAP entries). Unfortunately, function fgets(buf,
sizeof(buf), r) returns NULL, because size of buf variable is bigger (buf
array has 8192 bytes) and it breaks the for (;;) loop. In the effect I can't
see LDAP entries:

//
// a fragment of parsesearch() function
//
counter=0;
for (;;)
{
  if (fgets(buf, sizeof(buf), r) == 0)
  {
    // printf ("ferror=%d<br>", ferror (r)) displays "ferror=0"
    // printf ("feof=%d<br>", feof (r)) displays "feof=1"
    break;
  }
  ...
}

How to resolve that problem? Should I write my own parsesearch function?
It's rather simple thing even for me, but I think that other solutions
exist.

Thanks in advance for your help

My best regards

Pawel Tecza

Reply via email to