1 /* 2 3 W3C Sample Code Library libwww HISTORY 4 5 6 7 8 !History Manager! 9 10 */ 11 12 /* 13 ** (c) COPYRIGHT MIT 1995. 14 ** Please first read the full copyright statement in the file COPYRIGH. 15 */ 16 17 /* 18 19 This is a simple history module for a WWW client. It keeps a linear 20 history, with a destructive or non-destructive backtrack, and 21 list sequencing (previous, next) operations. 22 23 If you are building a client, you don't have to use this: just don't 24 call it. This module is not used by any other modules in the libwww, 25 so if you don't refer to it you don't get it in your linked 26 application. 27 28 This module is implemented by HTHist.c, and it 29 is a part of the 30 W3C Sample Code Library. 31 32 */ 33 34 #ifndef HTHISTORY_H 35 #define HTHISTORY_H 36 37 #include "HTAnchor.h" 38 39 #ifdef __cplusplus 40 extern "C" { 41 #endif 42 43 /* 44 45 .Creation and Deletion Methods. 46 47 The history module can handle multiple history lists which can be 48 useful in a multithreaded environment with several open windows in the 49 client application. A new histrory lidt is referenced by the handle 50 returned from the creation method. 51 52 */ 53 54 typedef struct _HTHistory HTHistory; 55 56 extern HTHistory *HTHistory_new (void); 57 extern BOOL HTHistory_delete (HTHistory *old); 58 59 /* 60 61 .Add and delete History Elements. 62 63 (Record an entry in a list) 64 65 Registers the object in the linear list. The first entry is the home 66 page. No check is done for duplicates. Returns YES if ok, else NO 67 68 */ 69 70 extern BOOL HTHistory_record (HTHistory *hist, HTAnchor *cur); 71 72 /* 73 74 (Replace list with new element) 75 76 Iserts the new element at the current position and removes all any 77 old list from current position. For example if c is cur pos 78 79 o before: a b c d e 80 o after : a b f 81 82 Returns YES if ok, else NO 83 84 */ 85 86 extern BOOL HTHistory_replace (HTHistory *hist, HTAnchor *cur); 87 88 /* 89 90 (Delete last entry in a list) 91 92 Deletes the last object from the list Returns YES if OK, else NO 93 94 */ 95 96 extern BOOL HTHistory_removeLast (HTHistory *hist); 97 98 /* 99 100 (Remove the History list from position) 101 102 Deletes the history list FROM the entry at position 'cur' (excluded). 103 Home page has position 1. Returns YES if OK, else NO 104 105 */ 106 107 extern BOOL HTHistory_removeFrom (HTHistory *hist, int pos); 108 109 /* 110 111 (Number of elements stored) 112 113 Returns the size of the history list or -1 if none. 114 115 */ 116 117 extern int HTHistory_count (HTHistory *hist); 118 119 /* 120 121 (Current Position) 122 123 Returns the current position or -1 on error 124 125 */ 126 127 extern int HTHistory_position (HTHistory *hist); 128 129 /* 130 131 (Find and re-register visited anchor) 132 133 Finds already registered anchor at given position and registers it 134 again EXCEPT if last entry. This allows for `circular' history lists 135 with duplicate entries. Position 1 is the home anchor. The current 136 position is updated. 137 138 */ 139 140 extern HTAnchor * HTHistory_recall (HTHistory *hist, int pos); 141 142 /* 143 144 (Find Entry at position) 145 146 Entry with the given index in the list (1 is the home page). Like 147 HTHistory_recall but without re-registration. Un success, 148 the current position is updated to the value 'pos' value. 149 150 */ 151 152 extern HTAnchor * HTHistory_find (HTHistory *hist, int pos); 153 154 /* 155 156 (List the History List) 157 158 This function is like HTHistory_find() but does 159 not update the current position 160 161 */ 162 163 extern HTAnchor * HTHistory_list (HTHistory *hist, int pos); 164 165 /* 166 167 .Navigation. 168 169 (Can we back in history) 170 171 Returns YES if the current anchor is not the first entry (home page) 172 173 */ 174 175 extern BOOL HTHistory_canBacktrack (HTHistory *hist); 176 177 /* 178 179 (Backtrack with deletion) 180 181 Returns the previous object and erases the last object. This does not 182 allow for 'forward' as we are always at the end of the list. If no 183 previous object exists, NULL is returned so that the application knows 184 that no previous object was found. See also HTHistory_back(). 185 186 */ 187 188 extern HTAnchor * HTHistory_backtrack (HTHistory *hist); 189 190 /* 191 192 (Backtrack without deletion) 193 194 Returns the previos object but does not erase the last object. This 195 does not allow for 'forward'. If no previous object exists, NULL is 196 returned so that the application knows that no previous object was 197 found. See also HTHistory_backtrack() 198 199 */ 200 201 extern HTAnchor * HTHistory_back (HTHistory *hist); 202 203 /* 204 205 (Can we go forward) 206 207 Returns YES if the current anchor is not the last entry 208 209 */ 210 211 extern BOOL HTHistory_canForward (HTHistory *hist); 212 213 /* 214 215 (Forward) 216 217 Return the next object in the list or NULL if none 218 219 */ 220 221 extern HTAnchor * HTHistory_forward (HTHistory *hist); 222 223 #ifdef __cplusplus 224 } 225 #endif 226 227 #endif /* HTHISTORY_H */ 228 229 /* 230 231 232 233 @(#) $Id$ 234 235 236 */ 237