2 * Copyright 1989 Software Research Associates, Inc., Tokyo, Japan
4 * Permission to use, copy, modify, and distribute this software and its
5 * documentation for any purpose and without fee is hereby granted, provided
6 * that the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of Software Research Associates not be used
9 * in advertising or publicity pertaining to distribution of the software
10 * without specific, written prior permission. Software Research Associates
11 * makes no representations about the suitability of this software for any
12 * purpose. It is provided "as is" without express or implied warranty.
14 * SOFTWARE RESEARCH ASSOCIATES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
15 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
16 * IN NO EVENT SHALL SOFTWARE RESEARCH ASSOCIATES BE LIABLE FOR ANY SPECIAL,
17 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
18 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
19 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THIS SOFTWARE.
22 * Author: Erik M. van der Poel
23 * Software Research Associates, Inc., Tokyo, Japan
29 #ifdef SEL_FILE_IGNORE_CASE
31 #endif /* def SEL_FILE_IGNORE_CASE */
35 #if defined(SVR4) || defined(SYSV) || defined(USG) || defined(__osf__)
37 #else /* defined(SVR4) || defined(SYSV) || defined(USG) */
40 #endif /* defined(SVR4) || defined(SYSV) || defined(USG) */
44 #if defined(SVR4) || defined(SYSV) || defined(USG)
46 #endif /* defined(SVR4) || defined(SYSV) || defined(USG) */
48 #ifdef SEL_FILE_IGNORE_CASE
50 SFcompareEntries(p, q)
71 return strcmp(p->real, q->real);
85 #else /* def SEL_FILE_IGNORE_CASE */
87 SFcompareEntries(p, q)
91 return strcmp(p->real, q->real);
93 #endif /* def SEL_FILE_IGNORE_CASE */
99 SFEntry *result = NULL;
109 maxChars = strlen(dir->dir) - 1;
123 (void) stat(".", &statBuf);
124 dir->mtime = statBuf.st_mtime;
126 (void) readdir(dirp); /* throw away "." */
129 (void) readdir(dirp); /* throw away ".." */
130 #endif /* ndef S_IFLNK */
132 while (dp = readdir(dirp)) {
134 alloc = 2 * (alloc + 1);
135 result = (SFEntry *) XtRealloc((char *) result,
136 (unsigned) (alloc * sizeof(SFEntry)));
138 result[i].statDone = 0;
141 result[i].real = XtMalloc((unsigned) (len + 2));
142 (void) strcat(strcpy(result[i].real, str), " ");
143 if (len > maxChars) {
146 result[i].shown = result[i].real;
150 #if defined(SVR4) || defined(SYSV) || defined(USG)
151 qsort((char *) result, (unsigned) i, sizeof(SFEntry), SFcompareEntries);
152 #else /* defined(SVR4) || defined(SYSV) || defined(USG) */
153 qsort((char *) result, i, sizeof(SFEntry), SFcompareEntries);
154 #endif /* defined(SVR4) || defined(SYSV) || defined(USG) */
156 dir->entries = result;
158 dir->nChars = maxChars + 1;