Deleted Added
sdiff udiff text old ( 248102 ) new ( 273791 )
full compact
1/*-
2 * Copyright (c) 2008 Sean C. Farley <scf@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/lib/libutil/gr_util.c 273791 2014-10-28 16:27:29Z bapt $");
29
30#include <sys/param.h>
31#include <sys/errno.h>
32#include <sys/stat.h>
33
34#include <ctype.h>
35#include <err.h>
36#include <fcntl.h>

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

165gr_copy(int ffd, int tfd, const struct group *gr, struct group *old_gr)
166{
167 char buf[8192], *end, *line, *p, *q, *r, t;
168 struct group *fgr;
169 const struct group *sgr;
170 size_t len;
171 int eof, readlen;
172
173 if (old_gr == NULL && gr == NULL)
174 return(-1);
175
176 sgr = old_gr;
177 /* deleting a group */
178 if (gr == NULL) {
179 line = NULL;
180 } else {
181 if ((line = gr_make(gr)) == NULL)
182 return (-1);
183 }
184
185 /* adding a group */
186 if (sgr == NULL)
187 sgr = gr;
188
189 eof = 0;
190 len = 0;
191 p = q = end = buf;
192 for (;;) {
193 /* find the end of the current line */
194 for (p = q; q < end && *q != '\0'; ++q)
195 if (*q == '\n')
196 break;

--- 442 unchanged lines hidden ---