5
* Copyright 1989 Software Research Associates, Inc., Tokyo, Japan
7
* Permission to use, copy, modify, and distribute this software and its
8
* documentation for any purpose and without fee is hereby granted, provided
9
* that the above copyright notice appear in all copies and that both that
10
* copyright notice and this permission notice appear in supporting
11
* documentation, and that the name of Software Research Associates not be used
12
* in advertising or publicity pertaining to distribution of the software
13
* without specific, written prior permission. Software Research Associates
14
* makes no representations about the suitability of this software for any
15
* purpose. It is provided "as is" without express or implied warranty.
17
* SOFTWARE RESEARCH ASSOCIATES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
18
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
19
* IN NO EVENT SHALL SOFTWARE RESEARCH ASSOCIATES BE LIABLE FOR ANY SPECIAL,
20
* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
21
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
22
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
23
* PERFORMANCE OF THIS SOFTWARE.
25
* Author: Erik M. van der Poel
26
* Software Research Associates, Inc., Tokyo, Japan
34
#ifdef SEL_FILE_IGNORE_CASE
36
#endif /* def SEL_FILE_IGNORE_CASE */
38
#include "SFinternal.h"
44
# define dirent direct
46
# include <sys/ndir.h>
56
#if defined(SVR4) || defined(SYSV) || defined(USG) || defined(__osf__) || defined (__svr4__) || defined (__FreeBSD__) || defined(SCO)
58
#else /* defined(SVR4) || defined(SYSV) || defined(USG) */
61
#endif /* defined(SVR4) || defined(SYSV) || defined(USG) */
66
#if defined(SVR4) || defined(SYSV) || defined(USG)
68
#endif /* defined(SVR4) || defined(SYSV) || defined(USG) */
70
#ifdef SEL_FILE_IGNORE_CASE
72
SFcompareEntries(const void *vp, const void *vq) {
73
SFEntry *p = (SFEntry *) vp, *q = (SFEntry *) vq;
91
return strcmp(p->real, q->real);
105
#else /* def SEL_FILE_IGNORE_CASE */
107
SFcompareEntries(const void *vp, const void *vq) {
108
SFEntry *p = (SFEntry *) vp, *q = (SFEntry *) vq;
109
return strcmp(p->real, q->real);
111
#endif /* def SEL_FILE_IGNORE_CASE */
117
SFEntry *result = NULL;
127
maxChars = strlen(dir->dir) - 1;
141
(void) stat(".", &statBuf);
142
dir->mtime = statBuf.st_mtime;
144
(void) readdir(dirp); /* throw away "." */
147
(void) readdir(dirp); /* throw away ".." */
148
#endif /* ndef S_IFLNK */
150
while (dp = readdir(dirp)) {
152
alloc = 2 * (alloc + 1);
153
result = (SFEntry *) XtRealloc((char *) result,
154
(unsigned) (alloc * sizeof(SFEntry)));
156
result[i].statDone = 0;
159
result[i].real = XtMalloc((unsigned) (len + 2));
160
(void) strcat(strcpy(result[i].real, str), " ");
161
if (len > maxChars) {
164
result[i].shown = result[i].real;
168
#if defined(SVR4) || defined(SYSV) || defined(USG)
169
qsort((char *) result, (unsigned) i, sizeof(SFEntry), SFcompareEntries);
170
#else /* defined(SVR4) || defined(SYSV) || defined(USG) */
171
qsort((char *) result, i, sizeof(SFEntry), SFcompareEntries);
172
#endif /* defined(SVR4) || defined(SYSV) || defined(USG) */
174
dir->entries = result;
176
dir->nChars = maxChars + 1;