2024-05-19 23:09:40 +03:00
|
|
|
/* $NetBSD: dir.h,v 1.48 2024/05/19 20:09:40 sjg Exp $ */
|
1995-06-14 19:18:37 +04:00
|
|
|
|
1994-03-05 03:34:29 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
2003-08-07 15:13:06 +04:00
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* Adam de Boor.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* from: @(#)dir.h 8.1 (Berkeley) 6/6/93
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
1994-03-05 03:34:29 +03:00
|
|
|
* Copyright (c) 1988, 1989 by Adam de Boor
|
|
|
|
* Copyright (c) 1989 by Berkeley Softworks
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* Adam de Boor.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1996-11-06 20:58:58 +03:00
|
|
|
* from: @(#)dir.h 8.1 (Berkeley) 6/6/93
|
1994-03-05 03:34:29 +03:00
|
|
|
*/
|
|
|
|
|
2020-11-29 12:27:40 +03:00
|
|
|
#ifndef MAKE_DIR_H
|
|
|
|
#define MAKE_DIR_H
|
1994-03-05 03:34:29 +03:00
|
|
|
|
2020-11-29 11:48:24 +03:00
|
|
|
typedef struct CachedDir CachedDir;
|
1994-03-05 03:34:29 +03:00
|
|
|
|
2020-08-22 03:48:02 +03:00
|
|
|
void Dir_Init(void);
|
2002-11-26 09:12:59 +03:00
|
|
|
void Dir_InitCur(const char *);
|
2002-06-15 22:24:55 +04:00
|
|
|
void Dir_InitDot(void);
|
|
|
|
void Dir_End(void);
|
2002-11-26 09:12:59 +03:00
|
|
|
void Dir_SetPATH(void);
|
2023-01-24 03:24:02 +03:00
|
|
|
void Dir_SetSYSPATH(void);
|
2021-12-15 12:53:41 +03:00
|
|
|
bool Dir_HasWildcards(const char *) MAKE_ATTR_USE;
|
2021-01-23 13:48:49 +03:00
|
|
|
void SearchPath_Expand(SearchPath *, const char *, StringList *);
|
2021-12-15 12:53:41 +03:00
|
|
|
char *Dir_FindFile(const char *, SearchPath *) MAKE_ATTR_USE;
|
2024-05-19 23:09:40 +03:00
|
|
|
char *Dir_FindInclude(const char *, SearchPath *) MAKE_ATTR_USE;
|
2021-12-15 12:53:41 +03:00
|
|
|
char *Dir_FindHereOrAbove(const char *, const char *) MAKE_ATTR_USE;
|
2021-04-03 14:08:40 +03:00
|
|
|
void Dir_UpdateMTime(GNode *, bool);
|
2021-01-23 14:34:41 +03:00
|
|
|
CachedDir *SearchPath_Add(SearchPath *, const char *);
|
2021-12-15 12:53:41 +03:00
|
|
|
char *SearchPath_ToFlags(SearchPath *, const char *) MAKE_ATTR_USE;
|
2020-11-29 01:13:56 +03:00
|
|
|
void SearchPath_Clear(SearchPath *);
|
|
|
|
void SearchPath_AddAll(SearchPath *, SearchPath *);
|
2002-06-15 22:24:55 +04:00
|
|
|
void Dir_PrintDirectories(void);
|
2021-02-05 08:48:19 +03:00
|
|
|
void SearchPath_Print(const SearchPath *);
|
2021-12-15 12:53:41 +03:00
|
|
|
SearchPath *Dir_CopyDirSearchPath(void) MAKE_ATTR_USE;
|
1994-03-05 03:34:29 +03:00
|
|
|
|
2020-09-28 01:17:07 +03:00
|
|
|
/* Stripped-down variant of struct stat. */
|
make(1): remove redundant struct make_stat
In the cache for stat(2) and lstat(2), only one of the two timestamps
was ever used. To prevent a result from stat(2) leaking into the cache
for lstat(2), there have been two completely separate caches all the
time. Using different fields in the struct was therefore unnecessary.
By removing the redundant field, the internal struct in the cache is the
same as the external struct. This makes one of them redundant, thus
struct make_stat has been renamed to cached_stat, which better describes
its purpose, and the internal struct cache_st has been removed.
Just as before, the cache prevents any direct access to its internal
data. When passing it to the caller, it is copied.
Just as before, the field names of struct cached_stat cannot correspond
to those from struct stat, since the latter are often defined as macros.
Therefore they are prefixed with cst instead of st.
The redundancy had been added on 2020-06-05.
2020-11-14 22:24:24 +03:00
|
|
|
struct cached_stat {
|
2020-11-29 12:27:40 +03:00
|
|
|
time_t cst_mtime;
|
|
|
|
mode_t cst_mode;
|
2020-09-28 01:17:07 +03:00
|
|
|
};
|
|
|
|
|
make(1): remove redundant struct make_stat
In the cache for stat(2) and lstat(2), only one of the two timestamps
was ever used. To prevent a result from stat(2) leaking into the cache
for lstat(2), there have been two completely separate caches all the
time. Using different fields in the struct was therefore unnecessary.
By removing the redundant field, the internal struct in the cache is the
same as the external struct. This makes one of them redundant, thus
struct make_stat has been renamed to cached_stat, which better describes
its purpose, and the internal struct cache_st has been removed.
Just as before, the cache prevents any direct access to its internal
data. When passing it to the caller, it is copied.
Just as before, the field names of struct cached_stat cannot correspond
to those from struct stat, since the latter are often defined as macros.
Therefore they are prefixed with cst instead of st.
The redundancy had been added on 2020-06-05.
2020-11-14 22:24:24 +03:00
|
|
|
int cached_lstat(const char *, struct cached_stat *);
|
|
|
|
int cached_stat(const char *, struct cached_stat *);
|
2020-09-02 07:08:54 +03:00
|
|
|
|
2021-12-15 15:08:25 +03:00
|
|
|
#endif
|