Initial import of the CDE 2.1.30 sources from the Open Group.
This commit is contained in:
176
cde/programs/dtksh/ksh93/src/lib/libast/dir/dirlib.h
Normal file
176
cde/programs/dtksh/ksh93/src/lib/libast/dir/dirlib.h
Normal file
@@ -0,0 +1,176 @@
|
||||
/* $XConsortium: dirlib.h /main/3 1995/11/01 17:21:59 rswiston $ */
|
||||
/***************************************************************
|
||||
* *
|
||||
* AT&T - PROPRIETARY *
|
||||
* *
|
||||
* THIS IS PROPRIETARY SOURCE CODE LICENSED BY *
|
||||
* AT&T CORP. *
|
||||
* *
|
||||
* Copyright (c) 1995 AT&T Corp. *
|
||||
* All Rights Reserved *
|
||||
* *
|
||||
* This software is licensed by AT&T Corp. *
|
||||
* under the terms and conditions of the license in *
|
||||
* http://www.research.att.com/orgs/ssr/book/reuse *
|
||||
* *
|
||||
* This software was created by the *
|
||||
* Software Engineering Research Department *
|
||||
* AT&T Bell Laboratories *
|
||||
* *
|
||||
* For further information contact *
|
||||
* gsf@research.att.com *
|
||||
* *
|
||||
***************************************************************/
|
||||
|
||||
/* : : generated by proto : : */
|
||||
|
||||
/*
|
||||
* AT&T Bell Laboratories
|
||||
*
|
||||
* directory stream access library private definitions
|
||||
* library routines should include this file rather than <dirent.h>
|
||||
*/
|
||||
|
||||
#ifndef _DIRLIB_H
|
||||
#if !defined(__PROTO__)
|
||||
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
|
||||
#if defined(__cplusplus)
|
||||
#define __MANGLE__ "C"
|
||||
#else
|
||||
#define __MANGLE__
|
||||
#endif
|
||||
#define __STDARG__
|
||||
#define __PROTO__(x) x
|
||||
#define __OTORP__(x)
|
||||
#define __PARAM__(n,o) n
|
||||
#if !defined(__STDC__) && !defined(__cplusplus)
|
||||
#if !defined(c_plusplus)
|
||||
#define const
|
||||
#endif
|
||||
#define signed
|
||||
#define void int
|
||||
#define volatile
|
||||
#define __V_ char
|
||||
#else
|
||||
#define __V_ void
|
||||
#endif
|
||||
#else
|
||||
#define __PROTO__(x) ()
|
||||
#define __OTORP__(x) x
|
||||
#define __PARAM__(n,o) o
|
||||
#define __MANGLE__
|
||||
#define __V_ char
|
||||
#define const
|
||||
#define signed
|
||||
#define void int
|
||||
#define volatile
|
||||
#endif
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
#define __VARARG__ ...
|
||||
#else
|
||||
#define __VARARG__
|
||||
#endif
|
||||
#if defined(__STDARG__)
|
||||
#define __VA_START__(p,a) va_start(p,a)
|
||||
#else
|
||||
#define __VA_START__(p,a) va_start(p)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define _DIRLIB_H
|
||||
|
||||
#if defined(__STDPP__directive) && defined(__STDPP__hide)
|
||||
__STDPP__directive pragma pp:hide getdents
|
||||
#else
|
||||
#define getdents ______getdents
|
||||
#endif
|
||||
|
||||
#include <ast.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if _lib_opendir && ( _hdr_dirent || _hdr_ndir || _sys_dir )
|
||||
|
||||
#define _dir_ok 1
|
||||
|
||||
#include <ls.h>
|
||||
#ifndef _DIRENT_H
|
||||
#if _hdr_dirent
|
||||
#include <dirent.h>
|
||||
#else
|
||||
#if _hdr_ndir
|
||||
#include <ndir.h>
|
||||
#else
|
||||
#include <sys/dir.h>
|
||||
#endif
|
||||
#ifndef dirent
|
||||
#define dirent direct
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#if defined(__STDPP__directive) && defined(__STDPP__hide)
|
||||
__STDPP__directive pragma pp:hide DIR closedir dirent opendir readdir seekdir telldir
|
||||
#else
|
||||
#define DIR ______DIR
|
||||
#define closedir ______closedir
|
||||
#define dirent ______dirent
|
||||
#define opendir ______opendir
|
||||
#define readdir ______readdir
|
||||
#define seekdir ______seekdir
|
||||
#define telldir ______telldir
|
||||
#endif
|
||||
|
||||
#include <ast_param.h>
|
||||
|
||||
#include <ls.h>
|
||||
#include <limits.h>
|
||||
#include <sys/dir.h>
|
||||
|
||||
#if defined(__STDPP__directive) && defined(__STDPP__hide)
|
||||
__STDPP__directive pragma pp:nohide DIR closedir dirent opendir readdir seekdir telldir
|
||||
#else
|
||||
#undef DIR
|
||||
#undef closedir
|
||||
#undef dirent
|
||||
#undef opendir
|
||||
#undef readdir
|
||||
#undef seekdir
|
||||
#undef telldir
|
||||
#endif
|
||||
|
||||
#define _DIR_PRIVATE_ \
|
||||
int dd_loc; /* offset in block */ \
|
||||
int dd_size; /* valid data in block */ \
|
||||
char* dd_buf; /* directory block */
|
||||
|
||||
#include "dirstd.h"
|
||||
|
||||
#ifndef DIRBLKSIZ
|
||||
#ifdef DIRBLK
|
||||
#define DIRBLKSIZ DIRBLK
|
||||
#else
|
||||
#ifdef DIRBUF
|
||||
#define DIRBLKSIZ DIRBUF
|
||||
#else
|
||||
#define DIRBLKSIZ 8192
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__STDPP__directive) && defined(__STDPP__hide)
|
||||
__STDPP__directive pragma pp:nohide getdents
|
||||
#else
|
||||
#undef getdents
|
||||
#endif
|
||||
|
||||
#ifndef errno
|
||||
extern __MANGLE__ int errno;
|
||||
#endif
|
||||
|
||||
extern __MANGLE__ ssize_t getdents __PROTO__((int, __V_*, size_t));
|
||||
|
||||
#endif
|
||||
122
cde/programs/dtksh/ksh93/src/lib/libast/dir/dirnsys.h
Normal file
122
cde/programs/dtksh/ksh93/src/lib/libast/dir/dirnsys.h
Normal file
@@ -0,0 +1,122 @@
|
||||
/* $XConsortium: dirnsys.h /main/3 1995/11/01 17:22:15 rswiston $ */
|
||||
/***************************************************************
|
||||
* *
|
||||
* AT&T - PROPRIETARY *
|
||||
* *
|
||||
* THIS IS PROPRIETARY SOURCE CODE LICENSED BY *
|
||||
* AT&T CORP. *
|
||||
* *
|
||||
* Copyright (c) 1995 AT&T Corp. *
|
||||
* All Rights Reserved *
|
||||
* *
|
||||
* This software is licensed by AT&T Corp. *
|
||||
* under the terms and conditions of the license in *
|
||||
* http://www.research.att.com/orgs/ssr/book/reuse *
|
||||
* *
|
||||
* This software was created by the *
|
||||
* Software Engineering Research Department *
|
||||
* AT&T Bell Laboratories *
|
||||
* *
|
||||
* For further information contact *
|
||||
* gsf@research.att.com *
|
||||
* *
|
||||
***************************************************************/
|
||||
|
||||
/* : : generated by proto : : */
|
||||
|
||||
/*
|
||||
* AT&T Bell Laboratories
|
||||
*
|
||||
* <dirent.h> for systems with opendir() and <ndir.h>
|
||||
*/
|
||||
|
||||
#ifndef _DIRENT_H
|
||||
#if !defined(__PROTO__)
|
||||
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
|
||||
#if defined(__cplusplus)
|
||||
#define __MANGLE__ "C"
|
||||
#else
|
||||
#define __MANGLE__
|
||||
#endif
|
||||
#define __STDARG__
|
||||
#define __PROTO__(x) x
|
||||
#define __OTORP__(x)
|
||||
#define __PARAM__(n,o) n
|
||||
#if !defined(__STDC__) && !defined(__cplusplus)
|
||||
#if !defined(c_plusplus)
|
||||
#define const
|
||||
#endif
|
||||
#define signed
|
||||
#define void int
|
||||
#define volatile
|
||||
#define __V_ char
|
||||
#else
|
||||
#define __V_ void
|
||||
#endif
|
||||
#else
|
||||
#define __PROTO__(x) ()
|
||||
#define __OTORP__(x) x
|
||||
#define __PARAM__(n,o) o
|
||||
#define __MANGLE__
|
||||
#define __V_ char
|
||||
#define const
|
||||
#define signed
|
||||
#define void int
|
||||
#define volatile
|
||||
#endif
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
#define __VARARG__ ...
|
||||
#else
|
||||
#define __VARARG__
|
||||
#endif
|
||||
#if defined(__STDARG__)
|
||||
#define __VA_START__(p,a) va_start(p,a)
|
||||
#else
|
||||
#define __VA_START__(p,a) va_start(p)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define _DIRENT_H
|
||||
|
||||
#if defined(__STDPP__directive) && defined(__STDPP__hide)
|
||||
__STDPP__directive pragma pp:hide closedir opendir readdir seekdir telldir
|
||||
#else
|
||||
#define closedir ______closedir
|
||||
#define opendir ______opendir
|
||||
#define readdir ______readdir
|
||||
#define seekdir ______seekdir
|
||||
#define telldir ______telldir
|
||||
#endif
|
||||
|
||||
#include <ndir.h>
|
||||
|
||||
#if defined(__STDPP__directive) && defined(__STDPP__hide)
|
||||
__STDPP__directive pragma pp:nohide closedir opendir readdir seekdir telldir
|
||||
#else
|
||||
#undef closedir
|
||||
#undef opendir
|
||||
#undef readdir
|
||||
#undef seekdir
|
||||
#undef telldir
|
||||
#endif
|
||||
|
||||
#ifndef dirent
|
||||
#define dirent direct
|
||||
#endif
|
||||
|
||||
#if !defined(d_fileno) && !defined(d_ino)
|
||||
#define d_fileno d_ino
|
||||
#endif
|
||||
|
||||
#ifdef rewinddir
|
||||
#undef rewinddir
|
||||
#define rewinddir(p) seekdir(p,0L)
|
||||
#endif
|
||||
|
||||
extern __MANGLE__ DIR* opendir __PROTO__((const char*));
|
||||
extern __MANGLE__ void closedir __PROTO__((DIR*));
|
||||
extern __MANGLE__ struct dirent* readdir __PROTO__((DIR*));
|
||||
extern __MANGLE__ void seekdir __PROTO__((DIR*, long));
|
||||
extern __MANGLE__ long telldir __PROTO__((DIR*));
|
||||
|
||||
#endif
|
||||
108
cde/programs/dtksh/ksh93/src/lib/libast/dir/dirstd.h
Normal file
108
cde/programs/dtksh/ksh93/src/lib/libast/dir/dirstd.h
Normal file
@@ -0,0 +1,108 @@
|
||||
/* $XConsortium: dirstd.h /main/3 1995/11/01 17:22:29 rswiston $ */
|
||||
/***************************************************************
|
||||
* *
|
||||
* AT&T - PROPRIETARY *
|
||||
* *
|
||||
* THIS IS PROPRIETARY SOURCE CODE LICENSED BY *
|
||||
* AT&T CORP. *
|
||||
* *
|
||||
* Copyright (c) 1995 AT&T Corp. *
|
||||
* All Rights Reserved *
|
||||
* *
|
||||
* This software is licensed by AT&T Corp. *
|
||||
* under the terms and conditions of the license in *
|
||||
* http://www.research.att.com/orgs/ssr/book/reuse *
|
||||
* *
|
||||
* This software was created by the *
|
||||
* Software Engineering Research Department *
|
||||
* AT&T Bell Laboratories *
|
||||
* *
|
||||
* For further information contact *
|
||||
* gsf@research.att.com *
|
||||
* *
|
||||
***************************************************************/
|
||||
|
||||
/* : : generated by proto : : */
|
||||
|
||||
/*
|
||||
* AT&T Bell Laboratories
|
||||
*
|
||||
* <dirent.h> for systems with no opendir()
|
||||
*/
|
||||
|
||||
#ifndef _DIRENT_H
|
||||
#if !defined(__PROTO__)
|
||||
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
|
||||
#if defined(__cplusplus)
|
||||
#define __MANGLE__ "C"
|
||||
#else
|
||||
#define __MANGLE__
|
||||
#endif
|
||||
#define __STDARG__
|
||||
#define __PROTO__(x) x
|
||||
#define __OTORP__(x)
|
||||
#define __PARAM__(n,o) n
|
||||
#if !defined(__STDC__) && !defined(__cplusplus)
|
||||
#if !defined(c_plusplus)
|
||||
#define const
|
||||
#endif
|
||||
#define signed
|
||||
#define void int
|
||||
#define volatile
|
||||
#define __V_ char
|
||||
#else
|
||||
#define __V_ void
|
||||
#endif
|
||||
#else
|
||||
#define __PROTO__(x) ()
|
||||
#define __OTORP__(x) x
|
||||
#define __PARAM__(n,o) o
|
||||
#define __MANGLE__
|
||||
#define __V_ char
|
||||
#define const
|
||||
#define signed
|
||||
#define void int
|
||||
#define volatile
|
||||
#endif
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
#define __VARARG__ ...
|
||||
#else
|
||||
#define __VARARG__
|
||||
#endif
|
||||
#if defined(__STDARG__)
|
||||
#define __VA_START__(p,a) va_start(p,a)
|
||||
#else
|
||||
#define __VA_START__(p,a) va_start(p)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define _DIRENT_H
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int dd_fd; /* file descriptor */
|
||||
#ifdef _DIR_PRIVATE_
|
||||
_DIR_PRIVATE_
|
||||
#endif
|
||||
} DIR;
|
||||
|
||||
struct dirent
|
||||
{
|
||||
long d_fileno; /* entry serial number */
|
||||
int d_reclen; /* entry length */
|
||||
int d_namlen; /* entry name length */
|
||||
char d_name[1]; /* entry name */
|
||||
};
|
||||
|
||||
#ifdef rewinddir
|
||||
#undef rewinddir
|
||||
#define rewinddir(p) seekdir(p,0L)
|
||||
#endif
|
||||
|
||||
extern __MANGLE__ DIR* opendir __PROTO__((const char*));
|
||||
extern __MANGLE__ void closedir __PROTO__((DIR*));
|
||||
extern __MANGLE__ struct dirent* readdir __PROTO__((DIR*));
|
||||
extern __MANGLE__ void seekdir __PROTO__((DIR*, long));
|
||||
extern __MANGLE__ long telldir __PROTO__((DIR*));
|
||||
|
||||
#endif
|
||||
122
cde/programs/dtksh/ksh93/src/lib/libast/dir/dirsys.h
Normal file
122
cde/programs/dtksh/ksh93/src/lib/libast/dir/dirsys.h
Normal file
@@ -0,0 +1,122 @@
|
||||
/* $XConsortium: dirsys.h /main/3 1995/11/01 17:22:42 rswiston $ */
|
||||
/***************************************************************
|
||||
* *
|
||||
* AT&T - PROPRIETARY *
|
||||
* *
|
||||
* THIS IS PROPRIETARY SOURCE CODE LICENSED BY *
|
||||
* AT&T CORP. *
|
||||
* *
|
||||
* Copyright (c) 1995 AT&T Corp. *
|
||||
* All Rights Reserved *
|
||||
* *
|
||||
* This software is licensed by AT&T Corp. *
|
||||
* under the terms and conditions of the license in *
|
||||
* http://www.research.att.com/orgs/ssr/book/reuse *
|
||||
* *
|
||||
* This software was created by the *
|
||||
* Software Engineering Research Department *
|
||||
* AT&T Bell Laboratories *
|
||||
* *
|
||||
* For further information contact *
|
||||
* gsf@research.att.com *
|
||||
* *
|
||||
***************************************************************/
|
||||
|
||||
/* : : generated by proto : : */
|
||||
|
||||
/*
|
||||
* AT&T Bell Laboratories
|
||||
*
|
||||
* <dirent.h> for systems with opendir() and no <ndir.h>
|
||||
*/
|
||||
|
||||
#ifndef _DIRENT_H
|
||||
#if !defined(__PROTO__)
|
||||
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
|
||||
#if defined(__cplusplus)
|
||||
#define __MANGLE__ "C"
|
||||
#else
|
||||
#define __MANGLE__
|
||||
#endif
|
||||
#define __STDARG__
|
||||
#define __PROTO__(x) x
|
||||
#define __OTORP__(x)
|
||||
#define __PARAM__(n,o) n
|
||||
#if !defined(__STDC__) && !defined(__cplusplus)
|
||||
#if !defined(c_plusplus)
|
||||
#define const
|
||||
#endif
|
||||
#define signed
|
||||
#define void int
|
||||
#define volatile
|
||||
#define __V_ char
|
||||
#else
|
||||
#define __V_ void
|
||||
#endif
|
||||
#else
|
||||
#define __PROTO__(x) ()
|
||||
#define __OTORP__(x) x
|
||||
#define __PARAM__(n,o) o
|
||||
#define __MANGLE__
|
||||
#define __V_ char
|
||||
#define const
|
||||
#define signed
|
||||
#define void int
|
||||
#define volatile
|
||||
#endif
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
#define __VARARG__ ...
|
||||
#else
|
||||
#define __VARARG__
|
||||
#endif
|
||||
#if defined(__STDARG__)
|
||||
#define __VA_START__(p,a) va_start(p,a)
|
||||
#else
|
||||
#define __VA_START__(p,a) va_start(p)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define _DIRENT_H
|
||||
|
||||
#if defined(__STDPP__directive) && defined(__STDPP__hide)
|
||||
__STDPP__directive pragma pp:hide closedir opendir readdir seekdir telldir
|
||||
#else
|
||||
#define closedir ______closedir
|
||||
#define opendir ______opendir
|
||||
#define readdir ______readdir
|
||||
#define seekdir ______seekdir
|
||||
#define telldir ______telldir
|
||||
#endif
|
||||
|
||||
#include <sys/dir.h>
|
||||
|
||||
#if defined(__STDPP__directive) && defined(__STDPP__hide)
|
||||
__STDPP__directive pragma pp:nohide closedir opendir readdir seekdir telldir
|
||||
#else
|
||||
#undef closedir
|
||||
#undef opendir
|
||||
#undef readdir
|
||||
#undef seekdir
|
||||
#undef telldir
|
||||
#endif
|
||||
|
||||
#ifndef dirent
|
||||
#define dirent direct
|
||||
#endif
|
||||
|
||||
#if !defined(d_fileno) && !defined(d_ino)
|
||||
#define d_fileno d_ino
|
||||
#endif
|
||||
|
||||
#ifdef rewinddir
|
||||
#undef rewinddir
|
||||
#define rewinddir(p) seekdir(p,0L)
|
||||
#endif
|
||||
|
||||
extern __MANGLE__ DIR* opendir __PROTO__((const char*));
|
||||
extern __MANGLE__ void closedir __PROTO__((DIR*));
|
||||
extern __MANGLE__ struct dirent* readdir __PROTO__((DIR*));
|
||||
extern __MANGLE__ void seekdir __PROTO__((DIR*, long));
|
||||
extern __MANGLE__ long telldir __PROTO__((DIR*));
|
||||
|
||||
#endif
|
||||
212
cde/programs/dtksh/ksh93/src/lib/libast/dir/getdents.c
Normal file
212
cde/programs/dtksh/ksh93/src/lib/libast/dir/getdents.c
Normal file
@@ -0,0 +1,212 @@
|
||||
/* $XConsortium: getdents.c /main/3 1995/11/01 17:22:56 rswiston $ */
|
||||
/***************************************************************
|
||||
* *
|
||||
* AT&T - PROPRIETARY *
|
||||
* *
|
||||
* THIS IS PROPRIETARY SOURCE CODE LICENSED BY *
|
||||
* AT&T CORP. *
|
||||
* *
|
||||
* Copyright (c) 1995 AT&T Corp. *
|
||||
* All Rights Reserved *
|
||||
* *
|
||||
* This software is licensed by AT&T Corp. *
|
||||
* under the terms and conditions of the license in *
|
||||
* http://www.research.att.com/orgs/ssr/book/reuse *
|
||||
* *
|
||||
* This software was created by the *
|
||||
* Software Engineering Research Department *
|
||||
* AT&T Bell Laboratories *
|
||||
* *
|
||||
* For further information contact *
|
||||
* gsf@research.att.com *
|
||||
* *
|
||||
***************************************************************/
|
||||
|
||||
/* : : generated by proto : : */
|
||||
|
||||
#if !defined(__PROTO__)
|
||||
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
|
||||
#if defined(__cplusplus)
|
||||
#define __MANGLE__ "C"
|
||||
#else
|
||||
#define __MANGLE__
|
||||
#endif
|
||||
#define __STDARG__
|
||||
#define __PROTO__(x) x
|
||||
#define __OTORP__(x)
|
||||
#define __PARAM__(n,o) n
|
||||
#if !defined(__STDC__) && !defined(__cplusplus)
|
||||
#if !defined(c_plusplus)
|
||||
#define const
|
||||
#endif
|
||||
#define signed
|
||||
#define void int
|
||||
#define volatile
|
||||
#define __V_ char
|
||||
#else
|
||||
#define __V_ void
|
||||
#endif
|
||||
#else
|
||||
#define __PROTO__(x) ()
|
||||
#define __OTORP__(x) x
|
||||
#define __PARAM__(n,o) o
|
||||
#define __MANGLE__
|
||||
#define __V_ char
|
||||
#define const
|
||||
#define signed
|
||||
#define void int
|
||||
#define volatile
|
||||
#endif
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
#define __VARARG__ ...
|
||||
#else
|
||||
#define __VARARG__
|
||||
#endif
|
||||
#if defined(__STDARG__)
|
||||
#define __VA_START__(p,a) va_start(p,a)
|
||||
#else
|
||||
#define __VA_START__(p,a) va_start(p)
|
||||
#endif
|
||||
#endif
|
||||
#include "dirlib.h"
|
||||
|
||||
#if _dir_ok || _lib_getdents
|
||||
|
||||
NoN(getdents)
|
||||
|
||||
#else
|
||||
|
||||
/*
|
||||
* getdents
|
||||
*
|
||||
* read directory entries into directory block
|
||||
*
|
||||
* NOTE: directory entries must fit within DIRBLKSIZ boundaries
|
||||
*/
|
||||
|
||||
#ifndef MAXNAMLEN
|
||||
#define MAXNAMLEN 255
|
||||
#endif
|
||||
|
||||
#if _lib_dirread
|
||||
extern __MANGLE__ int dirread __PROTO__((int, char*, int));
|
||||
#endif
|
||||
#if _lib_getdirentries
|
||||
extern __MANGLE__ int getdirentries __PROTO__((int, char*, int, long*));
|
||||
#endif
|
||||
|
||||
ssize_t
|
||||
getdents __PARAM__((int fd, __V_* buf, size_t siz), (fd, buf, siz)) __OTORP__(int fd; __V_* buf; size_t siz;){
|
||||
struct stat st;
|
||||
|
||||
if (siz < DIRBLKSIZ)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return(-1);
|
||||
}
|
||||
if (fstat(fd, &st)) return(-1);
|
||||
if (!S_ISDIR(st.st_mode))
|
||||
{
|
||||
#ifdef ENOTDIR
|
||||
errno = ENOTDIR;
|
||||
#else
|
||||
errno = EBADF;
|
||||
#endif
|
||||
return(-1);
|
||||
}
|
||||
#if _lib_getdirentries
|
||||
{
|
||||
long off;
|
||||
return(getdirentries(fd, buf, siz, &off));
|
||||
}
|
||||
#else
|
||||
#if _lib_dirread
|
||||
{
|
||||
register char* sp; /* system */
|
||||
register struct dirent* up; /* user */
|
||||
char* u;
|
||||
int n;
|
||||
int m;
|
||||
int i;
|
||||
|
||||
m = (siz * 6) / 10;
|
||||
m = roundof(m, 8);
|
||||
sp = (char*)buf + siz - m - 1;
|
||||
if (!(n = dirread(fd, sp, m))) return(0);
|
||||
if (n > 0)
|
||||
{
|
||||
up = (struct dirent*)buf;
|
||||
sp[n] = 0;
|
||||
while (sp < (char*)buf + siz - m + n)
|
||||
{
|
||||
i = 0;
|
||||
while (*sp >= '0' && *sp <= '9')
|
||||
i = 10 * i + *sp++ - '0';
|
||||
while (*sp && *sp != '\t') sp++;
|
||||
if (*sp++)
|
||||
{
|
||||
up->d_fileno = i;
|
||||
u = up->d_name;
|
||||
while ((*u = *sp++) && u < up->d_name + MAXNAMLEN) u++;
|
||||
*u = 0;
|
||||
up->d_reclen = sizeof(struct dirent) - sizeof(up->d_name) + (up->d_namlen = u - up->d_name) + 1;
|
||||
up->d_reclen = roundof(up->d_reclen, 8);
|
||||
up = (struct dirent*)((char*)up + up->d_reclen);
|
||||
}
|
||||
}
|
||||
return((char*)up - (char*)buf);
|
||||
}
|
||||
}
|
||||
#else
|
||||
#if _mem_d_reclen_direct
|
||||
return(read(fd, buf, siz));
|
||||
#else
|
||||
{
|
||||
|
||||
#define MAXREC roundof(sizeof(*up)-sizeof(up->d_name)+sizeof(sp->d_name)+1,8)
|
||||
|
||||
register struct direct* sp; /* system */
|
||||
register struct dirent* up; /* user */
|
||||
register char* s;
|
||||
register char* u;
|
||||
int n;
|
||||
int m;
|
||||
char tmp[sizeof(sp->d_name) + 1];
|
||||
|
||||
/*
|
||||
* we assume sizeof(struct dirent) > sizeof(struct direct)
|
||||
*/
|
||||
|
||||
up = (struct dirent*)buf;
|
||||
n = (siz / MAXREC) * sizeof(struct direct);
|
||||
if ((!(m = n & ~511) || m < MAXREC) && (!(m = n & ~255) || m < MAXREC)) m = n;
|
||||
do
|
||||
{
|
||||
if ((n = read(fd, (char*)buf + siz - m, m)) <= 0) break;
|
||||
sp = (struct direct*)((char*)buf + siz - m);
|
||||
while (sp < (struct direct*)((char*)buf + siz - m + n))
|
||||
{
|
||||
if (sp->d_ino)
|
||||
{
|
||||
up->d_fileno = sp->d_ino;
|
||||
s = sp->d_name;
|
||||
u = tmp;
|
||||
while (s < sp->d_name + sizeof(sp->d_name) && *s)
|
||||
*u++ = *s++;
|
||||
*u = 0;
|
||||
strcpy(up->d_name, tmp);
|
||||
up->d_reclen = sizeof(struct dirent) - sizeof(up->d_name) + (up->d_namlen = u - tmp) + 1;
|
||||
up->d_reclen = roundof(up->d_reclen, 8);
|
||||
up = (struct dirent*)((char*)up + up->d_reclen);
|
||||
}
|
||||
sp++;
|
||||
}
|
||||
} while (up == (struct dirent*)buf);
|
||||
return((char*)up - (char*)buf);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
128
cde/programs/dtksh/ksh93/src/lib/libast/dir/opendir.c
Normal file
128
cde/programs/dtksh/ksh93/src/lib/libast/dir/opendir.c
Normal file
@@ -0,0 +1,128 @@
|
||||
/* $XConsortium: opendir.c /main/3 1995/11/01 17:23:11 rswiston $ */
|
||||
/***************************************************************
|
||||
* *
|
||||
* AT&T - PROPRIETARY *
|
||||
* *
|
||||
* THIS IS PROPRIETARY SOURCE CODE LICENSED BY *
|
||||
* AT&T CORP. *
|
||||
* *
|
||||
* Copyright (c) 1995 AT&T Corp. *
|
||||
* All Rights Reserved *
|
||||
* *
|
||||
* This software is licensed by AT&T Corp. *
|
||||
* under the terms and conditions of the license in *
|
||||
* http://www.research.att.com/orgs/ssr/book/reuse *
|
||||
* *
|
||||
* This software was created by the *
|
||||
* Software Engineering Research Department *
|
||||
* AT&T Bell Laboratories *
|
||||
* *
|
||||
* For further information contact *
|
||||
* gsf@research.att.com *
|
||||
* *
|
||||
***************************************************************/
|
||||
|
||||
/* : : generated by proto : : */
|
||||
|
||||
#if !defined(__PROTO__)
|
||||
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
|
||||
#if defined(__cplusplus)
|
||||
#define __MANGLE__ "C"
|
||||
#else
|
||||
#define __MANGLE__
|
||||
#endif
|
||||
#define __STDARG__
|
||||
#define __PROTO__(x) x
|
||||
#define __OTORP__(x)
|
||||
#define __PARAM__(n,o) n
|
||||
#if !defined(__STDC__) && !defined(__cplusplus)
|
||||
#if !defined(c_plusplus)
|
||||
#define const
|
||||
#endif
|
||||
#define signed
|
||||
#define void int
|
||||
#define volatile
|
||||
#define __V_ char
|
||||
#else
|
||||
#define __V_ void
|
||||
#endif
|
||||
#else
|
||||
#define __PROTO__(x) ()
|
||||
#define __OTORP__(x) x
|
||||
#define __PARAM__(n,o) o
|
||||
#define __MANGLE__
|
||||
#define __V_ char
|
||||
#define const
|
||||
#define signed
|
||||
#define void int
|
||||
#define volatile
|
||||
#endif
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
#define __VARARG__ ...
|
||||
#else
|
||||
#define __VARARG__
|
||||
#endif
|
||||
#if defined(__STDARG__)
|
||||
#define __VA_START__(p,a) va_start(p,a)
|
||||
#else
|
||||
#define __VA_START__(p,a) va_start(p)
|
||||
#endif
|
||||
#endif
|
||||
#include "dirlib.h"
|
||||
|
||||
#if _dir_ok
|
||||
|
||||
NoN(opendir)
|
||||
|
||||
#else
|
||||
|
||||
static const char id_dir[] = "\n@(#)directory (AT&T Bell Laboratories) 04/01/93\0\n";
|
||||
|
||||
static DIR* freedirp; /* always keep one dirp */
|
||||
|
||||
DIR*
|
||||
opendir __PARAM__((register const char* path), (path)) __OTORP__(register const char* path;){
|
||||
register DIR* dirp = 0;
|
||||
register int fd;
|
||||
struct stat st;
|
||||
|
||||
if ((fd = open(path, 0)) < 0) return(0);
|
||||
if (fstat(fd, &st) < 0 ||
|
||||
!S_ISDIR(st.st_mode) && (errno = ENOTDIR) ||
|
||||
fcntl(fd, F_SETFD, FD_CLOEXEC) ||
|
||||
!(dirp = freedirp ? freedirp :
|
||||
#if defined(_DIR_PRIVATE) || _ptr_dd_buf
|
||||
newof(0, DIR, 1, DIRBLKSIZ)
|
||||
#else
|
||||
newof(0, DIR, 1, 0)
|
||||
#endif
|
||||
))
|
||||
{
|
||||
close(fd);
|
||||
if (dirp)
|
||||
{
|
||||
if (!freedirp) freedirp = dirp;
|
||||
else free(dirp);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
freedirp = 0;
|
||||
dirp->dd_fd = fd;
|
||||
dirp->dd_loc = dirp->dd_size = 0; /* refill needed */
|
||||
#if defined(_DIR_PRIVATE) || _ptr_dd_buf
|
||||
dirp->dd_buf = (__V_*)((char*)dirp + sizeof(DIR));
|
||||
#endif
|
||||
return(dirp);
|
||||
}
|
||||
|
||||
void
|
||||
closedir __PARAM__((register DIR* dirp), (dirp)) __OTORP__(register DIR* dirp;){
|
||||
if (dirp)
|
||||
{
|
||||
close(dirp->dd_fd);
|
||||
if (!freedirp) freedirp = dirp;
|
||||
else free(dirp);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
100
cde/programs/dtksh/ksh93/src/lib/libast/dir/readdir.c
Normal file
100
cde/programs/dtksh/ksh93/src/lib/libast/dir/readdir.c
Normal file
@@ -0,0 +1,100 @@
|
||||
/* $XConsortium: readdir.c /main/3 1995/11/01 17:23:29 rswiston $ */
|
||||
/***************************************************************
|
||||
* *
|
||||
* AT&T - PROPRIETARY *
|
||||
* *
|
||||
* THIS IS PROPRIETARY SOURCE CODE LICENSED BY *
|
||||
* AT&T CORP. *
|
||||
* *
|
||||
* Copyright (c) 1995 AT&T Corp. *
|
||||
* All Rights Reserved *
|
||||
* *
|
||||
* This software is licensed by AT&T Corp. *
|
||||
* under the terms and conditions of the license in *
|
||||
* http://www.research.att.com/orgs/ssr/book/reuse *
|
||||
* *
|
||||
* This software was created by the *
|
||||
* Software Engineering Research Department *
|
||||
* AT&T Bell Laboratories *
|
||||
* *
|
||||
* For further information contact *
|
||||
* gsf@research.att.com *
|
||||
* *
|
||||
***************************************************************/
|
||||
|
||||
/* : : generated by proto : : */
|
||||
|
||||
#if !defined(__PROTO__)
|
||||
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
|
||||
#if defined(__cplusplus)
|
||||
#define __MANGLE__ "C"
|
||||
#else
|
||||
#define __MANGLE__
|
||||
#endif
|
||||
#define __STDARG__
|
||||
#define __PROTO__(x) x
|
||||
#define __OTORP__(x)
|
||||
#define __PARAM__(n,o) n
|
||||
#if !defined(__STDC__) && !defined(__cplusplus)
|
||||
#if !defined(c_plusplus)
|
||||
#define const
|
||||
#endif
|
||||
#define signed
|
||||
#define void int
|
||||
#define volatile
|
||||
#define __V_ char
|
||||
#else
|
||||
#define __V_ void
|
||||
#endif
|
||||
#else
|
||||
#define __PROTO__(x) ()
|
||||
#define __OTORP__(x) x
|
||||
#define __PARAM__(n,o) o
|
||||
#define __MANGLE__
|
||||
#define __V_ char
|
||||
#define const
|
||||
#define signed
|
||||
#define void int
|
||||
#define volatile
|
||||
#endif
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
#define __VARARG__ ...
|
||||
#else
|
||||
#define __VARARG__
|
||||
#endif
|
||||
#if defined(__STDARG__)
|
||||
#define __VA_START__(p,a) va_start(p,a)
|
||||
#else
|
||||
#define __VA_START__(p,a) va_start(p)
|
||||
#endif
|
||||
#endif
|
||||
#include "dirlib.h"
|
||||
|
||||
#if _dir_ok
|
||||
|
||||
NoN(readdir)
|
||||
|
||||
#else
|
||||
|
||||
struct dirent*
|
||||
readdir __PARAM__((register DIR* dirp), (dirp)) __OTORP__(register DIR* dirp;){
|
||||
register struct dirent* dp;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (dirp->dd_loc >= dirp->dd_size)
|
||||
{
|
||||
if (dirp->dd_size < 0) return(0);
|
||||
dirp->dd_loc = 0;
|
||||
if ((dirp->dd_size = getdents(dirp->dd_fd, dirp->dd_buf, DIRBLKSIZ)) <= 0)
|
||||
return(0);
|
||||
}
|
||||
dp = (struct dirent*)&dirp->dd_buf[dirp->dd_loc];
|
||||
if (dp->d_reclen <= 0) return(0);
|
||||
dirp->dd_loc += dp->d_reclen;
|
||||
if (dp->d_fileno) return(dp);
|
||||
}
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
#endif
|
||||
86
cde/programs/dtksh/ksh93/src/lib/libast/dir/rewinddir.c
Normal file
86
cde/programs/dtksh/ksh93/src/lib/libast/dir/rewinddir.c
Normal file
@@ -0,0 +1,86 @@
|
||||
/* $XConsortium: rewinddir.c /main/3 1995/11/01 17:23:42 rswiston $ */
|
||||
/***************************************************************
|
||||
* *
|
||||
* AT&T - PROPRIETARY *
|
||||
* *
|
||||
* THIS IS PROPRIETARY SOURCE CODE LICENSED BY *
|
||||
* AT&T CORP. *
|
||||
* *
|
||||
* Copyright (c) 1995 AT&T Corp. *
|
||||
* All Rights Reserved *
|
||||
* *
|
||||
* This software is licensed by AT&T Corp. *
|
||||
* under the terms and conditions of the license in *
|
||||
* http://www.research.att.com/orgs/ssr/book/reuse *
|
||||
* *
|
||||
* This software was created by the *
|
||||
* Software Engineering Research Department *
|
||||
* AT&T Bell Laboratories *
|
||||
* *
|
||||
* For further information contact *
|
||||
* gsf@research.att.com *
|
||||
* *
|
||||
***************************************************************/
|
||||
|
||||
/* : : generated by proto : : */
|
||||
|
||||
#if !defined(__PROTO__)
|
||||
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
|
||||
#if defined(__cplusplus)
|
||||
#define __MANGLE__ "C"
|
||||
#else
|
||||
#define __MANGLE__
|
||||
#endif
|
||||
#define __STDARG__
|
||||
#define __PROTO__(x) x
|
||||
#define __OTORP__(x)
|
||||
#define __PARAM__(n,o) n
|
||||
#if !defined(__STDC__) && !defined(__cplusplus)
|
||||
#if !defined(c_plusplus)
|
||||
#define const
|
||||
#endif
|
||||
#define signed
|
||||
#define void int
|
||||
#define volatile
|
||||
#define __V_ char
|
||||
#else
|
||||
#define __V_ void
|
||||
#endif
|
||||
#else
|
||||
#define __PROTO__(x) ()
|
||||
#define __OTORP__(x) x
|
||||
#define __PARAM__(n,o) o
|
||||
#define __MANGLE__
|
||||
#define __V_ char
|
||||
#define const
|
||||
#define signed
|
||||
#define void int
|
||||
#define volatile
|
||||
#endif
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
#define __VARARG__ ...
|
||||
#else
|
||||
#define __VARARG__
|
||||
#endif
|
||||
#if defined(__STDARG__)
|
||||
#define __VA_START__(p,a) va_start(p,a)
|
||||
#else
|
||||
#define __VA_START__(p,a) va_start(p)
|
||||
#endif
|
||||
#endif
|
||||
#include "dirlib.h"
|
||||
|
||||
#if _dir_ok && ( defined(rewinddir) || _lib_rewinddir )
|
||||
|
||||
NoN(rewinddir)
|
||||
|
||||
#else
|
||||
|
||||
#undef rewinddir
|
||||
|
||||
void
|
||||
rewinddir __PARAM__((DIR* dirp), (dirp)) __OTORP__(DIR* dirp;){
|
||||
seekdir(dirp, 0L);
|
||||
}
|
||||
|
||||
#endif
|
||||
94
cde/programs/dtksh/ksh93/src/lib/libast/dir/seekdir.c
Normal file
94
cde/programs/dtksh/ksh93/src/lib/libast/dir/seekdir.c
Normal file
@@ -0,0 +1,94 @@
|
||||
/* $XConsortium: seekdir.c /main/3 1995/11/01 17:23:59 rswiston $ */
|
||||
/***************************************************************
|
||||
* *
|
||||
* AT&T - PROPRIETARY *
|
||||
* *
|
||||
* THIS IS PROPRIETARY SOURCE CODE LICENSED BY *
|
||||
* AT&T CORP. *
|
||||
* *
|
||||
* Copyright (c) 1995 AT&T Corp. *
|
||||
* All Rights Reserved *
|
||||
* *
|
||||
* This software is licensed by AT&T Corp. *
|
||||
* under the terms and conditions of the license in *
|
||||
* http://www.research.att.com/orgs/ssr/book/reuse *
|
||||
* *
|
||||
* This software was created by the *
|
||||
* Software Engineering Research Department *
|
||||
* AT&T Bell Laboratories *
|
||||
* *
|
||||
* For further information contact *
|
||||
* gsf@research.att.com *
|
||||
* *
|
||||
***************************************************************/
|
||||
|
||||
/* : : generated by proto : : */
|
||||
|
||||
#if !defined(__PROTO__)
|
||||
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
|
||||
#if defined(__cplusplus)
|
||||
#define __MANGLE__ "C"
|
||||
#else
|
||||
#define __MANGLE__
|
||||
#endif
|
||||
#define __STDARG__
|
||||
#define __PROTO__(x) x
|
||||
#define __OTORP__(x)
|
||||
#define __PARAM__(n,o) n
|
||||
#if !defined(__STDC__) && !defined(__cplusplus)
|
||||
#if !defined(c_plusplus)
|
||||
#define const
|
||||
#endif
|
||||
#define signed
|
||||
#define void int
|
||||
#define volatile
|
||||
#define __V_ char
|
||||
#else
|
||||
#define __V_ void
|
||||
#endif
|
||||
#else
|
||||
#define __PROTO__(x) ()
|
||||
#define __OTORP__(x) x
|
||||
#define __PARAM__(n,o) o
|
||||
#define __MANGLE__
|
||||
#define __V_ char
|
||||
#define const
|
||||
#define signed
|
||||
#define void int
|
||||
#define volatile
|
||||
#endif
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
#define __VARARG__ ...
|
||||
#else
|
||||
#define __VARARG__
|
||||
#endif
|
||||
#if defined(__STDARG__)
|
||||
#define __VA_START__(p,a) va_start(p,a)
|
||||
#else
|
||||
#define __VA_START__(p,a) va_start(p)
|
||||
#endif
|
||||
#endif
|
||||
#include "dirlib.h"
|
||||
|
||||
#if _dir_ok
|
||||
|
||||
NoN(seekdir)
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
seekdir __PARAM__((register DIR* dirp, long loc), (dirp, loc)) __OTORP__(register DIR* dirp; long loc;){
|
||||
off_t base; /* file location of block */
|
||||
off_t offset; /* offset within block */
|
||||
|
||||
if (telldir(dirp) != loc)
|
||||
{
|
||||
lseek(dirp->dd_fd, 0L, SEEK_SET);
|
||||
dirp->dd_loc = dirp->dd_size = 0;
|
||||
while (telldir(dirp) != loc)
|
||||
if (!readdir(dirp))
|
||||
break; /* "can't happen" */
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
84
cde/programs/dtksh/ksh93/src/lib/libast/dir/telldir.c
Normal file
84
cde/programs/dtksh/ksh93/src/lib/libast/dir/telldir.c
Normal file
@@ -0,0 +1,84 @@
|
||||
/* $XConsortium: telldir.c /main/3 1995/11/01 17:24:14 rswiston $ */
|
||||
/***************************************************************
|
||||
* *
|
||||
* AT&T - PROPRIETARY *
|
||||
* *
|
||||
* THIS IS PROPRIETARY SOURCE CODE LICENSED BY *
|
||||
* AT&T CORP. *
|
||||
* *
|
||||
* Copyright (c) 1995 AT&T Corp. *
|
||||
* All Rights Reserved *
|
||||
* *
|
||||
* This software is licensed by AT&T Corp. *
|
||||
* under the terms and conditions of the license in *
|
||||
* http://www.research.att.com/orgs/ssr/book/reuse *
|
||||
* *
|
||||
* This software was created by the *
|
||||
* Software Engineering Research Department *
|
||||
* AT&T Bell Laboratories *
|
||||
* *
|
||||
* For further information contact *
|
||||
* gsf@research.att.com *
|
||||
* *
|
||||
***************************************************************/
|
||||
|
||||
/* : : generated by proto : : */
|
||||
|
||||
#if !defined(__PROTO__)
|
||||
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
|
||||
#if defined(__cplusplus)
|
||||
#define __MANGLE__ "C"
|
||||
#else
|
||||
#define __MANGLE__
|
||||
#endif
|
||||
#define __STDARG__
|
||||
#define __PROTO__(x) x
|
||||
#define __OTORP__(x)
|
||||
#define __PARAM__(n,o) n
|
||||
#if !defined(__STDC__) && !defined(__cplusplus)
|
||||
#if !defined(c_plusplus)
|
||||
#define const
|
||||
#endif
|
||||
#define signed
|
||||
#define void int
|
||||
#define volatile
|
||||
#define __V_ char
|
||||
#else
|
||||
#define __V_ void
|
||||
#endif
|
||||
#else
|
||||
#define __PROTO__(x) ()
|
||||
#define __OTORP__(x) x
|
||||
#define __PARAM__(n,o) o
|
||||
#define __MANGLE__
|
||||
#define __V_ char
|
||||
#define const
|
||||
#define signed
|
||||
#define void int
|
||||
#define volatile
|
||||
#endif
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
#define __VARARG__ ...
|
||||
#else
|
||||
#define __VARARG__
|
||||
#endif
|
||||
#if defined(__STDARG__)
|
||||
#define __VA_START__(p,a) va_start(p,a)
|
||||
#else
|
||||
#define __VA_START__(p,a) va_start(p)
|
||||
#endif
|
||||
#endif
|
||||
#include "dirlib.h"
|
||||
|
||||
#if _dir_ok
|
||||
|
||||
NoN(telldir)
|
||||
|
||||
#else
|
||||
|
||||
long
|
||||
telldir __PARAM__((DIR* dirp), (dirp)) __OTORP__(DIR* dirp;){
|
||||
return(lseek(dirp->dd_fd, 0L, SEEK_CUR) + (long)dirp->dd_loc);
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user