Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
3f1bc3a0
Commit
3f1bc3a0
authored
May 27, 2006
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bin2res: Clean output files when aborting on an error or signal.
parent
25dc6d91
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
6 deletions
+28
-6
bin2res.c
tools/bin2res.c
+28
-6
No files found.
tools/bin2res.c
View file @
3f1bc3a0
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
#include "config.h"
#include "config.h"
#include "wine/port.h"
#include "wine/port.h"
#include <signal.h>
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <ctype.h>
#include <ctype.h>
...
@@ -33,6 +34,8 @@
...
@@ -33,6 +34,8 @@
# include <sys/param.h>
# include <sys/param.h>
#endif
#endif
static
const
char
*
clean_file
;
static
const
char
*
help
=
static
const
char
*
help
=
"Usage: bin2res [OPTIONS] <rsrc.rc>
\n
"
"Usage: bin2res [OPTIONS] <rsrc.rc>
\n
"
" -a archive binaries into the <rsrc.rc> file
\n
"
" -a archive binaries into the <rsrc.rc> file
\n
"
...
@@ -70,6 +73,16 @@ static void usage(void)
...
@@ -70,6 +73,16 @@ static void usage(void)
exit
(
1
);
exit
(
1
);
}
}
static
void
cleanup_files
(
void
)
{
if
(
clean_file
)
unlink
(
clean_file
);
}
static
void
exit_on_signal
(
int
sig
)
{
exit
(
1
);
/* this will call the atexit functions */
}
static
int
insert_hexdump
(
FILE
*
outfile
,
FILE
*
infile
)
static
int
insert_hexdump
(
FILE
*
outfile
,
FILE
*
infile
)
{
{
int
i
,
c
;
int
i
,
c
;
...
@@ -148,6 +161,7 @@ static int process_resources(const char* input_file_name, const char* specific_f
...
@@ -148,6 +161,7 @@ static int process_resources(const char* input_file_name, const char* specific_f
strcpy
(
tmp_file_name
,
"/tmp/bin2res-XXXXXX.temp"
);
strcpy
(
tmp_file_name
,
"/tmp/bin2res-XXXXXX.temp"
);
if
((
fd
=
mkstemps
(
tmp_file_name
,
5
))
==
-
1
)
return
0
;
if
((
fd
=
mkstemps
(
tmp_file_name
,
5
))
==
-
1
)
return
0
;
}
}
clean_file
=
tmp_file_name
;
if
(
!
(
ftmp
=
fdopen
(
fd
,
"w"
)))
return
0
;
if
(
!
(
ftmp
=
fdopen
(
fd
,
"w"
)))
return
0
;
}
}
...
@@ -167,17 +181,21 @@ static int process_resources(const char* input_file_name, const char* specific_f
...
@@ -167,17 +181,21 @@ static int process_resources(const char* input_file_name, const char* specific_f
if
(
inserting
)
fputc
(
c
,
ftmp
);
if
(
inserting
)
fputc
(
c
,
ftmp
);
if
(
c
==
EOF
)
break
;
if
(
c
==
EOF
)
break
;
if
(
!
(
fres
=
fopen
(
res_file_name
,
inserting
?
"rb"
:
"wb"
)))
break
;
if
(
inserting
)
if
(
inserting
)
{
{
if
(
!
(
fres
=
fopen
(
res_file_name
,
"rb"
)))
break
;
if
(
!
insert_hexdump
(
ftmp
,
fres
))
break
;
if
(
!
insert_hexdump
(
ftmp
,
fres
))
break
;
while
(
(
c
=
fgetc
(
fin
))
!=
EOF
&&
c
!=
'}'
)
/**/
;
while
(
(
c
=
fgetc
(
fin
))
!=
EOF
&&
c
!=
'}'
)
/**/
;
fclose
(
fres
);
}
}
else
else
{
{
clean_file
=
res_file_name
;
if
(
!
(
fres
=
fopen
(
res_file_name
,
"wb"
)))
break
;
if
(
!
extract_hexdump
(
fres
,
fin
))
break
;
if
(
!
extract_hexdump
(
fres
,
fin
))
break
;
}
fclose
(
fres
);
fclose
(
fres
);
clean_file
=
NULL
;
}
}
}
fclose
(
fin
);
fclose
(
fin
);
...
@@ -191,14 +209,11 @@ static int process_resources(const char* input_file_name, const char* specific_f
...
@@ -191,14 +209,11 @@ static int process_resources(const char* input_file_name, const char* specific_f
{
{
/* try unlinking first, Windows rename is brain-damaged */
/* try unlinking first, Windows rename is brain-damaged */
if
(
unlink
(
input_file_name
)
<
0
||
rename
(
tmp_file_name
,
input_file_name
)
<
0
)
if
(
unlink
(
input_file_name
)
<
0
||
rename
(
tmp_file_name
,
input_file_name
)
<
0
)
{
unlink
(
tmp_file_name
);
return
0
;
return
0
;
}
}
clean_file
=
NULL
;
}
}
}
}
else
unlink
(
tmp_file_name
);
}
return
c
==
EOF
;
return
c
==
EOF
;
}
}
...
@@ -210,6 +225,13 @@ int main(int argc, char **argv)
...
@@ -210,6 +225,13 @@ int main(int argc, char **argv)
const
char
*
input_file_name
=
0
;
const
char
*
input_file_name
=
0
;
const
char
*
specific_file_name
=
0
;
const
char
*
specific_file_name
=
0
;
atexit
(
cleanup_files
);
signal
(
SIGTERM
,
exit_on_signal
);
signal
(
SIGINT
,
exit_on_signal
);
#ifdef SIGHUP
signal
(
SIGHUP
,
exit_on_signal
);
#endif
while
((
optc
=
getopt
(
argc
,
argv
,
"axi:o:fhv"
))
!=
EOF
)
while
((
optc
=
getopt
(
argc
,
argv
,
"axi:o:fhv"
))
!=
EOF
)
{
{
switch
(
optc
)
switch
(
optc
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment