#include #include #include "reverse.h" struct line { char chars[MAX_LINE_SIZE]; struct line * next; }; static struct line * first_line = 0; void reverse_init() { first_line = 0; } int reverse_add_line(const char * l) { struct line * new_line = malloc(sizeof(struct line)); if (!new_line) return 0; int i; for(i = 0; i < MAX_LINE_SIZE - 1 && l[i] != 0; ++i) new_line->chars[i] = l[i]; new_line->chars[i] = 0; new_line->next = first_line; first_line = new_line; return 1; } void reverse_print() { struct line * l; for(l = first_line; l != 0; l = l->next) printf("%s", l->chars); } void reverse_shutdown() { while (first_line) { struct line * next = first_line->next; free(first_line); first_line = next; } }