1bf21e6bwollman/*
2bf21e6bwollman * Copyright 1997 Massachusetts Institute of Technology
3bf21e6bwollman *
4bf21e6bwollman * Permission to use, copy, modify, and distribute this software and
5bf21e6bwollman * its documentation for any purpose and without fee is hereby
6bf21e6bwollman * granted, provided that both the above copyright notice and this
7bf21e6bwollman * permission notice appear in all copies, that both the above
8bf21e6bwollman * copyright notice and this permission notice appear in all
9bf21e6bwollman * supporting documentation, and that the name of M.I.T. not be used
10bf21e6bwollman * in advertising or publicity pertaining to distribution of the
11bf21e6bwollman * software without specific, written prior permission.  M.I.T. makes
12bf21e6bwollman * no representations about the suitability of this software for any
13bf21e6bwollman * purpose.  It is provided "as is" without express or implied
14bf21e6bwollman * warranty.
15bf21e6bwollman *
16bf21e6bwollman * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''.  M.I.T. DISCLAIMS
17bf21e6bwollman * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
18bf21e6bwollman * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19bf21e6bwollman * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
20bf21e6bwollman * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21bf21e6bwollman * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22bf21e6bwollman * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23bf21e6bwollman * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24bf21e6bwollman * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25bf21e6bwollman * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26bf21e6bwollman * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27bf21e6bwollman * SUCH DAMAGE.
28bf21e6bwollman */
29bf21e6bwollman
30bf21e6bwollmanstatic const char copyright[] =
31bf21e6bwollman	"Copyright (C) 1997, Massachusetts Institute of Technology\r\n";
32d806166gad
33505db80gad#include "lp.cdefs.h"		/* A cross-platform version of <sys/cdefs.h> */
34505db80gad__FBSDID("$FreeBSD$");
35bf21e6bwollman
36bf21e6bwollman#include <sys/types.h>
37bf21e6bwollman#include <sys/stat.h>
38bf21e6bwollman
39bf21e6bwollman#include <stdlib.h>
40bf21e6bwollman#include <unistd.h>
41bf21e6bwollman
42bf21e6bwollman#include <sys/param.h>		/* needed for lp.h but not used here */
43bf21e6bwollman#include <dirent.h>		/* ditto */
44bf21e6bwollman#include <stdio.h>		/* ditto */
45bf21e6bwollman#include "lp.h"
46bf21e6bwollman#include "lp.local.h"
47bf21e6bwollman
48bf21e6bwollmanvoid
49bf21e6bwollmaninit_request(struct request *rp)
50bf21e6bwollman{
51bf21e6bwollman	static struct request zero;
52bf21e6bwollman
53bf21e6bwollman	*rp = zero;
54bf21e6bwollman	TAILQ_INIT(&rp->users);
55bf21e6bwollman	TAILQ_INIT(&rp->jobids);
56bf21e6bwollman}
57bf21e6bwollman
58bf21e6bwollmanvoid
59bf21e6bwollmanfree_request(struct request *rp)
60bf21e6bwollman{
61bf21e6bwollman	struct req_user *ru;
62bf21e6bwollman	struct req_jobid *rj;
63bf21e6bwollman
64bf21e6bwollman	if (rp->logname)
65bf21e6bwollman		free(rp->logname);
66bf21e6bwollman	if (rp->authname)
67bf21e6bwollman		free(rp->authname);
68bf21e6bwollman	if (rp->prettyname)
69bf21e6bwollman		free(rp->prettyname);
70bf21e6bwollman	if (rp->authinfo)
71bf21e6bwollman		free(rp->authinfo);
72d2d72fepfg	while ((ru = TAILQ_FIRST(&rp->users)) != NULL) {
73bf21e6bwollman		TAILQ_REMOVE(&rp->users, ru, ru_link);
74bf21e6bwollman		free(ru);
75bf21e6bwollman	}
76d2d72fepfg	while ((rj = TAILQ_FIRST(&rp->jobids)) != NULL) {
77bf21e6bwollman		TAILQ_REMOVE(&rp->jobids, rj, rj_link);
78bf21e6bwollman		free(rj);
79bf21e6bwollman	}
80bf21e6bwollman	init_request(rp);
81bf21e6bwollman}
82