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