-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetwin.c
43 lines (37 loc) · 992 Bytes
/
getwin.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <stdlib.h>
#include "curses.h"
#include "window.h"
#include "privfunc.h"
/*AT&T
AT&T The getwin() routine reads window related data stored in the file
AT&T by putwin(). The routine then creates and initialises a new window
AT&T using that data. It returns a pointer to the new window.
AT&T */
WINDOW *
getwin(FILE *filep)
{
WINDOW *win, fwin;
_LINE *ystart, *yend;
int linesz;
if(filep == 0) return((WINDOW*)0);
if(fread((char*)&fwin, sizeof(WINDOW), 1, filep) != sizeof(WINDOW))
return((WINDOW*)0);;
win = _mallocwindow(fwin._rows,fwin._cols,FALSE);
if(win==(WINDOW*)0) return((WINDOW*)0);
*win = fwin;
win->_parent = 0;
win->_children = 0;
ystart = win->_lines;
yend = ystart + win->_rows;
linesz = sizeof(chtype)*win->_cols;
for(; ystart != yend; ystart++)
{
if(fread((char *)ystart->line, linesz, 1, filep) != sizeof(WINDOW))
{
free(win);
return((WINDOW*)0);
}
}
(void)touchwin(win);
return(win);
}