#include #include #include "reverse.h" #ifndef MAX_INPUT_SIZE #define MAX_INPUT_SIZE 1024 #endif static char lines[MAX_INPUT_SIZE][MAX_LINE_SIZE]; static int line_count; void reverse_init() { line_count = 0; } int reverse_add_line(const char * l) { if (line_count < MAX_INPUT_SIZE) { int i; for(i = 0; i < MAX_LINE_SIZE - 1 && l[i]; ++i) lines[line_count][i] = l[i]; lines[line_count][i] = 0; ++line_count; return 1; } else { return 0; } } void reverse_print() { int i; for(i = line_count; i > 0; --i) printf("%s", lines[i - 1]); } void reverse_shutdown() { line_count = 0; }