Annotation of src/usr.bin/make/dir.h, Revision 1.15
1.15 ! espie 1: #ifndef DIR_H
! 2: #define DIR_H
! 3:
1.14 espie 4: /* $OpenPackages$ */
5: /* $OpenBSD: dir.h,v 1.4 1998/12/05 00:06:27 espie Exp $ */
6: /* $NetBSD: dir.h,v 1.4 1996/11/06 17:59:05 christos Exp $ */
1.1 deraadt 7:
8: /*
9: * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
10: * Copyright (c) 1988, 1989 by Adam de Boor
11: * Copyright (c) 1989 by Berkeley Softworks
12: * All rights reserved.
13: *
14: * This code is derived from software contributed to Berkeley by
15: * Adam de Boor.
16: *
17: * Redistribution and use in source and binary forms, with or without
18: * modification, are permitted provided that the following conditions
19: * are met:
20: * 1. Redistributions of source code must retain the above copyright
21: * notice, this list of conditions and the following disclaimer.
22: * 2. Redistributions in binary form must reproduce the above copyright
23: * notice, this list of conditions and the following disclaimer in the
24: * documentation and/or other materials provided with the distribution.
25: * 3. All advertising materials mentioning features or use of this software
26: * must display the following acknowledgement:
27: * This product includes software developed by the University of
28: * California, Berkeley and its contributors.
29: * 4. Neither the name of the University nor the names of its contributors
30: * may be used to endorse or promote products derived from this software
31: * without specific prior written permission.
32: *
33: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
34: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
35: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
36: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
37: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
38: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
39: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
40: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
41: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
42: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
43: * SUCH DAMAGE.
44: *
1.14 espie 45: * from: @(#)dir.h 8.1 (Berkeley) 6/6/93
1.1 deraadt 46: */
47:
1.15 ! espie 48: #ifndef TIMESTAMP_TYPE
! 49: #include "timestamp_t.h"
! 50: #endif
! 51:
! 52: /* dir --
! 53: * Directory searching using wildcards and/or normal names...
! 54: * Used both for source wildcarding in the Makefile and for finding
! 55: * implicit sources.
! 56: */
! 57:
! 58: /* Dir_Init()
! 59: * Initialize the module.
! 60: */
! 61: extern void Dir_Init(void);
! 62:
! 63: /* Dir_End()
! 64: * Cleanup the module.
! 65: */
! 66: #ifdef CLEANUP
! 67: extern void Dir_End(void);
! 68: #else
! 69: #define Dir_End()
! 70: #endif
! 71:
! 72: /*
! 73: * Manipulating paths. By convention, the empty path always allows for
! 74: * finding files in the current directory.
! 75: */
! 76:
! 77: /* Dir_AddDiri(path, name, end);
! 78: * Add directory (name, end) to a search path.
! 79: */
! 80: extern void Dir_AddDiri(Lst, const char *, const char *);
! 81: #define Dir_AddDir(l, n) Dir_AddDiri(l, n, NULL)
! 82:
! 83: /* Dir_Concat(p1, p2);
! 84: * Concatenate two paths, adding dirs in p2 to the end of p1, but
! 85: * avoiding duplicates.
! 86: */
! 87: extern void Dir_Concat(Lst, Lst);
! 88:
! 89: /* Dir_Destroy(d);
! 90: * Destroy a directory in a search path.
! 91: */
! 92: extern void Dir_Destroy(void *);
! 93:
! 94: /* p2 = Dir_CopyDir(p);
! 95: * Return a copy of a directory. Callback to duplicate search paths.
1.1 deraadt 96: */
1.15 ! espie 97: extern void *Dir_CopyDir(void *);
! 98:
! 99: /* Dir_PrintPath(p);
! 100: * Print the directory names along a given path.
! 101: */
! 102: extern void Dir_PrintPath(Lst);
! 103:
1.1 deraadt 104:
1.15 ! espie 105: /*
! 106: * Handling file names, and looking them up in paths
! 107: */
! 108:
! 109: /* boolean = Dir_HasWildcardsi(name, end)
! 110: * Returns true if (name, end) needs to be wildcard-expanded.
! 111: */
! 112: extern bool Dir_HasWildcardsi(const char *, const char *);
! 113: #define Dir_HasWildcards(n) Dir_HasWildcardsi(n, strchr(n, '\0'))
1.1 deraadt 114:
1.15 ! espie 115: /* Dir_Expandi(pattern, endp, path, expansions);
! 116: * Expand (pattern, endp) to Lst of names matching on the search path.
! 117: * Put result in expansions.
! 118: */
! 119: extern void Dir_Expandi(const char *, const char *, Lst, Lst);
! 120: #define Dir_Expand(n, l1, l2) Dir_Expandi(n, strchr(n, '\0'), l1, l2)
1.1 deraadt 121:
1.15 ! espie 122: /* fullname = Dir_FindFilei(name, end, path)
! 123: * Searches for a file (name, end) on a given search path. If it exists,
! 124: * return the fullname of the file, otherwise NULL.
! 125: * The fullname is always a copy, and the caller is responsible for
! 126: * free()ing it.
! 127: * Looking for a simple name always looks in the current directory.
! 128: * For complex names, the current directory search only occurs for
! 129: * paths with dot in them.
! 130: */
1.14 espie 131: extern char *Dir_FindFilei(const char *, const char *, Lst);
132: #define Dir_FindFile(n, e) Dir_FindFilei(n, strchr(n, '\0'), e)
1.15 ! espie 133:
! 134: /* stamp = Dir_MTime(gn);
! 135: * Return the modification time of node gn, searching along
! 136: * the default search path.
! 137: * Side effect: the path and mtime fields of gn are filled in.
! 138: * Return specific value if file can't be found, to be tested by
! 139: * is_out_of_date().
! 140: */
1.14 espie 141: extern TIMESTAMP Dir_MTime(GNode *);
1.15 ! espie 142:
! 143:
! 144:
! 145:
! 146: /*
! 147: * Misc
! 148: */
! 149:
! 150: /* string = Dir_MakeFlags(flag, path);
! 151: * Given a search path and a command flag, create a string with each
! 152: * of the directories in the path preceded by the command flag and all
! 153: * of them separated by spaces.
! 154: */
1.14 espie 155: extern char *Dir_MakeFlags(const char *, Lst);
1.15 ! espie 156:
! 157:
! 158: #ifdef DEBUG_DIRECTORY_CACHE
! 159: /* Dir_PrintDirectories();
! 160: * Print stats about the directory cache.
! 161: */
1.14 espie 162: extern void Dir_PrintDirectories(void);
1.15 ! espie 163: #endif
! 164:
! 165: /* List of directories to search when looking for targets. */
! 166: extern Lst dirSearchPath;
1.1 deraadt 167:
1.14 espie 168: #endif /* DIR_H */