L4Re/departure

libext2fs/lib/libsupport/dict.h

617:2733e5770ee9
9 months ago Paul Boddie Made the run command wait for completion, introducing the spawn command to run programs in the background. Introduced conveniences for waiting for the last job to be initiated and for piping from the last job, also subscribing to signals from pipe-supplying jobs so that they may be transparently removed from the job list upon completion. Augmented the job listing with the "+" notation familiar from Unix. Prevented new jobs from being started when no job slots are available.
     1 /*     2  * Dictionary Abstract Data Type     3  * Copyright (C) 1997 Kaz Kylheku <kaz@ashi.footprints.net>     4  *     5  * Free Software License:     6  *     7  * All rights are reserved by the author, with the following exceptions:     8  * Permission is granted to freely reproduce and distribute this software,     9  * possibly in exchange for a fee, provided that this copyright notice appears    10  * intact. Permission is also granted to adapt this software to produce    11  * derivative works, as long as the modified versions carry this copyright    12  * notice and additional notices stating that the work has been modified.    13  * This source code may be translated into executable form and incorporated    14  * into proprietary software; there is no requirement for such software to    15  * contain a copyright notice related to this source.    16  *    17  * $Id: dict.h,v 1.22.2.6 2000/11/13 01:36:44 kaz Exp $    18  * $Name: kazlib_1_20 $    19  */    20     21 #ifndef DICT_H    22 #define DICT_H    23     24 #include <limits.h>    25 #ifdef KAZLIB_SIDEEFFECT_DEBUG    26 #include "sfx.h"    27 #endif    28     29 /*    30  * Blurb for inclusion into C++ translation units    31  */    32     33 #ifdef __cplusplus    34 extern "C" {    35 #endif    36     37 typedef unsigned long dictcount_t;    38 #define DICTCOUNT_T_MAX ULONG_MAX    39     40 /*    41  * The dictionary is implemented as a red-black tree    42  */    43     44 typedef enum { dnode_red, dnode_black } dnode_color_t;    45     46 typedef struct dnode_t {    47 #if defined(DICT_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)    48     struct dnode_t *dict_left;    49     struct dnode_t *dict_right;    50     struct dnode_t *dict_parent;    51     dnode_color_t dict_color;    52     const void *dict_key;    53     void *dict_data;    54 #else    55     int dict_dummy;    56 #endif    57 } dnode_t;    58     59 typedef int (*dict_comp_t)(const void *, const void *, const void *);    60 typedef dnode_t *(*dnode_alloc_t)(void *);    61 typedef void (*dnode_free_t)(dnode_t *, void *);    62     63 typedef struct dict_t {    64 #if defined(DICT_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)    65     dnode_t dict_nilnode;    66     dictcount_t dict_nodecount;    67     dictcount_t dict_maxcount;    68     dict_comp_t dict_compare;    69     dnode_alloc_t dict_allocnode;    70     dnode_free_t dict_freenode;    71     void *dict_context;    72     void *cmp_ctx;    73     int dict_dupes;    74 #else    75     int dict_dummmy;    76 #endif    77 } dict_t;    78     79 typedef void (*dnode_process_t)(dict_t *, dnode_t *, void *);    80     81 typedef struct dict_load_t {    82 #if defined(DICT_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)    83     dict_t *dict_dictptr;    84     dnode_t dict_nilnode;    85 #else    86     int dict_dummmy;    87 #endif    88 } dict_load_t;    89     90 extern dict_t *dict_create(dictcount_t, dict_comp_t);    91 extern void dict_set_allocator(dict_t *, dnode_alloc_t, dnode_free_t, void *);    92 extern void dict_set_cmp_context(dict_t *, void *);    93 extern void dict_destroy(dict_t *);    94 extern void dict_free_nodes(dict_t *);    95 extern void dict_free(dict_t *);    96 extern dict_t *dict_init(dict_t *, dictcount_t, dict_comp_t);    97 extern void dict_init_like(dict_t *, const dict_t *);    98 extern int dict_verify(dict_t *);    99 extern int dict_similar(const dict_t *, const dict_t *);   100 extern dnode_t *dict_lookup(dict_t *, const void *);   101 extern dnode_t *dict_lower_bound(dict_t *, const void *);   102 extern dnode_t *dict_upper_bound(dict_t *, const void *);   103 extern void dict_insert(dict_t *, dnode_t *, const void *);   104 extern dnode_t *dict_delete(dict_t *, dnode_t *);   105 extern int dict_alloc_insert(dict_t *, const void *, void *);   106 extern void dict_delete_free(dict_t *, dnode_t *);   107 extern dnode_t *dict_first(dict_t *);   108 extern dnode_t *dict_last(dict_t *);   109 extern dnode_t *dict_next(dict_t *, dnode_t *);   110 extern dnode_t *dict_prev(dict_t *, dnode_t *);   111 extern dictcount_t dict_count(dict_t *);   112 extern int dict_isempty(dict_t *);   113 extern int dict_isfull(dict_t *);   114 extern int dict_contains(dict_t *, dnode_t *);   115 extern void dict_allow_dupes(dict_t *);   116 extern int dnode_is_in_a_dict(dnode_t *);   117 extern dnode_t *dnode_create(void *);   118 extern dnode_t *dnode_init(dnode_t *, void *);   119 extern void dnode_destroy(dnode_t *);   120 extern void *dnode_get(dnode_t *);   121 extern const void *dnode_getkey(dnode_t *);   122 extern void dnode_put(dnode_t *, void *);   123 extern void dict_process(dict_t *, void *, dnode_process_t);   124 extern void dict_load_begin(dict_load_t *, dict_t *);   125 extern void dict_load_next(dict_load_t *, dnode_t *, const void *);   126 extern void dict_load_end(dict_load_t *);   127 extern void dict_merge(dict_t *, dict_t *);   128    129 #if defined(DICT_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)   130 #ifdef KAZLIB_SIDEEFFECT_DEBUG   131 #define dict_isfull(D) (SFX_CHECK(D)->dict_nodecount == (D)->dict_maxcount)   132 #else   133 #define dict_isfull(D) ((D)->dict_nodecount == (D)->dict_maxcount)   134 #endif   135 #define dict_count(D) ((D)->dict_nodecount)   136 #define dict_isempty(D) ((D)->dict_nodecount == 0)   137 #define dnode_get(N) ((N)->dict_data)   138 #define dnode_getkey(N) ((N)->dict_key)   139 #define dnode_put(N, X) ((N)->dict_data = (X))   140 #endif   141    142 #ifdef __cplusplus   143 }   144 #endif   145    146 #endif