[BACK]Return to dir.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / make

Annotation of src/usr.bin/make/dir.h, Revision 1.25

1.15      espie       1: #ifndef DIR_H
                      2: #define DIR_H
                      3:
1.14      espie       4: /*     $OpenPackages$ */
1.24      espie       5: /*     $OpenBSD$       */
1.14      espie       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.
1.16      millert    25:  * 3. Neither the name of the University nor the names of its contributors
1.1       deraadt    26:  *    may be used to endorse or promote products derived from this software
                     27:  *    without specific prior written permission.
                     28:  *
                     29:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     30:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     31:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     32:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     33:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     34:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     35:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     36:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     37:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     38:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     39:  * SUCH DAMAGE.
                     40:  *
1.14      espie      41:  *     from: @(#)dir.h 8.1 (Berkeley) 6/6/93
1.1       deraadt    42:  */
                     43:
1.15      espie      44: #ifndef TIMESTAMP_TYPE
                     45: #include "timestamp_t.h"
                     46: #endif
                     47:
                     48: /* dir --
                     49:  *     Directory searching using wildcards and/or normal names...
                     50:  *     Used both for source wildcarding in the Makefile and for finding
                     51:  *     implicit sources.
                     52:  */
                     53:
                     54: /* Dir_Init()
                     55:  *     Initialize the module.
                     56:  */
                     57: extern void Dir_Init(void);
                     58:
                     59: /* Dir_End()
                     60:  *     Cleanup the module.
                     61:  */
                     62: #ifdef CLEANUP
                     63: extern void Dir_End(void);
                     64: #else
                     65: #define Dir_End()
                     66: #endif
                     67:
                     68: /*
                     69:  * Manipulating paths. By convention, the empty path always allows for
                     70:  * finding files in the current directory.
                     71:  */
                     72:
                     73: /* Dir_AddDiri(path, name, end);
                     74:  *     Add directory (name, end) to a search path.
                     75:  */
                     76: extern void Dir_AddDiri(Lst, const char *, const char *);
                     77: #define Dir_AddDir(l, n)       Dir_AddDiri(l, n, NULL)
                     78:
                     79: /* Dir_Concat(p1, p2);
                     80:  *     Concatenate two paths, adding dirs in p2 to the end of p1, but
                     81:  *     avoiding duplicates.
                     82:  */
                     83: extern void Dir_Concat(Lst, Lst);
                     84:
1.22      espie      85: /* Dir_Destroy(d);
                     86:  *     Destroy a directory in a search path.
1.15      espie      87:  */
                     88: extern void Dir_Destroy(void *);
                     89:
                     90: /* p2 = Dir_CopyDir(p);
                     91:  *     Return a copy of a directory. Callback to duplicate search paths.
1.1       deraadt    92:  */
1.15      espie      93: extern void *Dir_CopyDir(void *);
                     94:
                     95: /* Dir_PrintPath(p);
                     96:  *     Print the directory names along a given path.
                     97:  */
                     98: extern void Dir_PrintPath(Lst);
                     99:
1.1       deraadt   100:
1.15      espie     101: /*
                    102:  * Handling file names, and looking them up in paths
                    103:  */
                    104:
1.17      espie     105: /* fullname = Dir_FindFileComplexi(name, end, path, checkCurdirFirst)
1.22      espie     106:  *     Searches for a file (name, end) on a given search path.  If it exists,
1.15      espie     107:  *     return the fullname of the file, otherwise NULL.
                    108:  *     The fullname is always a copy, and the caller is responsible for
                    109:  *     free()ing it.
1.17      espie     110:  *     Looking for a simple name always looks in the current directory,
                    111:  *     unless checkCurdirFirst is false.
1.15      espie     112:  *     For complex names, the current directory search only occurs for
                    113:  *     paths with dot in them.
                    114:  */
1.17      espie     115: extern char *Dir_FindFileComplexi(const char *, const char *, Lst, bool);
                    116: #define Dir_FindFilei(n, e, p) Dir_FindFileComplexi(n, e, p, true)
                    117: #define Dir_FindFileNoDoti(n, e, p) Dir_FindFileComplexi(n, e, p, false)
                    118: #define Dir_FindFile(n, p) Dir_FindFilei(n, strchr(n, '\0'), p)
                    119: #define Dir_FindFileNoDot(n, p) Dir_FindFileNoDoti(n, strchr(n, '\0'), p)
1.15      espie     120:
                    121: /* stamp = Dir_MTime(gn);
                    122:  *     Return the modification time of node gn, searching along
1.22      espie     123:  *     the default search path.
1.15      espie     124:  *     Side effect: the path and mtime fields of gn are filled in.
                    125:  *     Return specific value if file can't be found, to be tested by
                    126:  *     is_out_of_date().
                    127:  */
1.14      espie     128: extern TIMESTAMP Dir_MTime(GNode *);
1.15      espie     129:
                    130:
                    131:
                    132:
1.22      espie     133: /*
1.15      espie     134:  * Misc
                    135:  */
                    136:
                    137: /* string = Dir_MakeFlags(flag, path);
1.22      espie     138:  *     Given a search path and a command flag, create a string with each
                    139:  *     of the directories in the path preceded by the command flag and all
1.15      espie     140:  *     of them separated by spaces.
                    141:  */
1.14      espie     142: extern char *Dir_MakeFlags(const char *, Lst);
1.15      espie     143:
                    144:
                    145: /* List of directories to search when looking for targets. */
1.23      espie     146: extern Lst     defaultPath;
1.1       deraadt   147:
1.18      espie     148:
                    149: /* communication between dir.c and direxpand.c */
1.19      espie     150: struct PathEntry;
                    151: extern struct PathEntry *dot;
1.18      espie     152: /* Handles wildcard expansion on a given directory. */
1.22      espie     153: extern  void Dir_MatchFilesi(const char *, const char *, struct PathEntry *,
1.18      espie     154:     Lst);
1.24      espie     155: extern char *PathEntry_name(struct PathEntry *);
1.14      espie     156: #endif /* DIR_H */