summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/alpm_list.h
diff options
context:
space:
mode:
authorAaron Griffin <aaron@archlinux.org>2007-01-19 10:28:44 +0100
committerAaron Griffin <aaron@archlinux.org>2007-01-19 10:28:44 +0100
commit616701726425417989ef1dca145b805deae6fe93 (patch)
tree2da68e080703c61a2c2116c0346b2dd58025015f /lib/libalpm/alpm_list.h
parent6d6ab5ed188d98fa057dbe2c83e8ce5126854426 (diff)
downloadpacman-616701726425417989ef1dca145b805deae6fe93.tar.gz
pacman-616701726425417989ef1dca145b805deae6fe93.tar.xz
Preliminary checkin for alpm_list conversion
* renamed pmlist_t -> alpm_list_t * made alpm_list_t a public type (alpm_list.h header) * removed additional storage for registered DBs in pacman source * some code cleanup * removed duplicate (pm)list_display functions from pacman source * misc code cleanup
Diffstat (limited to 'lib/libalpm/alpm_list.h')
-rw-r--r--lib/libalpm/alpm_list.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/lib/libalpm/alpm_list.h b/lib/libalpm/alpm_list.h
new file mode 100644
index 00000000..df19c9e9
--- /dev/null
+++ b/lib/libalpm/alpm_list.h
@@ -0,0 +1,71 @@
+/*
+ * alpm_alpm_list.h
+ *
+ * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ */
+#ifndef _ALPM_LIST_H
+#define _ALPM_LIST_H
+
+#include "alpm.h"
+
+/* Chained list struct */
+struct __alpm_list_t {
+ void *data;
+ struct __alpm_list_t *prev;
+ struct __alpm_list_t *next;
+};
+
+/* TODO we should do away with these... they're messy */
+#define _FREELIST(p, f) do { if(p) { alpm_list_free(p, f); p = NULL; } } while(0)
+#define FREELIST(p) _FREELIST(p, free)
+#define FREELISTPTR(p) _FREELIST(p, NULL)
+
+typedef void (*alpm_list_fn_free)(void *); /* item deallocation callback */
+typedef int (*alpm_list_fn_cmp)(const void *, const void *); /* item comparison callback */
+
+/* allocation */
+alpm_list_t *alpm_list_new(void);
+void alpm_list_free(alpm_list_t *list, alpm_list_fn_free fn);
+void alpm_list_free_outer(alpm_list_t *list);
+
+/* item mutators */
+alpm_list_t *alpm_list_add(alpm_list_t *list, void *data);
+alpm_list_t *alpm_list_add_sorted(alpm_list_t *list, void *data, alpm_list_fn_cmp fn);
+alpm_list_t* alpm_list_mmerge(alpm_list_t *left, alpm_list_t *right, alpm_list_fn_cmp fn);
+alpm_list_t* alpm_list_msort(alpm_list_t *list, int n, alpm_list_fn_cmp fn);
+alpm_list_t *alpm_list_remove(alpm_list_t *haystack, void *needle, alpm_list_fn_cmp fn, void **data);
+alpm_list_t *alpm_list_remove_dupes(alpm_list_t *list);
+alpm_list_t *alpm_list_strdup(alpm_list_t *list);
+alpm_list_t *alpm_list_reverse(alpm_list_t *list);
+
+/* item accessors */
+alpm_list_t *alpm_list_first(alpm_list_t *list);
+alpm_list_t* alpm_list_nth(alpm_list_t *list, int n);
+alpm_list_t *alpm_list_next(alpm_list_t *list);
+alpm_list_t *alpm_list_last(alpm_list_t *list);
+void *alpm_list_getdata(const alpm_list_t *entry);
+#define alpm_list_data(type, list) (type)alpm_list_getdata((list))
+
+/* misc */
+int alpm_list_count(const alpm_list_t *list);
+int alpm_list_is_in(const void *needle, alpm_list_t *haystack);
+int alpm_list_is_strin(const char *needle, alpm_list_t *haystack);
+
+#endif /* _ALPM_LIST_H */
+
+/* vim: set ts=2 sw=2 noet: */