os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/compat/opendir.c
Update contrib.
4 * This file provides dirent-style directory-reading procedures
5 * for V7 Unix systems that don't have such procedures. The
6 * origin of this code is unclear, but it seems to have come
7 * originally from Larry Wall.
10 * RCS: @(#) $Id: opendir.c,v 1.2 1998/09/14 18:39:44 stanton Exp $
18 ((sizeof (struct dirent) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
31 myname = ((*name == '\0') ? "." : name);
32 if ((fd = open(myname, 0, 0)) == -1)
34 if ((dirp = (DIR *)ckalloc(sizeof(DIR))) == NULL) {
44 * read an old style directory entry and present it as a new one
51 char od_name[ODIRSIZ];
53 #else /* a Pyramid in the ATT universe */
58 short od_fill1, od_fill2;
59 char od_name[ODIRSIZ];
64 * get next entry in a directory.
70 register struct olddirect *dp;
71 static struct dirent dir;
74 if (dirp->dd_loc == 0) {
75 dirp->dd_size = read(dirp->dd_fd, dirp->dd_buf,
77 if (dirp->dd_size <= 0)
80 if (dirp->dd_loc >= dirp->dd_size) {
84 dp = (struct olddirect *)(dirp->dd_buf + dirp->dd_loc);
85 dirp->dd_loc += sizeof(struct olddirect);
88 dir.d_ino = dp->od_ino;
89 strncpy(dir.d_name, dp->od_name, ODIRSIZ);
90 dir.d_name[ODIRSIZ] = '\0'; /* insure null termination */
91 dir.d_namlen = strlen(dir.d_name);
92 dir.d_reclen = DIRSIZ(&dir);
107 ckfree((char *) dirp);