Blame library/seq.h

Packit Service 6d40f9
/*
Packit Service 6d40f9
 * adcli
Packit Service 6d40f9
 *
Packit Service 6d40f9
 * Copyright (C) 2013 Red Hat Inc.
Packit Service 6d40f9
 *
Packit Service 6d40f9
 * This program is free software; you can redistribute it and/or modify
Packit Service 6d40f9
 * it under the terms of the GNU Lesser General Public License as
Packit Service 6d40f9
 * published by the Free Software Foundation; either version 2.1 of
Packit Service 6d40f9
 * the License, or (at your option) any later version.
Packit Service 6d40f9
 *
Packit Service 6d40f9
 * This program is distributed in the hope that it will be useful, but
Packit Service 6d40f9
 * WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 6d40f9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 6d40f9
 * Lesser General Public License for more details.
Packit Service 6d40f9
 *
Packit Service 6d40f9
 * You should have received a copy of the GNU Lesser General Public
Packit Service 6d40f9
 * License along with this program; if not, write to the Free Software
Packit Service 6d40f9
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
Packit Service 6d40f9
 * MA 02110-1301 USA
Packit Service 6d40f9
 *
Packit Service 6d40f9
 * Author: Stef Walter <stefw@redhat.com>
Packit Service 6d40f9
 */
Packit Service 6d40f9
Packit Service 6d40f9
#ifndef SEQ_H_
Packit Service 6d40f9
#define SEQ_H_
Packit Service 6d40f9
Packit Service 6d40f9
#ifdef __GNUC__
Packit Service 6d40f9
#define WARN_UNUSED __attribute__((warn_unused_result))
Packit Service 6d40f9
#else
Packit Service 6d40f9
#define WARN_UNUSED
Packit Service 6d40f9
#endif
Packit Service 6d40f9
Packit Service 6d40f9
/*
Packit Service 6d40f9
 * It's expected that callers will pass in their own arrays of
Packit Service 6d40f9
 * pointer values such as char ** in place of seq_voidp.
Packit Service 6d40f9
 * We use a typedef'd void* to avoid silly casts everywhere.
Packit Service 6d40f9
 */
Packit Service 6d40f9
typedef void *     seq_voidp;
Packit Service 6d40f9
Packit Service 6d40f9
typedef int        (* seq_compar)             (void *match,
Packit Service 6d40f9
                                               void *value);
Packit Service 6d40f9
Packit Service 6d40f9
typedef void *     (* seq_copy)               (void *value);
Packit Service 6d40f9
Packit Service 6d40f9
typedef void       (* seq_destroy)            (void *value);
Packit Service 6d40f9
Packit Service 6d40f9
seq_voidp          seq_push                   (seq_voidp seq,
Packit Service 6d40f9
                                               int *length,
Packit Service 6d40f9
                                               void *value) WARN_UNUSED;
Packit Service 6d40f9
Packit Service 6d40f9
#define            seq_at(seq, i)             (((void **)(seq))[(i)])
Packit Service 6d40f9
Packit Service 6d40f9
seq_voidp          seq_insert                 (seq_voidp seq,
Packit Service 6d40f9
                                               int *length,
Packit Service 6d40f9
                                               void *value,
Packit Service 6d40f9
                                               seq_compar compar,
Packit Service 6d40f9
                                               seq_destroy destroy);
Packit Service 6d40f9
Packit Service 6d40f9
void               seq_remove                 (seq_voidp seq,
Packit Service 6d40f9
                                               int *length,
Packit Service 6d40f9
                                               void *match,
Packit Service 6d40f9
                                               seq_compar compar,
Packit Service 6d40f9
                                               seq_destroy destroy);
Packit Service 6d40f9
Packit Service 6d40f9
seq_voidp          seq_lookup                 (seq_voidp seq,
Packit Service 6d40f9
                                               int *length,
Packit Service 6d40f9
                                               void *match,
Packit Service 6d40f9
                                               seq_compar compar);
Packit Service 6d40f9
Packit Service 6d40f9
void               seq_filter                 (seq_voidp seq,
Packit Service 6d40f9
                                               int *length,
Packit Service 6d40f9
                                               void *match,
Packit Service 6d40f9
                                               seq_compar compar,
Packit Service 6d40f9
                                               seq_destroy destroy);
Packit Service 6d40f9
Packit Service 6d40f9
int                seq_count                  (seq_voidp seq);
Packit Service 6d40f9
Packit Service 6d40f9
seq_voidp          seq_dup                    (seq_voidp seq,
Packit Service 6d40f9
                                               int *length,
Packit Service 6d40f9
                                               seq_copy copy);
Packit Service 6d40f9
Packit Service 6d40f9
void               seq_free                   (seq_voidp seq,
Packit Service 6d40f9
                                               seq_destroy destroy);
Packit Service 6d40f9
Packit Service 6d40f9
#endif /* SEQ_H_ */