w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

glob.c
Go to the documentation of this file.
1 /* MS-DOS GLOB (3C) FUNCTION
2  *
3  * MS-DOS GLOB FUNCTION - Copyright (c) 1990,4 Data Logic Limited.
4  *
5  * This code is subject to the following copyright restrictions:
6  *
7  * 1. Redistribution and use in source and binary forms are permitted
8  * provided that the above copyright notice is duplicated in the
9  * source form.
10  *
11  * $Header: /usr/users/istewart/shell/sh2.3/Release/RCS/glob.c,v 2.3 1994/08/25 20:49:11 istewart Exp $
12  *
13  * $Log: glob.c,v $
14  * Revision 2.3 1994/08/25 20:49:11 istewart
15  * MS Shell 2.3 Release
16  *
17  * Revision 2.2 1994/02/01 10:25:20 istewart
18  * Release 2.3 Beta 2, including first NT port
19  *
20  * Revision 2.1 1993/06/14 10:59:32 istewart
21  * More changes for 223 beta
22  *
23  * Revision 2.0 1992/04/13 17:39:09 Ian_Stewartson
24  * MS-Shell 2.0 Baseline release
25  *
26  */
27 
28 #include "config.h"
29 #include <sys/types.h> /* MS-DOS type definitions */
30 #include <sys/stat.h> /* File status definitions */
31 #include <stdio.h> /* Standard I/O delarations */
32 #include <stdlib.h> /* Standard library functions */
33 #include <string.h> /* String library functions */
34 #include <limits.h> /* String library functions */
35 #include <dirent.h> /* Direction I/O functions */
36 #include <ctype.h> /* Character types function */
37 #include <unistd.h> /* Other functions */
38 
39 
40 #ifdef __TURBOC__
41 # include <alloc.h> /* Malloc functions */
42 # include <dir.h> /* Dos directory functions */
43 #else
44 # include <malloc.h> /* Malloc functions */
45 #endif
46 
47 #include <glob.h>
48 
49 #if defined (MSDOS) || defined (__OS2__) || defined (__TURBOC__) || defined (WIN32)
50 # if defined (OS2) || defined (__OS2__)
51 
52 # define INCL_DOSDEVICES
53 # define INCL_DOSMISC
54 # include <os2.h> /* OS2 functions declarations */
55 
56 # if defined (__OS2__)
57 # define DISABLE_HARD_ERRORS DosError (FERR_DISABLEHARDERR)
58 # define ENABLE_HARD_ERRORS DosError (FERR_ENABLEHARDERR)
59 # else
60 # define DISABLE_HARD_ERRORS DosError (HARDERROR_DISABLE)
61 # define ENABLE_HARD_ERRORS DosError (HARDERROR_ENABLE)
62 # endif
63 
64 # elif defined (WIN32)
65 # include <windows.h>
66 # define DISABLE_HARD_ERRORS SetErrorMode (0)
67 # define ENABLE_HARD_ERRORS SetErrorMode (SEM_FAILCRITICALERRORS | \
68  SEM_NOOPENFILEERRORBOX);
69 
70 # else
71 # include <bios.h> /* DOS BIOS functions */
72 # include <dos.h> /* DOS functions */
73 # define DISABLE_HARD_ERRORS
74 # define ENABLE_HARD_ERRORS
75 # endif
76 #endif
77 
78 /*
79  * OS/2 2.x has these missing
80  */
81 
82 #ifndef S_IFMT
83 # define S_IFMT 0xf000 /* type of file */
84 #endif
85 
86 #ifndef S_ISDIR
87 # define S_ISDIR(m) ((((m) & S_IFMT) == S_IFDIR))
88 #endif
89 
90 /*
91  * Functions
92  */
93 
94 static int _GP_SortCompare _PROTO ((char **, char **));
95 static int _GP_ExpandField _PROTO ((char *, char *, glob_t *));
96 static int _GP_ExpandMetaCharacters _PROTO ((char *, glob_t *));
97 static int _GP_AddArgument _PROTO ((char *, glob_t *));
98 static bool _GP_MatchPattern _PROTO ((char *, char *));
99 static bool _GP_access _PROTO ((char *, int));
100 static bool _GP_stat _PROTO ((char *, struct stat *));
101 
102 static char *_GP_MetaChars = "?*[\\";
103 static char *_GP_NullString = "";
104 
105 #if defined (MSDOS) || defined (__OS2__) || defined (__TURBOC__) || defined (WIN32)
106 static int _GP_GetNumberofFloppyDrives (void);
107 
108 # if defined (OS2) || defined (__OS2__) || defined (__TURBOC__) || defined (WIN32)
109 static void _dos_setdrive (unsigned int, unsigned int *);
110 static void _dos_getdrive (unsigned int *);
111 # endif
112 
113 static char *_GP_CheckForMultipleDrives _PROTO ((char *));
114 #endif
115 
116 /*
117  * There appears to be no alloca in TurboC
118  */
119 
120 #ifdef __TURBOC__
121 # define alloca(x) malloc (x)
122 # define alloca_free(x) free (x)
123 #else
124 # define alloca_free(x)
125 #endif
126 
127 /*
128  * Free up space
129  */
130 
131 void globfree (gp)
132 glob_t *gp;
133 {
134  int i = (gp->gl_flags & GLOB_DOOFFS) ? gp->gl_offs : 0;
135 
136  while (i < gp->gl_pathc)
137  free (gp->gl_pathv[i++]);
138 
139  free (gp->gl_pathv);
140 }
141 
142 /* Main search function */
143 
144 int glob (Pattern, flags, ErrorFunction, gp)
145 char *Pattern;
146 int flags;
147 int (*ErrorFunction) _PROTO ((char *, int));
148 glob_t *gp;
149 {
150  int ReturnValue;
151  char *PatternCopy;
152  char *cp;
153 
154 /* If no append mode - initialise */
155 
156  if (!(flags & GLOB_APPEND))
157  {
158  gp->gl_pathc = 0;
159  gp->gl_pathv = (char **)NULL;
160  }
161 
162  gp->gl_flags = flags;
163  gp->gl_ef = ErrorFunction;
164 
165  if ((PatternCopy = alloca (strlen (Pattern) + 1)) == (char *)NULL)
166  return GLOB_NOSPACE;
167 
168 /* Expand and kill environment */
169 
170  if (ReturnValue = _GP_ExpandMetaCharacters (strcpy (PatternCopy, Pattern),
171  gp))
172  {
174  return ReturnValue;
175  }
176 
177 /* Check for no finds. If add value, strip out \ from the string */
178 
179  if ((gp->gl_pathc == 0) && (flags & GLOB_NOCHECK))
180  {
182 
183  while ((cp = strpbrk (cp, "?*[")) != (char *)NULL)
184  {
185  if ((cp == PatternCopy) || (*(cp - 1) != '\\'))
186  cp++;
187 
188  else
189  memmove (cp - 1, cp, strlen (cp) + 1);
190  }
191 
192  if (ReturnValue = _GP_AddArgument (PatternCopy, gp))
193  {
195  return ReturnValue;
196  }
197  }
198 
199 /* Terminate string */
200 
201  if ((gp->gl_pathc != 0) &&
202  (ReturnValue = _GP_AddArgument ((char *)NULL, gp)))
203  {
205  return ReturnValue;
206  }
207 
208 /* Get the sort length */
209 
210  ReturnValue = (gp->gl_flags & GLOB_DOOFFS) ? gp->gl_offs : 0;
211 
212  if ((!(flags & GLOB_NOSORT)) && (gp->gl_pathc > 1))
213  qsort (&gp->gl_pathv[ReturnValue], gp->gl_pathc, sizeof (char *),
214  (int (*) (const void *, const void *)) _GP_SortCompare);
215 
217  return 0;
218 }
219 
220 /* Compare function for sort */
221 
222 static int _GP_SortCompare (a1, a2)
223 char **a1, **a2;
224 {
225  return strcmp (*a1, *a2);
226 }
227 
228 /* Expand a field if it has metacharacters in it */
229 
230 static int _GP_ExpandField (CurrentDirectoryPattern, AppendString, gp)
231 char *CurrentDirectoryPattern; /* Prefix field */
232 char *AppendString; /* Postfix field */
233 glob_t *gp;
234 {
235  int i;
236  int ReturnValue = 0; /* Return Value */
237  char *FullFileName; /* Search file name */
238  char *FileNameStart;
239  char *MatchString; /* Match string */
240  DIR *DirHandler;
241  struct dirent *CurrentDirectoryEntry;
242 
243 #if defined (MSDOS) || defined (__OS2__) || defined (__TURBOC__) || defined (WIN32)
244  unsigned int CurrentDrive; /* Current drive */
245  unsigned int MaxDrives; /* Max drive */
246  unsigned int SelectedDrive; /* Selected drive */
247  unsigned int x_drive, y_drive; /* Dummies */
248  char *DriveCharacter; /* Multi-drive flag */
249  char SDriveString[2];
250 
251 /* Convert file name to lower case */
252 
253 # if defined (OS2) || defined (__OS2__) || (WIN32)
254  if (!IsHPFSFileSystem (CurrentDirectoryPattern))
255  strlwr (CurrentDirectoryPattern);
256 # else
257  strlwr (CurrentDirectoryPattern);
258 # endif
259 
260 /* Search all drives ? */
261 
262  if ((DriveCharacter = _GP_CheckForMultipleDrives (CurrentDirectoryPattern))
263  != (char *)NULL)
264  {
265  _dos_getdrive (&CurrentDrive); /* Get number of drives */
266  _dos_setdrive (CurrentDrive, &MaxDrives);
267  SDriveString[1] = 0;
268 
269  for (SelectedDrive = 1; SelectedDrive <= MaxDrives; ++SelectedDrive)
270  {
271  _dos_setdrive (SelectedDrive, &x_drive);
272  _dos_getdrive (&y_drive);
273  _dos_setdrive (CurrentDrive, &x_drive);
274 
275 /* Check to see if the second diskette drive is really there */
276 
277  if ((_GP_GetNumberofFloppyDrives () < 2) && (SelectedDrive == 2))
278  continue;
279 
280 /* If the drive exists and is in our list - process it */
281 
282  *DriveCharacter = 0;
283  *SDriveString = (char)(SelectedDrive + 'a' - 1);
284  strlwr (CurrentDirectoryPattern);
285 
286  if ((y_drive == SelectedDrive) &&
287  _GP_MatchPattern (SDriveString, CurrentDirectoryPattern))
288  {
289  if ((FullFileName = alloca (strlen (DriveCharacter) + 3))
290  == (char *)NULL)
291  return GLOB_NOSPACE;
292 
293  *DriveCharacter = ':';
294  *FullFileName = *SDriveString;
295  strcpy (FullFileName + 1, DriveCharacter);
296 
297  i = _GP_ExpandField (FullFileName, AppendString, gp);
298  alloca_free (FullFileName);
299 
300  if (i)
301  return i;
302  }
303 
304  *DriveCharacter = ':';
305  }
306 
307  return 0;
308  }
309 #endif
310 
311 /* Get the path length */
312 
313  MatchString = strrchr (CurrentDirectoryPattern, '/');
314 
315 #if defined (MSDOS) || defined (__OS2__) || defined (__TURBOC__) || defined (WIN32)
316  if ((MatchString == (char *)NULL) &&
317  (*(CurrentDirectoryPattern + 1) == ':'))
318  MatchString = CurrentDirectoryPattern + 1;
319 #endif
320 
321 /* Set up file name for search */
322 
323  if ((MatchString == (char *)NULL) || (*MatchString == ':'))
324  {
325  if ((FullFileName = alloca (NAME_MAX + 7 +
326  strlen (AppendString))) == (char *)NULL)
327  return GLOB_NOSPACE;
328 
329  if (MatchString != (char *)NULL)
330  *(strcpy (FullFileName, "x:.")) = *CurrentDirectoryPattern;
331 
332  else
333  strcpy (FullFileName, ".");
334 
335  FileNameStart = FullFileName +
336  (int)((MatchString != (char *)NULL) ? 2 : 0);
337  }
338 
339 /* Case of /<directory>/... */
340 
341  else if ((FullFileName = alloca (NAME_MAX + 4 + strlen (AppendString) +
342  (i = (int)(MatchString - CurrentDirectoryPattern))))
343  == (char *)NULL)
344  return GLOB_NOSPACE;
345 
346  else
347  {
348  strncpy (FullFileName, CurrentDirectoryPattern, i);
349  *((FileNameStart = FullFileName + i)) = 0;
350  strcpy (FileNameStart++, "/");
351  }
352 
353  MatchString = (MatchString == (char *)NULL) ? CurrentDirectoryPattern
354  : MatchString + 1;
355 
356 /* Search for file names */
357 
358  if ((DirHandler = opendir (FullFileName)) == (DIR *)NULL)
359  {
360  i = 0;
361 
362  if (((gp->gl_ef != NULL) && (*gp->gl_ef)(FullFileName, errno)) ||
363  (gp->gl_flags & GLOB_ERR))
364  i = GLOB_ABEND;
365 
366  alloca_free (FullFileName);
367  return i;
368  }
369 
370 /* Are there any matches */
371 
372  while ((CurrentDirectoryEntry = readdir (DirHandler)) !=
373  (struct dirent *)NULL)
374  {
375  if ((*CurrentDirectoryEntry->d_name == '.') && (*MatchString != '.'))
376  continue;
377 
378 /* Check for match */
379 
380  if (_GP_MatchPattern (CurrentDirectoryEntry->d_name, MatchString))
381  {
382  strcpy (FileNameStart, CurrentDirectoryEntry->d_name);
383 
384 /* If the postfix is not null, this must be a directory */
385 
386  if (strlen (AppendString))
387  {
388  struct stat statb;
389  char *p;
390 
391 /* If not a directory - go to the next file */
392 
393  if (!_GP_stat (FullFileName, &statb) ||
394  !S_ISDIR (statb.st_mode & S_IFMT))
395  continue;
396 
397 /* Are there any metacharacters in the postfix? */
398 
399  if ((p = strpbrk (AppendString, _GP_MetaChars)) == (char *)NULL)
400  {
401 
402 /* No - build the file name and check it exists */
403 
404  strcat (strcat (FileNameStart, "/"), AppendString);
405 
406  if (_GP_access (FullFileName, F_OK) &&
407  (ReturnValue = _GP_AddArgument (FullFileName, gp)))
408  break;
409  }
410 
411 /* Yes - build the filename upto the start of the meta characters */
412 
413  else
414  {
415  if ((p = strchr (p, '/')) != (char *)NULL)
416  *(p++) = 0;
417 
418  else
419  p = _GP_NullString;
420 
421 /* Build the new directory name and check it out */
422 
423  strcat (strcat (FileNameStart, "/"), AppendString);
424  ReturnValue = _GP_ExpandField (FullFileName, p, gp);
425 
426  if (p != _GP_NullString)
427  *(--p) = '/';
428 
429 /* Check for errors */
430 
431  if (ReturnValue)
432  break;
433  }
434  }
435 
436 /* Process this file. If error - terminate */
437 
438  else if (_GP_access (FullFileName, F_OK) &&
439  (ReturnValue = _GP_AddArgument (FullFileName, gp)))
440  break;
441  }
442  }
443 
444  closedir (DirHandler);
445  alloca_free (FullFileName);
446  return ReturnValue;
447 }
448 
449 /* Find the location of meta-characters. If no meta, add the argument and
450  * return. If meta characters, expand directory containing meta characters.
451  */
452 
454 char *file;
455 glob_t *gp;
456 {
457  char *p;
458  int ReturnValue;
459 
460 /* No metas - add to string */
461 
462  if ((p = strpbrk (file, _GP_MetaChars)) == (char *)NULL)
463  {
464  if (!_GP_access (file, F_OK))
465  return 0;
466 
467  return _GP_AddArgument (file, gp);
468  }
469 
470 /* Ok - metas, find the end of the start of the directory */
471 
472  else if ((p = strchr (p, '/')) != (char *)NULL)
473  *(p++) = 0;
474 
475  else
476  p = _GP_NullString;
477 
478 /* Continue recusive match */
479 
480  ReturnValue = _GP_ExpandField (file, p, gp);
481 
482 /* Restore if necessary */
483 
484  if (p != _GP_NullString)
485  *(--p) = '/';
486 
487  return ReturnValue;
488 }
489 
490 /* Add an argument to the stack - file is assumed to be a array big enough
491  * for the file name + 2
492  */
493 
494 static int _GP_AddArgument (file, gp)
495 char *file;
496 glob_t *gp;
497 {
498  int Offset;
499  char **p1;
500  struct stat FileStatus;
501 
502  Offset = gp->gl_pathc + ((gp->gl_flags & GLOB_DOOFFS) ? gp->gl_offs : 0);
503  p1 = gp->gl_pathv;
504 
505 /* Malloc space if necessary */
506 
507  if (gp->gl_pathc == 0)
508  p1 = (char **)calloc (sizeof (char *), (50 + Offset));
509 
510  else if ((gp->gl_pathc % 50) == 0)
511  p1 = (char **)realloc (p1, (Offset + 50) * (sizeof (char *)));
512 
513  if (p1 == (char **)NULL)
514  return GLOB_NOSPACE;
515 
516 /* OK got space */
517 
518  gp->gl_pathv = p1;
519 
520 /* End of list ? */
521 
522  if (file == (char *)NULL)
523  p1[Offset] = (char *)NULL;
524 
525  else
526  {
527  if ((gp->gl_flags & GLOB_MARK) && (file[strlen (file) - 1] != '/') &&
528  _GP_stat (file, &FileStatus) && (S_ISDIR (FileStatus.st_mode)))
529  strcat (file, "/");
530 
531  if ((p1[Offset] = strdup (file)) == (char *)NULL)
532  return GLOB_NOSPACE;
533 
534  strcpy (p1[Offset], file);
535 
536 /* Increment counter */
537 
538  ++(gp->gl_pathc);
539  }
540 
541  return 0;
542 }
543 
544 /* Check for multi_drive prefix */
545 
546 #if defined (MSDOS) || defined (__OS2__) || defined (__TURBOC__) || defined (WIN32)
547 static char *_GP_CheckForMultipleDrives (prefix)
548 char *prefix;
549 {
550  if (strlen (prefix) < 2)
551  return (char *)NULL;
552 
553  if (((*prefix == '*') || (*prefix == '?')) && (prefix[1] == ':'))
554  return prefix + 1;
555 
556  if (*prefix != '[')
557  return (char *)NULL;
558 
559  while (*prefix && (*prefix != ']'))
560  {
561  if ((*prefix == '\\') && (*(prefix + 1)))
562  ++prefix;
563 
564  ++prefix;
565  }
566 
567  return (*prefix && (*(prefix + 1) == ':')) ? prefix + 1 : (char *)NULL;
568 }
569 
570 /*
571  * Some Turboc Functions to emulate MSC functions
572  */
573 
574 # if defined (__TURBOC__)
575 static void _dos_getdrive (cdp)
576 unsigned int *cdp;
577 {
578  *cdp = (unsigned int)getdisk () + 1;
579 }
580 
581 static void _dos_setdrive (cdr, ndp)
582 unsigned int cdr;
583 unsigned int *ndp;
584 {
585  *ndp = (unsigned int)setdisk (cdr - 1);
586 }
587 # endif
588 
589 /*
590  * Some OS/2 functions to emulate the DOS functions
591  */
592 
593 # if defined (OS2) || defined (__OS2__)
594 static void _dos_getdrive (cdp)
595 unsigned int *cdp;
596 {
597  USHORT cdr;
598  ULONG ndr;
599 
600  DosQCurDisk((PUSHORT)&cdr, (PULONG) &ndr);
601  *cdp = (unsigned int)cdr;
602 }
603 
604 static void _dos_setdrive (cdr, ndp)
605 unsigned int cdr;
606 unsigned int *ndp;
607 {
608  ULONG ulDrives;
609  USHORT usDisk;
610  int i;
611 
612  DosSelectDisk ((USHORT)cdr);
613 
614 /* Get the current disk and check that to see the number of drives */
615 
616  DosQCurDisk (&usDisk, &ulDrives); /* gets current drive */
617 
618  for (i = 25; (!(ulDrives & (1L << i))) && (i >= 0); --i)
619  continue;
620 
621  *ndp = i + 1;
622 }
623 
624 # elif defined (WIN32)
625 
626 static void _dos_getdrive (cdp)
627 unsigned int *cdp;
628 {
629  char szCurDir [MAX_PATH];
630 
631  GetCurrentDirectory (MAX_PATH, szCurDir);
632 
633  *cdp = (unsigned int)(szCurDir[0] - 'A' + 1);
634 }
635 
636 static void _dos_setdrive (cdr, ndp)
637 unsigned int cdr;
638 unsigned int *ndp;
639 {
640  char szNewDrive[3];
641  DWORD dwLogicalDrives;
642  unsigned int i;
643 
644  szNewDrive[0] = cdr + 'A' - 1;
645  szNewDrive[1] = ':';
646  szNewDrive[2] = 0;
647  *ndp = 0;
648 
649  if (!SetCurrentDirectory (szNewDrive))
650  return;
651 
652  dwLogicalDrives = GetLogicalDrives ();
653 
654  for (i = 25; (!(dwLogicalDrives & (1L << i))) && i >= 0; --i)
655  continue;
656 
657  *ndp = i + 1;
658 }
659 # endif
660 
661 /* Return the number of floppy disks */
662 
663 # if defined (OS2) || defined (__OS2__)
664 static int _GP_GetNumberofFloppyDrives ()
665 {
666  BYTE nflop = 1;
667 
668  DosDevConfig (&nflop, DEVINFO_FLOPPY, 0);
669 
670  return nflop;
671 }
672 
673 # elif defined (WIN32)
674 static int _GP_GetNumberofFloppyDrives ()
675 {
676  char szNewDrive[4];
677  DWORD dwLogicalDrives = GetLogicalDrives();
678  int LastTest = 0;
679  int i;
680 
681  strcpy (szNewDrive, "x:\\");
682 
683 /* Look at each drive until we find a non-floppy which exists */
684 
685  for (i = 0; i < 25; i++)
686  {
687  if (dwLogicalDrives & (1L << i))
688  {
689  szNewDrive[0] = i + 'A';
690 
691  if (GetDriveType (szNewDrive) != DRIVE_REMOVABLE)
692  break;
693 
694  LastTest = i + 1;
695  }
696  }
697 
698  return LastTest;
699 }
700 
701 # elif defined (__TURBOC__)
702 static int _GP_GetNumberofFloppyDrives ()
703 {
704  return ((biosequip () & 0x00c0) >> 6) + 1;
705 }
706 
707 # else
708 static int _GP_GetNumberofFloppyDrives ()
709 {
710  return ((_bios_equiplist () & 0x00c0) >> 6) + 1;
711 }
712 # endif
713 #endif
714 
715 /*
716  * Pattern Matching function
717  */
718 
719 static bool _GP_MatchPattern (string, pattern)
720 char *string; /* String to match */
721 char *pattern; /* Pattern to match against */
722 {
723  register int cur_s; /* Current string character */
724  register int cur_p; /* Current pattern character */
725 
726 /* Match string */
727 
728  while (cur_p = *(pattern++))
729  {
730  cur_s = *(string++); /* Load current string character */
731 
732  switch (cur_p) /* Switch on pattern character */
733  {
734  case '[': /* Match class of characters */
735  {
736  while(1)
737  {
738  if (!(cur_p = *(pattern++)))
739  return 0;
740 
741  if (cur_p == ']')
742  return FALSE;
743 
744  if (cur_s != cur_p)
745  {
746  if (*pattern == '-')
747  {
748  if(cur_p > cur_s)
749  continue;
750 
751  if (cur_s > *(++pattern))
752  continue;
753  }
754  else
755  continue;
756  }
757 
758  break;
759  }
760 
761  while (*pattern)
762  {
763  if (*(pattern++) == ']')
764  break;
765  }
766 
767  break;
768  }
769 
770  case '?': /* Match any character */
771  {
772  if (!cur_s)
773  return FALSE;
774 
775  break;
776  }
777 
778  case '*': /* Match any number of any character*/
779  {
780  string--;
781 
782  do
783  {
784  if (_GP_MatchPattern (string, pattern))
785  return TRUE;
786  }
787  while (*(string++));
788 
789  return FALSE;
790  }
791 
792  case '\\': /* Next character is non-meta */
793  {
794  if (!(cur_p = *(pattern++)))
795  return FALSE;
796  }
797 
798  default: /* Match against current pattern */
799  {
800  if (cur_p != cur_s)
801  return FALSE;
802 
803  break;
804  }
805  }
806  }
807 
808  return (!*string) ? TRUE : FALSE;
809 }
810 
811 /*
812  * Local Stat function to do some additional checks
813  */
814 
815 static bool _GP_stat (char *FileName, struct stat *Status)
816 {
817  int rc;
818 
820  rc = stat (FileName, Status);
822 
823  return rc ? FALSE : TRUE;
824 }
825 
826 /*
827  * Local access function to do some additional checks
828  */
829 
830 static bool _GP_access (char *FileName, int mode)
831 {
832  int rc;
833 
835  rc = access (FileName, mode);
837 
838  return rc ? FALSE : TRUE;
839 }
840 
841 /*
842  * Test program
843  */
844 
845 #ifdef TEST
846 int main (int argc, char **argv)
847 {
848  int i;
849 
850  for (i = 0; i < argc; i++)
851  printf ("Arg %d = <%s>\n", i, argv[i]);
852 
853  return 0;
854 }
855 #endif
#define strdup
Definition: Utility.h:167
#define strlwr
Definition: Utility.h:162
cp
Definition: action.c:1035
#define mode
Definition: aptex-macros.h:510
static pointer cur_p
Definition: aptex.h:591
static integer cur_s
Definition: aptex.h:545
char *__cdecl strpbrk(char const *_Str, char const *_Control)
int rc
Definition: bmpfont.h:9
char * p1
Definition: bmpfont.h:62
@ FALSE
Definition: dd.h:101
@ TRUE
Definition: dd.h:102
#define strrchr
Definition: detex.c:67
#define ENABLE_HARD_ERRORS
Definition: director.c:73
#define DISABLE_HARD_ERRORS
Definition: director.c:72
#define F_OK
Definition: defs.h:34
char * strncpy()
int strcmp()
Definition: coll.cpp:143
int printf()
char * strcpy()
#define MAX_PATH
Definition: dvispc.c:163
char pattern[8]
Definition: gemtopnm.c:50
#define a1
#define a2
#define GLOB_ABEND
Definition: glob.h:26
#define GLOB_NOSORT
Definition: glob.h:21
#define GLOB_APPEND
Definition: glob.h:24
#define GLOB_DOOFFS
Definition: glob.h:23
#define GLOB_ERR
Definition: glob.h:19
#define GLOB_NOSPACE
Definition: glob.h:27
#define GLOB_MARK
Definition: glob.h:20
#define GLOB_NOCHECK
Definition: glob.h:22
#define strchr
Definition: gsftopk.c:59
#define memmove(d, s, n)
Definition: gsftopk.c:65
static bool _GP_stat()
static bool _GP_MatchPattern()
static int _GP_ExpandMetaCharacters()
static int _GP_AddArgument()
#define S_ISDIR(m)
Definition: glob.c:87
#define alloca_free(x)
Definition: glob.c:124
static int _GP_SortCompare()
#define S_IFMT
Definition: glob.c:83
static int _GP_ExpandField()
static char * _GP_MetaChars
Definition: glob.c:102
static bool _GP_access()
static char * _GP_NullString
Definition: glob.c:103
void globfree(glob_t *gp)
Definition: glob.c:131
int glob(char *Pattern, int flags, int *ErrorFunction, glob_t *gp)
Definition: glob.c:144
small capitals from c petite p
Definition: afcover.h:72
small capitals from c petite p scientific i
Definition: afcover.h:80
sizeof(AF_ModuleRec)
voidp calloc()
unsigned char BYTE
Definition: sfnt.h:34
unsigned short USHORT
Definition: sfnt.h:36
USHORT Offset
Definition: tt_gsub.c:43
#define NAME_MAX
Definition: c-namemx.h:33
struct dirent * readdir(DIR *dirp)
Definition: dirent.c:138
int closedir(DIR *dirp)
Definition: dirent.c:123
DIR * opendir(char *fname)
Definition: dirent.c:60
#define access
Definition: win32lib.h:59
#define string
Definition: ctangleboot.c:111
#define prefix
Definition: cwebboot.c:154
int stat(const char *path, struct stat *sbuf)
struct Pattern Pattern
#define NULL
Definition: glob.c:87
void qsort()
void free()
int errno
char * alloca()
#define realloc
Definition: glob.c:206
unsigned int DWORD
Definition: mktexlib.h:49
int FileName
Definition: mktexpk.c:60
unsigned long ULONG
Definition: pdfgen.h:158
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d &reg2 endm macro vzip8 reg2 vzip d d &reg2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
#define gp
#define _PROTO(p)
Definition: proto.h:54
#define flags
struct pattern * PatternCopy(struct pattern *old, float transform[6])
Definition: splineutil.c:2730
#define IsHPFSFileSystem(a)
Definition: sh.h:1127
Definition: dirent.h:44
Definition: dirent.h:34
char d_name[260]
Definition: dirent.h:37
Definition: filedef.h:30
Definition: glob.h:10
while(temp)
Definition: t4ht.c:858
*job_name strlen((char *) job_name) - 4)
char * file
Definition: t4ht.c:931
#define Offset
Definition: tabledir.c:19
return() int(((double) *(font_tbl[cur_fnt].wtbl+(int)(*(font_tbl[cur_fnt].char_wi+(int)(ch - font_tbl[cur_fnt].char_f)% 256)))/(double)(1L<< 20)) *(double) font_tbl[cur_fnt].scale)
#define argv
Definition: xmain.c:270
#define main
Definition: xmain.c:31
#define argc
Definition: xmain.c:269