about summary refs log tree commit diff stats
path: root/WWW/Library/Implementation/HTList.h
blob: 93f91473212a2e7aa39d34199c86d9c44f25cb87 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*              List object
 *
 *      The list object is a generic container for storing collections
 *      of things in order.
 */
#ifndef HTLIST_H
#define HTLIST_H

#ifndef HTUTILS_H
#include <HTUtils.h>
#endif

#ifdef __cplusplus
extern "C" {
#endif
    typedef struct _HTList HTList;

    struct _HTList {
	void *object;
	HTList *next;
    };

/*	Fast macro to traverse a list.  Call it first with copy of the list
 *	header.  It returns the first object and increments the passed list
 *	pointer.  Call it with the same variable until it returns NULL.
 */
#define HTList_nextObject(me) \
	((me) && ((me) = (me)->next) ? (me)->object : NULL)

/*	Macro to find object pointed to by the head (returns NULL
 *	if list is empty, OR if it doesn't exist - Yuk!)
 */
#define HTList_lastObject(me) \
	((me) && (me)->next ? (me)->next->object : NULL)

/*	Macro to check if a list is empty (or doesn't exist - Yuk!)
*/
#define HTList_isEmpty(me) ((me) ? ((me)->next == NULL) : YES)

/*	Create list.
*/
    extern HTList *HTList_new(void);

/*	Delete list.
*/
    extern void HTList_delete(HTList *me);

/*	Reverse a list.
*/
    extern HTList *HTList_reverse(HTList *start);

/*	Append two lists, making second list empty.
*/
    extern HTList *HTList_appendList(HTList *start,
				     HTList *tail);

/*      Add object to START of list (so it is pointed to by the head).
*/
    extern void HTList_addObject(HTList *me,
				 void *newObject);

/*      Append object to END of list (furthest from the head).
*/
    extern void HTList_appendObject(HTList *me,
				    void *newObject);

/*	Insert an object into the list at a specified position.
 *      If position is 0, this places the object at the head of the list
 *      and is equivalent to HTList_addObject().
 */
    extern void HTList_insertObjectAt(HTList *me,
				      void *newObject,
				      int pos);

/*	Remove specified object from list.
*/
    extern BOOL HTList_removeObject(HTList *me,
				    void *oldObject);

/*	Remove object at a given position in the list, where 0 is the
 *	object pointed to by the head (returns a pointer to the element
 *	(->object) for the object, and NULL if the list is empty, or
 *	if it doesn't exist - Yuk!).
 */
    extern void *HTList_removeObjectAt(HTList *me,
				       int position);

/*	Remove object from START of list (the Last one inserted
 *	via HTList_addObject(), and pointed to by the head).
 */
    extern void *HTList_removeLastObject(HTList *me);

/*	Remove object from END of list (the First one inserted
 *	via HTList_addObject(), and furthest from the head).
 */
    extern void *HTList_removeFirstObject(HTList *me);

/*	Determine total number of objects in the list,
 *	not counting the head.
 */
    extern int HTList_count(HTList *me);

/*	Determine position of an object in the list (a value of 0
 *	means it is pointed to by the head; returns -1 if not found).
 */
    extern int HTList_indexOf(HTList *me,
			      void *object);

/*	Return pointer to the object at a specified position in the list,
 *	where 0 is the object pointed to by the head (returns NULL if
 *	the list is empty, or if it doesn't exist - Yuk!).
 */
    extern void *HTList_objectAt(HTList *me,
				 int position);

/*      Link object to START of list (so it is pointed to by the head).
 *
 *      Unlike HTList_addObject(), it does not malloc memory for HTList entry,
 *	it use already allocated memory which should not be free'd by any
 *	list operations (optimization).
 */
    extern void HTList_linkObject(HTList *me,
				  void *newObject,
				  HTList *newNode);

/*	Unlink object from START of list (the Last one inserted
 *	via HTList_linkObject(), and pointed to by the head).
 *	It does not free memory.
 */
    extern void *HTList_unlinkLastObject(HTList *me);

/*	Unlink specified object from list.
 *	It does not free memory.
 */
    extern BOOL HTList_unlinkObject(HTList *me,
				    void *oldObject);

#ifdef __cplusplus
}
#endif
#endif				/* HTLIST_H */
w"> 244, COLOR_SELECTABLE_FOREGROUND = 238, COLOR_SELECTABLE_BACKGROUND = 250, COLOR_ERROR_FOREGROUND = COLOR_FOREGROUND, COLOR_ERROR_BACKGROUND = 124, /* deep red */ COLOR_SAFE_NORMAL = 46, /* green */ COLOR_SAFE_REVERSE = 28, /* green */ COLOR_WARN_NORMAL = 208, /* orange */ COLOR_WARN_REVERSE = 130, /* orange */ COLOR_RISK_NORMAL = 196, /* red */ COLOR_RISK_REVERSE = 196, /* red */ COLOR_LUA_COMMENT = 39, /* blue */ COLOR_LUA_KEYWORD = 172, /* orange */ COLOR_LUA_CONSTANT = 37, /* cyan */ COLOR_MATCH_FOREGROUND = COLOR_BACKGROUND, COLOR_MATCH_BACKGROUND = 28, /* green */ }; #elif COLOR_SCHEME == 2 /* Solarized dark. */ enum color { COLOR_FOREGROUND = 250, /* almost white */ COLOR_BACKGROUND = 24, /* dark blue-green */ COLOR_FADE = 246, /* closer to background */ COLOR_MENU_ALTERNATE = 244, COLOR_SELECTABLE_FOREGROUND = 250, COLOR_SELECTABLE_BACKGROUND = 31, COLOR_ERROR_FOREGROUND = 250, COLOR_ERROR_BACKGROUND = 124, /* deep red */ COLOR_SAFE_NORMAL = 46, /* green */ COLOR_SAFE_REVERSE = 28, /* green */ COLOR_WARN_NORMAL = 208, /* orange */ COLOR_WARN_REVERSE = 130, /* orange */ COLOR_RISK_NORMAL = 201, /* red */ COLOR_RISK_REVERSE = 196, /* red */ COLOR_LUA_COMMENT = 45, /* light blue */ COLOR_LUA_KEYWORD = 172, /* orange */ COLOR_LUA_CONSTANT = 37, /* cyan */ COLOR_MATCH_FOREGROUND = COLOR_FOREGROUND, COLOR_MATCH_BACKGROUND = 125, /* magenta */ }; #endif enum color_pair { COLOR_PAIR_NORMAL = 0, COLOR_PAIR_SELECTABLE = 1, COLOR_PAIR_FADE = 2, COLOR_PAIR_MENU_ALTERNATE = 3, COLOR_PAIR_LUA_COMMENT = 4, COLOR_PAIR_LUA_KEYWORD = 5, COLOR_PAIR_LUA_CONSTANT = 6, COLOR_PAIR_MATCH = 7, COLOR_PAIR_SAFE = 251, /* reserved for teliva; apps shouldn't use it */ COLOR_PAIR_WARN = 252, /* reserved for teliva; apps shouldn't use it */ COLOR_PAIR_RISK = 253, /* reserved for teliva; apps shouldn't use it */ COLOR_PAIR_MENU = 254, /* reserved for teliva; apps shouldn't use it */ COLOR_PAIR_ERROR = 255, /* reserved for teliva; apps shouldn't use it */ }; /*** C Interface */ /* Each category of primitives below shows a few options from high to low * levels of abstraction. * (Lower levels aren't complete or well-designed, just what code outside * teliva.c needs.) */ /* Integrate with Lua VM */ extern char** Argv; extern char* Previous_message; extern int load_image(lua_State* L, char** argv, int n); extern void developer_mode(lua_State* L); extern void permissions_mode(lua_State* L); extern int file_operation_permitted(const char* filename, const char* mode); extern int net_operations_permitted; extern void load_editor_buffer_to_current_definition_in_image(lua_State* L); extern int load_editor_buffer_to_current_definition_in_image_and_reload(lua_State* L); extern void save_to_current_definition_and_editor_buffer(lua_State* L, const char* definition); extern void save_editor_state(int rowoff, int coloff, int cy, int cx); int editor_view_in_progress(lua_State* L); extern void assign_call_graph_depth_to_name(lua_State* L, int depth, const char* name); extern char* get_caller(lua_State* L); extern void save_caller(lua_State* L, const char* name, int call_graph_depth); extern void draw_callers_of_current_definition(lua_State* L); extern char* get_caller_of_caller(lua_State* L); extern void append_to_audit_log(lua_State* L, const char* buffer); /* Standard UI elements */ extern void render_trusted_teliva_data(lua_State* L); extern void draw_menu_item(const char* key, const char* name); extern void draw_string_on_menu(const char* s); extern int menu_column; extern const char* character_name(char c); /* Error reporting */ extern const char* Previous_error; extern int report_in_developer_mode(lua_State* L, int status); extern void render_previous_error(void); /* Misc */ extern int starts_with(const char* s, const char* prefix); #endif