Logo Search packages:      
Sourcecode: samba-doc-ja version File versions

struct smbc_dirent* smbc_readdir ( unsigned int  dh  )  [read]

Get a single directory entry.

Parameters:
dh Valid directory as returned by smbc_opendir()
Returns:
A pointer to a smbc_dirent structure, or NULL if an error occurs or end-of-directory is reached:
  • EBADF Invalid directory handle
  • EINVAL smbc_init() failed or has not been called
See also:
smbc_dirent, smbc_getdents(), smbc_open()

Definition at line 1891 of file libsmbclient.c.

References smbc_dirent::comment, smbc_dirent::dirlen, smbc_dirent::name, and smbc_dirent::namelen.

{
      struct smbc_file *fe;
      struct smbc_dirent *dirp, *dirent;

      /* Check that all is ok first ... */

      if (!smbc_initialized) {

            errno = EINVAL;
            return NULL;

      }

      if (fd < smbc_start_fd || fd >= (smbc_start_fd + SMBC_MAX_FD)) {

            errno = EBADF;
            return NULL;

      }

      fe = smbc_file_table[fd - smbc_start_fd];

      if (!fe) {

            errno = EBADF;
            return NULL;

      }

      if (fe->file != False) { /* FIXME, should be dir, perhaps */

            errno = ENOTDIR;
            return NULL;

      }

      if (!fe->dir_next)
            return NULL;
      else {

            dirent = fe->dir_next->dirent;

            if (!dirent) {

                  errno = ENOENT;
                  return NULL;

            }

            /* Hmmm, do I even need to copy it? */

            memcpy(smbc_local_dirent, dirent, dirent->dirlen); /* Copy the dirent */
            dirp = (struct smbc_dirent *)smbc_local_dirent;
            dirp->comment = (char *)(dirp->name + dirent->namelen + 1);
            fe->dir_next = fe->dir_next->next;

            return (struct smbc_dirent *)smbc_local_dirent;
      }

}


Generated by  Doxygen 1.6.0   Back to index