Crash landing of the fix for bug #472883: BSD curses.h allready declares LL.
This commit is contained in:
@@ -348,7 +348,7 @@ mem_top_screen (int rep, int display)
|
|||||||
int threshold = 400, unique;
|
int threshold = 400, unique;
|
||||||
int i;
|
int i;
|
||||||
proc_mem_info *p;
|
proc_mem_info *p;
|
||||||
LL *procs;
|
LinkedList *procs;
|
||||||
static int first = 1;
|
static int first = 1;
|
||||||
|
|
||||||
if (first) {
|
if (first) {
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ typedef struct client_data {
|
|||||||
int ack;
|
int ack;
|
||||||
char *name;
|
char *name;
|
||||||
// and other stuff... doesn't matter yet
|
// and other stuff... doesn't matter yet
|
||||||
LL *screenlist;
|
LinkedList *screenlist;
|
||||||
// list of requested keys...
|
// list of requested keys...
|
||||||
char *client_keys ;
|
char *client_keys ;
|
||||||
LL *menulist;
|
LinkedList *menulist;
|
||||||
|
|
||||||
} client_data;
|
} client_data;
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@
|
|||||||
#include "client_data.h"
|
#include "client_data.h"
|
||||||
#include "shared/debug.h"
|
#include "shared/debug.h"
|
||||||
|
|
||||||
LL *clients;
|
LinkedList *clients;
|
||||||
|
|
||||||
// Initialize and kill client list...
|
// Initialize and kill client list...
|
||||||
int
|
int
|
||||||
|
|||||||
+2
-2
@@ -7,12 +7,12 @@
|
|||||||
typedef struct client {
|
typedef struct client {
|
||||||
int sock;
|
int sock;
|
||||||
char addr[64];
|
char addr[64];
|
||||||
LL *messages;
|
LinkedList *messages;
|
||||||
client_data *data;
|
client_data *data;
|
||||||
|
|
||||||
} client;
|
} client;
|
||||||
|
|
||||||
extern LL *clients;
|
extern LinkedList *clients;
|
||||||
|
|
||||||
// Initialize and kill client list...
|
// Initialize and kill client list...
|
||||||
int client_init ();
|
int client_init ();
|
||||||
|
|||||||
+1
-1
@@ -25,7 +25,7 @@
|
|||||||
// lcd.h is used for the driver API definition
|
// lcd.h is used for the driver API definition
|
||||||
|
|
||||||
|
|
||||||
LL * loaded_drivers = NULL;
|
LinkedList * loaded_drivers = NULL;
|
||||||
|
|
||||||
long int empty_function() { return 0; }
|
long int empty_function() { return 0; }
|
||||||
|
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ lcd_physical_driver drivers[] = {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
LL *list;
|
LinkedList *list;
|
||||||
|
|
||||||
#define CurrentDriver (drivers[i].name)
|
#define CurrentDriver (drivers[i].name)
|
||||||
#define NextDriver (drivers[i+1].name)
|
#define NextDriver (drivers[i+1].name)
|
||||||
|
|||||||
+2
-2
@@ -41,7 +41,7 @@ static int reset;
|
|||||||
|
|
||||||
#define BUFSIZE 1024
|
#define BUFSIZE 1024
|
||||||
|
|
||||||
static int draw_frame (LL * list, char fscroll, int left, int top, int right, int bottom, int fwid, int fhgt, int fspeed, int timer);
|
static int draw_frame (LinkedList * list, char fscroll, int left, int top, int right, int bottom, int fwid, int fhgt, int fspeed, int timer);
|
||||||
|
|
||||||
int
|
int
|
||||||
draw_screen (screen * s, int timer)
|
draw_screen (screen * s, int timer)
|
||||||
@@ -145,7 +145,7 @@ draw_screen (screen * s, int timer)
|
|||||||
// Best thing to do is to remove support for frames... but anyway...
|
// Best thing to do is to remove support for frames... but anyway...
|
||||||
//
|
//
|
||||||
static int
|
static int
|
||||||
draw_frame (LL * list,
|
draw_frame (LinkedList * list,
|
||||||
char fscroll, // direction of scrolling
|
char fscroll, // direction of scrolling
|
||||||
int left, // left edge of frame
|
int left, // left edge of frame
|
||||||
int top, // top edge of frame
|
int top, // top edge of frame
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ typedef struct screen {
|
|||||||
int duration;
|
int duration;
|
||||||
int heartbeat;
|
int heartbeat;
|
||||||
char *keys;
|
char *keys;
|
||||||
LL *widgets;
|
LinkedList *widgets;
|
||||||
client *parent;
|
client *parent;
|
||||||
} screen;
|
} screen;
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -13,7 +13,7 @@ int screenlist_action = 0;
|
|||||||
|
|
||||||
int timer = 0;
|
int timer = 0;
|
||||||
|
|
||||||
LL *screenlist;
|
LinkedList *screenlist;
|
||||||
|
|
||||||
int screenlist_add_end (screen * screen);
|
int screenlist_add_end (screen * screen);
|
||||||
screen *screenlist_next_roll ();
|
screen *screenlist_next_roll ();
|
||||||
@@ -76,7 +76,7 @@ screenlist_remove_all (screen * s)
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
LL *
|
LinkedList *
|
||||||
screenlist_getlist ()
|
screenlist_getlist ()
|
||||||
{
|
{
|
||||||
debug ("screenlist_getlist()\n");
|
debug ("screenlist_getlist()\n");
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ extern int timer;
|
|||||||
int screenlist_init ();
|
int screenlist_init ();
|
||||||
int screenlist_shutdown ();
|
int screenlist_shutdown ();
|
||||||
|
|
||||||
LL *screenlist_getlist ();
|
LinkedList *screenlist_getlist ();
|
||||||
screen *screenlist_current ();
|
screen *screenlist_current ();
|
||||||
|
|
||||||
int screenlist_add (screen * s);
|
int screenlist_add (screen * s);
|
||||||
|
|||||||
+7
-7
@@ -22,8 +22,8 @@ char *types[] = { "none",
|
|||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
static widget *widget_finder (LL * list, char *id);
|
static widget *widget_finder (LinkedList * list, char *id);
|
||||||
static int widget_remover (LL * list, widget * w);
|
static int widget_remover (LinkedList * list, widget * w);
|
||||||
|
|
||||||
widget *
|
widget *
|
||||||
widget_create ()
|
widget_create ()
|
||||||
@@ -59,7 +59,7 @@ widget_create ()
|
|||||||
int
|
int
|
||||||
widget_destroy (widget * w)
|
widget_destroy (widget * w)
|
||||||
{
|
{
|
||||||
LL *list;
|
LinkedList *list;
|
||||||
widget *foo;
|
widget *foo;
|
||||||
|
|
||||||
if (!w)
|
if (!w)
|
||||||
@@ -110,7 +110,7 @@ widget_find (screen * s, char *id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
widget *
|
widget *
|
||||||
widget_finder (LL * list, char *id)
|
widget_finder (LinkedList * list, char *id)
|
||||||
{
|
{
|
||||||
widget *w, *err;
|
widget *w, *err;
|
||||||
|
|
||||||
@@ -153,7 +153,7 @@ widget_add (screen * s, char *id, char *type, char *in, int sock)
|
|||||||
int valid = 0;
|
int valid = 0;
|
||||||
int wid_type = 0;
|
int wid_type = 0;
|
||||||
widget *w, *parent;
|
widget *w, *parent;
|
||||||
LL *list;
|
LinkedList *list;
|
||||||
|
|
||||||
debug ("widget_add(%s, %s, %s)\n", id, type, in);
|
debug ("widget_add(%s, %s, %s)\n", id, type, in);
|
||||||
|
|
||||||
@@ -249,7 +249,7 @@ int
|
|||||||
widget_remove (screen * s, char *id, int sock)
|
widget_remove (screen * s, char *id, int sock)
|
||||||
{
|
{
|
||||||
widget *w;
|
widget *w;
|
||||||
LL *list;
|
LinkedList *list;
|
||||||
|
|
||||||
debug ("widget_remove(%s)\n", id);
|
debug ("widget_remove(%s)\n", id);
|
||||||
|
|
||||||
@@ -286,7 +286,7 @@ widget_remove (screen * s, char *id, int sock)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
widget_remover (LL * list, widget * w)
|
widget_remover (LinkedList * list, widget * w)
|
||||||
{
|
{
|
||||||
widget *foo, *bar;
|
widget *foo, *bar;
|
||||||
int err;
|
int err;
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ typedef struct widget {
|
|||||||
int length; // size or direction
|
int length; // size or direction
|
||||||
int speed; // For scroller...
|
int speed; // For scroller...
|
||||||
char *text; // text or binary data
|
char *text; // text or binary data
|
||||||
LL *kids; // Frames can contain more widgets...
|
LinkedList *kids; // Frames can contain more widgets...
|
||||||
} widget;
|
} widget;
|
||||||
|
|
||||||
// These correspond to the index into the "types" array...
|
// These correspond to the index into the "types" array...
|
||||||
|
|||||||
+33
-33
@@ -11,12 +11,12 @@
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Creates a new list...
|
// Creates a new list...
|
||||||
LL *
|
LinkedList *
|
||||||
LL_new ()
|
LL_new ()
|
||||||
{
|
{
|
||||||
LL *list;
|
LinkedList *list;
|
||||||
|
|
||||||
list = malloc (sizeof (LL));
|
list = malloc (sizeof (LinkedList));
|
||||||
if (!list)
|
if (!list)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ LL_new ()
|
|||||||
// Destroys the entire list
|
// Destroys the entire list
|
||||||
// Warning! Does not free the list data! (only the list itself)
|
// Warning! Does not free the list data! (only the list itself)
|
||||||
int
|
int
|
||||||
LL_Destroy (LL * list)
|
LL_Destroy (LinkedList * list)
|
||||||
{
|
{
|
||||||
LL_node *node, *next;
|
LL_node *node, *next;
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ LL_node_DestroyData (LL_node * node)
|
|||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Returns to the beginning of the list...
|
// Returns to the beginning of the list...
|
||||||
int
|
int
|
||||||
LL_Rewind (LL * list)
|
LL_Rewind (LinkedList * list)
|
||||||
{
|
{
|
||||||
if (!list)
|
if (!list)
|
||||||
return -1;
|
return -1;
|
||||||
@@ -136,7 +136,7 @@ LL_Rewind (LL * list)
|
|||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Goes to the end of the list...
|
// Goes to the end of the list...
|
||||||
int
|
int
|
||||||
LL_End (LL * list)
|
LL_End (LinkedList * list)
|
||||||
{
|
{
|
||||||
if (!list)
|
if (!list)
|
||||||
return -1;
|
return -1;
|
||||||
@@ -152,7 +152,7 @@ LL_End (LL * list)
|
|||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Go to the next node
|
// Go to the next node
|
||||||
int
|
int
|
||||||
LL_Next (LL * list)
|
LL_Next (LinkedList * list)
|
||||||
{
|
{
|
||||||
if (!list)
|
if (!list)
|
||||||
return -1;
|
return -1;
|
||||||
@@ -170,7 +170,7 @@ LL_Next (LL * list)
|
|||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Go to the previous node
|
// Go to the previous node
|
||||||
int
|
int
|
||||||
LL_Prev (LL * list)
|
LL_Prev (LinkedList * list)
|
||||||
{
|
{
|
||||||
if (!list)
|
if (!list)
|
||||||
return -1;
|
return -1;
|
||||||
@@ -188,7 +188,7 @@ LL_Prev (LL * list)
|
|||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Data manipulation
|
// Data manipulation
|
||||||
void *
|
void *
|
||||||
LL_Get (LL * list)
|
LL_Get (LinkedList * list)
|
||||||
{
|
{
|
||||||
if (!list)
|
if (!list)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -200,7 +200,7 @@ LL_Get (LL * list)
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
int
|
int
|
||||||
LL_Put (LL * list, void *data)
|
LL_Put (LinkedList * list, void *data)
|
||||||
{
|
{
|
||||||
if (!list)
|
if (!list)
|
||||||
return -1;
|
return -1;
|
||||||
@@ -214,7 +214,7 @@ LL_Put (LL * list, void *data)
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
LL_node *
|
LL_node *
|
||||||
LL_GetNode (LL * list)
|
LL_GetNode (LinkedList * list)
|
||||||
{
|
{
|
||||||
if (!list)
|
if (!list)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -225,7 +225,7 @@ LL_GetNode (LL * list)
|
|||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Don't use this unless you know what you're doing.
|
// Don't use this unless you know what you're doing.
|
||||||
int
|
int
|
||||||
LL_PutNode (LL * list, LL_node * node)
|
LL_PutNode (LinkedList * list, LL_node * node)
|
||||||
{
|
{
|
||||||
if (!list)
|
if (!list)
|
||||||
return -1;
|
return -1;
|
||||||
@@ -239,7 +239,7 @@ LL_PutNode (LL * list, LL_node * node)
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
void *
|
void *
|
||||||
LL_GetFirst (LL * list) // gets data from first node
|
LL_GetFirst (LinkedList * list) // gets data from first node
|
||||||
{
|
{
|
||||||
if (!list)
|
if (!list)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -253,7 +253,7 @@ LL_GetFirst (LL * list) // gets data from first node
|
|||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
void *
|
void *
|
||||||
LL_GetNext (LL * list) // ... next node
|
LL_GetNext (LinkedList * list) // ... next node
|
||||||
{
|
{
|
||||||
if (!list)
|
if (!list)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -266,7 +266,7 @@ LL_GetNext (LL * list) // ... next node
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
void *
|
void *
|
||||||
LL_GetPrev (LL * list) // ... prev node
|
LL_GetPrev (LinkedList * list) // ... prev node
|
||||||
{
|
{
|
||||||
if (!list)
|
if (!list)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -279,7 +279,7 @@ LL_GetPrev (LL * list) // ... prev node
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
void *
|
void *
|
||||||
LL_GetLast (LL * list) // ... last node
|
LL_GetLast (LinkedList * list) // ... last node
|
||||||
{
|
{
|
||||||
if (!list)
|
if (!list)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -292,7 +292,7 @@ LL_GetLast (LL * list) // ... last node
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
int
|
int
|
||||||
LL_AddNode (LL * list, void *add) // Adds node AFTER current one
|
LL_AddNode (LinkedList * list, void *add) // Adds node AFTER current one
|
||||||
{
|
{
|
||||||
LL_node *node;
|
LL_node *node;
|
||||||
|
|
||||||
@@ -348,7 +348,7 @@ LL_AddNode (LL * list, void *add) // Adds node AFTER current one
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
int
|
int
|
||||||
LL_InsertNode (LL * list, void *add) // Adds node BEFORE current one
|
LL_InsertNode (LinkedList * list, void *add) // Adds node BEFORE current one
|
||||||
{
|
{
|
||||||
LL_node *node;
|
LL_node *node;
|
||||||
|
|
||||||
@@ -384,7 +384,7 @@ LL_InsertNode (LL * list, void *add) // Adds node BEFORE current one
|
|||||||
// Removes a node from the link
|
// Removes a node from the link
|
||||||
// ... and advances one node forward
|
// ... and advances one node forward
|
||||||
void *
|
void *
|
||||||
LL_DeleteNode (LL * list)
|
LL_DeleteNode (LinkedList * list)
|
||||||
{
|
{
|
||||||
LL_node *next, *prev;
|
LL_node *next, *prev;
|
||||||
void *data;
|
void *data;
|
||||||
@@ -434,7 +434,7 @@ LL_DeleteNode (LL * list)
|
|||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Removes a specific node...
|
// Removes a specific node...
|
||||||
void *
|
void *
|
||||||
LL_Remove (LL * list, void *data)
|
LL_Remove (LinkedList * list, void *data)
|
||||||
{
|
{
|
||||||
void *find;
|
void *find;
|
||||||
|
|
||||||
@@ -454,7 +454,7 @@ LL_Remove (LL * list, void *data)
|
|||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Stack operations
|
// Stack operations
|
||||||
int
|
int
|
||||||
LL_Push (LL * list, void *add) // Add node to end of list
|
LL_Push (LinkedList * list, void *add) // Add node to end of list
|
||||||
{
|
{
|
||||||
if (!list)
|
if (!list)
|
||||||
return -1;
|
return -1;
|
||||||
@@ -470,7 +470,7 @@ LL_Push (LL * list, void *add) // Add node to end of list
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
void *
|
void *
|
||||||
LL_Pop (LL * list) // Remove node from end of list
|
LL_Pop (LinkedList * list) // Remove node from end of list
|
||||||
{
|
{
|
||||||
if (!list)
|
if (!list)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -483,14 +483,14 @@ LL_Pop (LL * list) // Remove node from end of list
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
void *
|
void *
|
||||||
LL_Top (LL * list) // Peek at end node
|
LL_Top (LinkedList * list) // Peek at end node
|
||||||
{
|
{
|
||||||
return LL_GetLast (list);
|
return LL_GetLast (list);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
void *
|
void *
|
||||||
LL_Shift (LL * list) // Remove node from start of list
|
LL_Shift (LinkedList * list) // Remove node from start of list
|
||||||
{
|
{
|
||||||
if (!list)
|
if (!list)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -503,14 +503,14 @@ LL_Shift (LL * list) // Remove node from start of list
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
void *
|
void *
|
||||||
LL_Look (LL * list) // Peek at first node
|
LL_Look (LinkedList * list) // Peek at first node
|
||||||
{
|
{
|
||||||
return LL_GetFirst (list);
|
return LL_GetFirst (list);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
int
|
int
|
||||||
LL_Unshift (LL * list, void *add) // Add node to beginning of list
|
LL_Unshift (LinkedList * list, void *add) // Add node to beginning of list
|
||||||
{
|
{
|
||||||
if (!list)
|
if (!list)
|
||||||
return -1;
|
return -1;
|
||||||
@@ -524,7 +524,7 @@ LL_Unshift (LL * list, void *add) // Add node to beginning of list
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
int
|
int
|
||||||
LL_Roll (LL * list) // Make last node first
|
LL_Roll (LinkedList * list) // Make last node first
|
||||||
{
|
{
|
||||||
LL_node *node, *next;
|
LL_node *node, *next;
|
||||||
|
|
||||||
@@ -566,7 +566,7 @@ LL_Roll (LL * list) // Make last node first
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
int
|
int
|
||||||
LL_UnRoll (LL * list) // Roll the other way...
|
LL_UnRoll (LinkedList * list) // Roll the other way...
|
||||||
{
|
{
|
||||||
LL_node *node, *prev;
|
LL_node *node, *prev;
|
||||||
|
|
||||||
@@ -610,7 +610,7 @@ LL_UnRoll (LL * list) // Roll the other way...
|
|||||||
// Add an item to the end of its "priority group"
|
// Add an item to the end of its "priority group"
|
||||||
// The list is assumed to be sorted already...
|
// The list is assumed to be sorted already...
|
||||||
int
|
int
|
||||||
LL_PriorityEnqueue (LL * list, void *add, int compare (void *, void *))
|
LL_PriorityEnqueue (LinkedList * list, void *add, int compare (void *, void *))
|
||||||
{
|
{
|
||||||
void *data;
|
void *data;
|
||||||
int i;
|
int i;
|
||||||
@@ -696,7 +696,7 @@ LL_nSwapNodes (int one, int two) // Switch two nodes positions...
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
int
|
int
|
||||||
LL_Length (LL * list) // Returns # of nodes in entire list
|
LL_Length (LinkedList * list) // Returns # of nodes in entire list
|
||||||
{
|
{
|
||||||
LL_node *node;
|
LL_node *node;
|
||||||
int num = 0;
|
int num = 0;
|
||||||
@@ -722,7 +722,7 @@ LL_Length (LL * list) // Returns # of nodes in entire list
|
|||||||
// Note that this does *not* rewind the list first! You should do
|
// Note that this does *not* rewind the list first! You should do
|
||||||
// it yourself if you want to start from the beginning!
|
// it yourself if you want to start from the beginning!
|
||||||
void *
|
void *
|
||||||
LL_Find (LL * list, int compare (void *, void *), void *value)
|
LL_Find (LinkedList * list, int compare (void *, void *), void *value)
|
||||||
{
|
{
|
||||||
void *data;
|
void *data;
|
||||||
|
|
||||||
@@ -747,7 +747,7 @@ LL_Find (LL * list, int compare (void *, void *), void *value)
|
|||||||
// Sorts the list, then rewinds it...
|
// Sorts the list, then rewinds it...
|
||||||
//
|
//
|
||||||
int
|
int
|
||||||
LL_Sort (LL * list, int compare (void *, void *))
|
LL_Sort (LinkedList * list, int compare (void *, void *))
|
||||||
{
|
{
|
||||||
int i, j; // Junk / loop variables
|
int i, j; // Junk / loop variables
|
||||||
int numnodes; // number of nodes in list
|
int numnodes; // number of nodes in list
|
||||||
@@ -797,7 +797,7 @@ LL_Sort (LL * list, int compare (void *, void *))
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
LL_dprint (LL * list)
|
LL_dprint (LinkedList * list)
|
||||||
{
|
{
|
||||||
LL_node *current;
|
LL_node *current;
|
||||||
|
|
||||||
|
|||||||
+36
-36
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
To create a list, do the following:
|
To create a list, do the following:
|
||||||
|
|
||||||
LL *list;
|
LinkedList *list;
|
||||||
list = LL_new();
|
list = LL_new();
|
||||||
if(!list) handle_an_error();
|
if(!list) handle_an_error();
|
||||||
|
|
||||||
@@ -120,81 +120,81 @@ typedef struct LL_node {
|
|||||||
void *data;
|
void *data;
|
||||||
} LL_node;
|
} LL_node;
|
||||||
|
|
||||||
typedef struct LL {
|
typedef struct LinkedList {
|
||||||
LL_node head, tail;
|
LL_node head, tail;
|
||||||
LL_node *current;
|
LL_node *current;
|
||||||
} LL;
|
} LinkedList;
|
||||||
|
|
||||||
// Creates a new list...
|
// Creates a new list...
|
||||||
LL *LL_new ();
|
LinkedList *LL_new ();
|
||||||
// Destroying lists...
|
// Destroying lists...
|
||||||
int LL_Destroy (LL * list);
|
int LL_Destroy (LinkedList * list);
|
||||||
int LL_node_Destroy (LL_node * node);
|
int LL_node_Destroy (LL_node * node);
|
||||||
int LL_node_Unlink (LL_node * node);
|
int LL_node_Unlink (LL_node * node);
|
||||||
int LL_node_DestroyData (LL_node * node);
|
int LL_node_DestroyData (LL_node * node);
|
||||||
|
|
||||||
// Returns to the beginning of the list...
|
// Returns to the beginning of the list...
|
||||||
int LL_Rewind (LL * list);
|
int LL_Rewind (LinkedList * list);
|
||||||
// Goes to the end of the list...
|
// Goes to the end of the list...
|
||||||
int LL_End (LL * list);
|
int LL_End (LinkedList * list);
|
||||||
// Go to the next node
|
// Go to the next node
|
||||||
int LL_Next (LL * list);
|
int LL_Next (LinkedList * list);
|
||||||
// Go to the previous node
|
// Go to the previous node
|
||||||
int LL_Prev (LL * list);
|
int LL_Prev (LinkedList * list);
|
||||||
|
|
||||||
// Data manipulation
|
// Data manipulation
|
||||||
void *LL_Get (LL * list);
|
void *LL_Get (LinkedList * list);
|
||||||
int LL_Put (LL * list, void *data);
|
int LL_Put (LinkedList * list, void *data);
|
||||||
// Don't use these next two unless you really know what you're doing.
|
// Don't use these next two unless you really know what you're doing.
|
||||||
LL_node *LL_GetNode (LL * list);
|
LL_node *LL_GetNode (LinkedList * list);
|
||||||
int LL_PutNode (LL * list, LL_node * node);
|
int LL_PutNode (LinkedList * list, LL_node * node);
|
||||||
|
|
||||||
void *LL_GetFirst (LL * list); // gets data from first node
|
void *LL_GetFirst (LinkedList * list); // gets data from first node
|
||||||
void *LL_GetNext (LL * list); // ... next node
|
void *LL_GetNext (LinkedList * list); // ... next node
|
||||||
void *LL_GetPrev (LL * list); // ... prev node
|
void *LL_GetPrev (LinkedList * list); // ... prev node
|
||||||
void *LL_GetLast (LL * list); // ... last node
|
void *LL_GetLast (LinkedList * list); // ... last node
|
||||||
|
|
||||||
int LL_AddNode (LL * list, void *add); // Adds node AFTER current one
|
int LL_AddNode (LinkedList * list, void *add); // Adds node AFTER current one
|
||||||
int LL_InsertNode (LL * list, void *add); // Adds node BEFORE current one
|
int LL_InsertNode (LinkedList * list, void *add); // Adds node BEFORE current one
|
||||||
// Removes a node from the link; returns the data from the node
|
// Removes a node from the link; returns the data from the node
|
||||||
void *LL_DeleteNode (LL * list);
|
void *LL_DeleteNode (LinkedList * list);
|
||||||
// Removes a specific node...
|
// Removes a specific node...
|
||||||
void *LL_Remove (LL * list, void *data);
|
void *LL_Remove (LinkedList * list, void *data);
|
||||||
|
|
||||||
// Stack operations
|
// Stack operations
|
||||||
int LL_Push (LL * list, void *add); // Add node to end of list
|
int LL_Push (LinkedList * list, void *add); // Add node to end of list
|
||||||
void *LL_Pop (LL * list); // Remove node from end of list
|
void *LL_Pop (LinkedList * list); // Remove node from end of list
|
||||||
void *LL_Top (LL * list); // Peek at end node
|
void *LL_Top (LinkedList * list); // Peek at end node
|
||||||
void *LL_Shift (LL * list); // Remove node from start of list
|
void *LL_Shift (LinkedList * list); // Remove node from start of list
|
||||||
void *LL_Look (LL * list); // Peek at first node
|
void *LL_Look (LinkedList * list); // Peek at first node
|
||||||
int LL_Unshift (LL * list, void *add); // Add node to beginning of list
|
int LL_Unshift (LinkedList * list, void *add); // Add node to beginning of list
|
||||||
|
|
||||||
int LL_Roll (LL * list); // Make first node last
|
int LL_Roll (LinkedList * list); // Make first node last
|
||||||
int LL_UnRoll (LL * list); // Roll the other way...
|
int LL_UnRoll (LinkedList * list); // Roll the other way...
|
||||||
|
|
||||||
// Queue operations...
|
// Queue operations...
|
||||||
//int LL_Enqueue(LL *list, void *add);
|
//int LL_Enqueue(LinkedList *list, void *add);
|
||||||
//void * LL_Dequeue(LL *list);
|
//void * LL_Dequeue(LinkedList *list);
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Queue operations...
|
// Queue operations...
|
||||||
#define LL_Enqueue(list,add) LL_Push(list,add)
|
#define LL_Enqueue(list,add) LL_Push(list,add)
|
||||||
|
|
||||||
#define LL_Dequeue(list) LL_Shift(list)
|
#define LL_Dequeue(list) LL_Shift(list)
|
||||||
|
|
||||||
int LL_PriorityEnqueue (LL * list, void *add, int compare (void *, void *));
|
int LL_PriorityEnqueue (LinkedList * list, void *add, int compare (void *, void *));
|
||||||
|
|
||||||
int LL_SwapNodes (LL_node * one, LL_node * two); // Switch two nodes positions...
|
int LL_SwapNodes (LL_node * one, LL_node * two); // Switch two nodes positions...
|
||||||
int LL_nSwapNodes (int one, int two); // Switch two nodes positions...
|
int LL_nSwapNodes (int one, int two); // Switch two nodes positions...
|
||||||
|
|
||||||
int LL_Length (LL * list); // Returns # of nodes in entire list
|
int LL_Length (LinkedList * list); // Returns # of nodes in entire list
|
||||||
|
|
||||||
// Searching...
|
// Searching...
|
||||||
void *LL_Find (LL * list, int compare (void *, void *), void *value);
|
void *LL_Find (LinkedList * list, int compare (void *, void *), void *value);
|
||||||
|
|
||||||
// Sorts the list...
|
// Sorts the list...
|
||||||
int LL_Sort (LL * list, int compare (void *, void *));
|
int LL_Sort (LinkedList * list, int compare (void *, void *));
|
||||||
|
|
||||||
// Debugging...
|
// Debugging...
|
||||||
void LL_dprint (LL * list);
|
void LL_dprint (LinkedList * list);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user