[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.29

1.15      espie       1: #ifndef DIR_H
                      2: #define DIR_H
                      3:
1.29    ! espie       4: /*     $OpenBSD: dir.h,v 1.28 2012/12/07 07:15:31 espie Exp $  */
1.14      espie       5: /*     $NetBSD: dir.h,v 1.4 1996/11/06 17:59:05 christos Exp $ */
1.1       deraadt     6:
                      7: /*
                      8:  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
                      9:  * Copyright (c) 1988, 1989 by Adam de Boor
                     10:  * Copyright (c) 1989 by Berkeley Softworks
                     11:  * All rights reserved.
                     12:  *
                     13:  * This code is derived from software contributed to Berkeley by
                     14:  * Adam de Boor.
                     15:  *
                     16:  * Redistribution and use in source and binary forms, with or without
                     17:  * modification, are permitted provided that the following conditions
                     18:  * are met:
                     19:  * 1. Redistributions of source code must retain the above copyright
                     20:  *    notice, this list of conditions and the following disclaimer.
                     21:  * 2. Redistributions in binary form must reproduce the above copyright
                     22:  *    notice, this list of conditions and the following disclaimer in the
                     23:  *    documentation and/or other materials provided with the distribution.
1.16      millert    24:  * 3. Neither the name of the University nor the names of its contributors
1.1       deraadt    25:  *    may be used to endorse or promote products derived from this software
                     26:  *    without specific prior written permission.
                     27:  *
                     28:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     29:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     30:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     31:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     32:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     33:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     34:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     35:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     36:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     37:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     38:  * SUCH DAMAGE.
                     39:  *
1.14      espie      40:  *     from: @(#)dir.h 8.1 (Berkeley) 6/6/93
1.1       deraadt    41:  */
                     42:
1.29    ! espie      43: #include <sys/time.h>
1.15      espie      44:
                     45: /* dir --
                     46:  *     Directory searching using wildcards and/or normal names...
                     47:  *     Used both for source wildcarding in the Makefile and for finding
                     48:  *     implicit sources.
                     49:  */
                     50:
                     51: /* Dir_Init()
                     52:  *     Initialize the module.
                     53:  */
                     54: extern void Dir_Init(void);
                     55:
                     56: /*
                     57:  * Manipulating paths. By convention, the empty path always allows for
                     58:  * finding files in the current directory.
                     59:  */
                     60:
                     61: /* Dir_AddDiri(path, name, end);
                     62:  *     Add directory (name, end) to a search path.
                     63:  */
                     64: extern void Dir_AddDiri(Lst, const char *, const char *);
                     65: #define Dir_AddDir(l, n)       Dir_AddDiri(l, n, NULL)
                     66:
                     67: /* Dir_Concat(p1, p2);
                     68:  *     Concatenate two paths, adding dirs in p2 to the end of p1, but
                     69:  *     avoiding duplicates.
                     70:  */
                     71: extern void Dir_Concat(Lst, Lst);
                     72:
1.22      espie      73: /* Dir_Destroy(d);
                     74:  *     Destroy a directory in a search path.
1.15      espie      75:  */
                     76: extern void Dir_Destroy(void *);
                     77:
                     78: /* p2 = Dir_CopyDir(p);
                     79:  *     Return a copy of a directory. Callback to duplicate search paths.
1.1       deraadt    80:  */
1.15      espie      81: extern void *Dir_CopyDir(void *);
                     82:
                     83: /* Dir_PrintPath(p);
                     84:  *     Print the directory names along a given path.
                     85:  */
                     86: extern void Dir_PrintPath(Lst);
                     87:
1.1       deraadt    88:
1.15      espie      89: /*
                     90:  * Handling file names, and looking them up in paths
                     91:  */
                     92:
1.17      espie      93: /* fullname = Dir_FindFileComplexi(name, end, path, checkCurdirFirst)
1.22      espie      94:  *     Searches for a file (name, end) on a given search path.  If it exists,
1.15      espie      95:  *     return the fullname of the file, otherwise NULL.
                     96:  *     The fullname is always a copy, and the caller is responsible for
                     97:  *     free()ing it.
1.17      espie      98:  *     Looking for a simple name always looks in the current directory,
                     99:  *     unless checkCurdirFirst is false.
1.15      espie     100:  *     For complex names, the current directory search only occurs for
                    101:  *     paths with dot in them.
                    102:  */
1.17      espie     103: extern char *Dir_FindFileComplexi(const char *, const char *, Lst, bool);
                    104: #define Dir_FindFilei(n, e, p) Dir_FindFileComplexi(n, e, p, true)
                    105: #define Dir_FindFileNoDoti(n, e, p) Dir_FindFileComplexi(n, e, p, false)
                    106: #define Dir_FindFile(n, p) Dir_FindFilei(n, strchr(n, '\0'), p)
                    107: #define Dir_FindFileNoDot(n, p) Dir_FindFileNoDoti(n, strchr(n, '\0'), p)
1.15      espie     108:
                    109: /* stamp = Dir_MTime(gn);
                    110:  *     Return the modification time of node gn, searching along
1.22      espie     111:  *     the default search path.
1.15      espie     112:  *     Side effect: the path and mtime fields of gn are filled in.
                    113:  *     Return specific value if file can't be found, to be tested by
                    114:  *     is_out_of_date().
                    115:  */
1.29    ! espie     116: extern struct timespec Dir_MTime(GNode *);
1.15      espie     117:
                    118:
                    119:
                    120:
1.22      espie     121: /*
1.15      espie     122:  * Misc
                    123:  */
                    124:
                    125: /* List of directories to search when looking for targets. */
1.23      espie     126: extern Lst     defaultPath;
1.1       deraadt   127:
1.18      espie     128:
                    129: /* communication between dir.c and direxpand.c */
1.19      espie     130: struct PathEntry;
                    131: extern struct PathEntry *dot;
1.18      espie     132: /* Handles wildcard expansion on a given directory. */
1.22      espie     133: extern  void Dir_MatchFilesi(const char *, const char *, struct PathEntry *,
1.18      espie     134:     Lst);
1.24      espie     135: extern char *PathEntry_name(struct PathEntry *);
1.14      espie     136: #endif /* DIR_H */