Print this page
make: unifdef SUN5_0 (defined)


  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 /*
  27  *      files.c
  28  *
  29  *      Various file related routines:
  30  *              Figure out if file exists
  31  *              Wildcard resolution for directory reader
  32  *              Directory reader
  33  */
  34 
  35 
  36 /*
  37  * Included files
  38  */
  39 #if defined(SUN5_0) || defined(HP_UX)
  40 #include <dirent.h>               /* opendir() */
  41 #else
  42 #include <sys/dir.h>              /* opendir() */
  43 #endif
  44 #include <errno.h>                /* errno */
  45 #include <mk/defs.h>
  46 #include <mksh/macro.h>           /* getvar() */
  47 #include <mksh/misc.h>            /* get_prop(), append_prop() */
  48 #include <sys/stat.h>             /* lstat() */
  49 
  50 /*
  51  * Defined macros
  52  */
  53 
  54 /*
  55  * typedefs & structs
  56  */
  57 
  58 /*
  59  * Static variables
  60  */
  61 
  62 /*
  63  * File table of contents


 289  *
 290  *      Global variables used:
 291  *              debug_level     Should we trace the dir reading?
 292  *              dot             The Name ".", compared against
 293  *              sccs_dir_path   The path to the SCCS dir (from PROJECTDIR)
 294  *              vpath_defined   Was the variable VPATH defined in environment?
 295  *              vpath_name      The Name "VPATH", use to get macro value
 296  */
 297 int
 298 read_dir(Name dir, wchar_t *pattern, Property line, wchar_t *library)
 299 {
 300         wchar_t                 file_name[MAXPATHLEN];
 301         wchar_t                 *file_name_p = file_name;
 302         Name                    file;
 303         wchar_t                 plain_file_name[MAXPATHLEN];
 304         wchar_t                 *plain_file_name_p;
 305         Name                    plain_file;
 306         wchar_t                 tmp_wcs_buffer[MAXPATHLEN];
 307         DIR                     *dir_fd;
 308         int                     m_local_dependency=0;
 309 #if defined(SUN5_0) || defined(HP_UX)
 310 #define d_fileno d_ino
 311         register struct dirent  *dp;
 312 #else
 313         register struct direct  *dp;
 314 #endif
 315         wchar_t                 *vpath = NULL;
 316         wchar_t                 *p;
 317         int                     result = 0;
 318 
 319         if(dir->hash.length >= MAXPATHLEN) {
 320                 return 0;
 321         }
 322 
 323         Wstring wcb(dir);
 324         Wstring vps;
 325 
 326         /* A directory is only read once unless we need to expand wildcards. */
 327         if (pattern == NULL) {
 328                 if (dir->has_read_dir) {
 329                         return 0;
 330                 }
 331                 dir->has_read_dir = true;
 332         }
 333         /* Check if VPATH is active and setup list if it is. */
 334         if (vpath_defined && (dir == dot)) {




  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 /*
  27  *      files.c
  28  *
  29  *      Various file related routines:
  30  *              Figure out if file exists
  31  *              Wildcard resolution for directory reader
  32  *              Directory reader
  33  */
  34 
  35 
  36 /*
  37  * Included files
  38  */

  39 #include <dirent.h>               /* opendir() */



  40 #include <errno.h>                /* errno */
  41 #include <mk/defs.h>
  42 #include <mksh/macro.h>           /* getvar() */
  43 #include <mksh/misc.h>            /* get_prop(), append_prop() */
  44 #include <sys/stat.h>             /* lstat() */
  45 
  46 /*
  47  * Defined macros
  48  */
  49 
  50 /*
  51  * typedefs & structs
  52  */
  53 
  54 /*
  55  * Static variables
  56  */
  57 
  58 /*
  59  * File table of contents


 285  *
 286  *      Global variables used:
 287  *              debug_level     Should we trace the dir reading?
 288  *              dot             The Name ".", compared against
 289  *              sccs_dir_path   The path to the SCCS dir (from PROJECTDIR)
 290  *              vpath_defined   Was the variable VPATH defined in environment?
 291  *              vpath_name      The Name "VPATH", use to get macro value
 292  */
 293 int
 294 read_dir(Name dir, wchar_t *pattern, Property line, wchar_t *library)
 295 {
 296         wchar_t                 file_name[MAXPATHLEN];
 297         wchar_t                 *file_name_p = file_name;
 298         Name                    file;
 299         wchar_t                 plain_file_name[MAXPATHLEN];
 300         wchar_t                 *plain_file_name_p;
 301         Name                    plain_file;
 302         wchar_t                 tmp_wcs_buffer[MAXPATHLEN];
 303         DIR                     *dir_fd;
 304         int                     m_local_dependency=0;

 305 #define d_fileno d_ino
 306         register struct dirent  *dp;



 307         wchar_t                 *vpath = NULL;
 308         wchar_t                 *p;
 309         int                     result = 0;
 310 
 311         if(dir->hash.length >= MAXPATHLEN) {
 312                 return 0;
 313         }
 314 
 315         Wstring wcb(dir);
 316         Wstring vps;
 317 
 318         /* A directory is only read once unless we need to expand wildcards. */
 319         if (pattern == NULL) {
 320                 if (dir->has_read_dir) {
 321                         return 0;
 322                 }
 323                 dir->has_read_dir = true;
 324         }
 325         /* Check if VPATH is active and setup list if it is. */
 326         if (vpath_defined && (dir == dot)) {