2004-08-29 04:03:19 -07:00
|
|
|
/* ugly ugly. avert your eyes. */
|
2008-06-07 03:06:14 -07:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
2008-06-06 11:31:49 -07:00
|
|
|
|
2008-10-26 10:18:19 -07:00
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <locale.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
2010-02-28 08:14:50 -08:00
|
|
|
#include <errno.h>
|
2008-10-26 10:18:19 -07:00
|
|
|
|
|
|
|
|
2008-03-24 01:09:06 -07:00
|
|
|
#include <Ecore_File.h>
|
2008-10-26 10:18:19 -07:00
|
|
|
#include <Ecore_Evas.h>
|
2008-06-06 11:31:49 -07:00
|
|
|
|
|
|
|
#include "edje_decc.h"
|
2004-08-29 04:03:19 -07:00
|
|
|
|
2009-12-22 05:46:00 -08:00
|
|
|
int _edje_cc_log_dom = -1;
|
2004-08-29 04:03:19 -07:00
|
|
|
char *progname = NULL;
|
|
|
|
char *file_in = NULL;
|
2007-03-01 23:24:32 -08:00
|
|
|
char *file_out = NULL;
|
2004-08-29 04:03:19 -07:00
|
|
|
|
2010-08-09 10:34:03 -07:00
|
|
|
Edje_File *edje_file = NULL;
|
2004-08-29 04:03:19 -07:00
|
|
|
SrcFile_List *srcfiles = NULL;
|
|
|
|
Font_List *fontlist = NULL;
|
|
|
|
|
|
|
|
int line = 0;
|
2009-12-02 13:00:57 -08:00
|
|
|
int build_sh = 1;
|
2009-12-02 13:06:11 -08:00
|
|
|
int new_dir = 1;
|
2004-08-29 04:03:19 -07:00
|
|
|
|
|
|
|
int decomp(void);
|
|
|
|
void output(void);
|
2005-03-16 10:39:39 -08:00
|
|
|
static int compiler_cmd_is_sane();
|
2005-03-16 11:40:25 -08:00
|
|
|
static int root_filename_is_sane();
|
2004-08-29 04:03:19 -07:00
|
|
|
|
|
|
|
static void
|
|
|
|
main_help(void)
|
|
|
|
{
|
|
|
|
printf
|
|
|
|
("Usage:\n"
|
2009-12-02 13:06:11 -08:00
|
|
|
"\t%s input_file.edj [-main-out file.edc] [-no-build-sh] [-current-dir]\n"
|
2004-08-29 04:03:19 -07:00
|
|
|
"\n"
|
2010-05-26 19:39:20 -07:00
|
|
|
" -main-out\tCreate a symbolic link to the main edc \n"
|
|
|
|
" -no-build-sh\tDon't output build.sh \n"
|
|
|
|
" -current-dir\tOutput to current directory \n"
|
|
|
|
"\n"
|
2004-08-29 04:03:19 -07:00
|
|
|
,progname);
|
|
|
|
}
|
|
|
|
|
2008-03-01 21:39:51 -08:00
|
|
|
Eet_File *ef;
|
|
|
|
Eet_Dictionary *ed;
|
|
|
|
|
2004-08-29 04:03:19 -07:00
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
setlocale(LC_NUMERIC, "C");
|
2010-02-01 09:26:25 -08:00
|
|
|
if (!eina_init())
|
|
|
|
exit(-1);
|
2009-12-22 05:46:00 -08:00
|
|
|
_edje_cc_log_dom = eina_log_domain_register("edje_decc", EDJE_CC_DEFAULT_LOG_COLOR);
|
|
|
|
if(_edje_cc_log_dom < 0)
|
|
|
|
{
|
|
|
|
EINA_LOG_ERR("Edje_decc: Impossible to create a log domain for edje_decc");
|
|
|
|
eina_shutdown();
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
eina_log_level_set(EINA_LOG_LEVEL_INFO);
|
2004-08-29 04:03:19 -07:00
|
|
|
progname = argv[0];
|
|
|
|
for (i = 1; i < argc; i++)
|
|
|
|
{
|
2010-05-26 19:39:20 -07:00
|
|
|
if (!strcmp(argv[i], "-h"))
|
|
|
|
{
|
|
|
|
main_help();
|
|
|
|
exit(0);
|
|
|
|
}
|
2004-08-29 04:03:19 -07:00
|
|
|
if (!file_in)
|
|
|
|
file_in = argv[i];
|
2007-03-01 23:24:32 -08:00
|
|
|
else if ((!strcmp(argv[i], "-main-out")) && (i < (argc - 1)))
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
file_out = argv[i];
|
|
|
|
}
|
2009-12-02 13:00:57 -08:00
|
|
|
else if (!strcmp(argv[i], "-no-build-sh"))
|
|
|
|
build_sh = 0;
|
2009-12-02 13:06:11 -08:00
|
|
|
else if (!strcmp(argv[i], "-current-dir"))
|
|
|
|
new_dir = 0;
|
2004-08-29 04:03:19 -07:00
|
|
|
}
|
|
|
|
if (!file_in)
|
|
|
|
{
|
2009-12-22 05:46:00 -08:00
|
|
|
ERR("%s: Error: no input file specified.", progname);
|
2004-08-29 04:03:19 -07:00
|
|
|
main_help();
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
2010-02-01 09:26:25 -08:00
|
|
|
if (!edje_init())
|
|
|
|
exit(-1);
|
2004-08-29 04:03:19 -07:00
|
|
|
source_edd();
|
2007-08-26 05:54:51 -07:00
|
|
|
|
2004-08-29 04:03:19 -07:00
|
|
|
if (!decomp()) return -1;
|
|
|
|
output();
|
|
|
|
|
2008-03-01 21:39:51 -08:00
|
|
|
eet_close(ef);
|
2010-02-01 09:26:25 -08:00
|
|
|
edje_shutdown();
|
2009-12-22 05:46:00 -08:00
|
|
|
eina_log_domain_unregister(_edje_cc_log_dom);
|
|
|
|
_edje_cc_log_dom = -1;
|
|
|
|
eina_shutdown();
|
2004-08-29 04:03:19 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
decomp(void)
|
|
|
|
{
|
|
|
|
ef = eet_open(file_in, EET_FILE_MODE_READ);
|
2004-08-29 05:28:53 -07:00
|
|
|
if (!ef)
|
|
|
|
{
|
2009-12-22 05:46:00 -08:00
|
|
|
ERR("ERROR: cannot open %s", file_in);
|
2004-08-29 05:28:53 -07:00
|
|
|
return 0;
|
|
|
|
}
|
2007-08-26 05:54:51 -07:00
|
|
|
|
2004-08-29 04:03:19 -07:00
|
|
|
srcfiles = source_load(ef);
|
2005-03-16 11:40:25 -08:00
|
|
|
if (!srcfiles || !srcfiles->list)
|
2004-08-29 04:03:19 -07:00
|
|
|
{
|
2009-12-22 05:46:00 -08:00
|
|
|
ERR("ERROR: %s has no decompile information", file_in);
|
2004-08-29 04:03:19 -07:00
|
|
|
eet_close(ef);
|
|
|
|
return 0;
|
|
|
|
}
|
2008-10-22 04:34:42 -07:00
|
|
|
if (!eina_list_data_get(srcfiles->list) || !root_filename_is_sane())
|
2005-03-16 11:40:25 -08:00
|
|
|
{
|
2009-12-22 05:46:00 -08:00
|
|
|
ERR("ERROR: Invalid root filename: '%s'", (char *) eina_list_data_get(srcfiles->list));
|
2005-03-16 11:40:25 -08:00
|
|
|
eet_close(ef);
|
|
|
|
return 0;
|
|
|
|
}
|
2010-08-09 10:34:03 -07:00
|
|
|
edje_file = eet_data_read(ef, _edje_edd_edje_file, "edje/file");
|
2004-08-29 05:28:53 -07:00
|
|
|
if (!edje_file)
|
|
|
|
{
|
2009-12-22 05:46:00 -08:00
|
|
|
ERR("ERROR: %s does not appear to be an edje file", file_in);
|
2004-08-29 05:28:53 -07:00
|
|
|
eet_close(ef);
|
|
|
|
return 0;
|
|
|
|
}
|
2005-03-16 10:39:39 -08:00
|
|
|
if (!edje_file->compiler)
|
|
|
|
{
|
|
|
|
edje_file->compiler = strdup("edje_cc");
|
|
|
|
}
|
|
|
|
else if (!compiler_cmd_is_sane())
|
|
|
|
{
|
2009-12-22 05:46:00 -08:00
|
|
|
ERR("ERROR: invalid compiler executable: '%s'", edje_file->compiler);
|
2005-03-16 10:39:39 -08:00
|
|
|
eet_close(ef);
|
|
|
|
return 0;
|
|
|
|
}
|
2004-08-29 04:03:19 -07:00
|
|
|
fontlist = source_fontmap_load(ef);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
output(void)
|
|
|
|
{
|
2008-10-22 04:34:42 -07:00
|
|
|
Eina_List *l;
|
2004-08-29 04:03:19 -07:00
|
|
|
Eet_File *ef;
|
2008-10-22 04:34:42 -07:00
|
|
|
SrcFile *sf;
|
2004-08-29 04:03:19 -07:00
|
|
|
char *outdir, *p;
|
2007-08-26 05:54:51 -07:00
|
|
|
|
2009-12-02 13:06:11 -08:00
|
|
|
if (!new_dir)
|
|
|
|
outdir = strdup(".");
|
2004-08-29 04:03:19 -07:00
|
|
|
else
|
2009-12-02 13:06:11 -08:00
|
|
|
{
|
|
|
|
p = strrchr(file_in, '/');
|
|
|
|
if (p)
|
|
|
|
outdir = strdup(p + 1);
|
|
|
|
else
|
|
|
|
outdir = strdup(file_in);
|
|
|
|
p = strrchr(outdir, '.');
|
|
|
|
if (p) *p = 0;
|
|
|
|
ecore_file_mkpath(outdir);
|
|
|
|
}
|
2007-08-26 05:54:51 -07:00
|
|
|
|
|
|
|
|
2004-08-29 04:03:19 -07:00
|
|
|
ef = eet_open(file_in, EET_FILE_MODE_READ);
|
2004-10-29 07:04:23 -07:00
|
|
|
|
2004-08-29 04:03:19 -07:00
|
|
|
if (edje_file->image_dir)
|
|
|
|
{
|
2008-10-22 04:34:42 -07:00
|
|
|
Edje_Image_Directory_Entry *ei;
|
2010-08-09 10:34:03 -07:00
|
|
|
unsigned int i;
|
2007-08-26 05:54:51 -07:00
|
|
|
|
2010-08-09 10:34:03 -07:00
|
|
|
for (i = 0; i < edje_file->image_dir->entries_count; ++i)
|
2008-10-22 04:34:42 -07:00
|
|
|
{
|
2010-08-09 10:34:03 -07:00
|
|
|
ei = &edje_file->image_dir->entries[i];
|
|
|
|
|
2007-08-26 05:54:51 -07:00
|
|
|
if ((ei->source_type > EDJE_IMAGE_SOURCE_TYPE_NONE) &&
|
2007-08-11 19:48:13 -07:00
|
|
|
(ei->source_type < EDJE_IMAGE_SOURCE_TYPE_LAST) &&
|
|
|
|
(ei->source_type != EDJE_IMAGE_SOURCE_TYPE_EXTERNAL) &&
|
|
|
|
(ei->entry))
|
2004-08-29 04:03:19 -07:00
|
|
|
{
|
2005-11-10 22:49:57 -08:00
|
|
|
Ecore_Evas *ee;
|
|
|
|
Evas *evas;
|
|
|
|
Evas_Object *im;
|
2004-08-29 04:03:19 -07:00
|
|
|
char buf[4096];
|
2005-11-10 22:49:57 -08:00
|
|
|
char out[4096];
|
|
|
|
char *pp;
|
2007-08-26 05:54:51 -07:00
|
|
|
|
2005-11-10 22:49:57 -08:00
|
|
|
ecore_init();
|
|
|
|
ecore_evas_init();
|
|
|
|
ee = ecore_evas_buffer_new(1, 1);
|
2006-01-23 07:13:44 -08:00
|
|
|
if (!ee)
|
|
|
|
{
|
2009-12-22 05:46:00 -08:00
|
|
|
ERR("Cannot create buffer engine canvas for image save.");
|
2006-01-23 07:13:44 -08:00
|
|
|
exit(-1);
|
|
|
|
}
|
2005-11-10 22:49:57 -08:00
|
|
|
evas = ecore_evas_get(ee);
|
|
|
|
im = evas_object_image_add(evas);
|
2006-01-23 07:13:44 -08:00
|
|
|
if (!im)
|
|
|
|
{
|
2009-12-22 05:46:00 -08:00
|
|
|
ERR("Cannot create image object for save.");
|
2006-01-23 07:13:44 -08:00
|
|
|
exit(-1);
|
|
|
|
}
|
2010-08-13 13:07:12 -07:00
|
|
|
snprintf(buf, sizeof(buf), "edje/images/%i", ei->id);
|
2005-11-10 22:49:57 -08:00
|
|
|
evas_object_image_file_set(im, file_in, buf);
|
|
|
|
snprintf(out, sizeof(out), "%s/%s", outdir, ei->entry);
|
|
|
|
printf("Output Image: %s\n", out);
|
|
|
|
pp = strdup(out);
|
|
|
|
p = strrchr(pp, '/');
|
|
|
|
*p = 0;
|
|
|
|
if (strstr(pp, "../"))
|
2004-08-29 04:03:19 -07:00
|
|
|
{
|
2009-12-22 05:46:00 -08:00
|
|
|
ERR("Potential security violation. attempt to write in parent dir.");
|
2006-01-23 07:13:44 -08:00
|
|
|
exit(-1);
|
2004-08-29 04:03:19 -07:00
|
|
|
}
|
2008-03-24 01:09:06 -07:00
|
|
|
ecore_file_mkpath(pp);
|
2005-11-10 22:49:57 -08:00
|
|
|
free(pp);
|
2006-01-23 07:13:44 -08:00
|
|
|
if (!evas_object_image_save(im, out, NULL, "quality=100 compress=9"))
|
|
|
|
{
|
2009-12-22 05:46:00 -08:00
|
|
|
ERR("Cannot write file %s. Perhaps missing JPEG or PNG saver modules for Evas.", out);
|
2006-01-23 07:13:44 -08:00
|
|
|
exit(-1);
|
|
|
|
}
|
2005-11-10 22:49:57 -08:00
|
|
|
evas_object_del(im);
|
|
|
|
ecore_evas_free(ee);
|
|
|
|
ecore_evas_shutdown();
|
|
|
|
ecore_shutdown();
|
2004-08-29 04:03:19 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-10-29 07:04:23 -07:00
|
|
|
|
2008-10-22 04:34:42 -07:00
|
|
|
EINA_LIST_FOREACH(srcfiles->list, l, sf)
|
2004-08-29 04:03:19 -07:00
|
|
|
{
|
|
|
|
char out[4096];
|
|
|
|
FILE *f;
|
|
|
|
char *pp;
|
2007-08-26 05:54:51 -07:00
|
|
|
|
2004-08-29 04:03:19 -07:00
|
|
|
snprintf(out, sizeof(out), "%s/%s", outdir, sf->name);
|
2009-12-22 05:46:00 -08:00
|
|
|
INF("Output Source File: %s\n", out);
|
2004-08-29 04:03:19 -07:00
|
|
|
pp = strdup(out);
|
|
|
|
p = strrchr(pp, '/');
|
|
|
|
*p = 0;
|
2004-08-29 05:28:53 -07:00
|
|
|
if (strstr(pp, "../"))
|
|
|
|
{
|
2009-12-22 05:46:00 -08:00
|
|
|
ERR("Potential security violation. attempt to write in parent dir.");
|
2004-08-29 05:28:53 -07:00
|
|
|
exit (-1);
|
|
|
|
}
|
2008-03-24 01:09:06 -07:00
|
|
|
ecore_file_mkpath(pp);
|
2004-08-29 04:03:19 -07:00
|
|
|
free(pp);
|
2004-08-29 05:28:53 -07:00
|
|
|
if (strstr(out, "../"))
|
|
|
|
{
|
2009-12-22 05:46:00 -08:00
|
|
|
ERR("Potential security violation. attempt to write in parent dir.");
|
2004-08-29 05:28:53 -07:00
|
|
|
exit (-1);
|
|
|
|
}
|
2008-06-28 02:11:48 -07:00
|
|
|
f = fopen(out, "wb");
|
2007-08-26 05:54:51 -07:00
|
|
|
if (!f)
|
2004-12-10 08:03:42 -08:00
|
|
|
{
|
2009-12-22 05:46:00 -08:00
|
|
|
ERR("Unable to write file (%s).", out);
|
2004-12-10 08:03:42 -08:00
|
|
|
exit (-1);
|
|
|
|
}
|
2006-02-13 10:20:26 -08:00
|
|
|
|
|
|
|
/* if the file is empty, sf->file will be NULL.
|
|
|
|
* note that that's not an error
|
|
|
|
*/
|
|
|
|
if (sf->file) fputs(sf->file, f);
|
2004-08-29 04:03:19 -07:00
|
|
|
fclose(f);
|
|
|
|
}
|
2010-08-13 13:07:12 -07:00
|
|
|
if (edje_file->fonts)
|
2004-08-29 04:03:19 -07:00
|
|
|
{
|
2010-08-13 13:07:12 -07:00
|
|
|
Edje_Font_Directory_Entry *fn;
|
|
|
|
Eina_Iterator *it;
|
2008-10-22 04:34:42 -07:00
|
|
|
|
2010-08-13 13:07:12 -07:00
|
|
|
it = eina_hash_iterator_data_new(edje_file->fonts);
|
|
|
|
EINA_ITERATOR_FOREACH(it, fn)
|
2004-08-29 04:03:19 -07:00
|
|
|
{
|
|
|
|
void *font;
|
|
|
|
int fontsize;
|
|
|
|
char out[4096];
|
2007-08-26 05:54:51 -07:00
|
|
|
|
2010-08-13 13:07:12 -07:00
|
|
|
snprintf(out, sizeof(out), "edje/fonts/%s", fn->entry);
|
2004-08-29 04:03:19 -07:00
|
|
|
font = eet_read(ef, out, &fontsize);
|
|
|
|
if (font)
|
|
|
|
{
|
|
|
|
FILE *f;
|
2004-08-29 05:28:53 -07:00
|
|
|
char *pp;
|
2007-08-26 05:54:51 -07:00
|
|
|
|
2004-08-29 04:03:19 -07:00
|
|
|
snprintf(out, sizeof(out), "%s/%s", outdir, fn->file);
|
2009-12-22 05:46:00 -08:00
|
|
|
INF("Output Font: %s", out);
|
2004-08-29 05:28:53 -07:00
|
|
|
pp = strdup(out);
|
|
|
|
p = strrchr(pp, '/');
|
|
|
|
*p = 0;
|
|
|
|
if (strstr(pp, "../"))
|
|
|
|
{
|
2009-12-22 05:46:00 -08:00
|
|
|
ERR("Potential security violation. attempt to write in parent dir.");
|
2004-08-29 05:28:53 -07:00
|
|
|
exit (-1);
|
|
|
|
}
|
2008-03-24 01:09:06 -07:00
|
|
|
ecore_file_mkpath(pp);
|
2004-08-29 05:28:53 -07:00
|
|
|
free(pp);
|
|
|
|
if (strstr(out, "../"))
|
|
|
|
{
|
2009-12-22 05:46:00 -08:00
|
|
|
ERR("Potential security violation. attempt to write in parent dir.");
|
2004-08-29 05:28:53 -07:00
|
|
|
exit (-1);
|
|
|
|
}
|
2010-07-30 22:24:47 -07:00
|
|
|
if (!(f = fopen(out, "wb")))
|
|
|
|
ERR("Could not open file: %s", out);
|
2010-02-28 08:14:50 -08:00
|
|
|
if (fwrite(font, fontsize, 1, f) != 1)
|
|
|
|
ERR("Could not write font: %s", strerror(errno));
|
2010-07-30 22:24:47 -07:00
|
|
|
if (f) fclose(f);
|
2004-08-29 04:03:19 -07:00
|
|
|
free(font);
|
|
|
|
}
|
|
|
|
}
|
2010-08-13 13:07:12 -07:00
|
|
|
eina_iterator_free(it);
|
2004-08-29 04:03:19 -07:00
|
|
|
}
|
|
|
|
{
|
|
|
|
char out[4096];
|
|
|
|
FILE *f;
|
2008-10-22 04:34:42 -07:00
|
|
|
SrcFile *sf = eina_list_data_get(srcfiles->list);
|
2007-08-26 05:54:51 -07:00
|
|
|
|
2009-12-02 13:00:57 -08:00
|
|
|
|
|
|
|
if (build_sh)
|
2004-08-29 05:28:53 -07:00
|
|
|
{
|
2009-12-02 13:00:57 -08:00
|
|
|
snprintf(out, sizeof(out), "%s/build.sh", outdir);
|
|
|
|
printf("Output Build Script: %s\n", out);
|
|
|
|
if (strstr(out, "../"))
|
|
|
|
{
|
2009-12-22 05:46:00 -08:00
|
|
|
ERR("potential security violation. attempt to write in parent dir.\n");
|
2009-12-02 13:00:57 -08:00
|
|
|
exit (-1);
|
|
|
|
}
|
|
|
|
f = fopen(out, "wb");
|
|
|
|
fprintf(f, "#!/bin/sh\n");
|
|
|
|
fprintf(f, "%s $@ -id . -fd . %s -o %s.edj\n", edje_file->compiler, sf->name, outdir);
|
|
|
|
fclose(f);
|
|
|
|
|
2009-12-22 05:46:00 -08:00
|
|
|
WRN("\n*** CAUTION ***\n"
|
|
|
|
"Please check the build script for anything malicious "
|
|
|
|
"before running it!\n\n");
|
2004-08-29 05:28:53 -07:00
|
|
|
}
|
2007-08-26 05:54:51 -07:00
|
|
|
|
2007-03-01 23:24:32 -08:00
|
|
|
if (file_out)
|
|
|
|
{
|
|
|
|
snprintf(out, sizeof(out), "%s/%s", outdir, file_out);
|
2009-12-08 21:46:02 -08:00
|
|
|
if (symlink(sf->name, out) != 0)
|
|
|
|
{
|
2009-12-22 05:46:00 -08:00
|
|
|
ERR("symlink %s -> %s failed\n", sf->name, out);
|
2009-12-08 21:46:02 -08:00
|
|
|
}
|
2007-03-01 23:24:32 -08:00
|
|
|
}
|
2004-10-29 07:04:23 -07:00
|
|
|
|
2004-08-29 04:03:19 -07:00
|
|
|
chmod(out, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP);
|
2005-03-16 10:46:47 -08:00
|
|
|
|
2004-08-29 04:03:19 -07:00
|
|
|
}
|
|
|
|
eet_close(ef);
|
|
|
|
}
|
|
|
|
|
2005-03-16 10:39:39 -08:00
|
|
|
static int
|
|
|
|
compiler_cmd_is_sane()
|
|
|
|
{
|
2010-07-30 22:10:44 -07:00
|
|
|
const char *c = edje_file->compiler, *ptr;
|
2005-03-16 10:39:39 -08:00
|
|
|
|
2010-07-30 22:10:44 -07:00
|
|
|
if ((!c) || (!*c))
|
2005-03-16 10:39:39 -08:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (ptr = c; ptr && *ptr; ptr++)
|
|
|
|
{
|
|
|
|
/* only allow [a-z][A-Z][0-9]_- */
|
2010-07-30 22:10:44 -07:00
|
|
|
if ((!isalnum(*ptr)) && (*ptr != '_') && (*ptr != '-'))
|
2005-03-16 10:39:39 -08:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
2005-03-16 11:40:25 -08:00
|
|
|
|
|
|
|
static int
|
|
|
|
root_filename_is_sane()
|
|
|
|
{
|
2008-10-22 04:34:42 -07:00
|
|
|
SrcFile *sf = eina_list_data_get(srcfiles->list);
|
2005-03-16 11:40:25 -08:00
|
|
|
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;
|
|
|
|
}
|