1 #include <stdlib.h>
2 #include <stdint.h>
3 #include <stdio.h>
4 #include <unistd.h>
5 #include <stdbool.h>
6
7 #include <arcan_shmif.h>
8
9 struct __attribute__((packed)) tui_raster_header {
10 uint32_t data_sz;
11 uint16_t lines;
12 uint16_t cells;
13 uint8_t direction;
14 uint16_t flags;
15 uint8_t bgc[4];
16 };
17
main(int argc,char ** argv)18 int main(int argc, char** argv)
19 {
20 if (argc <= 1){
21 fprintf(stderr, "use:\n\ttpack full.tpack [delta or full.tpack]*\n\n");
22 return EXIT_FAILURE;
23 }
24
25 FILE* fin = fopen(argv[1], "r");
26 if (!fin){
27 fprintf(stderr, "couldn't open %s\n", argv[1]);
28 return EXIT_FAILURE;
29 }
30
31 /* grab header and dimensions for the resize call */
32 struct tui_raster_header hdr;
33 if (1 != fread(&hdr, sizeof(hdr), 1, fin)){
34 fprintf(stderr, "couldn't grab header from input\n");
35 return EXIT_FAILURE;
36 }
37 fclose(fin);
38
39 struct arcan_shmif_cont conn =
40 arcan_shmif_open(SEGID_TUI, SHMIF_ACQUIRE_FATALFAIL, NULL);
41 conn.hints = SHMIF_RHINT_TPACK;
42 arcan_shmif_resize_ext(&conn, conn.w, conn.h,
43 (struct shmif_resize_ext){
44 .vbuf_cnt = -1, .abuf_cnt = -1,
45 .rows = hdr.lines, hdr.cells
46 });
47
48 while(1){
49 for (size_t i = 1; i < argc; i++){
50 fin = fopen(argv[i], "r");
51 fseek(fin, 0, SEEK_END);
52 /* assumes the first package sets the right size */
53 size_t nb = ftell(fin);
54 rewind(fin);
55 if (1 != fread(conn.vidb, nb, 1, fin))
56 return EXIT_FAILURE;
57 fclose(fin);
58 }
59 arcan_shmif_signal(&conn, SHMIF_SIGVID);
60 }
61 /* grab the dimensions from the main file */
62 /* iterate the list of inputs and send them along */
63 /* possibly add a raster mode where we do the rasterization ourselves for fuzzing */
64
65 return EXIT_SUCCESS;
66 }
67