Back to index

tetex-bin  3.0
str-llist.h
Go to the documentation of this file.
00001 /* str-llist.h: A linked list of strings,
00002 
00003 It's pretty disgusting that both this and str-list exist; the reason is
00004 that C cannot express iterators very well, and I don't want to change
00005 all the for loops right now.
00006 
00007 Copyright (C) 1993, 94 Karl Berry.
00008 
00009 This library is free software; you can redistribute it and/or
00010 modify it under the terms of the GNU Library General Public
00011 License as published by the Free Software Foundation; either
00012 version 2 of the License, or (at your option) any later version.
00013 
00014 This library is distributed in the hope that it will be useful,
00015 but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 Library General Public License for more details.
00018 
00019 You should have received a copy of the GNU Library General Public
00020 License along with this library; if not, write to the Free Software
00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
00022 
00023 #ifndef STR_LLIST_H
00024 #define STR_LLIST_H
00025 
00026 #include <kpathsea/c-proto.h>
00027 #include <kpathsea/types.h>
00028 
00029 
00030 /* It's a little bizarre to be using the same type for the list and the
00031    elements of the list, but no reason not to in this case, I think --
00032    we never need a NULL string in the middle of the list, and an extra
00033    NULL/NULL element always at the end is inconsequential.  */
00034 
00035 struct str_llist_elt
00036 {
00037   string str;
00038   boolean moved;
00039   struct str_llist_elt *next;
00040 };
00041 typedef struct str_llist_elt str_llist_elt_type;
00042 typedef struct str_llist_elt *str_llist_type;
00043 
00044 #define STR_LLIST(sl) ((sl).str)
00045 #define STR_LLIST_MOVED(sl) ((sl).moved)
00046 #define STR_LLIST_NEXT(sl) ((sl).next)
00047 
00048 
00049 /* Add the new string E to the end of the list L.  */
00050 extern void str_llist_add P2H(str_llist_type *l, string e);
00051 
00052 /* Reorganize L so that E is below only other elements that have already
00053    been moved.  Set `moved' member for E.  */
00054 extern void str_llist_float P2H(str_llist_type *l, str_llist_elt_type *e);
00055 
00056 #endif /* not STR_LLIST_H */