summaryrefslogtreecommitdiffstats
path: root/games/scare/files/patch-os_glk.c
blob: 4f4781a1bd9dc4d82f3758de221b44e6d76e09c6 (plain)
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
--- os_glk.c.orig	Sat Feb  5 19:58:33 2005
+++ os_glk.c	Sat Feb  5 20:17:22 2005
@@ -899,6 +899,8 @@
 		&& glk_gestalt (gestalt_Graphics, 0))
 	    {
 		sc_char		*buffer;
+		char		 fname[80];
+		int		 fd;
 
 		/*
 		 * Try to extract data with dd.  Assuming that works, back-
@@ -906,15 +908,23 @@
 		 * delay ten seconds and then delete the temporary file
 		 * containing the image.  Not exactly finessed.
 		 */
+		strcpy(fname, "/tmp/scare-XXXXXX.jpg");
+		fd = mkstemps(fname, 4);
+		if (fd < 0)
+			return;
+		close(fd);
 		assert (gsclinux_game_file != NULL);
 		buffer = gsc_malloc (strlen (gsclinux_game_file) + 128);
-		sprintf (buffer, "dd if=%s ibs=1c skip=%ld count=%ld obs=100k"
-				 " of=/tmp/scare.jpg 2>/dev/null",
-					gsclinux_game_file, offset, length);
+		sprintf (buffer, "dd if=%s ibs=1 skip=%ld count=%ld obs=100k"
+				 " of=%s 2>/dev/null",
+					gsclinux_game_file, offset, length,
+					fname);
+		system (buffer);
+		sprintf (buffer, "xv %s >/dev/null 2>&1 &", fname);
+		system (buffer);
+		sprintf (buffer, "( sleep 10; rm %s ) >/dev/null 2>&1 &", fname);
 		system (buffer);
 		free (buffer);
-		system ("xv /tmp/scare.jpg >/dev/null 2>&1 &");
-		system ("( sleep 10; rm /tmp/scare.jpg ) >/dev/null 2>&1 &");
 	    }
 }
 #else
OpenPOWER on IntegriCloud