Back to index

glibc  2.9
Functions
list.c File Reference
#include <errno.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>

Go to the source code of this file.

Functions

static int test (const char *name)
int main (int argc, char **argv)

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 63 of file list.c.

{
  int retval = 0;
  --argc;
  ++argv;

  if (argc == 0)
    retval = test (".");
  else
    while (argc-- > 0)
      retval |= test (*argv++);

  return retval;
}
static int test ( const char *  name) [static]

Definition at line 27 of file list.c.

{
  DIR *dirp;
  struct dirent *entp;
  int retval = 0;

  puts (name);

  dirp = opendir (name);
  if (dirp == NULL)
    {
      perror ("opendir");
      return 1;
    }

  errno = 0;
  while ((entp = readdir (dirp)) != NULL)
    printf ("%s\tfile number %lu\n",
           entp->d_name, (unsigned long int) entp->d_fileno);

  if (errno)
    {
      perror ("readdir");
      retval = 1;
    }

  if (closedir (dirp) < 0)
    {
      perror ("closedir");
      retval = 1;
    }

  return retval;
}

Here is the call graph for this function: