Package: jzip / 210r20001005d-2

jzexe-execute-bit Patch series | download
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
- fix jzip binary name
- create the executable file with the proper permissions

Originally apparently by Michael Stroucken <stroucki@debian.org>.

Adapted to quilt by Niko Tyni <ntyni@iki.fi>
Index: jzip-210r20001005/jzexe.c
===================================================================
--- jzip-210r20001005.orig/jzexe.c	2006-07-13 23:07:05.000000000 +0300
+++ jzip-210r20001005/jzexe.c	2006-07-13 23:27:21.000000000 +0300
@@ -36,6 +36,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include <fcntl.h>
 
 #include "jzexe.h"
 
@@ -67,7 +68,11 @@
 static char out_name[NAME_LENGTH + 1];
 
 /* The name of the JZip executable */
+#if defined(MSDOS) || defined(__MSDOS__)
 #define JZIP_NAME "jzip.exe"
+#else
+#define JZIP_NAME "/usr/games/jzip"
+#endif
 
 void abort_program( int exit_code )
 {
@@ -81,6 +86,7 @@
 {
    char *mode;
    FILE *f;
+   int tempfd;
 
    if ( input )
    {
@@ -89,14 +95,22 @@
        * just in case */
       in_name[NAME_LENGTH] = 0;
       mode = READ_MODE;
+
+      f = fopen(name, mode);
    }
    else
    {
       strncpy( out_name, name, NAME_LENGTH );
       out_name[NAME_LENGTH] = 0;
       mode = WRITE_MODE;
+
+      tempfd = creat(name, 0755);
+       if (tempfd == -1) {
+               fprintf(stderr, "Error creating file %s\n", name);
+               abort_program(1);
+       }
+       f = fdopen(tempfd, WRITE_MODE);
    }
-   f = fopen( name, mode );
    if ( !f )
    {
       fprintf( stderr, "Error opening file %s\n", name );