2011-02-06 05:44:45 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2010-04-01 05:28:00 +00:00
|
|
|
#include <malloc.h>
|
2011-02-06 05:44:45 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
2010-04-01 05:28:00 +00:00
|
|
|
#include "frame.h"
|
|
|
|
|
2010-04-05 07:33:10 +00:00
|
|
|
void allocate_frame(struct frame **frame) {
|
2011-02-06 05:44:45 +00:00
|
|
|
if (!(*frame = malloc(sizeof(**frame)))) {
|
|
|
|
fprintf(stderr, "%s: %s (%s:%d)\n", program_name, strerror(errno), __FILE__, __LINE__ - 1);
|
|
|
|
exit(errno);
|
|
|
|
}
|
2010-04-01 05:28:00 +00:00
|
|
|
|
2010-04-05 07:33:10 +00:00
|
|
|
return;
|
|
|
|
}
|
2010-04-01 05:28:00 +00:00
|
|
|
|
2010-04-05 07:33:10 +00:00
|
|
|
void initialize_frame(struct frame *frame) {
|
|
|
|
frame->shape = NULL;
|
2010-04-01 05:28:00 +00:00
|
|
|
frame->start_y = 0;
|
|
|
|
frame->start_x = 0;
|
|
|
|
|
2010-04-05 07:33:10 +00:00
|
|
|
return;
|
2010-04-01 05:28:00 +00:00
|
|
|
}
|
|
|
|
|
2011-02-14 02:10:47 +00:00
|
|
|
void free_frame(struct frame *frame) {
|
2011-02-12 03:26:03 +00:00
|
|
|
if (frame) {
|
|
|
|
delwin(frame->shape);
|
|
|
|
}
|
2010-04-01 05:28:00 +00:00
|
|
|
free(frame);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_frame(struct frame *frame, int start_y, int start_x) {
|
|
|
|
frame->start_y = start_y;
|
|
|
|
frame->start_x = start_x;
|
2010-04-10 17:37:43 +00:00
|
|
|
frame->shape = newwin(FRAME_HEIGHT,
|
|
|
|
FRAME_WIDTH,
|
2010-04-01 05:28:00 +00:00
|
|
|
frame->start_y,
|
|
|
|
frame->start_x);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|