1 /*@-type@*/ /* LCL: function typedefs */
7 #include <rpmio_internal.h>
16 extern int _rpmio_debug;
19 /* =============================================================== */
20 static int ftpMkdir(const char * path, /*@unused@*/ mode_t mode)
21 /*@globals fileSystem @*/
22 /*@modifies fileSystem @*/
25 if ((rc = ftpCmd("MKD", path, NULL)) != 0)
29 sprintf(buf, " 0%o", mode);
30 (void) ftpCmd("SITE CHMOD", path, buf);
36 static int ftpChdir(const char * path)
37 /*@globals fileSystem @*/
38 /*@modifies fileSystem @*/
40 return ftpCmd("CWD", path, NULL);
43 static int ftpRmdir(const char * path)
44 /*@globals fileSystem @*/
45 /*@modifies fileSystem @*/
47 return ftpCmd("RMD", path, NULL);
50 static int ftpRename(const char * oldpath, const char * newpath)
51 /*@globals fileSystem @*/
52 /*@modifies fileSystem @*/
55 if ((rc = ftpCmd("RNFR", oldpath, NULL)) != 0)
57 return ftpCmd("RNTO", newpath, NULL);
60 static int ftpUnlink(const char * path)
61 /*@globals fileSystem @*/
62 /*@modifies fileSystem @*/
64 return ftpCmd("DELE", path, NULL);
67 /* =============================================================== */
68 /* XXX rebuilddb.c: analogues to mkdir(2)/rmdir(2). */
69 int Mkdir (const char * path, mode_t mode)
72 int ut = urlPath(path, &lpath);
76 return ftpMkdir(path, mode);
77 /*@notreached@*/ break;
78 case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
87 /*@notreached@*/ break;
89 return mkdir(path, mode);
92 int Chdir (const char * path)
95 int ut = urlPath(path, &lpath);
99 return ftpChdir(path);
100 /*@notreached@*/ break;
101 case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
110 /*@notreached@*/ break;
115 int Rmdir (const char * path)
118 int ut = urlPath(path, &lpath);
122 return ftpRmdir(path);
123 /*@notreached@*/ break;
124 case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
133 /*@notreached@*/ break;
138 /* XXX rpmdb.c: analogue to rename(2). */
140 int Rename (const char * oldpath, const char * newpath)
142 const char *oe = NULL;
143 const char *ne = NULL;
146 /* XXX lib/install.c used to rely on this behavior. */
147 if (!strcmp(oldpath, newpath)) return 0;
149 oldut = urlPath(oldpath, &oe);
151 case URL_IS_FTP: /* XXX WRONG WRONG WRONG */
152 case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
159 /*@notreached@*/ break;
162 newut = urlPath(newpath, &ne);
166 fprintf(stderr, "*** rename old %*s new %*s\n", (int)(oe - oldpath), oldpath, (int)(ne - newpath), newpath);
167 if (!(oldut == newut && oe && ne && (oe - oldpath) == (ne - newpath) &&
168 !xstrncasecmp(oldpath, newpath, (oe - oldpath))))
170 return ftpRename(oldpath, newpath);
171 /*@notreached@*/ break;
172 case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
182 /*@notreached@*/ break;
184 return rename(oldpath, newpath);
187 int Link (const char * oldpath, const char * newpath)
189 const char *oe = NULL;
190 const char *ne = NULL;
193 oldut = urlPath(oldpath, &oe);
195 case URL_IS_FTP: /* XXX WRONG WRONG WRONG */
196 case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
203 /*@notreached@*/ break;
206 newut = urlPath(newpath, &ne);
208 case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
209 case URL_IS_FTP: /* XXX WRONG WRONG WRONG */
212 fprintf(stderr, "*** link old %*s new %*s\n", (int)(oe - oldpath), oldpath, (int)(ne - newpath), newpath);
213 if (!(oldut == newut && oe && ne && (oe - oldpath) == (ne - newpath) &&
214 !xstrncasecmp(oldpath, newpath, (oe - oldpath))))
224 /*@notreached@*/ break;
226 return link(oldpath, newpath);
229 /* XXX build/build.c: analogue to unlink(2). */
231 int Unlink(const char * path) {
233 int ut = urlPath(path, &lpath);
237 return ftpUnlink(path);
238 /*@notreached@*/ break;
239 case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
248 /*@notreached@*/ break;
253 /* XXX swiped from mc-4.5.39-pre9 vfs/ftpfs.c */
255 #define g_strdup xstrdup
259 * FIXME: this is broken. It depends on mc not crossing border on month!
262 static int current_mday;
264 static int current_mon;
266 static int current_year;
268 /* Following stuff (parse_ls_lga) is used by ftpfs and extfs */
272 static char *columns [MAXCOLS]; /* Points to the string in column n */
274 static int column_ptr [MAXCOLS]; /* Index from 0 to the starting positions of the columns */
277 vfs_split_text (char *p)
278 /*@globals columns, column_ptr @*/
279 /*@modifies *p, columns, column_ptr @*/
285 for (numcols = 0; *p && numcols < MAXCOLS; numcols++){
286 while (*p == ' ' || *p == '\r' || *p == '\n'){
290 columns [numcols] = p;
291 column_ptr [numcols] = p - original;
292 while (*p && *p != ' ' && *p != '\r' && *p != '\n')
302 if (!columns [idx] || columns [idx][0] < '0' || columns [idx][0] > '9')
308 is_dos_date(/*@null@*/ const char *str)
311 if (str != NULL && strlen(str) == 8 &&
312 str[2] == str[5] && strchr("\\-/", (int)str[2]) != NULL)
318 is_week (/*@null@*/ const char * str, /*@out@*/ struct tm * tim)
321 /*@observer@*/ static const char * week = "SunMonTueWedThuFriSat";
324 /*@-observertrans -mayaliasunique@*/
325 if (str != NULL && (pos=strstr(week, str)) != NULL) {
326 /*@=observertrans =mayaliasunique@*/
328 tim->tm_wday = (pos - week)/3;
335 is_month (/*@null@*/ const char * str, /*@out@*/ struct tm * tim)
338 /*@observer@*/ static const char * month = "JanFebMarAprMayJunJulAugSepOctNovDec";
341 /*@-observertrans -mayaliasunique@*/
342 if (str != NULL && (pos = strstr(month, str)) != NULL) {
343 /*@=observertrans -mayaliasunique@*/
345 tim->tm_mon = (pos - month)/3;
352 is_time (/*@null@*/ const char * str, /*@out@*/ struct tm * tim)
355 const char * p, * p2;
357 if (str != NULL && (p = strchr(str, ':')) && (p2 = strrchr(str, ':'))) {
359 if (sscanf (str, "%2d:%2d:%2d", &tim->tm_hour, &tim->tm_min, &tim->tm_sec) != 3)
362 if (sscanf (str, "%2d:%2d", &tim->tm_hour, &tim->tm_min) != 2)
371 static int is_year(/*@null@*/ const char * str, /*@out@*/ struct tm * tim)
382 if (strlen(str) != 4)
385 if (sscanf(str, "%ld", &year) != 1)
388 if (year < 1900 || year > 3000)
391 tim->tm_year = (int) (year - 1900);
397 * FIXME: this is broken. Consider following entry:
398 * -rwx------ 1 root root 1 Aug 31 10:04 2904 1234
399 * where "2904 1234" is filename. Well, this code decodes it as year :-(.
403 vfs_parse_filetype (char c)
407 case 'd': return S_IFDIR;
408 case 'b': return S_IFBLK;
409 case 'c': return S_IFCHR;
410 case 'l': return S_IFLNK;
412 #ifdef IS_IFSOCK /* And if not, we fall through to IFIFO, which is pretty close */
415 case 'p': return S_IFIFO;
416 case 'm': case 'n': /* Don't know what these are :-) */
417 case '-': case '?': return S_IFREG;
422 static int vfs_parse_filemode (const char *p)
424 { /* converts rw-rw-rw- into 0666 */
427 case 'r': res |= 0400; break;
432 case 'w': res |= 0200; break;
437 case 'x': res |= 0100; break;
438 case 's': res |= 0100 | S_ISUID; break;
439 case 'S': res |= S_ISUID; break;
444 case 'r': res |= 0040; break;
449 case 'w': res |= 0020; break;
454 case 'x': res |= 0010; break;
455 case 's': res |= 0010 | S_ISGID; break;
456 case 'l': /* Solaris produces these */
457 case 'S': res |= S_ISGID; break;
462 case 'r': res |= 0004; break;
467 case 'w': res |= 0002; break;
472 case 'x': res |= 0001; break;
473 case 't': res |= 0001 | S_ISVTX; break;
474 case 'T': res |= S_ISVTX; break;
481 static int vfs_parse_filedate(int idx, /*@out@*/ time_t *t)
483 { /* This thing parses from idx in columns[] array */
490 /* Let's setup default time values */
491 tim.tm_year = current_year;
492 tim.tm_mon = current_mon;
493 tim.tm_mday = current_mday;
497 tim.tm_isdst = -1; /* Let mktime() try to guess correct dst offset */
501 /* We eat weekday name in case of extfs */
506 if(is_month(p, &tim)){
507 /* And we expect, it followed by day number */
509 tim.tm_mday = (int)atol (columns [idx++]);
511 return 0; /* No day */
514 /* We usually expect:
517 But in case of extfs we allow these date formats:
520 Wek Mon DD hh:mm:ss YYYY
522 where Mon is Jan-Dec, DD, MM, YY two digit day, month, year,
523 YYYY four digit year, hh, mm, ss two digit hour, minute or second. */
525 /* Here just this special case with MM-DD-YY */
531 memset(d, 0, sizeof(d));
532 if (sscanf(p, "%2d-%2d-%2d", &d[0], &d[1], &d[2]) == 3){
539 /* Hmm... maybe, next time :)*/
541 /* At last, MM-DD-YY */
542 d[0]--; /* Months are zerobased */
552 return 0; /* sscanf failed */
554 return 0; /* unsupported format */
557 /* Here we expect to find time and/or year */
560 if(is_time(columns[idx], &tim) || (got_year = is_year(columns[idx], &tim))) {
563 /* This is a special case for ctime() or Mon DD YYYY hh:mm */
565 ((got_year = is_year(columns[idx], &tim)) || is_time(columns[idx], &tim)))
566 idx++; /* time & year or reverse */
567 } /* only time or date */
570 return 0; /* Nor time or date */
573 * If the date is less than 6 months in the past, it is shown without year
574 * other dates in the past or future are shown with year but without time
575 * This does not check for years before 1900 ... I don't know, how
576 * to represent them at all
579 current_mon < 6 && current_mon < tim.tm_mon &&
580 tim.tm_mon - current_mon >= 6)
584 if ((*t = mktime(&tim)) < 0)
590 vfs_parse_ls_lga (char * p, /*@out@*/ struct stat * st,
591 /*@out@*/ const char ** filename,
592 /*@out@*/ const char ** linkname)
593 /*@modifies *st, *filename, *linkname @*/
595 int idx, idx2, num_cols;
599 if (strncmp (p, "total", 5) == 0)
602 p_copy = g_strdup(p);
603 /* XXX FIXME: parse out inode number from "NLST -lai ." */
604 /* XXX FIXME: parse out sizein blocks from "NLST -lais ." */
606 if ((i = vfs_parse_filetype(*(p++))) == -1)
610 if (*p == ' ') /* Notwell 4 */
613 if (strlen (p) <= 8 || p [8] != ']')
615 /* Should parse here the Notwell permissions :) */
617 if (S_ISDIR (st->st_mode))
618 st->st_mode |= (S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR | S_IXUSR | S_IXGRP | S_IXOTH);
620 st->st_mode |= (S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR);
624 if ((i = vfs_parse_filemode(p)) == -1)
629 /* This is for an extra ACL attribute (HP-UX) */
635 p_copy = g_strdup(p);
636 num_cols = vfs_split_text (p);
638 st->st_nlink = atol (columns [0]);
639 if (st->st_nlink < 0)
644 st->st_uid = finduid (columns [1]);
646 (void) unameToUid (columns [1], &st->st_uid);
649 st->st_uid = (uid_t) atol (columns [1]);
651 /* Mhm, the ls -lg did not produce a group field */
652 for (idx = 3; idx <= 5; idx++)
653 if (is_month(columns [idx], NULL) || is_week(columns [idx], NULL) || is_dos_date(columns[idx]))
656 if (idx == 6 || (idx == 5 && !S_ISCHR (st->st_mode) && !S_ISBLK (st->st_mode)))
659 /* We don't have gid */
660 if (idx == 3 || (idx == 4 && (S_ISCHR(st->st_mode) || S_ISBLK (st->st_mode))))
663 /* We have gid field */
665 st->st_gid = (gid_t) atol (columns [2]);
668 st->st_gid = findgid (columns [2]);
670 (void) gnameToGid (columns [1], &st->st_gid);
676 if (S_ISCHR (st->st_mode) || S_ISBLK (st->st_mode)){
679 if (!is_num (idx2) || sscanf(columns [idx2], " %d,", &maj) != 1)
682 if (!is_num (++idx2) || sscanf(columns [idx2], " %d", &min) != 1)
686 st->st_rdev = ((maj & 0xff) << 8) | (min & 0xffff00ff);
691 /* Common file size */
695 st->st_size = (size_t) atol (columns [idx2]);
701 idx = vfs_parse_filedate(idx, &st->st_mtime);
704 /* Use resulting time value */
705 st->st_atime = st->st_ctime = st->st_mtime;
708 #ifdef HAVE_ST_BLKSIZE
709 st->st_blksize = 512;
711 #ifdef HAVE_ST_BLOCKS
712 st->st_blocks = (st->st_size + 511) / 512;
715 for (i = idx + 1, idx2 = 0; i < num_cols; i++ )
716 if (strcmp (columns [i], "->") == 0){
721 if (((S_ISLNK (st->st_mode) ||
722 (num_cols == idx + 3 && st->st_nlink > 1))) /* Maybe a hardlink? (in extfs) */
729 t = g_strndup (p_copy + column_ptr [idx], column_ptr [idx2] - column_ptr [idx] - 1);
731 int nb = column_ptr [idx2] - column_ptr [idx] - 1;
733 strncpy(t, p_copy + column_ptr [idx], nb);
738 t = g_strdup (p_copy + column_ptr [idx2+1]);
740 if (t [tlen-1] == '\r' || t [tlen-1] == '\n')
742 if (t [tlen-2] == '\r' || t [tlen-2] == '\n')
748 /* Extract the filename from the string copy, not from the columns
749 * this way we have a chance of entering hidden directories like ". ."
753 *filename = g_strdup (columns [idx++]);
758 t = g_strdup (p_copy + column_ptr [idx++]);
761 if (t [tlen-1] == '\r' || t [tlen-1] == '\n')
763 if (t [tlen-2] == '\r' || t [tlen-2] == '\n')
777 static int errorcount = 0;
779 if (++errorcount < 5) {
780 message_1s (1, "Could not parse:", p_copy);
781 } else if (errorcount == 5)
782 message_1s (1, "More parsing errors will be ignored.", "(sorry)" );
787 if (p_copy != p) /* Carefull! */
804 static size_t ftpBufAlloced = 0;
809 static /*@only@*/ char * ftpBuf = NULL;
811 #define alloca_strdup(_s) strcpy(alloca(strlen(_s)+1), (_s))
814 static int ftpNLST(const char * url, ftpSysCall_t ftpSysCall,
815 /*@out@*/ /*@null@*/ struct stat * st,
816 /*@out@*/ /*@null@*/ char * rlbuf, size_t rlbufsiz)
817 /*@globals fileSystem @*/
818 /*@modifies *st, *rlbuf, fileSystem @*/
822 int bufLength, moretodo;
823 const char *n, *ne, *o, *oe;
832 n = ne = o = oe = NULL;
833 (void) urlPath(url, &path);
837 switch (ftpSysCall) {
839 fd = ftpOpen(url, 0, 0, &u);
840 if (fd == NULL || u == NULL)
843 u->openError = ftpReq(fd, "NLST", path);
846 urldn = alloca_strdup(url);
848 if ((bn = strrchr(urldn, '/')) == NULL)
857 rc = ftpChdir(urldn); /* XXX don't care about CWD */
861 fd = ftpOpen(url, 0, 0, &u);
862 if (fd == NULL || u == NULL)
865 /* XXX possibly should do "NLST -lais" to get st_ino/st_blocks also */
866 u->openError = ftpReq(fd, "NLST", "-la");
868 if (bn == NULL || nbn <= 0) {
875 if (u->openError < 0) {
876 fd = fdLink(fd, "error data (ftpStat)");
881 if (ftpBufAlloced == 0 || ftpBuf == NULL) {
882 ftpBufAlloced = _url_iobuf_size;
883 ftpBuf = xcalloc(ftpBufAlloced, sizeof(ftpBuf[0]));
892 /* XXX FIXME: realloc ftpBuf if < ~128 chars remain */
893 if ((ftpBufAlloced - bufLength) < (1024+80)) {
895 ftpBuf = xrealloc(ftpBuf, ftpBufAlloced);
897 s = se = ftpBuf + bufLength;
900 rc = fdFgets(fd, se, (ftpBufAlloced - bufLength));
905 if (ftpSysCall == DO_FTP_GLOB) { /* XXX HACK */
906 bufLength += strlen(se);
910 for (s = se; *s != '\0'; s = se) {
913 while (*se && *se != '\n') se++;
914 if (se > s && se[-1] == '\r') se[-1] = '\0';
916 /*@innerbreak@*/ break;
919 if (!strncmp(s, "total ", sizeof("total ")-1))
920 /*@innercontinue@*/ continue;
923 for (bingo = 0, n = se; n >= s; n--) {
927 /*@switchbreak@*/ break;
929 if (o || !(n[-3] == ' ' && n[-2] == '-' && n[-1] == '>')) {
930 while (*(++n) == ' ')
933 /*@switchbreak@*/ break;
935 for (o = n + 1; *o == ' '; o++)
939 /*@switchbreak@*/ break;
941 /*@switchbreak@*/ break;
944 /*@innerbreak@*/ break;
947 if (nbn != (ne - n)) /* Same name length? */
948 /*@innercontinue@*/ continue;
949 if (strncmp(n, bn, nbn)) /* Same name? */
950 /*@innercontinue@*/ continue;
953 /*@innerbreak@*/ break;
956 if (moretodo && se > s) {
957 bufLength = se - s - 1;
959 memmove(ftpBuf, s, bufLength);
965 switch (ftpSysCall) {
968 /* XXX FIXME: symlink, replace urldn/bn from [o,oe) and restart */
972 if (st == NULL || !(n && ne)) {
975 rc = ((vfs_parse_ls_lga(s, st, NULL, NULL) > 0) ? 0 : -1);
978 case DO_FTP_READLINK:
979 if (rlbuf == NULL || !(o && oe)) {
985 memcpy(rlbuf, o, rc);
991 rc = 0; /* XXX WRONG WRONG WRONG */
994 rc = 0; /* XXX WRONG WRONG WRONG */
1004 static int ftpStat(const char * path, /*@out@*/ struct stat *st)
1005 /*@globals fileSystem @*/
1006 /*@modifies *st, fileSystem @*/
1008 return ftpNLST(path, DO_FTP_STAT, st, NULL, 0);
1011 static int ftpLstat(const char * path, /*@out@*/ struct stat *st)
1012 /*@globals fileSystem @*/
1013 /*@modifies *st, fileSystem @*/
1016 rc = ftpNLST(path, DO_FTP_LSTAT, st, NULL, 0);
1018 fprintf(stderr, "*** ftpLstat(%s) rc %d\n", path, rc);
1022 static int ftpReadlink(const char * path, /*@out@*/ char * buf, size_t bufsiz)
1023 /*@globals fileSystem @*/
1024 /*@modifies *buf, fileSystem @*/
1026 return ftpNLST(path, DO_FTP_READLINK, NULL, buf, bufsiz);
1029 static int ftpGlob(const char * path, int flags,
1030 int errfunc(const char * epath, int eerno),
1031 /*@out@*/ glob_t * pglob)
1032 /*@globals fileSystem @*/
1033 /*@modifies *pglob, fileSystem @*/
1039 rc = ftpNLST(path, DO_FTP_GLOB, NULL, NULL, 0);
1042 fprintf(stderr, "*** ftpGlob(%s,0x%x,%p,%p) ftpNLST rc %d\n", path, (unsigned)flags, (void *)errfunc, pglob, rc);
1046 rc = poptParseArgvString(ftpBuf, &pglob->gl_pathc, (const char ***)&pglob->gl_pathv);
1047 pglob->gl_offs = -1; /* XXX HACK HACK HACK */
1051 static void ftpGlobfree(glob_t * pglob)
1052 /*@modifies *pglob @*/
1056 fprintf(stderr, "*** ftpGlobfree(%p)\n", pglob);
1058 if (pglob->gl_offs == -1) { /* XXX HACK HACK HACK */
1059 free((void *)pglob->gl_pathv);
1060 pglob->gl_pathv = NULL;
1064 int Stat(const char * path, struct stat * st)
1067 int ut = urlPath(path, &lpath);
1070 fprintf(stderr, "*** Stat(%s,%p)\n", path, st);
1073 return ftpStat(path, st);
1074 /*@notreached@*/ break;
1075 case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
1079 case URL_IS_UNKNOWN:
1084 /*@notreached@*/ break;
1086 return stat(path, st);
1089 int Lstat(const char * path, struct stat * st)
1092 int ut = urlPath(path, &lpath);
1095 fprintf(stderr, "*** Lstat(%s,%p)\n", path, st);
1098 return ftpLstat(path, st);
1099 /*@notreached@*/ break;
1100 case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
1104 case URL_IS_UNKNOWN:
1109 /*@notreached@*/ break;
1111 return lstat(path, st);
1114 int Readlink(const char * path, char * buf, size_t bufsiz)
1117 int ut = urlPath(path, &lpath);
1121 return ftpReadlink(path, buf, bufsiz);
1122 /*@notreached@*/ break;
1123 case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
1127 case URL_IS_UNKNOWN:
1132 /*@notreached@*/ break;
1134 return readlink(path, buf, bufsiz);
1137 int Access(const char * path, int amode)
1140 int ut = urlPath(path, &lpath);
1143 fprintf(stderr, "*** Access(%s,%d)\n", path, amode);
1145 case URL_IS_FTP: /* XXX WRONG WRONG WRONG */
1146 case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
1150 case URL_IS_UNKNOWN:
1155 /*@notreached@*/ break;
1157 return access(path, amode);
1160 int Glob(const char *pattern, int flags,
1161 int errfunc(const char * epath, int eerrno), glob_t *pglob)
1164 int ut = urlPath(pattern, &lpath);
1168 fprintf(stderr, "*** Glob(%s,0x%x,%p,%p)\n", pattern, (unsigned)flags, (void *)errfunc, pglob);
1171 case URL_IS_FTP: /* XXX WRONG WRONG WRONG */
1172 return ftpGlob(pattern, flags, errfunc, pglob);
1173 /*@notreached@*/ break;
1174 case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
1178 case URL_IS_UNKNOWN:
1183 /*@notreached@*/ break;
1185 return glob(pattern, flags, errfunc, pglob);
1188 void Globfree(glob_t *pglob)
1191 fprintf(stderr, "*** Globfree(%p)\n", pglob);
1193 if (pglob->gl_offs == -1) /* XXX HACK HACK HACK */
1200 DIR * Opendir(const char * path)
1203 int ut = urlPath(path, &lpath);
1206 fprintf(stderr, "*** Opendir(%s)\n", path);
1208 case URL_IS_FTP: /* XXX WRONG WRONG WRONG */
1209 case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
1213 case URL_IS_UNKNOWN:
1218 /*@notreached@*/ break;
1220 return opendir(path);
1224 struct dirent * Readdir(DIR * dir)
1227 fprintf(stderr, "*** Readdir(%p)\n", (void *)dir);
1228 return readdir(dir);
1231 int Closedir(DIR * dir)
1234 fprintf(stderr, "*** Closedir(%p)\n", (void *)dir);
1235 return closedir(dir);