Deleted Added
full compact
gen_subs.c (76017) gen_subs.c (76351)
1/*-
2 * Copyright (c) 1992 Keith Muller.
3 * Copyright (c) 1992, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * Keith Muller of the University of California, San Diego.
8 *

--- 26 unchanged lines hidden (view full) ---

35 * SUCH DAMAGE.
36 */
37
38#ifndef lint
39#if 0
40static char sccsid[] = "@(#)gen_subs.c 8.1 (Berkeley) 5/31/93";
41#endif
42static const char rcsid[] =
1/*-
2 * Copyright (c) 1992 Keith Muller.
3 * Copyright (c) 1992, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * Keith Muller of the University of California, San Diego.
8 *

--- 26 unchanged lines hidden (view full) ---

35 * SUCH DAMAGE.
36 */
37
38#ifndef lint
39#if 0
40static char sccsid[] = "@(#)gen_subs.c 8.1 (Berkeley) 5/31/93";
41#endif
42static const char rcsid[] =
43 "$FreeBSD: head/bin/pax/gen_subs.c 76017 2001-04-26 08:37:00Z kris $";
43 "$FreeBSD: head/bin/pax/gen_subs.c 76351 2001-05-08 06:19:06Z kris $";
44#endif /* not lint */
45
46#include <sys/types.h>
47#include <sys/time.h>
48#include <sys/stat.h>
49#include <langinfo.h>
50#include <stdio.h>
51#include <utmp.h>

--- 26 unchanged lines hidden (view full) ---

78
79/*
80 * ls_list()
81 * list the members of an archive in ls format
82 */
83
84#ifdef __STDC__
85void
44#endif /* not lint */
45
46#include <sys/types.h>
47#include <sys/time.h>
48#include <sys/stat.h>
49#include <langinfo.h>
50#include <stdio.h>
51#include <utmp.h>

--- 26 unchanged lines hidden (view full) ---

78
79/*
80 * ls_list()
81 * list the members of an archive in ls format
82 */
83
84#ifdef __STDC__
85void
86ls_list(register ARCHD *arcn, time_t now)
86ls_list(register ARCHD *arcn, time_t now, FILE *fp)
87#else
88void
87#else
88void
89ls_list(arcn, now)
89ls_list(arcn, now, fp)
90 register ARCHD *arcn;
91 time_t now;
90 register ARCHD *arcn;
91 time_t now;
92 FILE *fp;
92#endif
93{
94 register struct stat *sbp;
95 char f_mode[MODELEN];
96 char f_date[DATELEN];
97 char *timefrmt;
98
99 /*
100 * if not verbose, just print the file name
101 */
102 if (!vflag) {
93#endif
94{
95 register struct stat *sbp;
96 char f_mode[MODELEN];
97 char f_date[DATELEN];
98 char *timefrmt;
99
100 /*
101 * if not verbose, just print the file name
102 */
103 if (!vflag) {
103 (void)printf("%s\n", arcn->name);
104 (void)fflush(stdout);
104 (void)fprintf(fp, "%s\n", arcn->name);
105 (void)fflush(fp);
105 return;
106 }
107
108 if (d_first < 0)
109 d_first = (*nl_langinfo(D_MD_ORDER) == 'd');
110 /*
111 * user wants long mode
112 */

--- 8 unchanged lines hidden (view full) ---

121 else
122 timefrmt = d_first ? CURFRMTD : CURFRMTM;
123
124 /*
125 * print file mode, link count, uid, gid and time
126 */
127 if (strftime(f_date,DATELEN,timefrmt,localtime(&(sbp->st_mtime))) == 0)
128 f_date[0] = '\0';
106 return;
107 }
108
109 if (d_first < 0)
110 d_first = (*nl_langinfo(D_MD_ORDER) == 'd');
111 /*
112 * user wants long mode
113 */

--- 8 unchanged lines hidden (view full) ---

122 else
123 timefrmt = d_first ? CURFRMTD : CURFRMTM;
124
125 /*
126 * print file mode, link count, uid, gid and time
127 */
128 if (strftime(f_date,DATELEN,timefrmt,localtime(&(sbp->st_mtime))) == 0)
129 f_date[0] = '\0';
129 (void)printf("%s%2u %-*s %-*s ", f_mode, sbp->st_nlink, UT_NAMESIZE,
130 name_uid(sbp->st_uid, 1), UT_GRPSIZE,
130 (void)fprintf(fp, "%s%2u %-*s %-*s ", f_mode, sbp->st_nlink,
131 UT_NAMESIZE, name_uid(sbp->st_uid, 1), UT_GRPSIZE,
131 name_gid(sbp->st_gid, 1));
132
133 /*
134 * print device id's for devices, or sizes for other nodes
135 */
136 if ((arcn->type == PAX_CHR) || (arcn->type == PAX_BLK))
137# ifdef NET2_STAT
132 name_gid(sbp->st_gid, 1));
133
134 /*
135 * print device id's for devices, or sizes for other nodes
136 */
137 if ((arcn->type == PAX_CHR) || (arcn->type == PAX_BLK))
138# ifdef NET2_STAT
138 (void)printf("%4u,%4u ", MAJOR(sbp->st_rdev),
139 (void)fprintf(fp, "%4u,%4u ", MAJOR(sbp->st_rdev),
139 MINOR(sbp->st_rdev));
140# else
140 MINOR(sbp->st_rdev));
141# else
141 (void)printf("%4lu,%4lu ", (unsigned long)MAJOR(sbp->st_rdev),
142 (void)fprintf(fp, "%4lu,%4lu ", (unsigned long)MAJOR(sbp->st_rdev),
142 (unsigned long)MINOR(sbp->st_rdev));
143# endif
144 else {
145# ifdef NET2_STAT
143 (unsigned long)MINOR(sbp->st_rdev));
144# endif
145 else {
146# ifdef NET2_STAT
146 (void)printf("%9lu ", sbp->st_size);
147 (void)fprintf(fp, "%9lu ", sbp->st_size);
147# else
148# else
148 (void)printf("%9qu ", sbp->st_size);
149 (void)fprintf(fp, "%9qu ", sbp->st_size);
149# endif
150 }
151
152 /*
153 * print name and link info for hard and soft links
154 */
150# endif
151 }
152
153 /*
154 * print name and link info for hard and soft links
155 */
155 (void)printf("%s %s", f_date, arcn->name);
156 (void)fprintf(fp, "%s %s", f_date, arcn->name);
156 if ((arcn->type == PAX_HLK) || (arcn->type == PAX_HRG))
157 if ((arcn->type == PAX_HLK) || (arcn->type == PAX_HRG))
157 (void)printf(" == %s\n", arcn->ln_name);
158 (void)fprintf(fp, " == %s\n", arcn->ln_name);
158 else if (arcn->type == PAX_SLK)
159 else if (arcn->type == PAX_SLK)
159 (void)printf(" => %s\n", arcn->ln_name);
160 (void)fprintf(fp, " => %s\n", arcn->ln_name);
160 else
161 else
161 (void)putchar('\n');
162 (void)fflush(stdout);
162 (void)putc('\n', fp);
163 (void)fflush(fp);
163 return;
164}
165
166/*
167 * tty_ls()
168 * print a short summary of file to tty.
169 */
170

--- 25 unchanged lines hidden (view full) ---

196 localtime(&(arcn->sb.st_mtime))) == 0)
197 f_date[0] = '\0';
198 strmode(arcn->sb.st_mode, f_mode);
199 tty_prnt("%s%s %s\n", f_mode, f_date, arcn->name);
200 return;
201}
202
203/*
164 return;
165}
166
167/*
168 * tty_ls()
169 * print a short summary of file to tty.
170 */
171

--- 25 unchanged lines hidden (view full) ---

197 localtime(&(arcn->sb.st_mtime))) == 0)
198 f_date[0] = '\0';
199 strmode(arcn->sb.st_mode, f_mode);
200 tty_prnt("%s%s %s\n", f_mode, f_date, arcn->name);
201 return;
202}
203
204/*
204 * zf_strncpy()
205 * copy src to dest up to len chars (stopping at first '\0'), when src is
206 * shorter than len, pads to len with '\0'. big performance win (and
207 * a lot easier to code) over strncpy(), then a strlen() then a
208 * memset(). (or doing the memset() first).
209 */
210
211#ifdef __STDC__
212void
213zf_strncpy(register char *dest, register char *src, int len)
214#else
215void
216zf_strncpy(dest, src, len)
217 register char *dest;
218 register char *src;
219 int len;
220#endif
221{
222 register char *stop;
223
224 stop = dest + len;
225 while ((dest < stop) && (*src != '\0'))
226 *dest++ = *src++;
227 while (dest < stop)
228 *dest++ = '\0';
229 return;
230}
231
232/*
233 * l_strncpy()
205 * l_strncpy()
234 * copy src to dest up to len chars (stopping at first '\0')
206 * copy src to dest up to len chars (stopping at first '\0').
207 * when src is shorter than len, pads to len with '\0'.
235 * Return:
236 * number of chars copied. (Note this is a real performance win over
208 * Return:
209 * number of chars copied. (Note this is a real performance win over
237 * doing a strncpy() then a strlen()
210 * doing a strncpy(), a strlen(), and then a possible memset())
238 */
239
240#ifdef __STDC__
241int
242l_strncpy(register char *dest, register char *src, int len)
243#else
244int
245l_strncpy(dest, src, len)

--- 4 unchanged lines hidden (view full) ---

250{
251 register char *stop;
252 register char *start;
253
254 stop = dest + len;
255 start = dest;
256 while ((dest < stop) && (*src != '\0'))
257 *dest++ = *src++;
211 */
212
213#ifdef __STDC__
214int
215l_strncpy(register char *dest, register char *src, int len)
216#else
217int
218l_strncpy(dest, src, len)

--- 4 unchanged lines hidden (view full) ---

223{
224 register char *stop;
225 register char *start;
226
227 stop = dest + len;
228 start = dest;
229 while ((dest < stop) && (*src != '\0'))
230 *dest++ = *src++;
258 if (dest < stop)
259 *dest = '\0';
260 return(dest - start);
231 len = dest - start;
232 while (dest < stop)
233 *dest++ = '\0';
234 return(len);
261}
262
263/*
264 * asc_ul()
265 * convert hex/octal character string into a u_long. We do not have to
266 * check for overflow! (the headers in all supported formats are not large
267 * enough to create an overflow).
268 * NOTE: strings passed to us are NOT TERMINATED.

--- 221 unchanged lines hidden ---
235}
236
237/*
238 * asc_ul()
239 * convert hex/octal character string into a u_long. We do not have to
240 * check for overflow! (the headers in all supported formats are not large
241 * enough to create an overflow).
242 * NOTE: strings passed to us are NOT TERMINATED.

--- 221 unchanged lines hidden ---