1/* 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * 4 * This code is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU General Public License version 2 only, as 6 * published by the Free Software Foundation. Oracle designates this 7 * particular file as subject to the "Classpath" exception as provided 8 * by Oracle in the LICENSE file that accompanied this code. 9 * 10 * This code is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * version 2 for more details (a copy is included in the LICENSE file that 14 * accompanied this code). 15 * 16 * You should have received a copy of the GNU General Public License version 17 * 2 along with this work; if not, write to the Free Software Foundation, 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 * 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * questions. 23 */ 24/* $XConsortium: list.h /main/4 1996/10/14 15:04:04 swick $ */ 25/** ------------------------------------------------------------------------ 26 This file contains routines for manipulating generic lists. 27 Lists are implemented with a "harness". In other words, each 28 node in the list consists of two pointers, one to the data item 29 and one to the next node in the list. The head of the list is 30 the same struct as each node, but the "item" ptr is used to point 31 to the current member of the list (used by the first_in_list and 32 next_in_list functions). 33 34 This file is available under and governed by the GNU General Public 35 License version 2 only, as published by the Free Software Foundation. 36 However, the following notice accompanied the original version of this 37 file: 38 39Copyright (c) 1994 Hewlett-Packard Co. 40Copyright (c) 1996 X Consortium 41 42Permission is hereby granted, free of charge, to any person obtaining 43a copy of this software and associated documentation files (the 44"Software"), to deal in the Software without restriction, including 45without limitation the rights to use, copy, modify, merge, publish, 46distribute, sublicense, and sell copies of the Software, and to 47permit persons to whom the Software is furnished to do so, subject to 48the following conditions: 49 50The above copyright notice and this permission notice shall be included 51in all copies or substantial portions of the Software. 52 53THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 54OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 55MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 56IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR 57OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 58ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 59OTHER DEALINGS IN THE SOFTWARE. 60 61Except as contained in this notice, the name of the X Consortium shall 62not be used in advertising or otherwise to promote the sale, use or 63other dealings in this Software without prior written authorization 64from the X Consortium. 65 66 -------------------------------------------------------------------- **/ 67 68#include "gdefs.h" 69 70#ifndef LIST_DEF 71#define LIST_DEF 72 73#define LESS -1 74#define EQUAL 0 75#define GREATER 1 76#define DUP_WHOLE_LIST 0 77#define START_AT_CURR 1 78 79typedef struct _list_item { 80 struct _list_item *next; 81 union { 82 void *item; /* in normal list node, pts to data */ 83 struct _list_item *curr; /* in list head, pts to curr for 1st, next */ 84 } ptr; 85} list, list_item, *list_ptr; 86 87typedef void (*DESTRUCT_FUNC_PTR)( 88#if NeedFunctionPrototypes 89void * 90#endif 91); 92 93void zero_list( 94#if NeedFunctionPrototypes 95 list_ptr 96#endif 97 ); 98int32_t add_to_list ( 99#if NeedFunctionPrototypes 100 list_ptr , void * 101#endif 102 ); 103list_ptr new_list ( 104#if NeedFunctionPrototypes 105 void 106#endif 107 ); 108list_ptr dup_list_head ( 109#if NeedFunctionPrototypes 110 list_ptr , int32_t 111#endif 112 ); 113uint32_t list_length( 114#if NeedFunctionPrototypes 115 list_ptr 116#endif 117 ); 118void *delete_from_list ( 119#if NeedFunctionPrototypes 120 list_ptr , void * 121#endif 122 ); 123void delete_list( 124#if NeedFunctionPrototypes 125 list_ptr , int32_t 126#endif 127 ); 128void delete_list_destroying ( 129#if NeedFunctionPrototypes 130 list_ptr , DESTRUCT_FUNC_PTR 131#endif 132 ); 133void *first_in_list ( 134#if NeedFunctionPrototypes 135 list_ptr 136#endif 137 ); 138void *next_in_list ( 139#if NeedFunctionPrototypes 140 list_ptr 141#endif 142 ); 143int32_t list_is_empty ( 144#if NeedFunctionPrototypes 145 list_ptr 146#endif 147 ); 148 149#endif 150