2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $TOG: pr.c /main/21 1998/02/06 11:10:30 kaleb $ */
26 Copyright (c) 1993, 1994, 1998 The Open Group
30 The above copyright notice and this permission notice shall be included in
31 all copies or substantial portions of the Software.
33 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
37 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
38 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40 Except as contained in this notice, the name of The Open Group shall not be
41 used in advertising or otherwise to promote the sale, use or other dealings
42 in this Software without prior written authorization from The Open Group.
48 extern struct inclist inclist[ MAXFILES ],
50 extern char *objprefix;
51 extern char *objsuffix;
53 extern boolean printed;
54 extern boolean verbose;
55 extern boolean show_where_not;
58 add_include(filep, file, file_red, include, dot, failOK)
59 struct filepointer *filep;
60 struct inclist *file, *file_red;
65 register struct inclist *newfile;
66 register struct filepointer *content;
69 * First decide what the pathname of this include file really is.
71 newfile = inc_path(file->i_file, include, dot);
72 if (newfile == NULL) {
76 warning("%s (reading %s, line %d): ",
77 file_red->i_file, file->i_file, filep->f_line);
79 warning("%s, line %d: ", file->i_file, filep->f_line);
80 warning1("cannot find include file \"%s\"\n", include);
81 show_where_not = TRUE;
82 newfile = inc_path(file->i_file, include, dot);
83 show_where_not = FALSE;
87 included_by(file, newfile);
88 if (!(newfile->i_flags & SEARCHED)) {
89 newfile->i_flags |= SEARCHED;
90 content = getfile(newfile->i_file);
91 find_includes(content, newfile, file_red, 0, failOK);
99 register struct inclist *ip;
102 static char *lastfile;
103 static int current_len;
108 len = strlen(ip->i_file)+1;
109 if (current_len + len > width || file != lastfile) {
111 snprintf(buf, BUFSIZ, "\n%s%s%s: %s", objprefix, base,
112 objsuffix, ip->i_file);
113 len = current_len = strlen(buf);
117 strncpy(buf+1, ip->i_file, BUFSIZ - 1);
120 fwrite(buf, len, 1, stdout);
123 * If verbose is set, then print out what this file includes.
125 if (! verbose || ip->i_list == NULL || ip->i_flags & NOTIFIED)
127 ip->i_flags |= NOTIFIED;
129 printf("\n# %s includes:", ip->i_file);
130 for (i=0; i<ip->i_listlen; i++)
131 printf("\n#\t%s", ip->i_list[ i ]->i_incstring);
135 recursive_pr_include(head, file, base)
136 register struct inclist *head;
137 register char *file, *base;
141 if (head->i_flags & MARKED)
143 head->i_flags |= MARKED;
144 if (head->i_file != file)
145 pr(head, file, base);
146 for (i=0; i<head->i_listlen; i++)
147 recursive_pr_include(head->i_list[ i ], file, base);