include correctly alloca.h and use ecore_file_mkpath instead of the local implementation

SVN revision: 34100
This commit is contained in:
doursse 2008-03-24 08:09:06 +00:00 committed by doursse
parent cbda36803a
commit ede49fdfb0
4 changed files with 22 additions and 61 deletions

View File

@ -66,6 +66,7 @@ PKG_CHECK_MODULES(EDJE, [
evas >= 0.9.9 evas >= 0.9.9
ecore-evas >= 0.9.9 ecore-evas >= 0.9.9
ecore-job >= 0.9.9 ecore-job >= 0.9.9
ecore-file >= 0.9.9
eet >= 0.9.10 eet >= 0.9.10
embryo >= 0.9.1 embryo >= 0.9.1
]) ])

View File

@ -8,6 +8,7 @@
#include <dirent.h> #include <dirent.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <Ecore_File.h>
#ifdef _WIN32 #ifdef _WIN32
# include <windows.h> # include <windows.h>
# include <shlobj.h> # include <shlobj.h>
@ -26,9 +27,6 @@ int line = 0;
int decomp(void); int decomp(void);
void output(void); void output(void);
int e_file_is_dir(char *file);
int e_file_mkdir(char *dir);
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 int root_filename_is_sane();
@ -184,7 +182,7 @@ output(void)
p = strrchr(outdir, '.'); p = strrchr(outdir, '.');
if (p) *p = 0; if (p) *p = 0;
e_file_mkpath(outdir); ecore_file_mkpath(outdir);
ef = eet_open(file_in, EET_FILE_MODE_READ); ef = eet_open(file_in, EET_FILE_MODE_READ);
@ -234,7 +232,7 @@ output(void)
printf("ERROR: potential security violation. attempt to write in parent dir.\n"); printf("ERROR: potential security violation. attempt to write in parent dir.\n");
exit(-1); exit(-1);
} }
e_file_mkpath(pp); ecore_file_mkpath(pp);
free(pp); free(pp);
if (!evas_object_image_save(im, out, NULL, "quality=100 compress=9")) if (!evas_object_image_save(im, out, NULL, "quality=100 compress=9"))
{ {
@ -267,7 +265,7 @@ output(void)
printf("ERROR: potential security violation. attempt to write in parent dir.\n"); printf("ERROR: potential security violation. attempt to write in parent dir.\n");
exit (-1); exit (-1);
} }
e_file_mkpath(pp); ecore_file_mkpath(pp);
free(pp); free(pp);
if (strstr(out, "../")) if (strstr(out, "../"))
{ {
@ -314,7 +312,7 @@ output(void)
printf("ERROR: potential security violation. attempt to write in parent dir.\n"); printf("ERROR: potential security violation. attempt to write in parent dir.\n");
exit (-1); exit (-1);
} }
e_file_mkpath(pp); ecore_file_mkpath(pp);
free(pp); free(pp);
if (strstr(out, "../")) if (strstr(out, "../"))
{ {
@ -362,55 +360,6 @@ output(void)
eet_close(ef); eet_close(ef);
} }
int
e_file_is_dir(char *file)
{
struct stat st;
if (stat(file, &st) < 0) return 0;
if (S_ISDIR(st.st_mode)) return 1;
return 0;
}
int
e_file_mkdir(char *dir)
{
#ifndef _WIN32
static mode_t default_mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
if (mkdir(dir, default_mode) < 0) return 0;
#else
if (mkdir(dir) < 0) return 0;
#endif /* _WIN32 */
return 1;
}
int
e_file_mkpath(char *path)
{
char ss[PATH_MAX];
int i, ii;
ss[0] = 0;
i = 0;
ii = 0;
while (path[i])
{
if (ii == sizeof(ss) - 1) return 0;
ss[ii++] = path[i];
ss[ii] = 0;
if (path[i] == '/')
{
if (!e_file_is_dir(ss)) e_file_mkdir(ss);
else if (!e_file_is_dir(ss)) return 0;
}
i++;
}
if (!e_file_is_dir(ss)) e_file_mkdir(ss);
else if (!e_file_is_dir(ss)) return 0;
return 1;
}
static int static int
compiler_cmd_is_sane() compiler_cmd_is_sane()
{ {

View File

@ -13,9 +13,6 @@
#include <stdarg.h> #include <stdarg.h>
#include <locale.h> #include <locale.h>
#include <ctype.h> #include <ctype.h>
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
/* types */ /* types */
typedef struct _Font Font; typedef struct _Font Font;

View File

@ -5,7 +5,6 @@
#include <config.h> #include <config.h>
#endif #endif
#include <sys/mman.h>
#include <Evas.h> #include <Evas.h>
#include <Ecore.h> #include <Ecore.h>
#include <Ecore_Evas.h> #include <Ecore_Evas.h>
@ -18,11 +17,26 @@
#include <errno.h> #include <errno.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/mman.h>
#include <stdarg.h> #include <stdarg.h>
#include <locale.h> #include <locale.h>
#include <ctype.h> #include <ctype.h>
#ifdef HAVE_ALLOCA_H #ifdef HAVE_ALLOCA_H
#include <alloca.h> # include <alloca.h>
#elif defined __GNUC__
# define alloca __builtin_alloca
#elif defined _AIX
# define alloca __alloca
#elif defined _MSC_VER
# include <malloc.h>
# define alloca _alloca
#else
# include <stddef.h>
# ifdef __cplusplus
extern "C"
# endif
void *alloca (size_t);
#endif #endif
#include "edje_private.h" #include "edje_private.h"