textlist.h (2252B)
1 /* $Id$ */ 2 #ifndef TEXTLIST_H 3 #define TEXTLIST_H 4 #include "Str.h" 5 6 /* General doubly linked list */ 7 8 typedef struct _listitem { 9 void *ptr; 10 struct _listitem *next; 11 struct _listitem *prev; 12 } ListItem; 13 14 typedef struct _generallist { 15 ListItem *first; 16 ListItem *last; 17 short nitem; 18 } GeneralList; 19 20 extern ListItem *newListItem(void *s, ListItem *n, ListItem *p); 21 extern GeneralList *newGeneralList(void); 22 extern void pushValue(GeneralList *tl, void *s); 23 extern void *popValue(GeneralList *tl); 24 extern void *rpopValue(GeneralList *tl); 25 extern void delValue(GeneralList *tl, ListItem *it); 26 extern GeneralList *appendGeneralList(GeneralList *, GeneralList *); 27 28 /* Text list */ 29 30 typedef struct _textlistitem { 31 char *ptr; 32 struct _textlistitem *next; 33 struct _textlistitem *prev; 34 } TextListItem; 35 36 typedef struct _textlist { 37 TextListItem *first; 38 TextListItem *last; 39 short nitem; 40 } TextList; 41 42 #define newTextList() ((TextList *)newGeneralList()) 43 #define pushText(tl, s) pushValue((GeneralList *)(tl), (void *)allocStr((s),-1)) 44 #define popText(tl) ((char *)popValue((GeneralList *)(tl))) 45 #define rpopText(tl) ((char *)rpopValue((GeneralList *)(tl))) 46 #define delText(tl, i) delValue((GeneralList *)(tl), (void *)(i)) 47 #define appendTextList(tl, tl2) ((TextList *)appendGeneralList((GeneralList *)(tl), (GeneralList *)(tl2))) 48 49 /* Line text list */ 50 51 typedef struct _TextLine { 52 Str line; 53 short pos; 54 } TextLine; 55 56 typedef struct _textlinelistitem { 57 TextLine *ptr; 58 struct _textlinelistitem *next; 59 struct _textlinelistitem *prev; 60 } TextLineListItem; 61 62 typedef struct _textlinelist { 63 TextLineListItem *first; 64 TextLineListItem *last; 65 short nitem; 66 } TextLineList; 67 68 extern TextLine *newTextLine(Str line, int pos); 69 extern void appendTextLine(TextLineList *tl, Str line, int pos); 70 #define newTextLineList() ((TextLineList *)newGeneralList()) 71 #define pushTextLine(tl,lbuf) pushValue((GeneralList *)(tl),(void *)(lbuf)) 72 #define popTextLine(tl) ((TextLine *)popValue((GeneralList *)(tl))) 73 #define rpopTextLine(tl) ((TextLine *)rpopValue((GeneralList *)(tl))) 74 #define appendTextLineList(tl, tl2) ((TextLineList *)appendGeneralList((GeneralList *)(tl), (GeneralList *)(tl2))) 75 76 #endif /* not TEXTLIST_H */