"Fossies" - the Fresh Open Source Software Archive

Member "msmtp-1.8.5/src/list.h" (13 Dec 2018, 2416 Bytes) of package /linux/privat/msmtp-1.8.5.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "list.h" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 1.8.1_vs_1.8.2.

    1 /*
    2  * list.h
    3  *
    4  * This file is part of msmtp, an SMTP client, and of mpop, a POP3 client.
    5  *
    6  * Copyright (C) 2000, 2003, 2004, 2005, 2007
    7  * Martin Lambers <marlam@marlam.de>
    8  *
    9  *   This program is free software; you can redistribute it and/or modify
   10  *   it under the terms of the GNU General Public License as published by
   11  *   the Free Software Foundation; either version 3 of the License, or
   12  *   (at your option) any later version.
   13  *
   14  *   This program is distributed in the hope that it will be useful,
   15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
   16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   17  *   GNU General Public License for more details.
   18  *
   19  *   You should have received a copy of the GNU General Public License
   20  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
   21  */
   22 
   23 #ifndef LIST_H
   24 #define LIST_H
   25 
   26 /*
   27  * A list element stores a pointer to arbitrary data. A list consists of
   28  * at least one head element and one foot element, both without data
   29  * (pointer data = NULL). foot->next points to foot.
   30  */
   31 
   32 typedef struct _list
   33 {
   34     void *data;
   35     struct _list *next;
   36 } list_t;
   37 
   38 
   39 /*
   40  * All list functions use xmalloc() and friends, so they cannot fail.
   41  */
   42 
   43 
   44 /*
   45  * Creates a new, empty list. Returns the pointer to the head element.
   46  */
   47 list_t *list_new(void);
   48 
   49 /*
   50  * Deletes a complete list, freeing its memory. Needs the head element
   51  * as parameter. See also list_xfree().
   52  */
   53 void list_free(list_t *head);
   54 
   55 /*
   56  * Deletes a complete list, freeing its memory and calling destruct() on
   57  * every data pointer in it. Needs the head element as parameter.
   58  * See also list_free().
   59  */
   60 void list_xfree(list_t *head, void (*destruct)(void *));
   61 
   62 /*
   63  * Inserts a new list element storing the pointer data behind the element e.
   64  */
   65 void list_insert(list_t *e, void *data);
   66 
   67 /*
   68  * Removes the list element behind element e from the list.
   69  * See also list_xremove().
   70  */
   71 void list_remove(list_t *e);
   72 
   73 /*
   74  * Removes the list element behind element e from the list and does a free()
   75  * on the data pointer in this element. See also list_remove().
   76  */
   77 void list_xremove(list_t *e, void (*destruct)(void *));
   78 
   79 /*
   80  * Returns 1 if the list is empty, 0 otherwise. Needs a pointer to the head
   81  * element of the list.
   82  */
   83 int list_is_empty(list_t *head);
   84 
   85 /*
   86  * Returns a pointer to the last element of the list.
   87  */
   88 list_t *list_last(list_t *e);
   89 
   90 #endif