Project/Real_code/book/ch05/ch05-catdir.c
int
process(char *dir)
{
	DIR *dp;
	struct dirent *ent;

	if ((dp = opendir(dir)) == NULL) {
		fprintf(stderr, "%s: %s: cannot open for reading: %s\n",
				myname, dir, strerror(errno));
		return 1;
	}

	errno = 0;
	while ((ent = readdir(dp)) != NULL)
		printf("%8ld %s\n", ent->d_ino, ent->d_name);

	if (errno != 0) {
		fprintf(stderr, "%s: %s: reading directory entries: %s\n",
				myname, dir, strerror(errno));
		return 1;
	}

	if (closedir(dp) != 0) {
		fprintf(stderr, "%s: %s: closedir: %s\n",
				myname, dir, strerror(errno));
		return 1;
	}

	return 0;
}
/*
 * process --- do something with the directory, in this case,
 *             print inode/name pairs on standard output.
 *             Returns 0 if all ok, 1 otherwise.
 */
do something with the directory, in this case,
print inode/name pairs on standard output.
Returns 0 if all ok, 1 otherwise.
do something with the directory in this case print inode / name pairs on standard output . Returns 0 if all ok 1 otherwise .
int
process(char *dir)
{
	DIR *dp;
	struct dirent *ent;
	if ((dp = opendir(dir)) == NULL) {
		fprintf(stderr, "%s: %s: cannot open for reading: %s\n",
				myname, dir, strerror(errno));
		return 1;
	}
	errno = 0;
	while ((ent = readdir(dp)) != NULL)
		printf("%8ld %s\n", ent->d_ino, ent->d_name);
	if (errno != 0) {
		fprintf(stderr, "%s: %s: reading directory entries: %s\n",
				myname, dir, strerror(errno));
		return 1;
	}
	if (closedir(dp) != 0) {
		fprintf(stderr, "%s: %s: closedir: %s\n",
				myname, dir, strerror(errno));
		return 1;
	}
	return 0;
}
int process ( char * dir ) { DIR * dp ; struct dirent * ent ; if ( ( dp = opendir ( dir ) ) == NULL ) { fprintf ( stderr , " \n " , myname , dir , strerror ( errno ) ) ; return 1 ; } errno = 0 ; while ( ( ent = readdir ( dp ) ) != NULL ) printf ( " \n " , ent -> d_ino , ent -> d_name ) ; if ( errno != 0 ) { fprintf ( stderr , " \n " , myname , dir , strerror ( errno ) ) ; return 1 ; } if ( closedir ( dp ) != 0 ) { fprintf ( stderr , " \n " , myname , dir , strerror ( errno ) ) ; return 1 ; } return 0 ; }
process --- do something with the directory, in this case,
             print inode/name pairs on standard output.
process --- do something with the directory in this case print inode / name pairs on standard output .