Replaced printf(translate(x)) with custom print_translate/get_translate functions
This commit is contained in:
parent
3c592e1d1c
commit
bef39999a6
File diff suppressed because it is too large
Load diff
|
@ -29,83 +29,86 @@
|
|||
#include "expresion.h"
|
||||
|
||||
FILE *f;
|
||||
int i,tamano;
|
||||
char* buffer;
|
||||
int i, tamano;
|
||||
char *buffer;
|
||||
int linea;
|
||||
char cfg[256];
|
||||
|
||||
/*void cfg_error(int error)
|
||||
void salta_spc()
|
||||
{
|
||||
printf(translate(41),cfg,linea,translate_cfg_error(error));
|
||||
printf(translate(42));
|
||||
exit(1);
|
||||
}*/
|
||||
|
||||
void salta_spc() {
|
||||
while(lower[buffer[i]]==0 && i<tamano) {
|
||||
if(buffer[i]=='\n') linea++;
|
||||
else if(buffer[i]=='\'') {
|
||||
while(buffer[i]!='\n' && i<tamano) i++;
|
||||
while (lower[buffer[i]] == 0 && i < tamano)
|
||||
{
|
||||
if (buffer[i] == '\n')
|
||||
linea++;
|
||||
else if (buffer[i] == '\'')
|
||||
{
|
||||
while (buffer[i] != '\n' && i < tamano)
|
||||
i++;
|
||||
linea++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void lee_ediv_cfg(char* ediv_cfg)
|
||||
void lee_ediv_cfg(char *ediv_cfg)
|
||||
{
|
||||
int c;
|
||||
char tag[20];
|
||||
|
||||
strcpy(cfg,ediv_cfg);
|
||||
strcpy(cfg, ediv_cfg);
|
||||
|
||||
/* Valores de las opciones por defecto */
|
||||
max_process=0;
|
||||
ignore_errors=0;
|
||||
free_sintax=0;
|
||||
extended_conditions=0;
|
||||
simple_conditions=0;
|
||||
comprueba_rango=1;
|
||||
comprueba_id=1;
|
||||
comprueba_null=1;
|
||||
hacer_strfix=1;
|
||||
optimizar=1;
|
||||
max_process = 0;
|
||||
ignore_errors = 0;
|
||||
free_sintax = 0;
|
||||
extended_conditions = 0;
|
||||
simple_conditions = 0;
|
||||
comprueba_rango = 1;
|
||||
comprueba_id = 1;
|
||||
comprueba_null = 1;
|
||||
hacer_strfix = 1;
|
||||
optimizar = 1;
|
||||
|
||||
if((f=fopen(ediv_cfg,"r"))==NULL) {
|
||||
if ((f = fopen(ediv_cfg, "r")) == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
fseek(f,0,SEEK_END);
|
||||
tamano=ftell(f);
|
||||
fseek(f,0,SEEK_SET);
|
||||
fseek(f, 0, SEEK_END);
|
||||
tamano = ftell(f);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
buffer = e_malloc(tamano);
|
||||
|
||||
fread(buffer,1,tamano,f);
|
||||
fread(buffer, 1, tamano, f);
|
||||
fclose(f);
|
||||
|
||||
for(i=0;i<tamano;i++) {
|
||||
for (i = 0; i < tamano; i++)
|
||||
{
|
||||
salta_spc();
|
||||
c=0;
|
||||
while(lower[buffer[i]]!=0 && c<20 && i<tamano)
|
||||
tag[c++]=lower[buffer[i++]];
|
||||
tag[c]=0;
|
||||
c = 0;
|
||||
while (lower[buffer[i]] != 0 && c < 20 && i < tamano)
|
||||
tag[c++] = lower[buffer[i++]];
|
||||
tag[c] = 0;
|
||||
|
||||
if(!strcmp(tag,"max_process")) {
|
||||
if (!strcmp(tag, "max_process"))
|
||||
{
|
||||
salta_spc();
|
||||
if(buffer[i]!='=') cfg_error(1); /* se esperaba '=' */
|
||||
if (buffer[i] != '=')
|
||||
cfg_error(1); /* se esperaba '=' */
|
||||
salta_spc();
|
||||
if(buffer[i]<'0' || buffer[i]>'9') cfg_error(2); /* se esperaba un dato numerico */
|
||||
c=0;
|
||||
while(buffer[i]>='0' && buffer[i]<='9' && i<tamano)
|
||||
tag[c++]=buffer[i++];
|
||||
tag[c]=0;
|
||||
if (buffer[i] < '0' || buffer[i] > '9')
|
||||
cfg_error(2); /* se esperaba un dato numerico */
|
||||
c = 0;
|
||||
while (buffer[i] >= '0' && buffer[i] <= '9' && i < tamano)
|
||||
tag[c++] = buffer[i++];
|
||||
tag[c] = 0;
|
||||
itoa(
|
||||
|
||||
max_process=constante();
|
||||
if (max_process<0) max_process=0;
|
||||
#ifdef _DEBUG
|
||||
#ifdef _DEBUG
|
||||
printf("dbg: max_process=%d\n",max_process);
|
||||
#endif
|
||||
#endif
|
||||
break;
|
||||
case 1: /* _extended_conditions */
|
||||
lexico();
|
||||
|
@ -155,8 +158,7 @@ void lee_ediv_cfg(char* ediv_cfg)
|
|||
lexico();
|
||||
comprueba_null=0;
|
||||
break;
|
||||
}
|
||||
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
free(buffer);
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
*/
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <winsock2.h>
|
||||
# include "dll_load.h"
|
||||
#include <winsock2.h>
|
||||
#include "dll_load.h"
|
||||
struct in_addr iahost;
|
||||
struct hostent *htent;
|
||||
struct servent *svent;
|
||||
|
@ -28,14 +28,14 @@ int status;
|
|||
char buffer[1024];
|
||||
SOCKET sock;
|
||||
|
||||
#define sock_error(s) fprintf(stderr,"\nerror: %d\n", WSAGetLastError())
|
||||
#define sock_error(s) fprintf(stderr, "\nerror: %d\n", WSAGetLastError())
|
||||
|
||||
void muestra_motd();
|
||||
void conecta(char *servidor, char *archivo);
|
||||
|
||||
#else
|
||||
# include <dlfcn.h> /* ¿será igual en BeOS? */
|
||||
# include <dirent.h>
|
||||
#include <dlfcn.h> /* ¿será igual en BeOS? */
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -59,262 +59,296 @@ void conecta(char *servidor, char *archivo);
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FILE *fp; /* stream del PRG */
|
||||
FILE *fp; /* stream del PRG */
|
||||
char *p;
|
||||
char libmagic[14]; /* cabecera "magic" de EDIVRUN.LIB */
|
||||
char libmagic[14]; /* cabecera "magic" de EDIVRUN.LIB */
|
||||
|
||||
int i,j;
|
||||
byte hayprog=0;
|
||||
int i, j;
|
||||
byte hayprog = 0;
|
||||
|
||||
char sistema[20];
|
||||
|
||||
n_errors=0;
|
||||
n_warnings=0;
|
||||
debug=0;
|
||||
listados=0;
|
||||
noexe=0;
|
||||
n_errors = 0;
|
||||
n_warnings = 0;
|
||||
debug = 0;
|
||||
listados = 0;
|
||||
noexe = 0;
|
||||
|
||||
/* Sistemas */
|
||||
#if defined(_WIN32)
|
||||
strcpy(sistema,"win32");
|
||||
#elif defined(__linux__)
|
||||
strcpy(sistema,"linux");
|
||||
#elif defined(__APPLE__)
|
||||
strcpy(sistema, "osx");
|
||||
#else
|
||||
strcpy(sistema, "unknown");
|
||||
#endif
|
||||
/* Sistemas */
|
||||
#if defined(_WIN32)
|
||||
strcpy(sistema, "win32");
|
||||
#elif defined(__linux__)
|
||||
strcpy(sistema, "linux");
|
||||
#elif defined(__APPLE__)
|
||||
strcpy(sistema, "osx");
|
||||
#else
|
||||
strcpy(sistema, "unknown");
|
||||
#endif
|
||||
|
||||
ini=iniparser_load("ediv.cfg");
|
||||
ini = iniparser_load("ediv.cfg");
|
||||
|
||||
idioma=detecta_idioma();
|
||||
idioma = detecta_idioma();
|
||||
|
||||
/* mensaje de cabecera */
|
||||
printf(translate(0));
|
||||
printf(translate(1));
|
||||
print_translate(0);
|
||||
print_translate(1);
|
||||
printf("\n");
|
||||
|
||||
if(argc<2) goto ayuda;
|
||||
if (argc < 2)
|
||||
goto ayuda;
|
||||
|
||||
if(strcmp(argv[1],"--version")==0 || strcmp(argv[1],"-v")==0)
|
||||
exit(0);
|
||||
if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-v") == 0)
|
||||
exit(0);
|
||||
|
||||
if(strcmp(argv[1],"--help")==0 || strcmp(argv[1],"-h")==0) {
|
||||
ayuda:
|
||||
if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0)
|
||||
{
|
||||
ayuda:
|
||||
/* pantalla de ayuda */
|
||||
printf(translate(2));
|
||||
printf(translate(3),argv[0]);
|
||||
printf(translate(4));
|
||||
printf(translate(5));
|
||||
printf(translate(6));
|
||||
printf(translate(7));
|
||||
printf(translate(8));
|
||||
printf(translate(9));
|
||||
printf(translate(10),sistema);
|
||||
printf(translate(48));
|
||||
printf(translate(11));
|
||||
exit(0);
|
||||
}
|
||||
print_translate(2);
|
||||
print_translate(3, argv[0]);
|
||||
print_translate(4);
|
||||
print_translate(5);
|
||||
print_translate(6);
|
||||
print_translate(7);
|
||||
print_translate(8);
|
||||
print_translate(9);
|
||||
print_translate(10, sistema);
|
||||
print_translate(48);
|
||||
print_translate(11);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
for(i=1;i<argc;i++) {
|
||||
if(argv[i][0]=='-') {
|
||||
if(argv[i][1]=='-') {
|
||||
if(strcmp(argv[i]+2,"debug")==0)
|
||||
debug=1;
|
||||
else if(strcmp(argv[i]+2,"list")==0)
|
||||
listados|=1;
|
||||
else if(strcmp(argv[i]+2,"table")==0)
|
||||
listados|=2;
|
||||
else if(strcmp(argv[i]+2,"check")==0)
|
||||
noexe=1;
|
||||
else if(strcmp(argv[i]+2,"system")==0)
|
||||
if(++i<argc) {
|
||||
strcpy(sistema,argv[i]);
|
||||
} else {
|
||||
printf(translate(12)); /* se debe indicar un sistema para --system */
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
if (argv[i][0] == '-')
|
||||
{
|
||||
if (argv[i][1] == '-')
|
||||
{
|
||||
if (strcmp(argv[i] + 2, "debug") == 0)
|
||||
debug = 1;
|
||||
else if (strcmp(argv[i] + 2, "list") == 0)
|
||||
listados |= 1;
|
||||
else if (strcmp(argv[i] + 2, "table") == 0)
|
||||
listados |= 2;
|
||||
else if (strcmp(argv[i] + 2, "check") == 0)
|
||||
noexe = 1;
|
||||
else if (strcmp(argv[i] + 2, "system") == 0)
|
||||
if (++i < argc)
|
||||
{
|
||||
strcpy(sistema, argv[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
print_translate(12); /* se debe indicar un sistema para --system */
|
||||
exit(1);
|
||||
}
|
||||
#ifdef _WIN32
|
||||
else if(strcmp(argv[i]+2,"news")==0) {
|
||||
else if (strcmp(argv[i] + 2, "news") == 0)
|
||||
{
|
||||
muestra_motd();
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
printf(translate(13),argv[i]); /* parámetro erróneo */
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
j=1;
|
||||
while(argv[i][j]!=0) {
|
||||
switch(argv[i][j]) {
|
||||
case 'd':
|
||||
debug=1;
|
||||
break;
|
||||
case 'l':
|
||||
listados|=1;
|
||||
break;
|
||||
case 't':
|
||||
listados|=2;
|
||||
break;
|
||||
case 'c':
|
||||
noexe=1;
|
||||
break;
|
||||
case 's':
|
||||
if(argv[i][j+1]!=0) {
|
||||
strcpy(sistema,argv[i]+j+1);
|
||||
j=strlen(argv[i])-1;
|
||||
else
|
||||
{
|
||||
print_translate(13, argv[i]); /* parámetro erróneo */
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
j = 1;
|
||||
while (argv[i][j] != 0)
|
||||
{
|
||||
switch (argv[i][j])
|
||||
{
|
||||
case 'd':
|
||||
debug = 1;
|
||||
break;
|
||||
case 'l':
|
||||
listados |= 1;
|
||||
break;
|
||||
case 't':
|
||||
listados |= 2;
|
||||
break;
|
||||
case 'c':
|
||||
noexe = 1;
|
||||
break;
|
||||
case 's':
|
||||
if (argv[i][j + 1] != 0)
|
||||
{
|
||||
strcpy(sistema, argv[i] + j + 1);
|
||||
j = strlen(argv[i]) - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (++i < argc)
|
||||
{
|
||||
strcpy(sistema, argv[i]);
|
||||
j = strlen(argv[i]) - 1;
|
||||
}
|
||||
else {
|
||||
if(++i<argc) {
|
||||
strcpy(sistema,argv[i]);
|
||||
j=strlen(argv[i])-1;
|
||||
}
|
||||
else {
|
||||
printf(translate(14)); /* se debe indicar un sistema para -s */
|
||||
exit(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
print_translate(14); /* se debe indicar un sistema para -s */
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
#ifdef _WIN32
|
||||
case 'n':
|
||||
muestra_motd();
|
||||
exit(0);
|
||||
case 'n':
|
||||
muestra_motd();
|
||||
exit(0);
|
||||
#endif
|
||||
default:
|
||||
printf(translate(15),argv[i][j]); /* parámetro erróneo */
|
||||
exit(1);
|
||||
}
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else switch (hayprog) {
|
||||
default:
|
||||
print_translate(15, argv[i][j]); /* parámetro erróneo */
|
||||
exit(1);
|
||||
}
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
switch (hayprog)
|
||||
{
|
||||
case 0:
|
||||
fichero_prg=argv[i];
|
||||
hayprog=1;
|
||||
fichero_prg = argv[i];
|
||||
hayprog = 1;
|
||||
break;
|
||||
case 1:
|
||||
strcpy(outfilename,argv[i]);
|
||||
hayprog=2;
|
||||
strcpy(outfilename, argv[i]);
|
||||
hayprog = 2;
|
||||
break;
|
||||
default:
|
||||
printf(translate(13),argv[i]); /* parámetro erróneo */
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if(hayprog==0) {
|
||||
printf(translate(16)); /* no se ha especificado un archivo */
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (i=0;i<=strlen(fichero_prg);i++) {
|
||||
if (*(fichero_prg+i) == '.')
|
||||
break;
|
||||
nombreprog[i] = *(fichero_prg+i);
|
||||
print_translate(13, argv[i]); /* parámetro erróneo */
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
nombreprog[i]=0;
|
||||
|
||||
if(!(fp = fopen(fichero_prg, "rb"))) {
|
||||
if(!strcmp(nombreprog,fichero_prg)) {
|
||||
strcpy(fichero_prg,nombreprog);
|
||||
strcat(fichero_prg,".prg");
|
||||
if(!(fp = fopen(fichero_prg, "rb"))) {
|
||||
strcpy(fichero_prg,nombreprog);
|
||||
strcat(fichero_prg,".PRG");
|
||||
if(!(fp = fopen(fichero_prg, "rb"))) {
|
||||
printf(translate(17),nombreprog); /* error al abrir archivo */
|
||||
if (hayprog == 0)
|
||||
{
|
||||
print_translate(16); /* no se ha especificado un archivo */
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (i = 0; i <= strlen(fichero_prg); i++)
|
||||
{
|
||||
if (*(fichero_prg + i) == '.')
|
||||
break;
|
||||
nombreprog[i] = *(fichero_prg + i);
|
||||
}
|
||||
nombreprog[i] = 0;
|
||||
|
||||
if (!(fp = fopen(fichero_prg, "rb")))
|
||||
{
|
||||
if (!strcmp(nombreprog, fichero_prg))
|
||||
{
|
||||
strcpy(fichero_prg, nombreprog);
|
||||
strcat(fichero_prg, ".prg");
|
||||
if (!(fp = fopen(fichero_prg, "rb")))
|
||||
{
|
||||
strcpy(fichero_prg, nombreprog);
|
||||
strcat(fichero_prg, ".PRG");
|
||||
if (!(fp = fopen(fichero_prg, "rb")))
|
||||
{
|
||||
print_translate(17, nombreprog); /* error al abrir archivo */
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf(translate(17),argv[1]); /* error al abrir archivo */
|
||||
else
|
||||
{
|
||||
print_translate(17, argv[1]); /* error al abrir archivo */
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Componemos el nombre del ejecutable */
|
||||
if(hayprog<2) {
|
||||
strcpy(outfilename,nombreprog);
|
||||
if(!strcmp(sistema,"win32"))
|
||||
strcat(outfilename,".exe");
|
||||
if (hayprog < 2)
|
||||
{
|
||||
strcpy(outfilename, nombreprog);
|
||||
if (!strcmp(sistema, "win32"))
|
||||
strcat(outfilename, ".exe");
|
||||
}
|
||||
|
||||
printf(translate(18),fichero_prg); /* compilando... */
|
||||
|
||||
print_translate(18, fichero_prg); /* compilando... */
|
||||
|
||||
/* mete el PRG en el buffer prog */
|
||||
fseek(fp,0,SEEK_END);
|
||||
progsize=ftell(fp);
|
||||
prog = e_malloc(progsize+1);
|
||||
fseek(fp,0,SEEK_SET);
|
||||
p=(char*)prog;
|
||||
do {
|
||||
fseek(fp, 0, SEEK_END);
|
||||
progsize = ftell(fp);
|
||||
prog = e_malloc(progsize + 1);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
p = (char *)prog;
|
||||
do
|
||||
{
|
||||
*p = getc(fp);
|
||||
p++;
|
||||
} while(!feof(fp));
|
||||
} while (!feof(fp));
|
||||
fclose(fp);
|
||||
|
||||
/* Comprueba si existe la edivrun.lib */
|
||||
if(!noexe) {
|
||||
strcpy(edivrun_lib,sistema);
|
||||
if(debug)
|
||||
strcat(edivrun_lib,".dbg");
|
||||
if (!noexe)
|
||||
{
|
||||
strcpy(edivrun_lib, sistema);
|
||||
if (debug)
|
||||
strcat(edivrun_lib, ".dbg");
|
||||
else
|
||||
strcat(edivrun_lib,".rel");
|
||||
strcat(edivrun_lib, ".rel");
|
||||
|
||||
if((fp = fopen(edivrun_lib, "rb"))==NULL) {
|
||||
printf(translate(19),edivrun_lib); /* no se encuentra el fichero */
|
||||
if ((fp = fopen(edivrun_lib, "rb")) == NULL)
|
||||
{
|
||||
print_translate(19, edivrun_lib); /* no se encuentra el fichero */
|
||||
exit(1);
|
||||
}
|
||||
else {
|
||||
fread(libmagic,1,14,fp);
|
||||
if(strcmp(libmagic,magic)) {
|
||||
printf(translate(20),edivrun_lib); /* formato incorrecto de edivrun.lib */
|
||||
else
|
||||
{
|
||||
fread(libmagic, 1, 14, fp);
|
||||
if (strcmp(libmagic, magic))
|
||||
{
|
||||
print_translate(20, edivrun_lib); /* formato incorrecto de edivrun.lib */
|
||||
fclose(fp);
|
||||
exit(1);
|
||||
}
|
||||
else {
|
||||
fread(&stub_size,1,4,fp);
|
||||
else
|
||||
{
|
||||
fread(&stub_size, 1, 4, fp);
|
||||
fclose(fp);
|
||||
#ifdef _DEBUG
|
||||
printf("dbg: STUB_SIZE: %d\n",stub_size);
|
||||
#endif
|
||||
#ifdef _DEBUG
|
||||
printf("dbg: STUB_SIZE: %d\n", stub_size);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!ini) {
|
||||
if (!ini)
|
||||
{
|
||||
/* Valores de las opciones por defecto */
|
||||
max_process=0;
|
||||
ignore_errors=0;
|
||||
free_sintax=0;
|
||||
extended_conditions=0;
|
||||
simple_conditions=0;
|
||||
comprueba_rango=1;
|
||||
comprueba_id=1;
|
||||
comprueba_null=1;
|
||||
hacer_strfix=1;
|
||||
optimizar=1;
|
||||
case_sensitive=0;
|
||||
} else {
|
||||
max_process=iniparser_getint(ini,"default_compiler_options:max_process",0);
|
||||
ignore_errors=iniparser_getboolean(ini,"default_compiler_options:ignore_errors",0);
|
||||
free_sintax=iniparser_getboolean(ini,"default_compiler_options:free_sintax",0);
|
||||
extended_conditions=iniparser_getboolean(ini,"default_compiler_options:extended_conditions",0);
|
||||
simple_conditions=iniparser_getboolean(ini,"default_compiler_options:simple_conditions",0);
|
||||
case_sensitive=iniparser_getboolean(ini,"default_compiler_options:case_sensitive",0);
|
||||
comprueba_rango=iniparser_getboolean(ini,"default_compiler_options:no_range_check",0)?0:1;
|
||||
comprueba_id=iniparser_getboolean(ini,"default_compiler_options:no_id_check",0)?0:1;
|
||||
comprueba_null=iniparser_getboolean(ini,"default_compiler_options:no_null_check",0)?0:1;
|
||||
hacer_strfix=iniparser_getboolean(ini,"default_compiler_options:no_strfix",0)?0:1;
|
||||
optimizar=iniparser_getboolean(ini,"default_compiler_options:no_optimization",0)?0:1;
|
||||
case_sensitive=iniparser_getboolean(ini,"default_compiler_options:case_sensitive",0);
|
||||
if(iniparser_getboolean(ini,"default_compiler_options:no_check",0))
|
||||
comprueba_rango=comprueba_id=comprueba_null=0;
|
||||
|
||||
max_process = 0;
|
||||
ignore_errors = 0;
|
||||
free_sintax = 0;
|
||||
extended_conditions = 0;
|
||||
simple_conditions = 0;
|
||||
comprueba_rango = 1;
|
||||
comprueba_id = 1;
|
||||
comprueba_null = 1;
|
||||
hacer_strfix = 1;
|
||||
optimizar = 1;
|
||||
case_sensitive = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
max_process = iniparser_getint(ini, "default_compiler_options:max_process", 0);
|
||||
ignore_errors = iniparser_getboolean(ini, "default_compiler_options:ignore_errors", 0);
|
||||
free_sintax = iniparser_getboolean(ini, "default_compiler_options:free_sintax", 0);
|
||||
extended_conditions = iniparser_getboolean(ini, "default_compiler_options:extended_conditions", 0);
|
||||
simple_conditions = iniparser_getboolean(ini, "default_compiler_options:simple_conditions", 0);
|
||||
case_sensitive = iniparser_getboolean(ini, "default_compiler_options:case_sensitive", 0);
|
||||
comprueba_rango = iniparser_getboolean(ini, "default_compiler_options:no_range_check", 0) ? 0 : 1;
|
||||
comprueba_id = iniparser_getboolean(ini, "default_compiler_options:no_id_check", 0) ? 0 : 1;
|
||||
comprueba_null = iniparser_getboolean(ini, "default_compiler_options:no_null_check", 0) ? 0 : 1;
|
||||
hacer_strfix = iniparser_getboolean(ini, "default_compiler_options:no_strfix", 0) ? 0 : 1;
|
||||
optimizar = iniparser_getboolean(ini, "default_compiler_options:no_optimization", 0) ? 0 : 1;
|
||||
case_sensitive = iniparser_getboolean(ini, "default_compiler_options:case_sensitive", 0);
|
||||
if (iniparser_getboolean(ini, "default_compiler_options:no_check", 0))
|
||||
comprueba_rango = comprueba_id = comprueba_null = 0;
|
||||
}
|
||||
|
||||
prepara_compilacion();
|
||||
|
@ -323,24 +357,23 @@ int main(int argc, char *argv[])
|
|||
compila();
|
||||
|
||||
#ifdef MULTI_ERROR
|
||||
printf("edivc: Finalizado - %d advertencias, %d errores\n",n_warnings,n_errors);
|
||||
printf("edivc: Finalizado - %d advertencias, %d errores\n", n_warnings, n_errors);
|
||||
#else
|
||||
if(n_errors)
|
||||
printf(translate(21),n_warnings);
|
||||
if (n_errors)
|
||||
print_translate(21, n_warnings);
|
||||
else
|
||||
printf(translate(22),n_warnings);
|
||||
print_translate(22, n_warnings);
|
||||
#endif
|
||||
|
||||
if(n_errors==0)
|
||||
if (n_errors == 0)
|
||||
return 0;
|
||||
else {
|
||||
printf(translate(23));
|
||||
else
|
||||
{
|
||||
print_translate(23);
|
||||
return 2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* void *e_malloc(size_t size)
|
||||
* Idéntico a malloc, pero con errormsg automático
|
||||
|
@ -348,12 +381,13 @@ int main(int argc, char *argv[])
|
|||
* Retorna:
|
||||
* El numero de bytes de memoria alojados o sale si no se puede reservar la memoria.
|
||||
*/
|
||||
void* e_malloc(size_t size)
|
||||
void *e_malloc(size_t size)
|
||||
{
|
||||
void* ret;
|
||||
void *ret;
|
||||
|
||||
if(!(ret = malloc(size))) {
|
||||
printf(translate(24)); /* memoria insuficiente */
|
||||
if (!(ret = malloc(size)))
|
||||
{
|
||||
print_translate(24); /* memoria insuficiente */
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -362,32 +396,47 @@ void* e_malloc(size_t size)
|
|||
|
||||
void e_free(void *puntero)
|
||||
{
|
||||
if (puntero) {
|
||||
if (puntero)
|
||||
{
|
||||
free(puntero);
|
||||
puntero=NULL;
|
||||
puntero = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void errormem()
|
||||
{
|
||||
printf(translate(24));
|
||||
print_translate(24);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Gestión de errores
|
||||
*/
|
||||
int _le,_t;
|
||||
int _le, _t;
|
||||
byte *_ie;
|
||||
|
||||
void save_error(word tipo) { /* Guarda una posicion de error (de 0 .. 3) */
|
||||
switch(tipo) {
|
||||
case 0: _le=linea; _ie=ierror; break;
|
||||
case 1: _le=old_linea; _ie=old_ierror_end; break;
|
||||
case 2: _le=old_linea; _ie=old_ierror; break;
|
||||
case 3: _le=old_linea; _ie=old_ierror_end; break;
|
||||
} _t=tipo;
|
||||
void save_error(word tipo)
|
||||
{ /* Guarda una posicion de error (de 0 .. 3) */
|
||||
switch (tipo)
|
||||
{
|
||||
case 0:
|
||||
_le = linea;
|
||||
_ie = ierror;
|
||||
break;
|
||||
case 1:
|
||||
_le = old_linea;
|
||||
_ie = old_ierror_end;
|
||||
break;
|
||||
case 2:
|
||||
_le = old_linea;
|
||||
_ie = old_ierror;
|
||||
break;
|
||||
case 3:
|
||||
_le = old_linea;
|
||||
_ie = old_ierror_end;
|
||||
break;
|
||||
}
|
||||
_t = tipo;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -399,48 +448,75 @@ void save_error(word tipo) { /* Guarda una posicion de error (de 0 .. 3) */
|
|||
*/
|
||||
void error(word tipo, word num, ...)
|
||||
{
|
||||
int columna=0;
|
||||
int columna = 0;
|
||||
int linea_error;
|
||||
byte *_p,*p;
|
||||
byte *_p, *p;
|
||||
va_list opparam;
|
||||
|
||||
switch(tipo) {
|
||||
case 0: linea_error=linea; p=ierror; break;
|
||||
case 1: linea_error=old_linea; _p=p=old_ierror_end; break;
|
||||
case 2: linea_error=old_linea; p=old_ierror; break;
|
||||
case 3: linea_error=old_linea; _p=p=old_ierror_end; break;
|
||||
case 4: linea_error=_le; _p=p=_ie; tipo=_t; break;
|
||||
switch (tipo)
|
||||
{
|
||||
case 0:
|
||||
linea_error = linea;
|
||||
p = ierror;
|
||||
break;
|
||||
case 1:
|
||||
linea_error = old_linea;
|
||||
_p = p = old_ierror_end;
|
||||
break;
|
||||
case 2:
|
||||
linea_error = old_linea;
|
||||
p = old_ierror;
|
||||
break;
|
||||
case 3:
|
||||
linea_error = old_linea;
|
||||
_p = p = old_ierror_end;
|
||||
break;
|
||||
case 4:
|
||||
linea_error = _le;
|
||||
_p = p = _ie;
|
||||
tipo = _t;
|
||||
break;
|
||||
}
|
||||
|
||||
if (num!=2 && num!=6) {
|
||||
while (--p>=prog) {
|
||||
if (*p==lf || (*p==cr && *(p+1)==lf)) break;
|
||||
if (num != 2 && num != 6)
|
||||
{
|
||||
while (--p >= prog)
|
||||
{
|
||||
if (*p == lf || (*p == cr && *(p + 1) == lf))
|
||||
break;
|
||||
columna++;
|
||||
}
|
||||
if (p<prog) columna++;
|
||||
if (p < prog)
|
||||
columna++;
|
||||
}
|
||||
|
||||
if (tipo==1) {
|
||||
if (*(_p+1)==' ' || *(_p+1)==cr || *(_p+1)==lf) columna++; columna++;
|
||||
} else if (tipo==3) columna++;
|
||||
if (tipo == 1)
|
||||
{
|
||||
if (*(_p + 1) == ' ' || *(_p + 1) == cr || *(_p + 1) == lf)
|
||||
columna++;
|
||||
columna++;
|
||||
}
|
||||
else if (tipo == 3)
|
||||
columna++;
|
||||
|
||||
va_start(opparam,num);
|
||||
printf(translate(25), fichero_prg, linea_error, columna, num);
|
||||
vprintf(translate_error(num),opparam);
|
||||
va_start(opparam, num);
|
||||
print_translate(25, fichero_prg, linea_error, columna, num);
|
||||
vprintf(translate_error(num), opparam);
|
||||
printf("\n");
|
||||
|
||||
n_errors++;
|
||||
|
||||
#ifdef MULTI_ERROR
|
||||
if(n_errors>20)
|
||||
if (n_errors > 20)
|
||||
printf("Demasiados errores. Compilación interrumpida.\n");
|
||||
|
||||
if(num==1 || num==2 || num==6 || n_errors>20) {
|
||||
printf("edivc: Finalizado - %d advertencias, %d errores\n",n_warnings,n_errors);
|
||||
if (num == 1 || num == 2 || num == 6 || n_errors > 20)
|
||||
{
|
||||
printf("edivc: Finalizado - %d advertencias, %d errores\n", n_warnings, n_errors);
|
||||
#else
|
||||
printf(translate(21),n_warnings);
|
||||
print_translate(21, n_warnings);
|
||||
#endif
|
||||
printf(translate(23));
|
||||
print_translate(23);
|
||||
exit(2);
|
||||
#ifdef MULTI_ERROR
|
||||
}
|
||||
|
@ -451,9 +527,9 @@ void warning(int num, ...)
|
|||
{
|
||||
va_list opparam;
|
||||
|
||||
va_start(opparam,num);
|
||||
printf(translate(26), fichero_prg, linea);
|
||||
vprintf(translate_warning(num),opparam);
|
||||
va_start(opparam, num);
|
||||
print_translate(26, fichero_prg, linea);
|
||||
vprintf(translate_warning(num), opparam);
|
||||
printf("\n");
|
||||
n_warnings++;
|
||||
}
|
||||
|
@ -464,21 +540,26 @@ void warning(int num, ...)
|
|||
#ifdef _WIN32
|
||||
void muestra_motd()
|
||||
{
|
||||
char* motdserver=NULL;
|
||||
char* motdpath=NULL;
|
||||
char *motdserver = NULL;
|
||||
char *motdpath = NULL;
|
||||
|
||||
if(ini) {
|
||||
motdserver=iniparser_getstr(ini,"general:motd_host");
|
||||
motdpath=iniparser_getstr(ini,"general:motd_path");
|
||||
if(!motdserver) {
|
||||
printf(translate(49)); /* el servidor de motd debe estar en ediv.cfg */
|
||||
if (ini)
|
||||
{
|
||||
motdserver = iniparser_getstr(ini, "general:motd_host");
|
||||
motdpath = iniparser_getstr(ini, "general:motd_path");
|
||||
if (!motdserver)
|
||||
{
|
||||
print_translate(49); /* el servidor de motd debe estar en ediv.cfg */
|
||||
exit(1);
|
||||
}
|
||||
if(!motdpath) motdpath="/ediv/actual/motd.txt";
|
||||
conecta(motdserver,motdpath);
|
||||
if (!motdpath)
|
||||
motdpath = "/ediv/actual/motd.txt";
|
||||
conecta(motdserver, motdpath);
|
||||
exit(0);
|
||||
} else {
|
||||
printf(translate(49)); /* el servidor de motd debe estar en ediv.cfg */
|
||||
}
|
||||
else
|
||||
{
|
||||
print_translate(49); /* el servidor de motd debe estar en ediv.cfg */
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -487,116 +568,128 @@ void conecta(char *servidor, char *archivo)
|
|||
{
|
||||
struct sockaddr_in sin;
|
||||
|
||||
char *size, *content,*ras;
|
||||
int tam,inc;
|
||||
char *size, *content, *ras;
|
||||
int tam, inc;
|
||||
WSADATA wsaData;
|
||||
WSAStartup(MAKEWORD(2,2),&wsaData);
|
||||
WSAStartup(MAKEWORD(2, 2), &wsaData);
|
||||
|
||||
iahost.s_addr=inet_addr(servidor);
|
||||
iahost.s_addr = inet_addr(servidor);
|
||||
|
||||
if (iahost.s_addr==INADDR_NONE)
|
||||
htent=gethostbyname(servidor);
|
||||
if (iahost.s_addr == INADDR_NONE)
|
||||
htent = gethostbyname(servidor);
|
||||
else
|
||||
htent=gethostbyaddr((const char *)&iahost,sizeof(struct in_addr),AF_INET);
|
||||
htent = gethostbyaddr((const char *)&iahost, sizeof(struct in_addr), AF_INET);
|
||||
|
||||
if (htent==NULL) {
|
||||
if (htent == NULL)
|
||||
{
|
||||
sock_error("gethostbyname()");
|
||||
return;
|
||||
}
|
||||
|
||||
sock=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
|
||||
sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
|
||||
if (sock==INVALID_SOCKET) {
|
||||
if (sock == INVALID_SOCKET)
|
||||
{
|
||||
sock_error("socket()");
|
||||
return;
|
||||
}
|
||||
|
||||
svent=getservbyname("http", "tcp");
|
||||
if (svent==NULL)
|
||||
sin.sin_port=htons((u_short)80);
|
||||
svent = getservbyname("http", "tcp");
|
||||
if (svent == NULL)
|
||||
sin.sin_port = htons((u_short)80);
|
||||
else
|
||||
sin.sin_port=svent->s_port;
|
||||
sin.sin_port = svent->s_port;
|
||||
|
||||
sin.sin_family=AF_INET;
|
||||
sin.sin_addr=*(struct in_addr *)*htent->h_addr_list;
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_addr = *(struct in_addr *)*htent->h_addr_list;
|
||||
|
||||
status=connect(sock,(struct sockaddr *)&sin,sizeof(sin));
|
||||
if (status==SOCKET_ERROR) {
|
||||
status = connect(sock, (struct sockaddr *)&sin, sizeof(sin));
|
||||
if (status == SOCKET_ERROR)
|
||||
{
|
||||
sock_error("connect()");
|
||||
closesocket(sock);
|
||||
return;
|
||||
}
|
||||
|
||||
sprintf(buffer,"GET %s HTTP/1.1\n"
|
||||
"User-Agent: Mozilla/4.76 (Windows 2000; U) Opera 5.12 [es]\n"
|
||||
"Host: %s\n"
|
||||
"Accept: text/html, image/png, image/jpeg, image/gif, image/x-xbitmap, */*\n"
|
||||
"Accept-Language: es\nAccept-Encoding: deflate, gzip, x-gzip, identity, *;q=0\n"
|
||||
"Connection: Keep-Alive\n"
|
||||
"\n"
|
||||
,archivo,servidor);
|
||||
sprintf(buffer, "GET %s HTTP/1.1\n"
|
||||
"User-Agent: Mozilla/4.76 (Windows 2000; U) Opera 5.12 [es]\n"
|
||||
"Host: %s\n"
|
||||
"Accept: text/html, image/png, image/jpeg, image/gif, image/x-xbitmap, */*\n"
|
||||
"Accept-Language: es\nAccept-Encoding: deflate, gzip, x-gzip, identity, *;q=0\n"
|
||||
"Connection: Keep-Alive\n"
|
||||
"\n",
|
||||
archivo, servidor);
|
||||
|
||||
#ifdef DEBUG_HTTP
|
||||
printf("GET %s HTTP/1.1\n"
|
||||
"User-Agent: Mozilla/4.76 (Windows 2000; U) Opera 5.12 [es]\n"
|
||||
"Host: %s\n"
|
||||
"Accept: text/html, image/png, image/jpeg, image/gif, image/x-xbitmap, */*\n"
|
||||
"Accept-Language: es\nAccept-Encoding: deflate, gzip, x-gzip, identity, *;q=0\n"
|
||||
"Connection: Keep-Alive\n"
|
||||
"\n"
|
||||
,archivo,servidor);
|
||||
"User-Agent: Mozilla/4.76 (Windows 2000; U) Opera 5.12 [es]\n"
|
||||
"Host: %s\n"
|
||||
"Accept: text/html, image/png, image/jpeg, image/gif, image/x-xbitmap, */*\n"
|
||||
"Accept-Language: es\nAccept-Encoding: deflate, gzip, x-gzip, identity, *;q=0\n"
|
||||
"Connection: Keep-Alive\n"
|
||||
"\n",
|
||||
archivo, servidor);
|
||||
#endif
|
||||
|
||||
status=send(sock,buffer,strlen(buffer),0);
|
||||
if (status==SOCKET_ERROR) {
|
||||
status = send(sock, buffer, strlen(buffer), 0);
|
||||
if (status == SOCKET_ERROR)
|
||||
{
|
||||
sock_error("send()");
|
||||
closesocket(sock);
|
||||
return;
|
||||
}
|
||||
|
||||
status=recv(sock,buffer,sizeof(buffer),0);
|
||||
if (status == SOCKET_ERROR) {
|
||||
status = recv(sock, buffer, sizeof(buffer), 0);
|
||||
if (status == SOCKET_ERROR)
|
||||
{
|
||||
sock_error("recv()");
|
||||
}
|
||||
|
||||
closesocket(sock);
|
||||
|
||||
if(*(buffer+9)!='2' || *(buffer+10)!='0' || *(buffer+10)!='0') {
|
||||
*strchr(buffer,0x0d)=0;
|
||||
printf("%s\n",buffer);
|
||||
if (*(buffer + 9) != '2' || *(buffer + 10) != '0' || *(buffer + 10) != '0')
|
||||
{
|
||||
*strchr(buffer, 0x0d) = 0;
|
||||
printf("%s\n", buffer);
|
||||
exit(1);
|
||||
}
|
||||
size=strstr(buffer,"Content-Type: ");
|
||||
if(!size) {
|
||||
printf(translate(50));
|
||||
size = strstr(buffer, "Content-Type: ");
|
||||
if (!size)
|
||||
{
|
||||
print_translate(50);
|
||||
exit(1);
|
||||
}
|
||||
size+=14;
|
||||
*(ras=strchr(size,0x0d))=0;
|
||||
if(strcmp(size,"text/plain")) {
|
||||
printf(translate(50));
|
||||
size += 14;
|
||||
*(ras = strchr(size, 0x0d)) = 0;
|
||||
if (strcmp(size, "text/plain"))
|
||||
{
|
||||
print_translate(50);
|
||||
exit(1);
|
||||
}
|
||||
*ras=0x0d;
|
||||
*ras = 0x0d;
|
||||
|
||||
size=strstr(buffer,"Content-Length: ");
|
||||
if(!size) {
|
||||
printf(translate(50));
|
||||
size = strstr(buffer, "Content-Length: ");
|
||||
if (!size)
|
||||
{
|
||||
print_translate(50);
|
||||
exit(1);
|
||||
}
|
||||
size+=16;
|
||||
ras=strchr(size,0x0d)-1;
|
||||
content=strstr(size,"\x0d\x0a\x0d\x0a")+4;
|
||||
tam=0; inc=1;
|
||||
for(;ras>=size;ras--) {
|
||||
if (*ras>='0' && *ras<='9')
|
||||
tam+=(*ras-'0')*inc;
|
||||
size += 16;
|
||||
ras = strchr(size, 0x0d) - 1;
|
||||
content = strstr(size, "\x0d\x0a\x0d\x0a") + 4;
|
||||
tam = 0;
|
||||
inc = 1;
|
||||
for (; ras >= size; ras--)
|
||||
{
|
||||
if (*ras >= '0' && *ras <= '9')
|
||||
tam += (*ras - '0') * inc;
|
||||
else
|
||||
break;
|
||||
inc*=10;
|
||||
inc *= 10;
|
||||
}
|
||||
if(tam>1024) tam=1024;
|
||||
if (tam > 1024)
|
||||
tam = 1024;
|
||||
|
||||
fwrite(content, tam, 1, stdout);
|
||||
fwrite(content, tam, 1, stdout);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -32,612 +32,664 @@
|
|||
#include "language.h"
|
||||
|
||||
int len;
|
||||
struct objeto * ob;
|
||||
struct objeto * ob2;
|
||||
struct objeto *ob;
|
||||
struct objeto *ob2;
|
||||
|
||||
int creaobj;
|
||||
int numparams;
|
||||
|
||||
byte decl_struct=0; /* 1 si se está declarando un struct */
|
||||
byte struct_reserved=0; /* 1 si se está declarando la estructura reserved */
|
||||
|
||||
byte decl_struct = 0; /* 1 si se está declarando un struct */
|
||||
byte struct_reserved = 0; /* 1 si se está declarando la estructura reserved */
|
||||
|
||||
/* Errores específicos en la ejecución de una DLL */
|
||||
void dll_error(int error, ...)
|
||||
{
|
||||
va_list opparam;
|
||||
|
||||
va_start(opparam,error);
|
||||
printf(translate(35), fichdll);
|
||||
vprintf(translate_dll_error(error-1),opparam);
|
||||
va_start(opparam, error);
|
||||
print_translate(35, fichdll);
|
||||
vprintf(translate_dll_error(error - 1), opparam);
|
||||
printf("\n");
|
||||
n_errors++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int EDIV_Export(char* cadena, int nparam, void* hfuncion)
|
||||
int EDIV_Export(char *cadena, int nparam, void *hfuncion)
|
||||
{
|
||||
if(decl_struct) {
|
||||
dll_error(6,cadena);
|
||||
if (decl_struct)
|
||||
{
|
||||
dll_error(6, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(nparam<0) {
|
||||
dll_error(5,cadena);
|
||||
if (nparam < 0)
|
||||
{
|
||||
dll_error(5, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
creaobj=crea_objeto((byte*)cadena,nparam);
|
||||
creaobj = crea_objeto((byte *)cadena, nparam);
|
||||
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_function:\t-- ID FUNCION: %d\n"
|
||||
"export_function:\tCadena exportada: %s\n"
|
||||
"export_function:\tN. parametros: %d\n"
|
||||
"export_function:\tOffset de la funcion: 0x%X\n",n_externs,cadena,nparam,(unsigned int)hfuncion);
|
||||
#endif
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_function:\t-- ID FUNCION: %d\n"
|
||||
"export_function:\tCadena exportada: %s\n"
|
||||
"export_function:\tN. parametros: %d\n"
|
||||
"export_function:\tOffset de la funcion: 0x%X\n",
|
||||
n_externs, cadena, nparam, (unsigned int)hfuncion);
|
||||
#endif
|
||||
|
||||
if(creaobj) {
|
||||
dll_error(creaobj,cadena);
|
||||
if (creaobj)
|
||||
{
|
||||
dll_error(creaobj, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ob=o;
|
||||
ob = o;
|
||||
|
||||
if (ob->tipo!=tnone) {
|
||||
dll_error(5,cadena);
|
||||
if (ob->tipo != tnone)
|
||||
{
|
||||
dll_error(5, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ob->tipo=tfext;
|
||||
ob->fext.codigo=n_externs;
|
||||
ob->fext.num_par=nparam;
|
||||
ob->tipo = tfext;
|
||||
ob->fext.codigo = n_externs;
|
||||
ob->fext.num_par = nparam;
|
||||
|
||||
n_externs++;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Entrypoint(int ep, void* hfuncion)
|
||||
int EDIV_Export_Entrypoint(int ep, void *hfuncion)
|
||||
{
|
||||
entrypoints[n_entrypoints].tipo=ep;
|
||||
entrypoints[n_entrypoints].hfuncion=hfuncion;
|
||||
entrypoints[n_entrypoints].dll=numdlls;
|
||||
entrypoints[n_entrypoints].tipo = ep;
|
||||
entrypoints[n_entrypoints].hfuncion = hfuncion;
|
||||
entrypoints[n_entrypoints].dll = numdlls;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Priority(int priority)
|
||||
{
|
||||
dlls[numdlls].prioridad=priority;
|
||||
dlls[numdlls].prioridad = priority;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Const(char* cadena, int valor)
|
||||
int EDIV_Export_Const(char *cadena, int valor)
|
||||
{
|
||||
if(decl_struct) {
|
||||
dll_error(6,cadena);
|
||||
if (decl_struct)
|
||||
{
|
||||
dll_error(6, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
creaobj=crea_objeto((byte*)cadena,-1);
|
||||
creaobj = crea_objeto((byte *)cadena, -1);
|
||||
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_const:\t-- ID OBJETO: %d\n"
|
||||
"export_const:\tCadena exportada: %s\n"
|
||||
"export_const:\tValor: %d\n"
|
||||
"export_const:\tOffset del objeto: 0x%X\n",num_obj-1,cadena,valor,(unsigned int)o);
|
||||
#endif
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_const:\t-- ID OBJETO: %d\n"
|
||||
"export_const:\tCadena exportada: %s\n"
|
||||
"export_const:\tValor: %d\n"
|
||||
"export_const:\tOffset del objeto: 0x%X\n",
|
||||
num_obj - 1, cadena, valor, (unsigned int)o);
|
||||
#endif
|
||||
|
||||
if(creaobj) {
|
||||
dll_error(creaobj,cadena);
|
||||
if (creaobj)
|
||||
{
|
||||
dll_error(creaobj, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ob=o;
|
||||
ob = o;
|
||||
|
||||
if (ob->tipo!=tnone) {
|
||||
dll_error(5,cadena);
|
||||
if (ob->tipo != tnone)
|
||||
{
|
||||
dll_error(5, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ob->tipo=tcons;
|
||||
ob->cons.valor=valor;
|
||||
ob->cons.literal=0;
|
||||
ob->tipo = tcons;
|
||||
ob->cons.valor = valor;
|
||||
ob->cons.literal = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Global(char* cadena, int valor)
|
||||
int EDIV_Export_Global(char *cadena, int valor)
|
||||
{
|
||||
if(decl_struct) {
|
||||
dll_error(6,cadena);
|
||||
if (decl_struct)
|
||||
{
|
||||
dll_error(6, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
creaobj=crea_objeto((byte*)cadena,-1);
|
||||
creaobj = crea_objeto((byte *)cadena, -1);
|
||||
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_global:\t-- ID OBJETO: %d\n"
|
||||
"export_global:\tCadena exportada: %s\n"
|
||||
"export_global:\tValor: %d\n"
|
||||
"export_global:\tOffset del objeto: 0x%X\n",num_obj-1,cadena,valor,(unsigned int)o);
|
||||
#endif
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_global:\t-- ID OBJETO: %d\n"
|
||||
"export_global:\tCadena exportada: %s\n"
|
||||
"export_global:\tValor: %d\n"
|
||||
"export_global:\tOffset del objeto: 0x%X\n",
|
||||
num_obj - 1, cadena, valor, (unsigned int)o);
|
||||
#endif
|
||||
|
||||
if(creaobj) {
|
||||
dll_error(creaobj,cadena);
|
||||
if (creaobj)
|
||||
{
|
||||
dll_error(creaobj, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ob=o;
|
||||
ob = o;
|
||||
|
||||
if (ob->tipo!=tnone) {
|
||||
dll_error(5,cadena);
|
||||
if (ob->tipo != tnone)
|
||||
{
|
||||
dll_error(5, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
indexa_variable(v_global,cadena,imem);
|
||||
indexa_variable(v_global, cadena, imem);
|
||||
|
||||
ob->tipo=tvglo;
|
||||
ob->vglo.offset=imem;
|
||||
mem[imem]=valor;
|
||||
ob->tipo = tvglo;
|
||||
ob->vglo.offset = imem;
|
||||
mem[imem] = valor;
|
||||
|
||||
return imem++;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Global_Tab(char* cadena, int numregs)
|
||||
int EDIV_Export_Global_Tab(char *cadena, int numregs)
|
||||
{
|
||||
if(decl_struct) {
|
||||
dll_error(6,cadena);
|
||||
if (decl_struct)
|
||||
{
|
||||
dll_error(6, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
creaobj=crea_objeto((byte*)cadena,-1);
|
||||
creaobj = crea_objeto((byte *)cadena, -1);
|
||||
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_global_tab:\t-- ID OBJETO: %d\n"
|
||||
"export_global_tab:\tCadena exportada: %s\n"
|
||||
"export_global_tab:\tN.regs: %d\n"
|
||||
"export_global_tab:\tOffset del objeto: 0x%X\n",num_obj-1,cadena,numregs,(unsigned int)o);
|
||||
#endif
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_global_tab:\t-- ID OBJETO: %d\n"
|
||||
"export_global_tab:\tCadena exportada: %s\n"
|
||||
"export_global_tab:\tN.regs: %d\n"
|
||||
"export_global_tab:\tOffset del objeto: 0x%X\n",
|
||||
num_obj - 1, cadena, numregs, (unsigned int)o);
|
||||
#endif
|
||||
|
||||
if(creaobj) {
|
||||
dll_error(creaobj,cadena);
|
||||
if (creaobj)
|
||||
{
|
||||
dll_error(creaobj, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ob=o;
|
||||
ob = o;
|
||||
|
||||
if (ob->tipo!=tnone) {
|
||||
dll_error(5,cadena);
|
||||
if (ob->tipo != tnone)
|
||||
{
|
||||
dll_error(5, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
indexa_variable(v_global,cadena,imem);
|
||||
indexa_variable(v_global, cadena, imem);
|
||||
|
||||
ob->tipo=ttglo;
|
||||
ob->tglo.offset=imem;
|
||||
ob->tglo.len1=len=numregs;
|
||||
ob->tglo.len2=-1;
|
||||
ob->tglo.len3=-1;
|
||||
ob->tglo.totalen=len+1;
|
||||
ob->tipo = ttglo;
|
||||
ob->tglo.offset = imem;
|
||||
ob->tglo.len1 = len = numregs;
|
||||
ob->tglo.len2 = -1;
|
||||
ob->tglo.len3 = -1;
|
||||
ob->tglo.totalen = len + 1;
|
||||
|
||||
/* Inicializamos la tabla a 0 */
|
||||
do {
|
||||
mem[imem++]=0;
|
||||
do
|
||||
{
|
||||
mem[imem++] = 0;
|
||||
} while (len--);
|
||||
|
||||
return ob->tglo.offset;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Global_Struct(char* cadena, int numregs)
|
||||
int EDIV_Export_Global_Struct(char *cadena, int numregs)
|
||||
{
|
||||
if(decl_struct) {
|
||||
dll_error(6,cadena);
|
||||
if (decl_struct)
|
||||
{
|
||||
dll_error(6, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
creaobj=crea_objeto((byte*)cadena,-1);
|
||||
creaobj = crea_objeto((byte *)cadena, -1);
|
||||
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_global_struct:\t-- ID OBJETO: %d\n"
|
||||
"export_global_struct:\tCadena exportada: %s\n"
|
||||
"export_global_struct:\tN.regs: %d\n"
|
||||
"export_global_struct:\tOffset del objeto: 0x%X\n",num_obj-1,cadena,numregs,(unsigned int)o);
|
||||
#endif
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_global_struct:\t-- ID OBJETO: %d\n"
|
||||
"export_global_struct:\tCadena exportada: %s\n"
|
||||
"export_global_struct:\tN.regs: %d\n"
|
||||
"export_global_struct:\tOffset del objeto: 0x%X\n",
|
||||
num_obj - 1, cadena, numregs, (unsigned int)o);
|
||||
#endif
|
||||
|
||||
if(creaobj) {
|
||||
dll_error(creaobj,cadena);
|
||||
if (creaobj)
|
||||
{
|
||||
dll_error(creaobj, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ob=o;
|
||||
ob = o;
|
||||
|
||||
if (ob->tipo!=tnone) {
|
||||
dll_error(5,cadena);
|
||||
if (ob->tipo != tnone)
|
||||
{
|
||||
dll_error(5, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
indexa_variable(v_global,cadena,imem);
|
||||
indexa_variable(v_global, cadena, imem);
|
||||
|
||||
decl_struct=1;
|
||||
decl_struct = 1;
|
||||
|
||||
ob->tipo=tsglo;
|
||||
ob->sglo.offset=imem;
|
||||
ob->sglo.items1=numregs;
|
||||
ob->sglo.items2=ob->sglo.items3=-1;
|
||||
ob->sglo.totalitems=numregs+1;
|
||||
ob->sglo.len_item=0;
|
||||
member=ob;
|
||||
len=0;
|
||||
ob->tipo = tsglo;
|
||||
ob->sglo.offset = imem;
|
||||
ob->sglo.items1 = numregs;
|
||||
ob->sglo.items2 = ob->sglo.items3 = -1;
|
||||
ob->sglo.totalitems = numregs + 1;
|
||||
ob->sglo.len_item = 0;
|
||||
member = ob;
|
||||
len = 0;
|
||||
|
||||
return imem;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Member_Int(char* cadena, int valor)
|
||||
int EDIV_Export_Member_Int(char *cadena, int valor)
|
||||
{
|
||||
if(!decl_struct) {
|
||||
dll_error(7,cadena);
|
||||
if (!decl_struct)
|
||||
{
|
||||
dll_error(7, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
creaobj=crea_objeto((byte*)cadena,-1);
|
||||
creaobj = crea_objeto((byte *)cadena, -1);
|
||||
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_member_int:\t-- ID OBJETO: %d\n"
|
||||
"export_member_int:\tCadena exportada: %s\n"
|
||||
"export_member_int:\tValor: %d\n"
|
||||
"export_member_int:\tOffset del objeto: 0x%X\n",num_obj-1,cadena,valor,(unsigned int)o);
|
||||
#endif
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_member_int:\t-- ID OBJETO: %d\n"
|
||||
"export_member_int:\tCadena exportada: %s\n"
|
||||
"export_member_int:\tValor: %d\n"
|
||||
"export_member_int:\tOffset del objeto: 0x%X\n",
|
||||
num_obj - 1, cadena, valor, (unsigned int)o);
|
||||
#endif
|
||||
|
||||
if(creaobj) {
|
||||
dll_error(creaobj,cadena);
|
||||
if (creaobj)
|
||||
{
|
||||
dll_error(creaobj, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ob2=o;
|
||||
ob2 = o;
|
||||
|
||||
if ((*ob2).tipo!=tnone) {
|
||||
dll_error(5,cadena);
|
||||
if ((*ob2).tipo != tnone)
|
||||
{
|
||||
dll_error(5, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(ob->tipo==tsglo) { /* int miembro de struct global */
|
||||
(*ob2).tipo=tvglo;
|
||||
(*ob2).vglo.offset=len++;
|
||||
mem[imem]=valor;
|
||||
if (ob->tipo == tsglo)
|
||||
{ /* int miembro de struct global */
|
||||
(*ob2).tipo = tvglo;
|
||||
(*ob2).vglo.offset = len++;
|
||||
mem[imem] = valor;
|
||||
ob->sglo.len_item++;
|
||||
return imem++;
|
||||
}
|
||||
else { /* int miembro de struct local */
|
||||
if(struct_reserved)
|
||||
indexa_variable(v_reserved,cadena,iloc);
|
||||
(*ob2).tipo=tvloc;
|
||||
(*ob2).vloc.offset=len++;
|
||||
loc[iloc]=valor;
|
||||
ob->sloc.len_item++;
|
||||
return iloc++;
|
||||
else
|
||||
{ /* int miembro de struct local */
|
||||
if (struct_reserved)
|
||||
indexa_variable(v_reserved, cadena, iloc);
|
||||
(*ob2).tipo = tvloc;
|
||||
(*ob2).vloc.offset = len++;
|
||||
loc[iloc] = valor;
|
||||
ob->sloc.len_item++;
|
||||
return iloc++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Member_Str(char* cadena, int tamano)
|
||||
int EDIV_Export_Member_Str(char *cadena, int tamano)
|
||||
{
|
||||
if(!decl_struct) {
|
||||
dll_error(7,cadena);
|
||||
if (!decl_struct)
|
||||
{
|
||||
dll_error(7, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
creaobj=crea_objeto((byte*)cadena,-1);
|
||||
creaobj = crea_objeto((byte *)cadena, -1);
|
||||
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_member_str:\t-- ID OBJETO: %d\n"
|
||||
"export_member_str:\tCadena exportada: %s\n"
|
||||
"export_member_str:\tTamano: %d\n"
|
||||
"export_member_str:\tOffset del objeto: 0x%X\n",num_obj-1,cadena,tamano,(unsigned int)o);
|
||||
#endif
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_member_str:\t-- ID OBJETO: %d\n"
|
||||
"export_member_str:\tCadena exportada: %s\n"
|
||||
"export_member_str:\tTamano: %d\n"
|
||||
"export_member_str:\tOffset del objeto: 0x%X\n",
|
||||
num_obj - 1, cadena, tamano, (unsigned int)o);
|
||||
#endif
|
||||
|
||||
if(creaobj) {
|
||||
dll_error(creaobj,cadena);
|
||||
if (creaobj)
|
||||
{
|
||||
dll_error(creaobj, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ob2=o;
|
||||
ob2 = o;
|
||||
|
||||
if ((*ob2).tipo!=tnone) {
|
||||
dll_error(5,cadena);
|
||||
if ((*ob2).tipo != tnone)
|
||||
{
|
||||
dll_error(5, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(ob->tipo==tsglo) { /* string miembro de struct global */
|
||||
if (ob->tipo == tsglo)
|
||||
{ /* string miembro de struct global */
|
||||
|
||||
(*ob2).tipo=tcglo;
|
||||
(*ob2).cglo.offset=len+1;
|
||||
(*ob2).tipo = tcglo;
|
||||
(*ob2).cglo.offset = len + 1;
|
||||
|
||||
if (((*ob2).cglo.totalen=tamano)<0) {
|
||||
dll_error(8,cadena);
|
||||
if (((*ob2).cglo.totalen = tamano) < 0)
|
||||
{
|
||||
dll_error(8, cadena);
|
||||
return 0;
|
||||
}
|
||||
if ((*ob2).cglo.totalen>0xFFFFF) {
|
||||
dll_error(8,cadena);
|
||||
if ((*ob2).cglo.totalen > 0xFFFFF)
|
||||
{
|
||||
dll_error(8, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
mem[imem]=0xDAD00000|(*ob2).cglo.totalen;
|
||||
len+=1+((*ob2).cglo.totalen+5)/4;
|
||||
mem[imem+1]=0;
|
||||
imem+=1+((*ob2).cglo.totalen+5)/4;
|
||||
ob->sglo.len_item+=1+((*ob2).cglo.totalen+5)/4;
|
||||
mem[imem] = 0xDAD00000 | (*ob2).cglo.totalen;
|
||||
len += 1 + ((*ob2).cglo.totalen + 5) / 4;
|
||||
mem[imem + 1] = 0;
|
||||
imem += 1 + ((*ob2).cglo.totalen + 5) / 4;
|
||||
ob->sglo.len_item += 1 + ((*ob2).cglo.totalen + 5) / 4;
|
||||
|
||||
return (*ob2).cglo.offset;
|
||||
}
|
||||
else { /* string miembro de struct local */
|
||||
else
|
||||
{ /* string miembro de struct local */
|
||||
|
||||
(*ob2).tipo=tcloc;
|
||||
(*ob2).cloc.offset=len+1;
|
||||
(*ob2).tipo = tcloc;
|
||||
(*ob2).cloc.offset = len + 1;
|
||||
|
||||
if (((*ob2).cloc.totalen=tamano)<0) {
|
||||
dll_error(8,cadena);
|
||||
if (((*ob2).cloc.totalen = tamano) < 0)
|
||||
{
|
||||
dll_error(8, cadena);
|
||||
return 0;
|
||||
}
|
||||
if ((*ob2).cloc.totalen>0xFFFFF) {
|
||||
dll_error(8,cadena);
|
||||
if ((*ob2).cloc.totalen > 0xFFFFF)
|
||||
{
|
||||
dll_error(8, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
loc[iloc]=0xDAD00000|(*ob2).cloc.totalen;
|
||||
len+=1+((*ob2).cloc.totalen+5)/4;
|
||||
loc[iloc+1]=0;
|
||||
iloc+=1+((*ob2).cloc.totalen+5)/4;
|
||||
ob->sloc.len_item+=1+((*ob2).cloc.totalen+5)/4;
|
||||
loc[iloc] = 0xDAD00000 | (*ob2).cloc.totalen;
|
||||
len += 1 + ((*ob2).cloc.totalen + 5) / 4;
|
||||
loc[iloc + 1] = 0;
|
||||
iloc += 1 + ((*ob2).cloc.totalen + 5) / 4;
|
||||
ob->sloc.len_item += 1 + ((*ob2).cloc.totalen + 5) / 4;
|
||||
|
||||
return (*ob2).cloc.offset;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Member_Tab(char* cadena, int numregs)
|
||||
int EDIV_Export_Member_Tab(char *cadena, int numregs)
|
||||
{
|
||||
if(!decl_struct) {
|
||||
dll_error(7,cadena);
|
||||
if (!decl_struct)
|
||||
{
|
||||
dll_error(7, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
creaobj=crea_objeto((byte*)cadena,-1);
|
||||
creaobj = crea_objeto((byte *)cadena, -1);
|
||||
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_member_tab:\t-- ID OBJETO: %d\n"
|
||||
"export_member_tab:\tCadena exportada: %s\n"
|
||||
"export_member_tab:\tN.regs: %d\n"
|
||||
"export_member_tab:\tOffset del objeto: 0x%X\n",num_obj-1,cadena,numregs,(unsigned int)o);
|
||||
#endif
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_member_tab:\t-- ID OBJETO: %d\n"
|
||||
"export_member_tab:\tCadena exportada: %s\n"
|
||||
"export_member_tab:\tN.regs: %d\n"
|
||||
"export_member_tab:\tOffset del objeto: 0x%X\n",
|
||||
num_obj - 1, cadena, numregs, (unsigned int)o);
|
||||
#endif
|
||||
|
||||
if(creaobj) {
|
||||
dll_error(creaobj,cadena);
|
||||
if (creaobj)
|
||||
{
|
||||
dll_error(creaobj, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ob2=o;
|
||||
ob2 = o;
|
||||
|
||||
if ((*ob2).tipo!=tnone) {
|
||||
dll_error(5,cadena);
|
||||
if ((*ob2).tipo != tnone)
|
||||
{
|
||||
dll_error(5, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(ob->tipo==tsglo) { /* array miembro de struct global */
|
||||
(*ob2).tipo=ttglo;
|
||||
(*ob2).tglo.offset=len;
|
||||
(*ob2).tglo.len1=numregs;
|
||||
(*ob2).tglo.len2=-1;
|
||||
(*ob2).tglo.len3=-1;
|
||||
(*ob2).tglo.totalen=numregs+1;
|
||||
len+=numregs+1;
|
||||
memset(&mem[imem],0,(numregs+1)*4);
|
||||
imem+=numregs+1;
|
||||
ob->sglo.len_item+=numregs+1;
|
||||
if (ob->tipo == tsglo)
|
||||
{ /* array miembro de struct global */
|
||||
(*ob2).tipo = ttglo;
|
||||
(*ob2).tglo.offset = len;
|
||||
(*ob2).tglo.len1 = numregs;
|
||||
(*ob2).tglo.len2 = -1;
|
||||
(*ob2).tglo.len3 = -1;
|
||||
(*ob2).tglo.totalen = numregs + 1;
|
||||
len += numregs + 1;
|
||||
memset(&mem[imem], 0, (numregs + 1) * 4);
|
||||
imem += numregs + 1;
|
||||
ob->sglo.len_item += numregs + 1;
|
||||
|
||||
return (*ob2).tglo.offset;
|
||||
}
|
||||
else { /* array miembro de struct local */
|
||||
if(struct_reserved)
|
||||
indexa_variable(v_reserved,cadena,iloc);
|
||||
(*ob2).tipo=ttloc;
|
||||
(*ob2).tloc.offset=len;
|
||||
(*ob2).tloc.len1=numregs;
|
||||
(*ob2).tloc.len2=-1;
|
||||
(*ob2).tloc.len3=-1;
|
||||
(*ob2).tloc.totalen=numregs+1;
|
||||
len+=numregs+1;
|
||||
memset(&loc[iloc],0,(numregs+1)*4);
|
||||
iloc+=numregs+1;
|
||||
ob->sloc.len_item+=numregs+1;
|
||||
else
|
||||
{ /* array miembro de struct local */
|
||||
if (struct_reserved)
|
||||
indexa_variable(v_reserved, cadena, iloc);
|
||||
(*ob2).tipo = ttloc;
|
||||
(*ob2).tloc.offset = len;
|
||||
(*ob2).tloc.len1 = numregs;
|
||||
(*ob2).tloc.len2 = -1;
|
||||
(*ob2).tloc.len3 = -1;
|
||||
(*ob2).tloc.totalen = numregs + 1;
|
||||
len += numregs + 1;
|
||||
memset(&loc[iloc], 0, (numregs + 1) * 4);
|
||||
iloc += numregs + 1;
|
||||
ob->sloc.len_item += numregs + 1;
|
||||
|
||||
return (*ob2).tloc.offset;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_EndStruct()
|
||||
{
|
||||
if(!decl_struct) {
|
||||
if (!decl_struct)
|
||||
{
|
||||
dll_error(9);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_endstruct:\t--- estructura cerrada\n");
|
||||
#endif
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_endstruct:\t--- estructura cerrada\n");
|
||||
#endif
|
||||
|
||||
member=NULL;
|
||||
member = NULL;
|
||||
|
||||
if(ob->tipo==tsglo) { /* cierra estructura global */
|
||||
if (ob->sglo.len_item==0) {
|
||||
if (ob->tipo == tsglo)
|
||||
{ /* cierra estructura global */
|
||||
if (ob->sglo.len_item == 0)
|
||||
{
|
||||
dll_error(10);
|
||||
return 0;
|
||||
}
|
||||
if (ob->sglo.totalitems>1) {
|
||||
len=(ob->sglo.totalitems-1)*ob->sglo.len_item-1;
|
||||
do {
|
||||
mem[imem]=mem[imem-ob->sglo.len_item];
|
||||
if (ob->sglo.totalitems > 1)
|
||||
{
|
||||
len = (ob->sglo.totalitems - 1) * ob->sglo.len_item - 1;
|
||||
do
|
||||
{
|
||||
mem[imem] = mem[imem - ob->sglo.len_item];
|
||||
imem++;
|
||||
} while (len--);
|
||||
}
|
||||
}
|
||||
else { /* cierra estructura local */
|
||||
if (ob->sloc.len_item==0) {
|
||||
else
|
||||
{ /* cierra estructura local */
|
||||
if (ob->sloc.len_item == 0)
|
||||
{
|
||||
dll_error(10);
|
||||
return 0;
|
||||
}
|
||||
if (ob->sloc.totalitems>1) {
|
||||
len=(ob->sloc.totalitems-1)*ob->sloc.len_item-1;
|
||||
do {
|
||||
loc[iloc]=loc[iloc-ob->sloc.len_item];
|
||||
if (ob->sloc.totalitems > 1)
|
||||
{
|
||||
len = (ob->sloc.totalitems - 1) * ob->sloc.len_item - 1;
|
||||
do
|
||||
{
|
||||
loc[iloc] = loc[iloc - ob->sloc.len_item];
|
||||
iloc++;
|
||||
} while (len--);
|
||||
}
|
||||
}
|
||||
|
||||
decl_struct=0;
|
||||
struct_reserved=0;
|
||||
decl_struct = 0;
|
||||
struct_reserved = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Local(char* cadena, int valor)
|
||||
int EDIV_Export_Local(char *cadena, int valor)
|
||||
{
|
||||
if(decl_struct) {
|
||||
dll_error(6,cadena);
|
||||
if (decl_struct)
|
||||
{
|
||||
dll_error(6, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
creaobj=crea_objeto((byte*)cadena,-1);
|
||||
creaobj = crea_objeto((byte *)cadena, -1);
|
||||
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_local:\t-- ID OBJETO: %d\n"
|
||||
"export_local:\tCadena exportada: %s\n"
|
||||
"export_local:\tValor: %d\n"
|
||||
"export_local:\tOffset del objeto: 0x%X\n",num_obj-1,cadena,valor,(unsigned int)o);
|
||||
#endif
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_local:\t-- ID OBJETO: %d\n"
|
||||
"export_local:\tCadena exportada: %s\n"
|
||||
"export_local:\tValor: %d\n"
|
||||
"export_local:\tOffset del objeto: 0x%X\n",
|
||||
num_obj - 1, cadena, valor, (unsigned int)o);
|
||||
#endif
|
||||
|
||||
if(creaobj) {
|
||||
dll_error(creaobj,cadena);
|
||||
if (creaobj)
|
||||
{
|
||||
dll_error(creaobj, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ob=o;
|
||||
ob = o;
|
||||
|
||||
if (ob->tipo!=tnone) {
|
||||
dll_error(5,cadena);
|
||||
if (ob->tipo != tnone)
|
||||
{
|
||||
dll_error(5, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
indexa_variable(v_local,cadena,iloc);
|
||||
indexa_variable(v_local, cadena, iloc);
|
||||
|
||||
ob->tipo=tvloc;
|
||||
ob->vloc.offset=iloc;
|
||||
loc[iloc]=valor;
|
||||
ob->tipo = tvloc;
|
||||
ob->vloc.offset = iloc;
|
||||
loc[iloc] = valor;
|
||||
|
||||
return iloc++;
|
||||
return iloc++;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Local_Tab(char* cadena, int numregs)
|
||||
int EDIV_Export_Local_Tab(char *cadena, int numregs)
|
||||
{
|
||||
if(decl_struct) {
|
||||
dll_error(6,cadena);
|
||||
if (decl_struct)
|
||||
{
|
||||
dll_error(6, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
creaobj=crea_objeto((byte*)cadena,-1);
|
||||
creaobj = crea_objeto((byte *)cadena, -1);
|
||||
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_local_tab:\t-- ID OBJETO: %d\n"
|
||||
"export_local_tab:\tCadena exportada: %s\n"
|
||||
"export_local_tab:\tN.regs: %d\n"
|
||||
"export_local_tab:\tOffset del objeto: 0x%X\n",num_obj-1,cadena,numregs,(unsigned int)o);
|
||||
#endif
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_local_tab:\t-- ID OBJETO: %d\n"
|
||||
"export_local_tab:\tCadena exportada: %s\n"
|
||||
"export_local_tab:\tN.regs: %d\n"
|
||||
"export_local_tab:\tOffset del objeto: 0x%X\n",
|
||||
num_obj - 1, cadena, numregs, (unsigned int)o);
|
||||
#endif
|
||||
|
||||
if(creaobj) {
|
||||
dll_error(creaobj,cadena);
|
||||
if (creaobj)
|
||||
{
|
||||
dll_error(creaobj, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ob=o;
|
||||
ob = o;
|
||||
|
||||
if (ob->tipo!=tnone) {
|
||||
dll_error(5,cadena);
|
||||
if (ob->tipo != tnone)
|
||||
{
|
||||
dll_error(5, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
indexa_variable(v_local,cadena,iloc);
|
||||
indexa_variable(v_local, cadena, iloc);
|
||||
|
||||
ob->tipo=ttloc;
|
||||
ob->tloc.offset=iloc;
|
||||
ob->tloc.len1=len=numregs;
|
||||
ob->tloc.len2=-1;
|
||||
ob->tloc.len3=-1;
|
||||
ob->tloc.totalen=len+1;
|
||||
ob->tipo = ttloc;
|
||||
ob->tloc.offset = iloc;
|
||||
ob->tloc.len1 = len = numregs;
|
||||
ob->tloc.len2 = -1;
|
||||
ob->tloc.len3 = -1;
|
||||
ob->tloc.totalen = len + 1;
|
||||
|
||||
/* Inicializamos la tabla a 0 */
|
||||
do {
|
||||
loc[iloc++]=0;
|
||||
do
|
||||
{
|
||||
loc[iloc++] = 0;
|
||||
} while (len--);
|
||||
|
||||
return ob->tloc.offset;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Local_Struct(char* cadena, int numregs)
|
||||
int EDIV_Export_Local_Struct(char *cadena, int numregs)
|
||||
{
|
||||
if(decl_struct) {
|
||||
dll_error(6,cadena);
|
||||
if (decl_struct)
|
||||
{
|
||||
dll_error(6, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
creaobj=crea_objeto((byte*)cadena,-1);
|
||||
creaobj = crea_objeto((byte *)cadena, -1);
|
||||
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_local_struct:\t-- ID OBJETO: %d\n"
|
||||
"export_local_struct:\tCadena exportada: %s\n"
|
||||
"export_local_struct:\tN.regs: %d\n"
|
||||
"export_local_struct:\tOffset del objeto: 0x%X\n",num_obj-1,cadena,numregs,(unsigned int)o);
|
||||
#endif
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_local_struct:\t-- ID OBJETO: %d\n"
|
||||
"export_local_struct:\tCadena exportada: %s\n"
|
||||
"export_local_struct:\tN.regs: %d\n"
|
||||
"export_local_struct:\tOffset del objeto: 0x%X\n",
|
||||
num_obj - 1, cadena, numregs, (unsigned int)o);
|
||||
#endif
|
||||
|
||||
if(creaobj) {
|
||||
dll_error(creaobj,cadena);
|
||||
if (creaobj)
|
||||
{
|
||||
dll_error(creaobj, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ob=o;
|
||||
ob = o;
|
||||
|
||||
if (ob->tipo!=tnone) {
|
||||
dll_error(5,cadena);
|
||||
if (ob->tipo != tnone)
|
||||
{
|
||||
dll_error(5, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
decl_struct=1;
|
||||
if(!strcmp(cadena,"reserved")) {
|
||||
struct_reserved=1;
|
||||
decl_struct = 1;
|
||||
if (!strcmp(cadena, "reserved"))
|
||||
{
|
||||
struct_reserved = 1;
|
||||
}
|
||||
else {
|
||||
indexa_variable(v_local,cadena,iloc);
|
||||
else
|
||||
{
|
||||
indexa_variable(v_local, cadena, iloc);
|
||||
}
|
||||
|
||||
ob->tipo=tsloc;
|
||||
ob->sloc.offset=iloc;
|
||||
ob->sloc.items1=numregs;
|
||||
ob->sloc.items2=ob->sloc.items3=-1;
|
||||
ob->sloc.totalitems=numregs+1;
|
||||
ob->sloc.len_item=0;
|
||||
member=ob;
|
||||
len=0;
|
||||
ob->tipo = tsloc;
|
||||
ob->sloc.offset = iloc;
|
||||
ob->sloc.items1 = numregs;
|
||||
ob->sloc.items2 = ob->sloc.items3 = -1;
|
||||
ob->sloc.totalitems = numregs + 1;
|
||||
ob->sloc.len_item = 0;
|
||||
member = ob;
|
||||
len = 0;
|
||||
|
||||
return iloc;
|
||||
return iloc;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#else
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
|
||||
#include "shared.h"
|
||||
|
@ -153,6 +154,35 @@ char *translate(int num)
|
|||
return e[idioma][num];
|
||||
}
|
||||
|
||||
void print_translate(int num, ...)
|
||||
{
|
||||
va_list arg_ptr;
|
||||
const char *message = translate(num);
|
||||
size_t msglen = strlen(message);
|
||||
char *strbuf = malloc(msglen + 1);
|
||||
|
||||
va_start(arg_ptr, message);
|
||||
vsprintf(strbuf, message, arg_ptr);
|
||||
va_end(arg_ptr);
|
||||
|
||||
printf("%s", strbuf);
|
||||
free(strbuf);
|
||||
}
|
||||
|
||||
const char *get_translate(int num, ...)
|
||||
{
|
||||
va_list arg_ptr;
|
||||
const char *message = translate(num);
|
||||
size_t msglen = strlen(message);
|
||||
char *strbuf = malloc(msglen + 1);
|
||||
|
||||
va_start(arg_ptr, message);
|
||||
vsprintf(strbuf, message, arg_ptr);
|
||||
va_end(arg_ptr);
|
||||
|
||||
return strbuf;
|
||||
}
|
||||
|
||||
static char *ediv_strlwr(char *str)
|
||||
{
|
||||
unsigned char *p = (unsigned char *)str;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -33,120 +33,152 @@
|
|||
|
||||
void ltlex_error(int error)
|
||||
{
|
||||
if(error==1)
|
||||
printf(translate(40),translate_ltlex_error(error));
|
||||
if (error == 1)
|
||||
print_translate(40, translate_ltlex_error(error));
|
||||
else
|
||||
printf(translate(41),"ltlex.def",linea,translate_ltlex_error(error));
|
||||
printf(translate(42));
|
||||
print_translate(41, "ltlex.def", linea, translate_ltlex_error(error));
|
||||
print_translate(42);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void analiza_ltlex(void){
|
||||
void analiza_ltlex(void)
|
||||
{
|
||||
|
||||
byte *_buf, * buf; /* Buffer del texto y puntero al carácter actual */
|
||||
byte cont=1; /* 0 indica final del archivo */
|
||||
int len; /* Tamaño del archivo */
|
||||
struct lex_ele * e; /* Puntero al lex_case correspondiente */
|
||||
FILE * def; /* Stream del fichero */
|
||||
byte *_buf, *buf; /* Buffer del texto y puntero al carácter actual */
|
||||
byte cont = 1; /* 0 indica final del archivo */
|
||||
int len; /* Tamaño del archivo */
|
||||
struct lex_ele *e; /* Puntero al lex_case correspondiente */
|
||||
FILE *def; /* Stream del fichero */
|
||||
|
||||
int t; /* token (pieza) */
|
||||
byte h; /* hash (para id) */
|
||||
byte * _ivnom;
|
||||
byte * * ptr;
|
||||
int t; /* token (pieza) */
|
||||
byte h; /* hash (para id) */
|
||||
byte *_ivnom;
|
||||
byte **ptr;
|
||||
|
||||
/* Busca el archivo ltlex.def */
|
||||
if ((def=fopen("system/ltlex.def","rb"))==NULL)
|
||||
/* Busca el archivo ltlex.def */
|
||||
if ((def = fopen("system/ltlex.def", "rb")) == NULL)
|
||||
ltlex_error(1);
|
||||
|
||||
/* Lo lee */
|
||||
fseek(def,0,SEEK_END);
|
||||
len=ftell(def);
|
||||
_buf=buf= e_malloc(len+1);
|
||||
fseek(def,0,SEEK_SET);
|
||||
len=fread(buf,1,len,def);
|
||||
fseek(def, 0, SEEK_END);
|
||||
len = ftell(def);
|
||||
_buf = buf = e_malloc(len + 1);
|
||||
fseek(def, 0, SEEK_SET);
|
||||
len = fread(buf, 1, len, def);
|
||||
|
||||
/* El carácter ASCII 0 indica final del fichero */
|
||||
*(buf+len)=0;
|
||||
*(buf + len) = 0;
|
||||
|
||||
#ifdef _DEBUG
|
||||
printf("dbg: tamano ltlex: %d\n",len);
|
||||
#endif
|
||||
#ifdef _DEBUG
|
||||
printf("dbg: tamano ltlex: %d\n", len);
|
||||
#endif
|
||||
|
||||
linea=1;
|
||||
linea = 1;
|
||||
|
||||
do {
|
||||
switch (*buf++) {
|
||||
/* Fin de fichero */
|
||||
case 0:
|
||||
cont=0; break;
|
||||
/* Ignoramos los espacios */
|
||||
case ' ':
|
||||
case tab:
|
||||
do
|
||||
{
|
||||
switch (*buf++)
|
||||
{
|
||||
/* Fin de fichero */
|
||||
case 0:
|
||||
cont = 0;
|
||||
break;
|
||||
/* Ignoramos los espacios */
|
||||
case ' ':
|
||||
case tab:
|
||||
break;
|
||||
/* Salta de linea */
|
||||
case cr:
|
||||
if (*buf == lf)
|
||||
buf++;
|
||||
case lf:
|
||||
linea++;
|
||||
break;
|
||||
/* Los ; indican línea de comentario */
|
||||
case ';':
|
||||
while (*buf != cr && *buf != lf)
|
||||
buf++;
|
||||
break;
|
||||
/* El símbolo & indica definición de token */
|
||||
case '&':
|
||||
*buf = lower[*buf];
|
||||
if (*buf >= '0' && *buf <= '9')
|
||||
t = (*buf++ - '0') << 4;
|
||||
else if (*buf >= 'a' && *buf <= 'f')
|
||||
t = (*buf++ - 'a' + 10) << 4;
|
||||
else
|
||||
ltlex_error(2);
|
||||
*buf = lower[*buf];
|
||||
if (*buf >= '0' && *buf <= '9')
|
||||
t += (*buf++ - '0');
|
||||
else if (*buf >= 'a' && *buf <= 'f')
|
||||
t += (*buf++ - 'a' + 10);
|
||||
else
|
||||
ltlex_error(2);
|
||||
if (*buf == cr || *buf == lf || *buf == ' ' || *buf == tab)
|
||||
break;
|
||||
/* Salta de linea */
|
||||
case cr:
|
||||
if(*buf==lf) buf++;
|
||||
case lf:
|
||||
linea++;
|
||||
break;
|
||||
/* Los ; indican línea de comentario */
|
||||
case ';':
|
||||
while (*buf!=cr && *buf!=lf) buf++; break;
|
||||
/* El símbolo & indica definición de token */
|
||||
case '&':
|
||||
*buf=lower[*buf];
|
||||
if (*buf>='0' && *buf<='9')
|
||||
t=(*buf++-'0')<<4;
|
||||
else if (lower[*buf])
|
||||
{ /* Analiza una palabra reservada */
|
||||
_ivnom = ivnom.b;
|
||||
*ivnom.p++ = 0;
|
||||
*ivnom.p++ = (unsigned char *)t;
|
||||
h = 0;
|
||||
while ((*ivnom.b = lower[*buf++]))
|
||||
h = ((byte)(h << 1) + (h >> 7)) ^ (*ivnom.b++);
|
||||
ptr = &vhash[h];
|
||||
while (*ptr)
|
||||
ptr = (unsigned char **)*ptr;
|
||||
*ptr = _ivnom;
|
||||
buf--;
|
||||
ivnom.b++;
|
||||
}
|
||||
else if (t >= 0x78 && t <= 0x7b)
|
||||
{ /* Analiza un delimitador de literal */
|
||||
lex_case[*buf] = (struct lex_ele *)l_lit;
|
||||
}
|
||||
else
|
||||
{ /* Analiza un nuevo símbolo */
|
||||
if ((e = lex_case[*buf]) == 0)
|
||||
{
|
||||
if (num_nodos++ == max_nodos)
|
||||
ltlex_error(3);
|
||||
e = lex_case[*buf] = ilex_simb++;
|
||||
e->caracter = *buf++;
|
||||
}
|
||||
else
|
||||
if (*buf>='a' && *buf<='f')
|
||||
t=(*buf++-'a'+10)<<4;
|
||||
else
|
||||
ltlex_error(2);
|
||||
*buf=lower[*buf];
|
||||
if (*buf>='0' && *buf<='9')
|
||||
t+=(*buf++-'0');
|
||||
else
|
||||
if (*buf>='a' && *buf<='f')
|
||||
t+=(*buf++-'a'+10);
|
||||
else
|
||||
ltlex_error(2);
|
||||
if (*buf==cr || *buf==lf || *buf==' ' || *buf==tab) break;
|
||||
else if (lower[*buf]) { /* Analiza una palabra reservada */
|
||||
_ivnom=ivnom.b; *ivnom.p++=0; *ivnom.p++=(unsigned char*)t; h=0;
|
||||
while ((*ivnom.b=lower[*buf++])) h=((byte)(h<<1)+(h>>7))^(*ivnom.b++);
|
||||
ptr=&vhash[h]; while (*ptr) ptr=(unsigned char * *)*ptr; *ptr=_ivnom;
|
||||
buf--; ivnom.b++;
|
||||
} else if (t>=0x78 && t<=0x7b) { /* Analiza un delimitador de literal */
|
||||
lex_case[*buf]=(struct lex_ele*)l_lit;
|
||||
} else { /* Analiza un nuevo símbolo */
|
||||
if ((e=lex_case[*buf])==0) {
|
||||
if (num_nodos++==max_nodos)
|
||||
buf++;
|
||||
while (*buf != ' ' && *buf != tab && *buf != cr)
|
||||
{
|
||||
if (lower[*buf])
|
||||
ltlex_error(4);
|
||||
if (e->siguiente == 0)
|
||||
if (num_nodos++ == max_nodos)
|
||||
ltlex_error(3);
|
||||
e=lex_case[*buf]=ilex_simb++;
|
||||
e->caracter=*buf++;
|
||||
}
|
||||
else
|
||||
e = e->siguiente = ilex_simb++;
|
||||
else
|
||||
buf++;
|
||||
while (*buf!=' ' && *buf!=tab && *buf!=cr) {
|
||||
if (lower[*buf]) ltlex_error(4);
|
||||
if (e->siguiente==0)
|
||||
if (num_nodos++==max_nodos) ltlex_error(3);
|
||||
else e=e->siguiente=ilex_simb++;
|
||||
else {
|
||||
e=e->siguiente;
|
||||
while (e->caracter!=*buf && e->alternativa)
|
||||
e=e->alternativa;
|
||||
if (e->caracter!=*buf) {
|
||||
if (num_nodos++==max_nodos) ltlex_error(3);
|
||||
else e=e->alternativa=ilex_simb++;
|
||||
}
|
||||
{
|
||||
e = e->siguiente;
|
||||
while (e->caracter != *buf && e->alternativa)
|
||||
e = e->alternativa;
|
||||
if (e->caracter != *buf)
|
||||
{
|
||||
if (num_nodos++ == max_nodos)
|
||||
ltlex_error(3);
|
||||
else
|
||||
e = e->alternativa = ilex_simb++;
|
||||
}
|
||||
e->caracter=*buf++;
|
||||
}
|
||||
e->token=t;
|
||||
} break;
|
||||
}} while (cont);
|
||||
e->caracter = *buf++;
|
||||
}
|
||||
e->token = t;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} while (cont);
|
||||
|
||||
e_free(_buf); _buf=NULL;
|
||||
fclose(def); def=NULL;
|
||||
e_free(_buf);
|
||||
_buf = NULL;
|
||||
fclose(def);
|
||||
def = NULL;
|
||||
}
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
*/
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "dll_load.h"
|
||||
#include <io.h>
|
||||
#include "dll_load.h"
|
||||
#include <io.h>
|
||||
#else
|
||||
#include <dlfcn.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
#include <dlfcn.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
@ -39,252 +39,267 @@ int imem_temp;
|
|||
int iloc_temp;
|
||||
|
||||
/* obtiene el nombre esencial de la libreria (sin extension ni path) */
|
||||
void get_rawname(char* completo, char* rawname)
|
||||
void get_rawname(char *completo, char *rawname)
|
||||
{
|
||||
char* p=completo;
|
||||
char *p = completo;
|
||||
int i;
|
||||
|
||||
for(i=strlen(completo)-1;i>0;i--)
|
||||
if(completo[i]=='\\' || completo[i]=='/') {
|
||||
p=&completo[i+1];
|
||||
for (i = strlen(completo) - 1; i > 0; i--)
|
||||
if (completo[i] == '\\' || completo[i] == '/')
|
||||
{
|
||||
p = &completo[i + 1];
|
||||
break;
|
||||
}
|
||||
|
||||
strcpy(rawname,p);
|
||||
i=strlen(rawname);
|
||||
strcpy(rawname, p);
|
||||
i = strlen(rawname);
|
||||
|
||||
#ifdef _WIN32
|
||||
if (rawname[i-4]=='.' && (rawname[i-3]=='d' || rawname[i-3]=='D')
|
||||
&& (rawname[i-2]=='l' || rawname[i-2]=='L')
|
||||
&& (rawname[i-1]=='l' || rawname[i-1]=='L'))
|
||||
#ifdef _WIN32
|
||||
if (rawname[i - 4] == '.' && (rawname[i - 3] == 'd' || rawname[i - 3] == 'D') && (rawname[i - 2] == 'l' || rawname[i - 2] == 'L') && (rawname[i - 1] == 'l' || rawname[i - 1] == 'L'))
|
||||
|
||||
rawname[i-4]=0;
|
||||
rawname[i - 4] = 0;
|
||||
|
||||
#else
|
||||
if(rawname[i-3]=='.' && (rawname[i-2]=='s' || rawname[i-2]=='S')
|
||||
&& (rawname[i-1]=='o' || rawname[i-1]=='O'))
|
||||
#else
|
||||
if (rawname[i - 3] == '.' && (rawname[i - 2] == 's' || rawname[i - 2] == 'S') && (rawname[i - 1] == 'o' || rawname[i - 1] == 'O'))
|
||||
|
||||
rawname[i-3]=0;
|
||||
#endif
|
||||
rawname[i - 3] = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* compara prioridades de dos dlls, para el qsort descendente */
|
||||
int compara(const void* _a, const void* _b)
|
||||
int compara(const void *_a, const void *_b)
|
||||
{
|
||||
struct _dlls a=*(struct _dlls*)_a;
|
||||
struct _dlls b=*(struct _dlls*)_b;
|
||||
return a.prioridad<b.prioridad?1:(a.prioridad>b.prioridad?-1:0);
|
||||
struct _dlls a = *(struct _dlls *)_a;
|
||||
struct _dlls b = *(struct _dlls *)_b;
|
||||
return a.prioridad < b.prioridad ? 1 : (a.prioridad > b.prioridad ? -1 : 0);
|
||||
}
|
||||
|
||||
int compara2(const void* _a, const void* _b)
|
||||
int compara2(const void *_a, const void *_b)
|
||||
{
|
||||
int a=*(int*)_a;
|
||||
int b=*(int*)_b;
|
||||
return dlls[a].prioridad<dlls[b].prioridad?1:(dlls[a].prioridad>dlls[b].prioridad?-1:0);
|
||||
int a = *(int *)_a;
|
||||
int b = *(int *)_b;
|
||||
return dlls[a].prioridad < dlls[b].prioridad ? 1 : (dlls[a].prioridad > dlls[b].prioridad ? -1 : 0);
|
||||
}
|
||||
|
||||
|
||||
void dll_func()
|
||||
{
|
||||
char dllkey[256]="dll_priority:";
|
||||
char dllkey[256] = "dll_priority:";
|
||||
char rawname[256];
|
||||
int carga=1;
|
||||
char *dir=NULL;
|
||||
int carga = 1;
|
||||
char *dir = NULL;
|
||||
int i;
|
||||
|
||||
#ifdef _WIN32
|
||||
int buscafich;
|
||||
struct _finddata_t fichero_dll; /* busqueda de DLLs */
|
||||
char mask[256];
|
||||
#else
|
||||
DIR *directorio;
|
||||
struct dirent *fichero_dll;
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
int buscafich;
|
||||
struct _finddata_t fichero_dll; /* busqueda de DLLs */
|
||||
char mask[256];
|
||||
#else
|
||||
DIR *directorio;
|
||||
struct dirent *fichero_dll;
|
||||
#endif
|
||||
|
||||
numdlls=0;
|
||||
n_externs=0;
|
||||
numdlls = 0;
|
||||
n_externs = 0;
|
||||
|
||||
#ifdef _WIN32
|
||||
/* Inicializa la carga de DLLs */
|
||||
CheckWindowsVersion();
|
||||
InitializeDLLLoad();
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
/* Inicializa la carga de DLLs */
|
||||
CheckWindowsVersion();
|
||||
InitializeDLLLoad();
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
if (ini)
|
||||
dir=iniparser_getstr(ini,"dll:windll");
|
||||
#ifdef _WIN32
|
||||
if (ini)
|
||||
dir = iniparser_getstr(ini, "dll:windll");
|
||||
|
||||
if (!dir)
|
||||
dir="dll";
|
||||
if (!dir)
|
||||
dir = "dll";
|
||||
|
||||
strcpy(mask,dir);
|
||||
strcat(mask,"\\*.dll");
|
||||
strcpy(mask, dir);
|
||||
strcat(mask, "\\*.dll");
|
||||
|
||||
/* Busca las DLLs que hay en el directorio */
|
||||
buscafich = _findfirst(mask, &fichero_dll);
|
||||
if (buscafich==-1)
|
||||
printf(translate(43)); /* no hay dlls */
|
||||
/* Busca las DLLs que hay en el directorio */
|
||||
buscafich = _findfirst(mask, &fichero_dll);
|
||||
if (buscafich == -1)
|
||||
print_translate(43); /* no hay dlls */
|
||||
|
||||
#ifdef _DEBUG
|
||||
printf("dbg: DLL encontrada: %s\n", fichero_dll.name);
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG
|
||||
printf("dbg: DLL encontrada: %s\n",fichero_dll.name);
|
||||
#endif
|
||||
sprintf(fichdll, "%s\\%s", dir, fichero_dll.name);
|
||||
|
||||
sprintf(fichdll,"%s\\%s",dir,fichero_dll.name);
|
||||
get_rawname(fichero_dll.name, rawname);
|
||||
strcat(dllkey, rawname);
|
||||
|
||||
get_rawname(fichero_dll.name,rawname);
|
||||
strcat(dllkey,rawname);
|
||||
if (ini)
|
||||
if (iniparser_getint(ini, dllkey, 0) <= P_NUNCA)
|
||||
carga = 0;
|
||||
|
||||
if (ini)
|
||||
if (iniparser_getint(ini,dllkey,0)<=P_NUNCA)
|
||||
carga=0;
|
||||
|
||||
if (carga)
|
||||
if(!leedll()) {
|
||||
dlls[numdlls].prioridad=0;
|
||||
if (carga)
|
||||
if (!leedll())
|
||||
{
|
||||
dlls[numdlls].prioridad = 0;
|
||||
/* guarda el nombre de fichero en la tabla de DLLs */
|
||||
dlls[0].nombre=e_malloc(strlen(rawname)+1);
|
||||
strcpy(dlls[0].nombre,rawname);
|
||||
dlls[0].nombre = e_malloc(strlen(rawname) + 1);
|
||||
strcpy(dlls[0].nombre, rawname);
|
||||
|
||||
/* importa las funciones de la DLL */
|
||||
if (ini)
|
||||
dlls[numdlls].prioridad=iniparser_getint(ini,dllkey,dlls[numdlls].prioridad);
|
||||
if (ini)
|
||||
dlls[numdlls].prioridad = iniparser_getint(ini, dllkey, dlls[numdlls].prioridad);
|
||||
|
||||
numdlls=1;
|
||||
numdlls = 1;
|
||||
}
|
||||
|
||||
/* hace lo mismo con el resto */
|
||||
while (1)
|
||||
{
|
||||
if (_findnext(buscafich, &fichero_dll) == 0)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
printf("dbg: DLL encontrada: %s\n", fichero_dll.name);
|
||||
#endif
|
||||
carga = 1;
|
||||
sprintf(fichdll, "%s\\%s", dir, fichero_dll.name);
|
||||
dlls[numdlls].prioridad = 0;
|
||||
get_rawname(fichero_dll.name, rawname);
|
||||
strcpy(dllkey, "dll_priority:");
|
||||
strcat(dllkey, rawname);
|
||||
if (ini)
|
||||
if (iniparser_getint(ini, dllkey, 0) <= P_NUNCA)
|
||||
carga = 0;
|
||||
if (carga)
|
||||
if (!leedll())
|
||||
{
|
||||
dlls[numdlls].nombre = e_malloc(strlen(rawname) + 1);
|
||||
strcpy(dlls[numdlls].nombre, rawname);
|
||||
dlls[numdlls].usado = 0;
|
||||
if (ini)
|
||||
dlls[numdlls].prioridad = iniparser_getint(ini, dllkey, dlls[numdlls].prioridad);
|
||||
numdlls++;
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
#else /* si estamos en Linux */
|
||||
|
||||
if (ini)
|
||||
dir = iniparser_getstr(ini, "dll:nixdll");
|
||||
if (!dir)
|
||||
dir = "so";
|
||||
|
||||
directorio = opendir(dir);
|
||||
if (!directorio)
|
||||
{
|
||||
print_translate(44, dir); /* no hay directorio so/ */
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Busca las .so */
|
||||
while ((fichero_dll = readdir(directorio)) != 0)
|
||||
{
|
||||
/* Salta los directorios actual '.' y padre ".." */
|
||||
if (strcmp(fichero_dll->d_name, ".") == 0)
|
||||
continue;
|
||||
|
||||
if (strcmp(fichero_dll->d_name, "..") == 0)
|
||||
continue;
|
||||
|
||||
if (fichero_dll->d_type == DT_REG)
|
||||
{
|
||||
char dllkey[256] = "dll_priority:";
|
||||
#ifdef _DEBUG
|
||||
printf("dbg: Librería encontrada: %s/%s\n", dir, fichero_dll->d_name);
|
||||
#endif
|
||||
carga = 1;
|
||||
sprintf(fichdll, "%s/%s", dir, fichero_dll->d_name);
|
||||
dlls[numdlls].prioridad = 0;
|
||||
get_rawname(fichero_dll->d_name, rawname);
|
||||
strcpy(dllkey, "dll_priority:");
|
||||
strcat(dllkey, rawname);
|
||||
|
||||
if (ini)
|
||||
{
|
||||
if (iniparser_getint(ini, dllkey, 0) <= P_NUNCA)
|
||||
carga = 0;
|
||||
}
|
||||
|
||||
/* hace lo mismo con el resto */
|
||||
while(1) {
|
||||
if(_findnext(buscafich,&fichero_dll)==0) {
|
||||
#ifdef _DEBUG
|
||||
printf("dbg: DLL encontrada: %s\n",fichero_dll.name);
|
||||
#endif
|
||||
carga=1;
|
||||
sprintf(fichdll,"%s\\%s",dir,fichero_dll.name);
|
||||
dlls[numdlls].prioridad=0;
|
||||
get_rawname(fichero_dll.name,rawname);
|
||||
strcpy(dllkey,"dll_priority:");
|
||||
strcat(dllkey,rawname);
|
||||
if(ini) if(iniparser_getint(ini,dllkey,0)<=P_NUNCA) carga=0;
|
||||
if(carga) if(!leedll()) {
|
||||
dlls[numdlls].nombre=e_malloc(strlen(rawname)+1);
|
||||
strcpy(dlls[numdlls].nombre,rawname);
|
||||
dlls[numdlls].usado=0;
|
||||
if(ini) dlls[numdlls].prioridad=iniparser_getint(ini,dllkey,dlls[numdlls].prioridad);
|
||||
if (carga)
|
||||
{
|
||||
if (!leedll())
|
||||
{
|
||||
dlls[numdlls].nombre = e_malloc(strlen(rawname) + 1);
|
||||
strcpy(dlls[numdlls].nombre, rawname);
|
||||
dlls[numdlls].usado = 0;
|
||||
|
||||
if (ini)
|
||||
dlls[numdlls].prioridad = iniparser_getint(ini, dllkey, dlls[numdlls].prioridad);
|
||||
|
||||
numdlls++;
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#else /* si estamos en Linux */
|
||||
#endif
|
||||
|
||||
if(ini) dir=iniparser_getstr(ini,"dll:nixdll");
|
||||
if(!dir) dir="so";
|
||||
if (numdlls == 0)
|
||||
print_translate(43); /* no hay librerias */
|
||||
|
||||
directorio=opendir(dir);
|
||||
if(!directorio) {
|
||||
printf(translate(44),dir); /* no hay directorio so/ */
|
||||
exit(1);
|
||||
}
|
||||
nuevo_orden = e_malloc(numdlls * 4);
|
||||
for (i = 0; i < numdlls; i++)
|
||||
nuevo_orden[i] = i;
|
||||
|
||||
/* Busca las .so */
|
||||
while ((fichero_dll = readdir(directorio)) != 0) {
|
||||
/* Salta los directorios actual '.' y padre ".." */
|
||||
if (strcmp(fichero_dll->d_name, ".") == 0)
|
||||
continue;
|
||||
|
||||
if (strcmp(fichero_dll->d_name, "..") == 0)
|
||||
continue;
|
||||
|
||||
if(fichero_dll->d_type==DT_REG) {
|
||||
char dllkey[256]="dll_priority:";
|
||||
#ifdef _DEBUG
|
||||
printf("dbg: Librería encontrada: %s/%s\n",dir,fichero_dll->d_name);
|
||||
#endif
|
||||
carga=1;
|
||||
sprintf(fichdll,"%s/%s",dir,fichero_dll->d_name);
|
||||
dlls[numdlls].prioridad=0;
|
||||
get_rawname(fichero_dll->d_name,rawname);
|
||||
strcpy(dllkey,"dll_priority:");
|
||||
strcat(dllkey,rawname);
|
||||
|
||||
if (ini) {
|
||||
if (iniparser_getint(ini,dllkey,0) <= P_NUNCA)
|
||||
carga=0;
|
||||
}
|
||||
|
||||
if(carga) {
|
||||
if(!leedll()) {
|
||||
dlls[numdlls].nombre=e_malloc(strlen(rawname)+1);
|
||||
strcpy(dlls[numdlls].nombre,rawname);
|
||||
dlls[numdlls].usado=0;
|
||||
|
||||
if (ini)
|
||||
dlls[numdlls].prioridad=iniparser_getint(ini,dllkey,dlls[numdlls].prioridad);
|
||||
|
||||
numdlls++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if(numdlls==0)
|
||||
printf(translate(43)); /* no hay librerias */
|
||||
|
||||
nuevo_orden=e_malloc(numdlls*4);
|
||||
for(i=0;i<numdlls;i++)
|
||||
nuevo_orden[i]=i;
|
||||
|
||||
qsort(nuevo_orden,numdlls,4,compara2);
|
||||
qsort(dlls,numdlls,sizeof(struct _dlls),compara);
|
||||
|
||||
#ifdef _DEBUG
|
||||
for(i=0;i<numdlls;i++)
|
||||
printf("dbg: %d - %s - prioridad: %d\n",i,dlls[i].nombre,dlls[i].prioridad);
|
||||
#endif
|
||||
qsort(nuevo_orden, numdlls, 4, compara2);
|
||||
qsort(dlls, numdlls, sizeof(struct _dlls), compara);
|
||||
|
||||
#ifdef _DEBUG
|
||||
for (i = 0; i < numdlls; i++)
|
||||
printf("dbg: %d - %s - prioridad: %d\n", i, dlls[i].nombre, dlls[i].prioridad);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void dll_func2()
|
||||
{
|
||||
int i=numdlls;
|
||||
char* dir=NULL;
|
||||
int i = numdlls;
|
||||
char *dir = NULL;
|
||||
|
||||
n_externs=0;
|
||||
n_externs = 0;
|
||||
|
||||
for(i=0;i<numdlls;i++)
|
||||
nuevo_orden[i]=i;
|
||||
for (i = 0; i < numdlls; i++)
|
||||
nuevo_orden[i] = i;
|
||||
|
||||
for(numdlls=0;numdlls<i;numdlls++) {
|
||||
if((dlls[numdlls].prioridad>P_NUNCA) && (dlls[numdlls].usado || dlls[numdlls].prioridad>=P_SIEMPRE)) {
|
||||
#ifdef _DEBUG
|
||||
printf("dbg: Se requiere %s (id=%d)\n",dlls[numdlls].nombre,numdlls);
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
if(ini) dir=iniparser_getstr(ini,"dll:windll");
|
||||
if(!dir) dir="dll";
|
||||
sprintf(fichdll,"%s\\%s.dll",dir,dlls[numdlls].nombre);
|
||||
#else
|
||||
if(ini) dir=iniparser_getstr(ini,"dll:nixdll");
|
||||
if(!dir) dir="so";
|
||||
sprintf(fichdll,"%s/%s.so",dir,dlls[numdlls].nombre);
|
||||
#endif
|
||||
for (numdlls = 0; numdlls < i; numdlls++)
|
||||
{
|
||||
if ((dlls[numdlls].prioridad > P_NUNCA) && (dlls[numdlls].usado || dlls[numdlls].prioridad >= P_SIEMPRE))
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
printf("dbg: Se requiere %s (id=%d)\n", dlls[numdlls].nombre, numdlls);
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
if (ini)
|
||||
dir = iniparser_getstr(ini, "dll:windll");
|
||||
if (!dir)
|
||||
dir = "dll";
|
||||
sprintf(fichdll, "%s\\%s.dll", dir, dlls[numdlls].nombre);
|
||||
#else
|
||||
if (ini)
|
||||
dir = iniparser_getstr(ini, "dll:nixdll");
|
||||
if (!dir)
|
||||
dir = "so";
|
||||
sprintf(fichdll, "%s/%s.so", dir, dlls[numdlls].nombre);
|
||||
#endif
|
||||
|
||||
if(leedll()) {
|
||||
printf(translate(45),dlls[numdlls].nombre); /* error al cargar libreria */
|
||||
if (leedll())
|
||||
{
|
||||
print_translate(45, dlls[numdlls].nombre); /* error al cargar libreria */
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int leedll()
|
||||
{
|
||||
TYPEOF_ExportaFuncs *ExportaFuncs;
|
||||
|
@ -292,58 +307,62 @@ int leedll()
|
|||
HINSTANCE hDLL;
|
||||
|
||||
/* Carga la DLL */
|
||||
hDLL=LoadDLL(fichdll);
|
||||
hDLL = LoadDLL(fichdll);
|
||||
|
||||
if(hDLL==NULL) {
|
||||
printf(translate(46),fichdll); /* no puedo cargar libreria */
|
||||
if (hDLL == NULL)
|
||||
{
|
||||
print_translate(46, fichdll); /* no puedo cargar libreria */
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Inicializa y ejecuta la funcion ExportaFuncs de la DLL */
|
||||
ExportaFuncs=NULL;
|
||||
ExportaFuncs=(TYPEOF_ExportaFuncs *)GetDLLProcAddress(hDLL,"ExportaFuncs");
|
||||
ExportaFuncs = NULL;
|
||||
ExportaFuncs = (TYPEOF_ExportaFuncs *)GetDLLProcAddress(hDLL, "ExportaFuncs");
|
||||
|
||||
if(ExportaFuncs==NULL) {
|
||||
printf(translate(47),fichdll); /* exportafuncs no encontrado */
|
||||
if (ExportaFuncs == NULL)
|
||||
{
|
||||
print_translate(47, fichdll); /* exportafuncs no encontrado */
|
||||
FreeDLL(hDLL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_DLL
|
||||
printf("dbg: ExportaFuncs encontrado!! :D\n");
|
||||
#endif
|
||||
#ifdef DEBUG_DLL
|
||||
printf("dbg: ExportaFuncs encontrado!! :D\n");
|
||||
#endif
|
||||
|
||||
ExportaFuncs(EXPORTAFUNCS_PARAMS);
|
||||
|
||||
FreeDLL(hDLL);
|
||||
|
||||
#else /* Linux */
|
||||
void *hDLL;
|
||||
char *errordll;
|
||||
#else /* Linux */
|
||||
void *hDLL;
|
||||
char *errordll;
|
||||
|
||||
/* Carga la DLL */
|
||||
hDLL=dlopen(fichdll,RTLD_NOW);
|
||||
hDLL = dlopen(fichdll, RTLD_NOW);
|
||||
|
||||
if(!hDLL) {
|
||||
printf(translate(46),fichdll,dlerror()); /* no puedo cargar libreria */
|
||||
if (!hDLL)
|
||||
{
|
||||
print_translate(46, fichdll, dlerror()); /* no puedo cargar libreria */
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Inicializa y ejecuta la funcion ExportaFuncs de la DLL */
|
||||
|
||||
ExportaFuncs=NULL;
|
||||
ExportaFuncs = NULL;
|
||||
|
||||
ExportaFuncs=(TYPEOF_ExportaFuncs *) dlsym(hDLL,"ExportaFuncs");
|
||||
ExportaFuncs = (TYPEOF_ExportaFuncs *)dlsym(hDLL, "ExportaFuncs");
|
||||
|
||||
if((errordll=dlerror())!=NULL) {
|
||||
printf(translate(47),fichdll,errordll); /* exportafuncs no encontrado */
|
||||
if ((errordll = dlerror()) != NULL)
|
||||
{
|
||||
print_translate(47, fichdll, errordll); /* exportafuncs no encontrado */
|
||||
dlclose(hDLL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_DLL
|
||||
printf("dbg: ExportaFuncs encontrado!! :D\n");
|
||||
#endif
|
||||
#ifdef DEBUG_DLL
|
||||
printf("dbg: ExportaFuncs encontrado!! :D\n");
|
||||
#endif
|
||||
|
||||
ExportaFuncs(EXPORTAFUNCS_PARAMS);
|
||||
dlclose(hDLL);
|
||||
|
|
|
@ -40,30 +40,31 @@
|
|||
#undef TRANSLATE
|
||||
#endif
|
||||
|
||||
#define TRANSLATE_ERROR 1
|
||||
#define TRANSLATE_WARNING 2
|
||||
#define TRANSLATE_DLL_ERROR 3
|
||||
#define TRANSLATE_LTLEX_ERROR 4
|
||||
#define TRANSLATE_COMPILER 5
|
||||
#define TRANSLATE_STUB 6
|
||||
#define TRANSLATE_RUNTIME_ERROR 7
|
||||
#define TRANSLATE_CRITICAL_ERROR 8
|
||||
|
||||
#define TRANSLATE_ERROR 1
|
||||
#define TRANSLATE_WARNING 2
|
||||
#define TRANSLATE_DLL_ERROR 3
|
||||
#define TRANSLATE_LTLEX_ERROR 4
|
||||
#define TRANSLATE_COMPILER 5
|
||||
#define TRANSLATE_STUB 6
|
||||
#define TRANSLATE_RUNTIME_ERROR 7
|
||||
#define TRANSLATE_CRITICAL_ERROR 8
|
||||
|
||||
int idioma;
|
||||
|
||||
/* comunes */
|
||||
int detecta_idioma();
|
||||
char* translate(int num);
|
||||
char* translate_dll_error(int num);
|
||||
char *translate(int num);
|
||||
char *translate_dll_error(int num);
|
||||
const char *get_translate(int num, ...);
|
||||
void print_translate(int num, ...);
|
||||
|
||||
/* compilador */
|
||||
char* translate_error(int num);
|
||||
char* translate_warning(int num);
|
||||
char* translate_ltlex_error(int num);
|
||||
char *translate_error(int num);
|
||||
char *translate_warning(int num);
|
||||
char *translate_ltlex_error(int num);
|
||||
|
||||
/* stub */
|
||||
char* translate_runtime_error(int num);
|
||||
char* translate_critical_error(int num);
|
||||
char *translate_runtime_error(int num);
|
||||
char *translate_critical_error(int num);
|
||||
|
||||
#endif /* __EDIV_LANGUAGE_H_ */
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
*/
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <windows.h>
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
|
@ -44,9 +44,9 @@ struct objeto * ob2;*/
|
|||
|
||||
int creaobj;
|
||||
|
||||
byte decl_struct=0; // 1 si se está declarando un struct
|
||||
byte decl_struct = 0; // 1 si se está declarando un struct
|
||||
|
||||
byte slocal=0; // para las structs. 0=global, 1=local
|
||||
byte slocal = 0; // para las structs. 0=global, 1=local
|
||||
int nregs;
|
||||
int offset;
|
||||
|
||||
|
@ -79,24 +79,22 @@ int offset;
|
|||
return 0;
|
||||
}*/
|
||||
|
||||
|
||||
// Errores específicos en la ejecución de una DLL
|
||||
|
||||
void dll_error(int error, ...)
|
||||
{
|
||||
va_list opparam;
|
||||
char mensaje[256];
|
||||
|
||||
va_start(opparam,error);
|
||||
va_start(opparam, error);
|
||||
|
||||
sprintf(mensaje,translate(3), fichdll);
|
||||
vsprintf(mensaje,translate_dll_error(error),opparam);
|
||||
sprintf(mensaje, get_translate(3, fichdll));
|
||||
vsprintf(mensaje, get_translate(translate_dll_error(error)), opparam);
|
||||
|
||||
#ifdef _WIN32
|
||||
MessageBox(0,mensaje,translate(4),MB_ICONERROR);
|
||||
#else
|
||||
printf("%s\n",mensaje);
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
MessageBox(0,mensaje,print_translate((4),MB_ICONERROR);
|
||||
#else
|
||||
printf("%s\n", mensaje);
|
||||
#endif
|
||||
|
||||
//printf("\n");
|
||||
//n_errors++;
|
||||
|
@ -104,25 +102,25 @@ void dll_error(int error, ...)
|
|||
exit(-1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int EDIV_Export(char* cadena, int nparam, void* hfuncion)
|
||||
int EDIV_Export(char *cadena, int nparam, void *hfuncion)
|
||||
{
|
||||
if(decl_struct) {
|
||||
dll_error(6,cadena);
|
||||
if (decl_struct)
|
||||
{
|
||||
dll_error(6, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// creaobj=crea_objeto((byte*)cadena);
|
||||
// creaobj=crea_objeto((byte*)cadena);
|
||||
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_function:\t-- ID FUNCION: %d\n"
|
||||
"export_function:\tCadena exportada: %s\n"
|
||||
"export_function:\tN. parametros: %d\n"
|
||||
"export_function:\tOffset de la funcion: 0x%X\n",n_externs,cadena,nparam,(unsigned int)hfuncion);
|
||||
#endif
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_function:\t-- ID FUNCION: %d\n"
|
||||
"export_function:\tCadena exportada: %s\n"
|
||||
"export_function:\tN. parametros: %d\n"
|
||||
"export_function:\tOffset de la funcion: 0x%X\n",
|
||||
n_externs, cadena, nparam, (unsigned int)hfuncion);
|
||||
#endif
|
||||
|
||||
/* if(creaobj) {
|
||||
/* if(creaobj) {
|
||||
dll_error(creaobj,cadena);
|
||||
return 0;
|
||||
}
|
||||
|
@ -138,56 +136,54 @@ int EDIV_Export(char* cadena, int nparam, void* hfuncion)
|
|||
ob->fext.codigo=n_externs;
|
||||
ob->fext.num_par=nparam; // es necesario?*/
|
||||
|
||||
extfuncs[n_externs]=hfuncion;
|
||||
extparms[n_externs]=nparam;
|
||||
extfuncs[n_externs] = hfuncion;
|
||||
extparms[n_externs] = nparam;
|
||||
|
||||
/* for(i=0;i<numdlls;i++)
|
||||
/* for(i=0;i<numdlls;i++)
|
||||
for(j=0;j<dlls[i].nfuncs;j++)
|
||||
if(strcmp(cadena,dlls[i].ext_funcs[j].cadena)==0) {
|
||||
dll_error(4,cadena);
|
||||
return 0;
|
||||
}*/
|
||||
|
||||
/*#define actfunc dlls[numdlls-1].ext_funcs[dlls[numdlls-1].nfuncs]
|
||||
/*#define actfunc dlls[numdlls-1].ext_funcs[dlls[numdlls-1].nfuncs]
|
||||
|
||||
actfunc.cadena=e_malloc(strlen(cadena)+1);
|
||||
strcpy(actfunc.cadena,cadena);
|
||||
actfunc.nparam = nparam;
|
||||
actfunc.hfuncion = hfuncion;*/
|
||||
|
||||
// dlls[numdlls-1].nfuncs++;
|
||||
// dlls[numdlls-1].nfuncs++;
|
||||
n_externs++;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Entrypoint(int ep, void* hfuncion)
|
||||
int EDIV_Export_Entrypoint(int ep, void *hfuncion)
|
||||
{
|
||||
entrypoints[n_entrypoints].tipo=ep;
|
||||
entrypoints[n_entrypoints].hfuncion=hfuncion;
|
||||
entrypoints[n_entrypoints++].dll=numdlls;
|
||||
entrypoints[n_entrypoints].tipo = ep;
|
||||
entrypoints[n_entrypoints].hfuncion = hfuncion;
|
||||
entrypoints[n_entrypoints++].dll = numdlls;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Priority(int priority)
|
||||
{
|
||||
dlls[numdlls].prioridad=priority;
|
||||
dlls[numdlls].prioridad = priority;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Const(char* cadena, int valor)
|
||||
int EDIV_Export_Const(char *cadena, int valor)
|
||||
{
|
||||
if(decl_struct) {
|
||||
dll_error(6,cadena);
|
||||
if (decl_struct)
|
||||
{
|
||||
dll_error(6, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// sólamente se tendrá que hacer algo en la versión con trazador
|
||||
|
||||
/* creaobj=crea_objeto((byte*)cadena);
|
||||
/* creaobj=crea_objeto((byte*)cadena);
|
||||
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_const:\t-- ID OBJETO: %d\n"
|
||||
|
@ -215,15 +211,15 @@ int EDIV_Export_Const(char* cadena, int valor)
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Global(char* cadena, int valor)
|
||||
int EDIV_Export_Global(char *cadena, int valor)
|
||||
{
|
||||
if(decl_struct) {
|
||||
dll_error(6,cadena);
|
||||
if (decl_struct)
|
||||
{
|
||||
dll_error(6, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* creaobj=crea_objeto((byte*)cadena);
|
||||
/* creaobj=crea_objeto((byte*)cadena);
|
||||
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_global:\t-- ID OBJETO: %d\n"
|
||||
|
@ -251,15 +247,15 @@ int EDIV_Export_Global(char* cadena, int valor)
|
|||
return dimem++;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Global_Tab(char* cadena, int numregs)
|
||||
int EDIV_Export_Global_Tab(char *cadena, int numregs)
|
||||
{
|
||||
if(decl_struct) {
|
||||
dll_error(6,cadena);
|
||||
if (decl_struct)
|
||||
{
|
||||
dll_error(6, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* creaobj=crea_objeto((byte*)cadena);
|
||||
/* creaobj=crea_objeto((byte*)cadena);
|
||||
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_global_tab:\t-- ID OBJETO: %d\n"
|
||||
|
@ -292,23 +288,23 @@ int EDIV_Export_Global_Tab(char* cadena, int numregs)
|
|||
mem[imem++]=0;
|
||||
} while (len--);
|
||||
*/
|
||||
offset=dimem;
|
||||
dimem+=numregs;
|
||||
offset = dimem;
|
||||
dimem += numregs;
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Global_Struct(char* cadena, int numregs)
|
||||
int EDIV_Export_Global_Struct(char *cadena, int numregs)
|
||||
{
|
||||
if(decl_struct) {
|
||||
dll_error(6,cadena);
|
||||
if (decl_struct)
|
||||
{
|
||||
dll_error(6, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
nregs=numregs;
|
||||
slocal=0;
|
||||
/* creaobj=crea_objeto((byte*)cadena);
|
||||
nregs = numregs;
|
||||
slocal = 0;
|
||||
/* creaobj=crea_objeto((byte*)cadena);
|
||||
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_global_struct:\t-- ID OBJETO: %d\n"
|
||||
|
@ -340,20 +336,20 @@ int EDIV_Export_Global_Struct(char* cadena, int numregs)
|
|||
member=ob;
|
||||
len=0;
|
||||
*/
|
||||
decl_struct=1;
|
||||
len=0;
|
||||
decl_struct = 1;
|
||||
len = 0;
|
||||
return dimem;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Member_Int(char* cadena, int valor)
|
||||
int EDIV_Export_Member_Int(char *cadena, int valor)
|
||||
{
|
||||
if(!decl_struct) {
|
||||
dll_error(7,cadena);
|
||||
if (!decl_struct)
|
||||
{
|
||||
dll_error(7, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* creaobj=crea_objeto((byte*)cadena);
|
||||
/* creaobj=crea_objeto((byte*)cadena);
|
||||
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_member_int:\t-- ID OBJETO: %d\n"
|
||||
|
@ -393,15 +389,15 @@ int EDIV_Export_Member_Int(char* cadena, int valor)
|
|||
return len++;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Member_Str(char* cadena, int tamano)
|
||||
int EDIV_Export_Member_Str(char *cadena, int tamano)
|
||||
{
|
||||
if(!decl_struct) {
|
||||
dll_error(7,cadena);
|
||||
if (!decl_struct)
|
||||
{
|
||||
dll_error(7, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* creaobj=crea_objeto((byte*)cadena);
|
||||
/* creaobj=crea_objeto((byte*)cadena);
|
||||
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_member_str:\t-- ID OBJETO: %d\n"
|
||||
|
@ -467,22 +463,21 @@ int EDIV_Export_Member_Str(char* cadena, int tamano)
|
|||
return (*ob2).cloc.offset;
|
||||
}*/
|
||||
|
||||
offset=len;
|
||||
len+=tamano;
|
||||
offset = len;
|
||||
len += tamano;
|
||||
|
||||
return offset;
|
||||
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Member_Tab(char* cadena, int numregs)
|
||||
int EDIV_Export_Member_Tab(char *cadena, int numregs)
|
||||
{
|
||||
if(!decl_struct) {
|
||||
dll_error(7,cadena);
|
||||
if (!decl_struct)
|
||||
{
|
||||
dll_error(7, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* creaobj=crea_objeto((byte*)cadena);
|
||||
/* creaobj=crea_objeto((byte*)cadena);
|
||||
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_member_tab:\t-- ID OBJETO: %d\n"
|
||||
|
@ -532,20 +527,20 @@ int EDIV_Export_Member_Tab(char* cadena, int numregs)
|
|||
return (*ob2).tloc.offset;
|
||||
}*/
|
||||
|
||||
offset=len;
|
||||
len+=numregs;
|
||||
offset = len;
|
||||
len += numregs;
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_EndStruct()
|
||||
{
|
||||
if(!decl_struct) {
|
||||
if (!decl_struct)
|
||||
{
|
||||
dll_error(9);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* #ifdef DEBUG_DLL
|
||||
/* #ifdef DEBUG_DLL
|
||||
printf("export_endstruct:\t--- estructura cerrada\n");
|
||||
#endif
|
||||
|
||||
|
@ -579,25 +574,28 @@ int EDIV_Export_EndStruct()
|
|||
// iloc+=ob->sloc.totalitems*ob->sloc.len_item;
|
||||
}
|
||||
*/
|
||||
if(len==0) dll_error(10);
|
||||
if (len == 0)
|
||||
dll_error(10);
|
||||
|
||||
if(slocal) diloc+=len*nregs;
|
||||
else dimem+=len*nregs;
|
||||
if (slocal)
|
||||
diloc += len * nregs;
|
||||
else
|
||||
dimem += len * nregs;
|
||||
|
||||
decl_struct=0;
|
||||
decl_struct = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Local(char* cadena, int valor)
|
||||
int EDIV_Export_Local(char *cadena, int valor)
|
||||
{
|
||||
if(decl_struct) {
|
||||
dll_error(6,cadena);
|
||||
if (decl_struct)
|
||||
{
|
||||
dll_error(6, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* creaobj=crea_objeto((byte*)cadena);
|
||||
/* creaobj=crea_objeto((byte*)cadena);
|
||||
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_local:\t-- ID OBJETO: %d\n"
|
||||
|
@ -622,18 +620,18 @@ int EDIV_Export_Local(char* cadena, int valor)
|
|||
ob->vloc.offset=iloc;
|
||||
loc[iloc]=valor;
|
||||
*/
|
||||
return diloc++;
|
||||
return diloc++;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Local_Tab(char* cadena, int numregs)
|
||||
int EDIV_Export_Local_Tab(char *cadena, int numregs)
|
||||
{
|
||||
if(decl_struct) {
|
||||
dll_error(6,cadena);
|
||||
if (decl_struct)
|
||||
{
|
||||
dll_error(6, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* creaobj=crea_objeto((byte*)cadena);
|
||||
/* creaobj=crea_objeto((byte*)cadena);
|
||||
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_local_tab:\t-- ID OBJETO: %d\n"
|
||||
|
@ -668,23 +666,23 @@ int EDIV_Export_Local_Tab(char* cadena, int numregs)
|
|||
|
||||
return ob->tloc.offset;*/
|
||||
|
||||
offset=diloc;
|
||||
diloc+=numregs;
|
||||
offset = diloc;
|
||||
diloc += numregs;
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Local_Struct(char* cadena, int numregs)
|
||||
int EDIV_Export_Local_Struct(char *cadena, int numregs)
|
||||
{
|
||||
if(decl_struct) {
|
||||
dll_error(6,cadena);
|
||||
if (decl_struct)
|
||||
{
|
||||
dll_error(6, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
nregs=numregs;
|
||||
slocal=1;
|
||||
nregs = numregs;
|
||||
slocal = 1;
|
||||
|
||||
/* creaobj=crea_objeto((byte*)cadena);
|
||||
/* creaobj=crea_objeto((byte*)cadena);
|
||||
|
||||
#ifdef DEBUG_DLL
|
||||
printf("export_local_struct:\t-- ID OBJETO: %d\n"
|
||||
|
@ -716,12 +714,11 @@ int EDIV_Export_Local_Struct(char* cadena, int numregs)
|
|||
member=ob;
|
||||
len=0;
|
||||
*/
|
||||
decl_struct=1;
|
||||
len=0;
|
||||
return diloc;
|
||||
decl_struct = 1;
|
||||
len = 0;
|
||||
return diloc;
|
||||
}
|
||||
|
||||
|
||||
////////////////
|
||||
/// Call_Entrypoint
|
||||
//////////////
|
||||
|
@ -729,90 +726,92 @@ int EDIV_Export_Local_Struct(char* cadena, int numregs)
|
|||
int Call_Entrypoint(int ep, ...)
|
||||
{
|
||||
va_list opparam;
|
||||
int i,c=0;
|
||||
for(i=0;i<n_entrypoints;i++) {
|
||||
if(entrypoints[i].tipo==ep) {
|
||||
int i, c = 0;
|
||||
for (i = 0; i < n_entrypoints; i++)
|
||||
{
|
||||
if (entrypoints[i].tipo == ep)
|
||||
{
|
||||
c++;
|
||||
va_start(opparam,ep);
|
||||
switch(ep) {
|
||||
va_start(opparam, ep);
|
||||
switch (ep)
|
||||
{
|
||||
|
||||
// void funcion(void)
|
||||
case EDIV_set_video_mode:
|
||||
case EDIV_process_palette:
|
||||
case EDIV_process_active_palette:
|
||||
case EDIV_background_to_buffer:
|
||||
case EDIV_buffer_to_video:
|
||||
case EDIV_post_process_scroll:
|
||||
case EDIV_post_process_m7:
|
||||
case EDIV_post_process_m8:
|
||||
case EDIV_post_process_buffer:
|
||||
case EDIV_post_process:
|
||||
case EDIV_ss_init:
|
||||
case EDIV_ss_frame:
|
||||
case EDIV_ss_end:
|
||||
case EDIV_quit:
|
||||
{
|
||||
void (*funcion_ep)(void);
|
||||
funcion_ep=entrypoints[i].hfuncion;
|
||||
funcion_ep();
|
||||
}
|
||||
break;
|
||||
case EDIV_frame:
|
||||
case EDIV_first_load:
|
||||
{
|
||||
void (*funcion_ep)(struct _fun_params* fp);
|
||||
funcion_ep=entrypoints[i].hfuncion;
|
||||
funcion_ep(&fp) ;
|
||||
}
|
||||
break;
|
||||
// void funcion(char*,int)
|
||||
case EDIV_process_sound:
|
||||
case EDIV_process_fpg:
|
||||
case EDIV_process_map:
|
||||
case EDIV_process_fnt:
|
||||
{
|
||||
void (*funcion_ep)(char *ptr,int lenght);
|
||||
char* _ptr=va_arg(opparam,char*);
|
||||
int _lenght=va_arg(opparam,int);
|
||||
funcion_ep=entrypoints[i].hfuncion;
|
||||
funcion_ep(_ptr,_lenght);
|
||||
}
|
||||
break;
|
||||
// void funcion(void)
|
||||
case EDIV_set_video_mode:
|
||||
case EDIV_process_palette:
|
||||
case EDIV_process_active_palette:
|
||||
case EDIV_background_to_buffer:
|
||||
case EDIV_buffer_to_video:
|
||||
case EDIV_post_process_scroll:
|
||||
case EDIV_post_process_m7:
|
||||
case EDIV_post_process_m8:
|
||||
case EDIV_post_process_buffer:
|
||||
case EDIV_post_process:
|
||||
case EDIV_ss_init:
|
||||
case EDIV_ss_frame:
|
||||
case EDIV_ss_end:
|
||||
case EDIV_quit:
|
||||
{
|
||||
void (*funcion_ep)(void);
|
||||
funcion_ep = entrypoints[i].hfuncion;
|
||||
funcion_ep();
|
||||
}
|
||||
break;
|
||||
case EDIV_frame:
|
||||
case EDIV_first_load:
|
||||
{
|
||||
void (*funcion_ep)(struct _fun_params * fp);
|
||||
funcion_ep = entrypoints[i].hfuncion;
|
||||
funcion_ep(&fp);
|
||||
}
|
||||
break;
|
||||
// void funcion(char*,int)
|
||||
case EDIV_process_sound:
|
||||
case EDIV_process_fpg:
|
||||
case EDIV_process_map:
|
||||
case EDIV_process_fnt:
|
||||
{
|
||||
void (*funcion_ep)(char *ptr, int lenght);
|
||||
char *_ptr = va_arg(opparam, char *);
|
||||
int _lenght = va_arg(opparam, int);
|
||||
funcion_ep = entrypoints[i].hfuncion;
|
||||
funcion_ep(_ptr, _lenght);
|
||||
}
|
||||
break;
|
||||
|
||||
case EDIV_put_sprite:
|
||||
{
|
||||
void (*funcion_ep)(unsigned char * si, int x,int y, int an, int al,
|
||||
int xg, int yg, int ang, int size, int flags);
|
||||
unsigned char* _si=va_arg(opparam,unsigned char*);
|
||||
int _x=va_arg(opparam,int);
|
||||
int _y=va_arg(opparam,int);
|
||||
int _an=va_arg(opparam,int);
|
||||
int _al=va_arg(opparam,int);
|
||||
int _xg=va_arg(opparam,int);
|
||||
int _yg=va_arg(opparam,int);
|
||||
int _ang=va_arg(opparam,int);
|
||||
int _size=va_arg(opparam,int);
|
||||
int _flags=va_arg(opparam,int);
|
||||
funcion_ep=entrypoints[i].hfuncion;
|
||||
funcion_ep(_si,_x,_y,_an,_al,_xg,_yg,_ang,_size,_flags);
|
||||
}
|
||||
case EDIV_put_sprite:
|
||||
{
|
||||
void (*funcion_ep)(unsigned char *si, int x, int y, int an, int al,
|
||||
int xg, int yg, int ang, int size, int flags);
|
||||
unsigned char *_si = va_arg(opparam, unsigned char *);
|
||||
int _x = va_arg(opparam, int);
|
||||
int _y = va_arg(opparam, int);
|
||||
int _an = va_arg(opparam, int);
|
||||
int _al = va_arg(opparam, int);
|
||||
int _xg = va_arg(opparam, int);
|
||||
int _yg = va_arg(opparam, int);
|
||||
int _ang = va_arg(opparam, int);
|
||||
int _size = va_arg(opparam, int);
|
||||
int _flags = va_arg(opparam, int);
|
||||
funcion_ep = entrypoints[i].hfuncion;
|
||||
funcion_ep(_si, _x, _y, _an, _al, _xg, _yg, _ang, _size, _flags);
|
||||
}
|
||||
#ifdef DBG
|
||||
// entrypoints del trazador
|
||||
// void funcion(int,char*,int*,void*);
|
||||
case EDIV_trace:
|
||||
case EDIV_debug:
|
||||
{
|
||||
void (*funcion_ep)(int imem, char* nombreprg, int* lin, void* dbg);
|
||||
int _imem=va_arg(opparam,int);
|
||||
char* _nombreprg=va_arg(opparam,char*);
|
||||
void* _lin=va_arg(opparam,void*);
|
||||
void* _dbg=va_arg(opparam,void*);
|
||||
//assert(0);
|
||||
funcion_ep=entrypoints[i].hfuncion;
|
||||
funcion_ep(_imem,_nombreprg,_lin,_dbg);
|
||||
}
|
||||
// entrypoints del trazador
|
||||
// void funcion(int,char*,int*,void*);
|
||||
case EDIV_trace:
|
||||
case EDIV_debug:
|
||||
{
|
||||
void (*funcion_ep)(int imem, char *nombreprg, int *lin, void *dbg);
|
||||
int _imem = va_arg(opparam, int);
|
||||
char *_nombreprg = va_arg(opparam, char *);
|
||||
void *_lin = va_arg(opparam, void *);
|
||||
void *_dbg = va_arg(opparam, void *);
|
||||
//assert(0);
|
||||
funcion_ep = entrypoints[i].hfuncion;
|
||||
funcion_ep(_imem, _nombreprg, _lin, _dbg);
|
||||
}
|
||||
#endif /* DBG */
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
*/
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <windows.h>
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
|
@ -55,29 +55,28 @@
|
|||
|
||||
void error(int num, ...)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
HWND ventanuka;
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
HWND ventanuka;
|
||||
#endif
|
||||
|
||||
va_list opparam;
|
||||
char mensaje[256];
|
||||
|
||||
va_start(opparam,num);
|
||||
sprintf(mensaje,translate(0), num);
|
||||
vsprintf(mensaje,translate_runtime_error(num-100),opparam);
|
||||
va_start(opparam, num);
|
||||
sprintf(mensaje, get_translate(0), num);
|
||||
vsprintf(mensaje, translate_runtime_error(num - 100), opparam);
|
||||
|
||||
#ifdef _WIN32
|
||||
ventanuka=GetActiveWindow();
|
||||
//MessageBox(
|
||||
MessageBox(ventanuka,mensaje,translate(1),MB_ICONERROR);
|
||||
#else
|
||||
printf("%s\n",mensaje);
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
ventanuka = GetActiveWindow();
|
||||
//MessageBox(
|
||||
MessageBox(ventanuka, mensaje, print_translate(1), MB_ICONERROR);
|
||||
#else
|
||||
printf("%s\n", mensaje);
|
||||
#endif
|
||||
|
||||
stub_quit(num);
|
||||
}
|
||||
|
||||
|
||||
/* critical_error ( numero, parametros [...] )
|
||||
*
|
||||
* Interrumpe el programa con un mensaje de error. No es posible trazar.
|
||||
|
@ -90,20 +89,19 @@ void critical_error(int num, ...)
|
|||
va_list opparam;
|
||||
char mensaje[256];
|
||||
|
||||
va_start(opparam,num);
|
||||
sprintf(mensaje,translate(0), num);
|
||||
vsprintf(mensaje,translate_critical_error(num),opparam);
|
||||
va_start(opparam, num);
|
||||
sprintf(mensaje, get_translate(0), num);
|
||||
vsprintf(mensaje, translate_critical_error(num), opparam);
|
||||
|
||||
#ifdef WIN32
|
||||
MessageBox(0,mensaje,translate(2),MB_ICONERROR);
|
||||
#else
|
||||
printf("%s\n",mensaje);
|
||||
#endif
|
||||
#ifdef WIN32
|
||||
MessageBox(0, mensaje, print_translate(2), MB_ICONERROR);
|
||||
#else
|
||||
printf("%s\n", mensaje);
|
||||
#endif
|
||||
|
||||
stub_quit(num);
|
||||
}
|
||||
|
||||
|
||||
/* custom_error (tipo, mensaje)
|
||||
*
|
||||
* Permite a las DLLs generar sus propios errores, para que no dependan de los
|
||||
|
@ -119,13 +117,13 @@ void critical_error(int num, ...)
|
|||
* DESVENTAJA: se pierde la capacidad multilingüe, a menos que la incluya la propia DLL.
|
||||
*/
|
||||
|
||||
void custom_error(tipoerror tipo, char* mensaje)
|
||||
void custom_error(tipoerror tipo, char *mensaje)
|
||||
{
|
||||
#ifdef WIN32
|
||||
MessageBox(0,mensaje,translate(tipo),MB_ICONERROR);
|
||||
#else
|
||||
printf("%s\n",mensaje);
|
||||
#endif
|
||||
#ifdef WIN32
|
||||
MessageBox(0, mensaje, print_translate(tipo), MB_ICONERROR);
|
||||
#else
|
||||
printf("%s\n", mensaje);
|
||||
#endif
|
||||
|
||||
stub_quit(500+tipo);
|
||||
stub_quit(500 + tipo);
|
||||
}
|
||||
|
|
|
@ -18,74 +18,77 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
|
||||
/**** ¡¡¡ OJO CON LAS COMAS !!! ****/
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <windows.h>
|
||||
#include <windows.h>
|
||||
#else
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
|
||||
#include "shared.h"
|
||||
#include "language.h"
|
||||
|
||||
|
||||
int detecta_idioma_iso(char* lang)
|
||||
int detecta_idioma_iso(char *lang)
|
||||
{
|
||||
int i;
|
||||
static char getid[NUM_LANGUAGES][3] = {
|
||||
"es", // español
|
||||
"it", // italiano
|
||||
"pt", // portugués
|
||||
"en", // inglés
|
||||
"ca", // catalán
|
||||
"eu" // euskera
|
||||
"es", // español
|
||||
"it", // italiano
|
||||
"pt", // portugués
|
||||
"en", // inglés
|
||||
"ca", // catalán
|
||||
"eu" // euskera
|
||||
};
|
||||
if(lang==NULL) return DEFAULT_LANGUAGE;
|
||||
if(strlen(lang)>2) lang[2]=0;
|
||||
if (lang == NULL)
|
||||
return DEFAULT_LANGUAGE;
|
||||
if (strlen(lang) > 2)
|
||||
lang[2] = 0;
|
||||
strlwr(lang);
|
||||
for(i=0;i<NUM_LANGUAGES;i++)
|
||||
if(lang[0]==getid[i][0])
|
||||
if(lang[1]==getid[i][1])
|
||||
for (i = 0; i < NUM_LANGUAGES; i++)
|
||||
if (lang[0] == getid[i][0])
|
||||
if (lang[1] == getid[i][1])
|
||||
break;
|
||||
if(i==NUM_LANGUAGES) i=DEFAULT_LANGUAGE;
|
||||
if (i == NUM_LANGUAGES)
|
||||
i = DEFAULT_LANGUAGE;
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
int detecta_idioma()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
int i;
|
||||
static int getid[NUM_LANGUAGES] = {
|
||||
0x0a, // español
|
||||
0x10, // italiano
|
||||
0x16, // portugués
|
||||
0x09, // inglés
|
||||
0x03, // catalán
|
||||
0x2d // euskera
|
||||
};
|
||||
LANGID lang;
|
||||
#ifdef _WIN32
|
||||
int i;
|
||||
static int getid[NUM_LANGUAGES] = {
|
||||
0x0a, // español
|
||||
0x10, // italiano
|
||||
0x16, // portugués
|
||||
0x09, // inglés
|
||||
0x03, // catalán
|
||||
0x2d // euskera
|
||||
};
|
||||
LANGID lang;
|
||||
|
||||
lang=GetSystemDefaultLangID()&0xff;
|
||||
for(i=0;i<NUM_LANGUAGES;i++)
|
||||
if(lang==getid[i]) break;
|
||||
if(i==NUM_LANGUAGES) i=DEFAULT_LANGUAGE;
|
||||
return i;
|
||||
#else
|
||||
char* langcfg=getenv("LANG");
|
||||
if(langcfg==NULL) return DEFAULT_LANGUAGE;
|
||||
else return detecta_idioma_iso(langcfg);
|
||||
#endif
|
||||
lang = GetSystemDefaultLangID() & 0xff;
|
||||
for (i = 0; i < NUM_LANGUAGES; i++)
|
||||
if (lang == getid[i])
|
||||
break;
|
||||
if (i == NUM_LANGUAGES)
|
||||
i = DEFAULT_LANGUAGE;
|
||||
return i;
|
||||
#else
|
||||
char *langcfg = getenv("LANG");
|
||||
if (langcfg == NULL)
|
||||
return DEFAULT_LANGUAGE;
|
||||
else
|
||||
return detecta_idioma_iso(langcfg);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
char* translate(int id_cadena)
|
||||
char *translate(int id_cadena)
|
||||
{
|
||||
static char *msg[NUM_LANGUAGES][5]= {
|
||||
static char *msg[NUM_LANGUAGES][5] = {
|
||||
|
||||
#define TRANSLATE TRANSLATE_STUB
|
||||
#include "language_aux.h"
|
||||
|
@ -94,15 +97,14 @@ char* translate(int id_cadena)
|
|||
return msg[idioma][id_cadena];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* NOTA: los huecos vacíos (184..199) son de errores no usados en DIV2, por favor
|
||||
* aprovechadlos para añadir nuevos errores.
|
||||
*/
|
||||
|
||||
char* translate_runtime_error(int num)
|
||||
char *translate_runtime_error(int num)
|
||||
{
|
||||
static char *e[NUM_LANGUAGES][101]= {
|
||||
static char *e[NUM_LANGUAGES][101] = {
|
||||
|
||||
#define TRANSLATE TRANSLATE_RUNTIME_ERROR
|
||||
#include "language_aux.h"
|
||||
|
@ -110,11 +112,9 @@ char* translate_runtime_error(int num)
|
|||
};
|
||||
|
||||
return e[idioma][num];
|
||||
|
||||
}
|
||||
|
||||
|
||||
char* translate_critical_error(int num)
|
||||
char *translate_critical_error(int num)
|
||||
{
|
||||
static char *e[NUM_LANGUAGES][10] = {
|
||||
|
||||
|
@ -126,8 +126,7 @@ char* translate_critical_error(int num)
|
|||
return e[idioma][num];
|
||||
}
|
||||
|
||||
|
||||
char* translate_dll_error(int num)
|
||||
char *translate_dll_error(int num)
|
||||
{
|
||||
static char *e[NUM_LANGUAGES][10] = {
|
||||
|
||||
|
@ -138,3 +137,31 @@ char* translate_dll_error(int num)
|
|||
return e[idioma][num];
|
||||
}
|
||||
|
||||
void print_translate(int num, ...)
|
||||
{
|
||||
va_list arg_ptr;
|
||||
const char *message = translate(num);
|
||||
size_t msglen = strlen(message);
|
||||
char *strbuf = malloc(msglen + 1);
|
||||
|
||||
va_start(arg_ptr, message);
|
||||
vsprintf(strbuf, message, arg_ptr);
|
||||
va_end(arg_ptr);
|
||||
|
||||
printf("%s", strbuf);
|
||||
free(strbuf);
|
||||
}
|
||||
|
||||
const char *get_translate(int num, ...)
|
||||
{
|
||||
va_list arg_ptr;
|
||||
const char *message = translate(num);
|
||||
size_t msglen = strlen(message);
|
||||
char *strbuf = malloc(msglen + 1);
|
||||
|
||||
va_start(arg_ptr, message);
|
||||
vsprintf(strbuf, message, arg_ptr);
|
||||
va_end(arg_ptr);
|
||||
|
||||
return strbuf;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue