<para>The format parameter is the same as the one used by printf.</para>
</sect2>
<sect2 id="debug">
<title>Send debugging information if important enough</title>
<para>Consider the debug function to be exactly the same as the report function. The only difference is that it is only compiled in if DEBUG is defined.</para>
<para>The list can hold any type of data. You will need to typecast your datatype to a "void *", though. So, to add something to the list, the following would be a good way to start:</para>
<screen>
typedef struct my_data {
char string[16];
int number;
} my_data;
my_data *thingie;
for(something to something else) {
thingie = malloc(sizeof(my_data));
LL_AddNode(list, (void *)thingie); // typecast it to a "void *"
}
</screen>
<para>For errors, the general convention is that "0" means success, and a negative number means failure. Check LL.c to be sure, though.</para>
</sect2>
<sect2 id="LL.h-edit">
<title>Changing data</title>
<para>To change the data, try this:</para>
<screen>
thingie = (my_data *)LL_Get(list); // typecast it back to "my_data"
thingie->number = another_number;
</screen>
<para>You don't need to "Put" the data back, but it doesn't hurt anything.</para>
<screen>
LL_Put(list, (void *)thingie);
</screen>
<para>However, if you want to point the node's data somewhere else, you'll need to get the current data first, keep track of it, then set the data to a new location:</para>
<screen>
my_data * old_thingie, new_thingie;
old_thingie = (my_data *)LL_Get(list);
LL_Put(list, (void *)new_thingie);
// Now, do something with old_thingie. (maybe, free it?)
</screen>
<para>Or, you could just delete the node entirely and then add a new one:</para>
<screen>
my_data * thingie;
thingie = (my_data *)LL_DeleteNode(list);
free(thingie);
thingie->number = 666;
LL_InsertNode(list, (void *)thingie);
</screen>
</sect2>
<sect2 id="LL.h-iterate">
<title>Iterations throught the list</title>
<para>To iterate on each list item, try this:</para>
<screen>
LL_Rewind(list);
do {
my_data = (my_data *)LL_Get(list);
/* ... do something to it ... */
} while(LL_Next(list) == 0);
</screen>
</sect2>
<sect2 id="LL.h-stack">
<title>Using the list as a stack or a queue</title>
<para>You can also treat the list like a stack, or a queue. Just use the following functions:</para>