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;
64 register struct inclist *newfile;
65 register struct filepointer *content;
68 * First decide what the pathname of this include file really is.
70 newfile = inc_path(file->i_file, include, dot);
71 if (newfile == NULL) {
75 warning("%s (reading %s, line %d): ",
76 file_red->i_file, file->i_file, filep->f_line);
78 warning("%s, line %d: ", file->i_file, filep->f_line);
79 warning1("cannot find include file \"%s\"\n", include);
80 show_where_not = TRUE;
81 newfile = inc_path(file->i_file, include, dot);
82 show_where_not = FALSE;
86 included_by(file, newfile);
87 if (!(newfile->i_flags & SEARCHED)) {
88 newfile->i_flags |= SEARCHED;
89 content = getfile(newfile->i_file);
90 find_includes(content, newfile, file_red, 0, failOK);
98 register struct inclist *ip;
101 static char *lastfile;
102 static int current_len;
107 len = strlen(ip->i_file)+1;
108 if (current_len + len > width || file != lastfile) {
110 sprintf(buf, "\n%s%s%s: %s", objprefix, base, objsuffix,
112 len = current_len = strlen(buf);
116 strcpy(buf+1, ip->i_file);
119 fwrite(buf, len, 1, stdout);
122 * If verbose is set, then print out what this file includes.
124 if (! verbose || ip->i_list == NULL || ip->i_flags & NOTIFIED)
126 ip->i_flags |= NOTIFIED;
128 printf("\n# %s includes:", ip->i_file);
129 for (i=0; i<ip->i_listlen; i++)
130 printf("\n#\t%s", ip->i_list[ i ]->i_incstring);
134 recursive_pr_include(head, file, base)
135 register struct inclist *head;
136 register char *file, *base;
140 if (head->i_flags & MARKED)
142 head->i_flags |= MARKED;
143 if (head->i_file != file)
144 pr(head, file, base);
145 for (i=0; i<head->i_listlen; i++)
146 recursive_pr_include(head->i_list[ i ], file, base);