Skip to content

Commit f2113ea

Browse files
committed
[darwin] Move print_nm to src to fix undefined symbol
1 parent 279383b commit f2113ea

2 files changed

Lines changed: 106 additions & 67 deletions

File tree

lib/dialects/darwin/dfile.c

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ static char copyright[] = "@(#) Copyright 2005-2007 Apple Inc. and Purdue "
3838

3939
#include "common.h"
4040

41-
#if defined(PROC_FP_GUARDED)
42-
extern struct pff_tab Pgf_tab[];
43-
#endif /* defined(PROC_FP_GUARDED) */
44-
4541
/*
4642
* enter_file_info() -- enter file information
4743
*/
@@ -245,69 +241,6 @@ void err2nm(struct lsof_context *ctx, /* context */
245241
enter_nm(ctx, Namech);
246242
}
247243

248-
/*
249-
* print_nm() -- print Name column
250-
*/
251-
void print_nm(struct lsof_context *ctx, struct lfile *lf) {
252-
unsigned char extra = 0;
253-
254-
printname(ctx, 0);
255-
256-
#if defined(PROC_PIDLISTFILEPORTS)
257-
if (lf->fileport)
258-
extra++;
259-
#endif /* defined(PROC_PIDLISTFILEPORTS) */
260-
261-
#if defined(PROC_FP_GUARDED)
262-
if (lf->guardflags)
263-
extra++;
264-
#endif /* defined(PROC_FP_GUARDED) */
265-
266-
if (extra)
267-
(void)printf(" (");
268-
269-
#if defined(PROC_PIDLISTFILEPORTS)
270-
if (lf->fileport)
271-
(void)printf("fileport=0x%04x", lf->fileport);
272-
#endif /* defined(PROC_PIDLISTFILEPORTS) */
273-
274-
#if defined(PROC_FP_GUARDED)
275-
if (extra > 1)
276-
putchar(',');
277-
if (lf->guardflags) {
278-
struct pff_tab *tp;
279-
long gf;
280-
281-
(void)printf("guard=");
282-
tp = Pgf_tab;
283-
gf = lf->guardflags;
284-
while (gf && !FsvFlagX) {
285-
while (tp->nm) {
286-
if (gf & tp->val)
287-
break;
288-
tp++;
289-
}
290-
if (!tp->nm)
291-
break;
292-
gf &= ~(tp->val);
293-
(void)printf("%s%s", tp->nm, gf ? "," : "");
294-
}
295-
/*
296-
* If flag bits remain, print them in hex. If hex output was
297-
* specified with +fG, print all flag values, including zero,
298-
* in hex.
299-
*/
300-
if (gf || FsvFlagX)
301-
(void)printf("0x%lx", gf);
302-
}
303-
#endif /* defined(PROC_FP_GUARDED) */
304-
305-
if (extra)
306-
(void)printf(")\n");
307-
else
308-
putchar('\n');
309-
}
310-
311244
/*
312245
* print_v_path() -- print vnode's path
313246
*/

src/dialects/darwin/dprint.c

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/*
2+
* dprint.c -- Darwin file processing functions for libproc-based lsof
3+
*/
4+
5+
/*
6+
* Portions Copyright 2005-2007 Apple Inc. All rights reserved.
7+
*
8+
* Copyright 2005 Purdue Research Foundation, West Lafayette, Indiana
9+
* 47907. All rights reserved.
10+
*
11+
* Written by Allan Nathanson, Apple Inc., and Victor A. Abell, Purdue
12+
* University.
13+
*
14+
* This software is not subject to any license of the American Telephone
15+
* and Telegraph Company or the Regents of the University of California.
16+
*
17+
* Permission is granted to anyone to use this software for any purpose on
18+
* any computer system, and to alter it and redistribute it freely, subject
19+
* to the following restrictions:
20+
*
21+
* 1. Neither the authors, nor Apple Inc. nor Purdue University are
22+
* responsible for any consequences of the use of this software.
23+
*
24+
* 2. The origin of this software must not be misrepresented, either
25+
* by explicit claim or by omission. Credit to the authors, Apple
26+
* Inc. and Purdue University must appear in documentation and sources.
27+
*
28+
* 3. Altered versions must be plainly marked as such, and must not be
29+
* misrepresented as being the original software.
30+
*
31+
* 4. This notice may not be removed or altered.
32+
*/
33+
34+
#ifndef lint
35+
static char copyright[] = "@(#) Copyright 2005-2007 Apple Inc. and Purdue "
36+
"Research Foundation.\nAll rights reserved.\n";
37+
#endif
38+
39+
#include "common.h"
40+
41+
#if defined(PROC_FP_GUARDED)
42+
extern struct pff_tab Pgf_tab[];
43+
#endif /* defined(PROC_FP_GUARDED) */
44+
45+
/*
46+
* print_nm() -- print Name column
47+
*/
48+
void print_nm(struct lsof_context *ctx, struct lfile *lf) {
49+
unsigned char extra = 0;
50+
51+
printname(ctx, 0);
52+
53+
#if defined(PROC_PIDLISTFILEPORTS)
54+
if (lf->fileport)
55+
extra++;
56+
#endif /* defined(PROC_PIDLISTFILEPORTS) */
57+
58+
#if defined(PROC_FP_GUARDED)
59+
if (lf->guardflags)
60+
extra++;
61+
#endif /* defined(PROC_FP_GUARDED) */
62+
63+
if (extra)
64+
(void)printf(" (");
65+
66+
#if defined(PROC_PIDLISTFILEPORTS)
67+
if (lf->fileport)
68+
(void)printf("fileport=0x%04x", lf->fileport);
69+
#endif /* defined(PROC_PIDLISTFILEPORTS) */
70+
71+
#if defined(PROC_FP_GUARDED)
72+
if (extra > 1)
73+
putchar(',');
74+
if (lf->guardflags) {
75+
struct pff_tab *tp;
76+
long gf;
77+
78+
(void)printf("guard=");
79+
tp = Pgf_tab;
80+
gf = lf->guardflags;
81+
while (gf && !FsvFlagX) {
82+
while (tp->nm) {
83+
if (gf & tp->val)
84+
break;
85+
tp++;
86+
}
87+
if (!tp->nm)
88+
break;
89+
gf &= ~(tp->val);
90+
(void)printf("%s%s", tp->nm, gf ? "," : "");
91+
}
92+
/*
93+
* If flag bits remain, print them in hex. If hex output was
94+
* specified with +fG, print all flag values, including zero,
95+
* in hex.
96+
*/
97+
if (gf || FsvFlagX)
98+
(void)printf("0x%lx", gf);
99+
}
100+
#endif /* defined(PROC_FP_GUARDED) */
101+
102+
if (extra)
103+
(void)printf(")\n");
104+
else
105+
putchar('\n');
106+
}

0 commit comments

Comments
 (0)