llwfp

Documentation
Login

Documentation

#ifndef _LLWFP_H_
#define _LLWFP_H_

#include "llwfp-data.h"

typedef enum
{
  LL_ERROR = -1,
  LL_OK    = 0,
  LL_END   = 1, /* EndOfLinkedList (current node is the last in list having data */
  LL_EMPTY = 2  /* EmptyLinkedList (head node is NULL) */
} ll_status_t;

/* Node definition with generic data type (void *) */
typedef struct node_t
{
  struct node_t *next;
  void *data;
} node_t;

/* Forward declaration */
struct nodewfp_t;
typedef struct nodewfp_t nwfp_t;

/* Typedef for the list object, containing the list's head and tail nodes, and the function pointers for data handling */
typedef struct nodewfp_t
{
  node_t *head;    /* First node in list */
  node_t *current; /* Current node in list */
  node_data_fp_t *df; /* Struct of function pointers to deal with node data */
} nodewfp_t;

typedef void (*data_init_t)(node_data_fp_t *ndfp);

/* Prototypes for node and list handling, i.e. the API */
void node_init(nodewfp_t *nwpf, data_init_t init_function);
status_t node_add(nodewfp_t *nwpf, void *data);
status_t node_set(nodewfp_t *nwpf, void *data);
void *node_get(nodewfp_t *nwpf, node_t *node, status_t *rc);
status_t node_del(nodewfp_t *nwpf);
int node_count(nodewfp_t *nwpf);
void node_print(nodewfp_t *nwpf);
node_t *node_sort(node_t *head);
node_t *node_reverse(node_t *head);
void node_cleanup(nodewfp_t *nwpf, node_t *node);
/* status_t node_sort(nodewfp_t *nwpf); */
/* status_t node_reverse(nodewfp_t *nwpf); */

#endif /* _LLWFP_H_ */