log.c File Reference

#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.

Detailed Description


Function Documentation

void log_destroy ( log_t l  ) 

Frees all internal memory associated with the log.

You may assume that:

  • This function will be called once per instance of log_t.
  • This funciton will be the last function called per instance of log_t.
  • All pointers will be valid, non-NULL pointer.
Parameters:
l Pointer to the log data structure to be destoryed.
void log_init ( log_t l  ) 

Initializes the log.

You may assuem that:

  • This function will only be called once per instance of log_t.
  • This function will be the first function called per instance of log_t.
  • All pointers will be valid, non-NULL pointer.
Returns:
The initialized log structure.
void log_push ( log_t l,
const char *  item 
)

Push an item to the log stack.

You may assume that:

  • All pointers will be valid, non-NULL pointer.
Parameters:
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:

  • All pointers will be valid, non-NULL pointer.
Parameters:
l Pointer to the log data structure.
prefix The prefix to test each entry in the log for a match.
Returns:
The newest entry in the log whose string matches the specified prefix. If no strings has the specified prefix, NULL is returned.

Generated on 23 Sep 2013 for MP3: Shell by  doxygen 1.6.1