don't hardcode the root filename for decompilation

SVN revision: 13758
This commit is contained in:
tsauerbeck 2005-03-16 19:40:25 +00:00 committed by tsauerbeck
parent 3b5686906b
commit 4ee218c3cc
2 changed files with 47 additions and 3 deletions

View File

@ -184,7 +184,15 @@ source_fetch_file(char *fil, char *filname)
void void
source_fetch(void) source_fetch(void)
{ {
source_fetch_file(file_in, "main_edje_source.edc"); char buf[PATH_MAX] = {0}, *ptr;
ptr = strrchr(file_in, '/');
if (ptr)
{
snprintf(buf, sizeof (buf), "%s", ptr + 1);
}
source_fetch_file(file_in, buf[0] ? buf : file_in);
} }
int int

View File

@ -24,6 +24,7 @@ int e_file_is_dir(char *file);
int e_file_mkdir(char *dir); int e_file_mkdir(char *dir);
int e_file_mkpath(char *path); int e_file_mkpath(char *path);
static int compiler_cmd_is_sane(); static int compiler_cmd_is_sane();
static int root_filename_is_sane();
static void static void
main_help(void) main_help(void)
@ -78,12 +79,18 @@ decomp(void)
} }
srcfiles = source_load(ef); srcfiles = source_load(ef);
if (!srcfiles) if (!srcfiles || !srcfiles->list)
{ {
printf("ERROR: %s has no decompile information\n", file_in); printf("ERROR: %s has no decompile information\n", file_in);
eet_close(ef); eet_close(ef);
return 0; return 0;
} }
if (!srcfiles->list->data || !root_filename_is_sane())
{
printf("ERROR: Invalid root filename: '%s'\n", (char *) srcfiles->list->data);
eet_close(ef);
return 0;
}
edje_file = eet_data_read(ef, _edje_edd_edje_file, "edje_file"); edje_file = eet_data_read(ef, _edje_edd_edje_file, "edje_file");
if (!edje_file) if (!edje_file)
{ {
@ -264,6 +271,7 @@ output(void)
{ {
char out[4096]; char out[4096];
FILE *f; FILE *f;
SrcFile *sf = srcfiles->list->data;
snprintf(out, sizeof(out), "%s/build.sh", outdir); snprintf(out, sizeof(out), "%s/build.sh", outdir);
printf("Output Build Script: %s\n", out); printf("Output Build Script: %s\n", out);
@ -274,7 +282,7 @@ output(void)
} }
f = fopen(out, "w"); f = fopen(out, "w");
fprintf(f, "#!/bin/sh\n"); fprintf(f, "#!/bin/sh\n");
fprintf(f, "%s $@ -id . -fd . main_edje_source.edc -o %s.eet\n", edje_file->compiler, outdir); fprintf(f, "%s $@ -id . -fd . %s -o %s.eet\n", edje_file->compiler, sf->name, outdir);
fclose(f); fclose(f);
#ifndef WIN32 #ifndef WIN32
@ -358,3 +366,31 @@ compiler_cmd_is_sane()
return 1; return 1;
} }
static int
root_filename_is_sane()
{
SrcFile *sf = srcfiles->list->data;
char *f = sf->name, *ptr;
if (!f || !*f)
{
return 0;
}
for (ptr = f; ptr && *ptr; ptr++)
{
/* only allow [a-z][A-Z][0-9]_-./ */
switch (*ptr)
{
case '_': case '-': case '.': case '/':
break;
default:
if (!isalnum(*ptr))
{
return 0;
}
}
}
return 1;
}