#include <stdlib.h>
#include <string.h>
#include "log.h"
Functions | |
void | log_init (log_t *l) |
Initializes the log. | |
void | log_destroy (log_t *l) |
Frees all internal memory associated with the log. | |
void | log_push (log_t *l, const char *item) |
Push an item to the log stack. | |
char * | log_search (log_t *l, const char *prefix) |
Preforms a newest-to-oldest search of log entries for an entry matching a given prefix. |
void log_destroy | ( | log_t * | l | ) |
Frees all internal memory associated with the log.
You may assume that:
l | Pointer to the log data structure to be destoryed. |
void log_init | ( | log_t * | l | ) |
void log_push | ( | log_t * | l, | |
const char * | item | |||
) |
Push an item to the log stack.
You may assume that:
l | Pointer to the log data structure. | |
item | Pointer to a string to be added to the log. |
char* log_search | ( | log_t * | l, | |
const char * | prefix | |||
) |
Preforms a newest-to-oldest search of log entries for an entry matching a given prefix.
This search starts with the most recent entry in the log and compares each entry to determine if the query is a prefix of the log entry. Upon reaching a match, a pointer to that element is returned. If no match is found, a NULL pointer is returned.
You may assume that:
l | Pointer to the log data structure. | |
prefix | The prefix to test each entry in the log for a match. |