summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_install/lib
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/pkg_install/lib')
-rw-r--r--usr.sbin/pkg_install/lib/Makefile4
-rw-r--r--usr.sbin/pkg_install/lib/lib.h25
-rw-r--r--usr.sbin/pkg_install/lib/lpkg.c64
-rw-r--r--usr.sbin/pkg_install/lib/str.c5
4 files changed, 92 insertions, 6 deletions
diff --git a/usr.sbin/pkg_install/lib/Makefile b/usr.sbin/pkg_install/lib/Makefile
index 9a28ecc5002..e2f467b4393 100644
--- a/usr.sbin/pkg_install/lib/Makefile
+++ b/usr.sbin/pkg_install/lib/Makefile
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.11 1999/03/13 23:22:44 lukem Exp $
+# $NetBSD: Makefile,v 1.12 1999/03/22 05:02:41 hubertf Exp $
# Original from FreeBSD, no rcs id.
LIB= install
-SRCS= exec.c file.c global.c pen.c pkgdb.c plist.c str.c
+SRCS= exec.c file.c global.c lpkg.c pen.c pkgdb.c plist.c str.c
MKLINT= no
MKMAN= no
diff --git a/usr.sbin/pkg_install/lib/lib.h b/usr.sbin/pkg_install/lib/lib.h
index f159111a9bd..9ba15b4ee24 100644
--- a/usr.sbin/pkg_install/lib/lib.h
+++ b/usr.sbin/pkg_install/lib/lib.h
@@ -1,4 +1,4 @@
-/* $NetBSD: lib.h,v 1.20 1999/03/09 11:10:40 agc Exp $ */
+/* $NetBSD: lib.h,v 1.21 1999/03/22 05:02:41 hubertf Exp $ */
/* from FreeBSD Id: lib.h,v 1.25 1997/10/08 07:48:03 charnier Exp */
@@ -28,6 +28,7 @@
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/file.h>
+#include <sys/queue.h>
#include <ctype.h>
#include <dirent.h>
@@ -88,6 +89,13 @@
/* The name of the "prefix" environment variable given to scripts */
#define PKG_PREFIX_VNAME "PKG_PREFIX"
+/* This should only happen on 1.3 and 1.3.1, not 1.3.2 and up */
+#ifndef TAILQ_FIRST
+#define TAILQ_FIRST(head) ((head)->tqh_first)
+#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
+#endif
+
+
/* enumerated constants for plist entry types */
typedef enum pl_ent_t {
PLIST_SHOW_ALL = -1,
@@ -137,6 +145,14 @@ enum {
LegibleChecksumLen = 33
};
+/* List of packages */
+typedef struct _lpkg_t {
+ TAILQ_ENTRY(_lpkg_t) lp_link;
+ char *lp_name;
+} lpkg_t;
+TAILQ_HEAD(_lpkg_head_t, _lpkg_t);
+typedef struct _lpkg_head_t lpkg_head_t;
+
/* type of function to be handed to findmatchingname; return value of this
* is currently ignored */
typedef int (*matchfn)(const char *found, char *data);
@@ -213,8 +229,13 @@ char* pkgdb_iter(void);
char* _pkgdb_getPKGDB_FILE(void);
char* _pkgdb_getPKGDB_DIR(void);
+/* List of packages functions */
+lpkg_t *alloc_lpkg(const char *);
+lpkg_t *find_on_queue(lpkg_head_t *, const char *);
+void free_lpkg(lpkg_t *);
+
/* For all */
-int pkg_perform(char **);
+int pkg_perform(lpkg_head_t *);
/* Externs */
extern Boolean Verbose;
diff --git a/usr.sbin/pkg_install/lib/lpkg.c b/usr.sbin/pkg_install/lib/lpkg.c
new file mode 100644
index 00000000000..1c514a6a8c7
--- /dev/null
+++ b/usr.sbin/pkg_install/lib/lpkg.c
@@ -0,0 +1,64 @@
+/* $NetBSD: lpkg.c,v 1.1 1999/03/22 05:02:41 hubertf Exp $ */
+
+/*
+ * Copyright (c) 1999 Christian E. Hopps
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Package-list auxiliary functions
+ */
+
+#include <err.h>
+#include "lib.h"
+
+/* add a package to the recursive delete list */
+lpkg_t *
+alloc_lpkg(const char *pkgname)
+{
+ lpkg_t *lpp;
+
+ if ((lpp = malloc(sizeof(*lpp))) == 0)
+ err(1, "cannot allocate recursion data");
+ if ((lpp->lp_name = strdup(pkgname)) == 0)
+ err(1, "cannot allocate recursion data");
+ return (lpp);
+}
+
+void
+free_lpkg(lpkg_t *lpp)
+{
+ free(lpp->lp_name);
+ free(lpp);
+}
+
+lpkg_t *
+find_on_queue(lpkg_head_t *qp, const char *name)
+{
+ lpkg_t *lpp;
+
+ for (lpp = TAILQ_FIRST(qp); lpp; lpp = TAILQ_NEXT(lpp, lp_link))
+ if (!strcmp(name, lpp->lp_name))
+ return (lpp);
+ return (0);
+}
diff --git a/usr.sbin/pkg_install/lib/str.c b/usr.sbin/pkg_install/lib/str.c
index 311ec5e7ac0..854a4ff1a96 100644
--- a/usr.sbin/pkg_install/lib/str.c
+++ b/usr.sbin/pkg_install/lib/str.c
@@ -1,11 +1,11 @@
-/* $NetBSD: str.c,v 1.13 1999/03/06 02:16:25 hubertf Exp $ */
+/* $NetBSD: str.c,v 1.14 1999/03/22 05:02:41 hubertf Exp $ */
#include <sys/cdefs.h>
#ifndef lint
#if 0
static const char *rcsid = "Id: str.c,v 1.5 1997/10/08 07:48:21 charnier Exp";
#else
-__RCSID("$NetBSD: str.c,v 1.13 1999/03/06 02:16:25 hubertf Exp $");
+__RCSID("$NetBSD: str.c,v 1.14 1999/03/22 05:02:41 hubertf Exp $");
#endif
#endif
@@ -261,6 +261,7 @@ findmatchingname(const char *dir, const char *pattern, matchfn match, char *data
if (pmatch(pattern, dp->d_name)) {
if (match) {
match(dp->d_name, data);
+ /* return value ignored for now */
}
found = 1;
}