Debian Codegraph @

common/shell_spool.h

raw
1 /*****************************************************************************
2 * Free42 -- an HP-42S calculator simulator
3 * Copyright (C) 2004-2026 Thomas Okken
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License, version 2,
7 * as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see http://www.gnu.org/licenses/.
16 *****************************************************************************/
17
18 #ifndef SHELL_SPOOL_H
19 #define SHELL_SPOOL_H 1
20
21 #ifndef ANDROID
22
23 #include "free42.h"
24
25 typedef void (*file_seeker)(int4 pos);
26 typedef void (*file_writer)(const char *text, int length);
27 typedef void (*file_newliner)();
28
29 #endif
30
31 /* hp2ascii()
32 *
33 * Converts characters outside the range 32-126 and 10 to their ASCII
34 * or extended ASCII equivalents. Substitutes escape sequences for
35 * undefined characters.
36 */
37 int hp2ascii(char *dst, const char *src, int srclen);
38
39 #ifndef ANDROID
40
41 /* shell_spool_txt()
42 *
43 * Shell helper that writes plain text to a file, optionally translating
44 * HP-42S characters to their closest ASCII equivalents or escape sequences.
45 * The actual I/O is all done through callbacks so that this routine is OS
46 * independent.
47 */
48 void shell_spool_txt(const char *text, int length,
49 file_writer writer, file_newliner newliner);
50
51 /* shell_spool_bitmap_to_txt()
52 *
53 * Shell helper that writes a bitmap to a text stream, using Unicode 2x2
54 * graphics block characters. Used by PRLCD.
55 */
56 void shell_spool_bitmap_to_txt(const char *bits, int bytesperline,
57 int x, int y, int width, int height,
58 file_writer writer, file_newliner newliner);
59
60 /* shell_start_gif()
61 *
62 * Shell helper for writing bitmaps to GIF files.
63 * This call writes the GIF header (except for the length, which isn't known
64 * yet) and initialized the GIF encoder.
65 * Returns 1 on success; 0 if it failed because of a memory allocation
66 * failure.
67 */
68 bool shell_start_gif(file_writer writer, int width, int provisional_height);
69
70 /* shell_spool_gif()
71 *
72 * Shell helper that writes bitmaps to a GIF file.
73 * The actual I/O is all done through callbacks so that this routine is OS
74 * independent.
75 */
76 void shell_spool_gif(const char *bits, int bytesperline,
77 int x, int y, int width, int height,
78 file_writer writer);
79
80 /* shell_finish_gif()
81 *
82 * Shell helper for writing bitmaps to GIF files.
83 * This call flushes the GIF encoder, and writes the final image height to the
84 * GIF header. After this call, the caller should close the output file.
85 */
86 void shell_finish_gif(file_seeker seeker, file_writer writer);
87
88 /* shell_spool_exit()
89 *
90 * Cleans up spooler's private data. Call this just before application exit.
91 */
92 void shell_spool_exit();
93
94 #endif
95
96 #endif