1scr_dump(5) File Formats Manual scr_dump(5)
2
3
4
6 scr_dump - format of curses screen-dumps.
7
9 scr_dump
10
12 The curses library provides applications with the ability to write the
13 contents of a window to an external file using scr_dump or putwin, and
14 read it back using scr_restore or getwin.
15
16 The putwin and getwin functions do the work; while scr_dump and
17 scr_restore conveniently save and restore the whole screen, i.e., std‐
18 scr.
19
20 ncurses6
21 A longstanding implementation of screen-dump was revised with ncurses6
22 to remedy problems with the earlier approach:
23
24 · A “magic number” is written to the beginning of the dump file,
25 allowing applications (such as file(1)) to recognize curses dump
26 files.
27
28 Because ncurses6 uses a new format, that requires a new magic num‐
29 ber was unused by other applications. This 16-bit number was
30 unused:
31
32 0x8888 (octal “\210\210”)
33
34 but to be more certain, this 32-bit number was chosen:
35
36 0x88888888 (octal “\210\210\210\210”)
37
38 This is the pattern submitted to the maintainers of the file pro‐
39 gram:
40
41 #
42 # ncurses5 (and before) did not use a magic number,
43 # making screen dumps "data".
44 #
45 # ncurses6 (2015) uses this format, ignoring byte-order
46 0 string \210\210\210\210ncurses ncurses6 screen image
47 #
48
49 · The screen dumps are written in textual form, so that internal data
50 sizes are not directly related to the dump-format, and enabling the
51 library to read dumps from either narrow- or wide-character- con‐
52 figurations.
53
54 The narrow library configuration holds characters and video
55 attributes in a 32-bit chtype, while the wide-character library
56 stores this information in the cchar_t structure, which is much
57 larger than 32-bits.
58
59 · It is possible to read a screen dump into a terminal with a differ‐
60 ent screen-size, because the library truncates or fills the screen
61 as necessary.
62
63 · The ncurses6 getwin reads the legacy screen dumps from ncurses5.
64
65 ncurses5 (legacy)
66 The screen-dump feature was added to ncurses in June 1995. While there
67 were fixes and improvements in succeeding years, the basic scheme was
68 unchanged:
69
70 · The WINDOW structure was written in binary form.
71
72 · The WINDOW structure refers to lines of data, which were written as
73 an array of binary data following the WINDOW.
74
75 · When getwin restored the window, it would keep track of offsets
76 into the array of line-data and adjust the WINDOW structure which
77 was read back into memory.
78
79 This is similar to Unix SystemV, but does not write a “magic number” to
80 identify the file format.
81
83 There is no standard format for putwin. This section gives a brief
84 description of the existing formats.
85
86 X/Open Curses
87 Refer to X/Open Curses, Issue 7 (2009).
88
89 X/Open's documentation for enhanced curses says only:
90
91 The getwin( ) function reads window-related data stored in the file
92 by putwin( ). The function then creates and initializes a new win‐
93 dow using that data.
94
95 The putwin( ) function writes all data associated with win into the
96 stdio stream to which filep points, using an unspecified format.
97 This information can be retrieved later using getwin( ).
98
99 In the mid-1990s when the X/Open Curses document was written, there
100 were still systems using older, less capable curses libraries (aside
101 from the BSD curses library which was not relevant to X/Open because it
102 did not meet the criteria for base curses). The document explained the
103 term “enhanced” as follows:
104
105 · Shading is used to identify X/Open Enhanced Curses material,
106 relating to interfaces included to provide enhanced capabilities
107 for applications originally written to be compiled on systems
108 based on the UNIX operating system. Therefore, the features
109 described may not be present on systems that conform to XPG4 or
110 to earlier XPG releases. The relevant reference pages may pro‐
111 vide additional or more specific portability warnings about use
112 of the material.
113
114 In the foregoing, emphasis was added to unspecified format and to XPG4
115 or to earlier XPG releases, for clarity.
116
117 Unix SystemV
118 Unix SystemV curses identified the file format by writing a “magic num‐
119 ber” at the beginning of the dump. The WINDOW data and the lines of
120 text follow, all in binary form.
121
122 The Solaris curses source has these definitions:
123
124 /* terminfo magic number */
125 #define MAGNUM 0432
126
127 /* curses screen dump magic number */
128 #define SVR2_DUMP_MAGIC_NUMBER 0433
129 #define SVR3_DUMP_MAGIC_NUMBER 0434
130