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
|
@ -34,18 +34,16 @@ char* buffer;
|
|||
int linea;
|
||||
char cfg[256];
|
||||
|
||||
/*void cfg_error(int error)
|
||||
void salta_spc()
|
||||
{
|
||||
printf(translate(41),cfg,linea,translate_cfg_error(error));
|
||||
printf(translate(42));
|
||||
exit(1);
|
||||
}*/
|
||||
|
||||
void salta_spc() {
|
||||
while(lower[buffer[i]]==0 && i<tamano) {
|
||||
if(buffer[i]=='\n') linea++;
|
||||
else if(buffer[i]=='\'') {
|
||||
while(buffer[i]!='\n' && i<tamano) i++;
|
||||
while (lower[buffer[i]] == 0 && i < tamano)
|
||||
{
|
||||
if (buffer[i] == '\n')
|
||||
linea++;
|
||||
else if (buffer[i] == '\'')
|
||||
{
|
||||
while (buffer[i] != '\n' && i < tamano)
|
||||
i++;
|
||||
linea++;
|
||||
}
|
||||
i++;
|
||||
|
@ -71,7 +69,8 @@ void lee_ediv_cfg(char* ediv_cfg)
|
|||
hacer_strfix = 1;
|
||||
optimizar = 1;
|
||||
|
||||
if((f=fopen(ediv_cfg,"r"))==NULL) {
|
||||
if ((f = fopen(ediv_cfg, "r")) == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -83,18 +82,22 @@ void lee_ediv_cfg(char* ediv_cfg)
|
|||
fread(buffer, 1, tamano, f);
|
||||
fclose(f);
|
||||
|
||||
for(i=0;i<tamano;i++) {
|
||||
for (i = 0; i < tamano; i++)
|
||||
{
|
||||
salta_spc();
|
||||
c = 0;
|
||||
while (lower[buffer[i]] != 0 && c < 20 && i < tamano)
|
||||
tag[c++] = lower[buffer[i++]];
|
||||
tag[c] = 0;
|
||||
|
||||
if(!strcmp(tag,"max_process")) {
|
||||
if (!strcmp(tag, "max_process"))
|
||||
{
|
||||
salta_spc();
|
||||
if(buffer[i]!='=') cfg_error(1); /* se esperaba '=' */
|
||||
if (buffer[i] != '=')
|
||||
cfg_error(1); /* se esperaba '=' */
|
||||
salta_spc();
|
||||
if(buffer[i]<'0' || buffer[i]>'9') cfg_error(2); /* se esperaba un dato numerico */
|
||||
if (buffer[i] < '0' || buffer[i] > '9')
|
||||
cfg_error(2); /* se esperaba un dato numerico */
|
||||
c = 0;
|
||||
while (buffer[i] >= '0' && buffer[i] <= '9' && i < tamano)
|
||||
tag[c++] = buffer[i++];
|
||||
|
@ -155,7 +158,6 @@ void lee_ediv_cfg(char* ediv_cfg)
|
|||
lexico();
|
||||
comprueba_null=0;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
free(buffer);
|
||||
|
|
|
@ -90,35 +90,40 @@ int main(int argc, char *argv[])
|
|||
idioma = detecta_idioma();
|
||||
|
||||
/* mensaje de cabecera */
|
||||
printf(translate(0));
|
||||
printf(translate(1));
|
||||
print_translate(0);
|
||||
print_translate(1);
|
||||
printf("\n");
|
||||
|
||||
if(argc<2) goto ayuda;
|
||||
if (argc < 2)
|
||||
goto ayuda;
|
||||
|
||||
if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-v") == 0)
|
||||
exit(0);
|
||||
|
||||
if(strcmp(argv[1],"--help")==0 || strcmp(argv[1],"-h")==0) {
|
||||
if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0)
|
||||
{
|
||||
ayuda:
|
||||
/* pantalla de ayuda */
|
||||
printf(translate(2));
|
||||
printf(translate(3),argv[0]);
|
||||
printf(translate(4));
|
||||
printf(translate(5));
|
||||
printf(translate(6));
|
||||
printf(translate(7));
|
||||
printf(translate(8));
|
||||
printf(translate(9));
|
||||
printf(translate(10),sistema);
|
||||
printf(translate(48));
|
||||
printf(translate(11));
|
||||
print_translate(2);
|
||||
print_translate(3, argv[0]);
|
||||
print_translate(4);
|
||||
print_translate(5);
|
||||
print_translate(6);
|
||||
print_translate(7);
|
||||
print_translate(8);
|
||||
print_translate(9);
|
||||
print_translate(10, sistema);
|
||||
print_translate(48);
|
||||
print_translate(11);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
for(i=1;i<argc;i++) {
|
||||
if(argv[i][0]=='-') {
|
||||
if(argv[i][1]=='-') {
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
if (argv[i][0] == '-')
|
||||
{
|
||||
if (argv[i][1] == '-')
|
||||
{
|
||||
if (strcmp(argv[i] + 2, "debug") == 0)
|
||||
debug = 1;
|
||||
else if (strcmp(argv[i] + 2, "list") == 0)
|
||||
|
@ -128,26 +133,34 @@ int main(int argc, char *argv[])
|
|||
else if (strcmp(argv[i] + 2, "check") == 0)
|
||||
noexe = 1;
|
||||
else if (strcmp(argv[i] + 2, "system") == 0)
|
||||
if(++i<argc) {
|
||||
if (++i < argc)
|
||||
{
|
||||
strcpy(sistema, argv[i]);
|
||||
} else {
|
||||
printf(translate(12)); /* se debe indicar un sistema para --system */
|
||||
}
|
||||
else
|
||||
{
|
||||
print_translate(12); /* se debe indicar un sistema para --system */
|
||||
exit(1);
|
||||
}
|
||||
#ifdef _WIN32
|
||||
else if(strcmp(argv[i]+2,"news")==0) {
|
||||
else if (strcmp(argv[i] + 2, "news") == 0)
|
||||
{
|
||||
muestra_motd();
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
printf(translate(13),argv[i]); /* parámetro erróneo */
|
||||
else
|
||||
{
|
||||
print_translate(13, argv[i]); /* parámetro erróneo */
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
j = 1;
|
||||
while(argv[i][j]!=0) {
|
||||
switch(argv[i][j]) {
|
||||
while (argv[i][j] != 0)
|
||||
{
|
||||
switch (argv[i][j])
|
||||
{
|
||||
case 'd':
|
||||
debug = 1;
|
||||
break;
|
||||
|
@ -161,17 +174,21 @@ int main(int argc, char *argv[])
|
|||
noexe = 1;
|
||||
break;
|
||||
case 's':
|
||||
if(argv[i][j+1]!=0) {
|
||||
if (argv[i][j + 1] != 0)
|
||||
{
|
||||
strcpy(sistema, argv[i] + j + 1);
|
||||
j = strlen(argv[i]) - 1;
|
||||
}
|
||||
else {
|
||||
if(++i<argc) {
|
||||
else
|
||||
{
|
||||
if (++i < argc)
|
||||
{
|
||||
strcpy(sistema, argv[i]);
|
||||
j = strlen(argv[i]) - 1;
|
||||
}
|
||||
else {
|
||||
printf(translate(14)); /* se debe indicar un sistema para -s */
|
||||
else
|
||||
{
|
||||
print_translate(14); /* se debe indicar un sistema para -s */
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -182,14 +199,16 @@ int main(int argc, char *argv[])
|
|||
exit(0);
|
||||
#endif
|
||||
default:
|
||||
printf(translate(15),argv[i][j]); /* parámetro erróneo */
|
||||
print_translate(15, argv[i][j]); /* parámetro erróneo */
|
||||
exit(1);
|
||||
}
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else switch (hayprog) {
|
||||
else
|
||||
switch (hayprog)
|
||||
{
|
||||
case 0:
|
||||
fichero_prg = argv[i];
|
||||
hayprog = 1;
|
||||
|
@ -199,51 +218,58 @@ int main(int argc, char *argv[])
|
|||
hayprog = 2;
|
||||
break;
|
||||
default:
|
||||
printf(translate(13),argv[i]); /* parámetro erróneo */
|
||||
print_translate(13, argv[i]); /* parámetro erróneo */
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if(hayprog==0) {
|
||||
printf(translate(16)); /* no se ha especificado un archivo */
|
||||
if (hayprog == 0)
|
||||
{
|
||||
print_translate(16); /* no se ha especificado un archivo */
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (i=0;i<=strlen(fichero_prg);i++) {
|
||||
for (i = 0; i <= strlen(fichero_prg); i++)
|
||||
{
|
||||
if (*(fichero_prg + i) == '.')
|
||||
break;
|
||||
nombreprog[i] = *(fichero_prg + i);
|
||||
}
|
||||
nombreprog[i] = 0;
|
||||
|
||||
if(!(fp = fopen(fichero_prg, "rb"))) {
|
||||
if(!strcmp(nombreprog,fichero_prg)) {
|
||||
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"))) {
|
||||
if (!(fp = fopen(fichero_prg, "rb")))
|
||||
{
|
||||
strcpy(fichero_prg, nombreprog);
|
||||
strcat(fichero_prg, ".PRG");
|
||||
if(!(fp = fopen(fichero_prg, "rb"))) {
|
||||
printf(translate(17),nombreprog); /* error al abrir archivo */
|
||||
if (!(fp = fopen(fichero_prg, "rb")))
|
||||
{
|
||||
print_translate(17, nombreprog); /* error al abrir archivo */
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf(translate(17),argv[1]); /* error al abrir archivo */
|
||||
else
|
||||
{
|
||||
print_translate(17, argv[1]); /* error al abrir archivo */
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Componemos el nombre del ejecutable */
|
||||
if(hayprog<2) {
|
||||
if (hayprog < 2)
|
||||
{
|
||||
strcpy(outfilename, nombreprog);
|
||||
if (!strcmp(sistema, "win32"))
|
||||
strcat(outfilename, ".exe");
|
||||
}
|
||||
|
||||
printf(translate(18),fichero_prg); /* compilando... */
|
||||
|
||||
print_translate(18, fichero_prg); /* compilando... */
|
||||
|
||||
/* mete el PRG en el buffer prog */
|
||||
fseek(fp, 0, SEEK_END);
|
||||
|
@ -251,32 +277,38 @@ int main(int argc, char *argv[])
|
|||
prog = e_malloc(progsize + 1);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
p = (char *)prog;
|
||||
do {
|
||||
do
|
||||
{
|
||||
*p = getc(fp);
|
||||
p++;
|
||||
} while (!feof(fp));
|
||||
fclose(fp);
|
||||
|
||||
/* Comprueba si existe la edivrun.lib */
|
||||
if(!noexe) {
|
||||
if (!noexe)
|
||||
{
|
||||
strcpy(edivrun_lib, sistema);
|
||||
if (debug)
|
||||
strcat(edivrun_lib, ".dbg");
|
||||
else
|
||||
strcat(edivrun_lib, ".rel");
|
||||
|
||||
if((fp = fopen(edivrun_lib, "rb"))==NULL) {
|
||||
printf(translate(19),edivrun_lib); /* no se encuentra el fichero */
|
||||
if ((fp = fopen(edivrun_lib, "rb")) == NULL)
|
||||
{
|
||||
print_translate(19, edivrun_lib); /* no se encuentra el fichero */
|
||||
exit(1);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
fread(libmagic, 1, 14, fp);
|
||||
if(strcmp(libmagic,magic)) {
|
||||
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);
|
||||
exit(1);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
fread(&stub_size, 1, 4, fp);
|
||||
fclose(fp);
|
||||
#ifdef _DEBUG
|
||||
|
@ -286,7 +318,8 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
if(!ini) {
|
||||
if (!ini)
|
||||
{
|
||||
/* Valores de las opciones por defecto */
|
||||
max_process = 0;
|
||||
ignore_errors = 0;
|
||||
|
@ -299,7 +332,9 @@ int main(int argc, char *argv[])
|
|||
hacer_strfix = 1;
|
||||
optimizar = 1;
|
||||
case_sensitive = 0;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
max_process = iniparser_getint(ini, "default_compiler_options:max_process", 0);
|
||||
ignore_errors = iniparser_getboolean(ini, "default_compiler_options:ignore_errors", 0);
|
||||
free_sintax = iniparser_getboolean(ini, "default_compiler_options:free_sintax", 0);
|
||||
|
@ -314,7 +349,6 @@ int main(int argc, char *argv[])
|
|||
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();
|
||||
|
@ -326,21 +360,20 @@ int main(int argc, char *argv[])
|
|||
printf("edivc: Finalizado - %d advertencias, %d errores\n", n_warnings, n_errors);
|
||||
#else
|
||||
if (n_errors)
|
||||
printf(translate(21),n_warnings);
|
||||
print_translate(21, n_warnings);
|
||||
else
|
||||
printf(translate(22),n_warnings);
|
||||
print_translate(22, n_warnings);
|
||||
#endif
|
||||
|
||||
if (n_errors == 0)
|
||||
return 0;
|
||||
else {
|
||||
printf(translate(23));
|
||||
else
|
||||
{
|
||||
print_translate(23);
|
||||
return 2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* void *e_malloc(size_t size)
|
||||
* Idéntico a malloc, pero con errormsg automático
|
||||
|
@ -352,8 +385,9 @@ void* e_malloc(size_t size)
|
|||
{
|
||||
void *ret;
|
||||
|
||||
if(!(ret = malloc(size))) {
|
||||
printf(translate(24)); /* memoria insuficiente */
|
||||
if (!(ret = malloc(size)))
|
||||
{
|
||||
print_translate(24); /* memoria insuficiente */
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -362,7 +396,8 @@ void* e_malloc(size_t size)
|
|||
|
||||
void e_free(void *puntero)
|
||||
{
|
||||
if (puntero) {
|
||||
if (puntero)
|
||||
{
|
||||
free(puntero);
|
||||
puntero = NULL;
|
||||
}
|
||||
|
@ -370,24 +405,38 @@ void e_free(void *puntero)
|
|||
|
||||
void errormem()
|
||||
{
|
||||
printf(translate(24));
|
||||
print_translate(24);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Gestión de errores
|
||||
*/
|
||||
int _le, _t;
|
||||
byte *_ie;
|
||||
|
||||
void save_error(word tipo) { /* Guarda una posicion de error (de 0 .. 3) */
|
||||
switch(tipo) {
|
||||
case 0: _le=linea; _ie=ierror; break;
|
||||
case 1: _le=old_linea; _ie=old_ierror_end; break;
|
||||
case 2: _le=old_linea; _ie=old_ierror; break;
|
||||
case 3: _le=old_linea; _ie=old_ierror_end; break;
|
||||
} _t=tipo;
|
||||
void save_error(word tipo)
|
||||
{ /* Guarda una posicion de error (de 0 .. 3) */
|
||||
switch (tipo)
|
||||
{
|
||||
case 0:
|
||||
_le = linea;
|
||||
_ie = ierror;
|
||||
break;
|
||||
case 1:
|
||||
_le = old_linea;
|
||||
_ie = old_ierror_end;
|
||||
break;
|
||||
case 2:
|
||||
_le = old_linea;
|
||||
_ie = old_ierror;
|
||||
break;
|
||||
case 3:
|
||||
_le = old_linea;
|
||||
_ie = old_ierror_end;
|
||||
break;
|
||||
}
|
||||
_t = tipo;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -404,28 +453,54 @@ void error(word tipo, word num, ...)
|
|||
byte *_p, *p;
|
||||
va_list opparam;
|
||||
|
||||
switch(tipo) {
|
||||
case 0: linea_error=linea; p=ierror; break;
|
||||
case 1: linea_error=old_linea; _p=p=old_ierror_end; break;
|
||||
case 2: linea_error=old_linea; p=old_ierror; break;
|
||||
case 3: linea_error=old_linea; _p=p=old_ierror_end; break;
|
||||
case 4: linea_error=_le; _p=p=_ie; tipo=_t; break;
|
||||
switch (tipo)
|
||||
{
|
||||
case 0:
|
||||
linea_error = linea;
|
||||
p = ierror;
|
||||
break;
|
||||
case 1:
|
||||
linea_error = old_linea;
|
||||
_p = p = old_ierror_end;
|
||||
break;
|
||||
case 2:
|
||||
linea_error = old_linea;
|
||||
p = old_ierror;
|
||||
break;
|
||||
case 3:
|
||||
linea_error = old_linea;
|
||||
_p = p = old_ierror_end;
|
||||
break;
|
||||
case 4:
|
||||
linea_error = _le;
|
||||
_p = p = _ie;
|
||||
tipo = _t;
|
||||
break;
|
||||
}
|
||||
|
||||
if (num!=2 && num!=6) {
|
||||
while (--p>=prog) {
|
||||
if (*p==lf || (*p==cr && *(p+1)==lf)) break;
|
||||
if (num != 2 && num != 6)
|
||||
{
|
||||
while (--p >= prog)
|
||||
{
|
||||
if (*p == lf || (*p == cr && *(p + 1) == lf))
|
||||
break;
|
||||
columna++;
|
||||
}
|
||||
if (p<prog) columna++;
|
||||
if (p < prog)
|
||||
columna++;
|
||||
}
|
||||
|
||||
if (tipo==1) {
|
||||
if (*(_p+1)==' ' || *(_p+1)==cr || *(_p+1)==lf) columna++; columna++;
|
||||
} else if (tipo==3) columna++;
|
||||
if (tipo == 1)
|
||||
{
|
||||
if (*(_p + 1) == ' ' || *(_p + 1) == cr || *(_p + 1) == lf)
|
||||
columna++;
|
||||
columna++;
|
||||
}
|
||||
else if (tipo == 3)
|
||||
columna++;
|
||||
|
||||
va_start(opparam, num);
|
||||
printf(translate(25), fichero_prg, linea_error, columna, num);
|
||||
print_translate(25, fichero_prg, linea_error, columna, num);
|
||||
vprintf(translate_error(num), opparam);
|
||||
printf("\n");
|
||||
|
||||
|
@ -435,12 +510,13 @@ void error(word tipo, word num, ...)
|
|||
if (n_errors > 20)
|
||||
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);
|
||||
#else
|
||||
printf(translate(21),n_warnings);
|
||||
print_translate(21, n_warnings);
|
||||
#endif
|
||||
printf(translate(23));
|
||||
print_translate(23);
|
||||
exit(2);
|
||||
#ifdef MULTI_ERROR
|
||||
}
|
||||
|
@ -452,7 +528,7 @@ void warning(int num, ...)
|
|||
va_list opparam;
|
||||
|
||||
va_start(opparam, num);
|
||||
printf(translate(26), fichero_prg, linea);
|
||||
print_translate(26, fichero_prg, linea);
|
||||
vprintf(translate_warning(num), opparam);
|
||||
printf("\n");
|
||||
n_warnings++;
|
||||
|
@ -467,18 +543,23 @@ void muestra_motd()
|
|||
char *motdserver = NULL;
|
||||
char *motdpath = NULL;
|
||||
|
||||
if(ini) {
|
||||
if (ini)
|
||||
{
|
||||
motdserver = iniparser_getstr(ini, "general:motd_host");
|
||||
motdpath = iniparser_getstr(ini, "general:motd_path");
|
||||
if(!motdserver) {
|
||||
printf(translate(49)); /* el servidor de motd debe estar en ediv.cfg */
|
||||
if (!motdserver)
|
||||
{
|
||||
print_translate(49); /* el servidor de motd debe estar en ediv.cfg */
|
||||
exit(1);
|
||||
}
|
||||
if(!motdpath) motdpath="/ediv/actual/motd.txt";
|
||||
if (!motdpath)
|
||||
motdpath = "/ediv/actual/motd.txt";
|
||||
conecta(motdserver, motdpath);
|
||||
exit(0);
|
||||
} else {
|
||||
printf(translate(49)); /* el servidor de motd debe estar en ediv.cfg */
|
||||
}
|
||||
else
|
||||
{
|
||||
print_translate(49); /* el servidor de motd debe estar en ediv.cfg */
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -499,14 +580,16 @@ void conecta(char *servidor, char *archivo)
|
|||
else
|
||||
htent = gethostbyaddr((const char *)&iahost, sizeof(struct in_addr), AF_INET);
|
||||
|
||||
if (htent==NULL) {
|
||||
if (htent == NULL)
|
||||
{
|
||||
sock_error("gethostbyname()");
|
||||
return;
|
||||
}
|
||||
|
||||
sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
|
||||
if (sock==INVALID_SOCKET) {
|
||||
if (sock == INVALID_SOCKET)
|
||||
{
|
||||
sock_error("socket()");
|
||||
return;
|
||||
}
|
||||
|
@ -521,7 +604,8 @@ void conecta(char *servidor, char *archivo)
|
|||
sin.sin_addr = *(struct in_addr *)*htent->h_addr_list;
|
||||
|
||||
status = connect(sock, (struct sockaddr *)&sin, sizeof(sin));
|
||||
if (status==SOCKET_ERROR) {
|
||||
if (status == SOCKET_ERROR)
|
||||
{
|
||||
sock_error("connect()");
|
||||
closesocket(sock);
|
||||
return;
|
||||
|
@ -533,8 +617,8 @@ void conecta(char *servidor, char *archivo)
|
|||
"Accept: text/html, image/png, image/jpeg, image/gif, image/x-xbitmap, */*\n"
|
||||
"Accept-Language: es\nAccept-Encoding: deflate, gzip, x-gzip, identity, *;q=0\n"
|
||||
"Connection: Keep-Alive\n"
|
||||
"\n"
|
||||
,archivo,servidor);
|
||||
"\n",
|
||||
archivo, servidor);
|
||||
|
||||
#ifdef DEBUG_HTTP
|
||||
printf("GET %s HTTP/1.1\n"
|
||||
|
@ -543,59 +627,68 @@ void conecta(char *servidor, char *archivo)
|
|||
"Accept: text/html, image/png, image/jpeg, image/gif, image/x-xbitmap, */*\n"
|
||||
"Accept-Language: es\nAccept-Encoding: deflate, gzip, x-gzip, identity, *;q=0\n"
|
||||
"Connection: Keep-Alive\n"
|
||||
"\n"
|
||||
,archivo,servidor);
|
||||
"\n",
|
||||
archivo, servidor);
|
||||
#endif
|
||||
|
||||
status = send(sock, buffer, strlen(buffer), 0);
|
||||
if (status==SOCKET_ERROR) {
|
||||
if (status == SOCKET_ERROR)
|
||||
{
|
||||
sock_error("send()");
|
||||
closesocket(sock);
|
||||
return;
|
||||
}
|
||||
|
||||
status = recv(sock, buffer, sizeof(buffer), 0);
|
||||
if (status == SOCKET_ERROR) {
|
||||
if (status == SOCKET_ERROR)
|
||||
{
|
||||
sock_error("recv()");
|
||||
}
|
||||
|
||||
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);
|
||||
exit(1);
|
||||
}
|
||||
size = strstr(buffer, "Content-Type: ");
|
||||
if(!size) {
|
||||
printf(translate(50));
|
||||
if (!size)
|
||||
{
|
||||
print_translate(50);
|
||||
exit(1);
|
||||
}
|
||||
size += 14;
|
||||
*(ras = strchr(size, 0x0d)) = 0;
|
||||
if(strcmp(size,"text/plain")) {
|
||||
printf(translate(50));
|
||||
if (strcmp(size, "text/plain"))
|
||||
{
|
||||
print_translate(50);
|
||||
exit(1);
|
||||
}
|
||||
*ras = 0x0d;
|
||||
|
||||
size = strstr(buffer, "Content-Length: ");
|
||||
if(!size) {
|
||||
printf(translate(50));
|
||||
if (!size)
|
||||
{
|
||||
print_translate(50);
|
||||
exit(1);
|
||||
}
|
||||
size += 16;
|
||||
ras = strchr(size, 0x0d) - 1;
|
||||
content = strstr(size, "\x0d\x0a\x0d\x0a") + 4;
|
||||
tam=0; inc=1;
|
||||
for(;ras>=size;ras--) {
|
||||
tam = 0;
|
||||
inc = 1;
|
||||
for (; ras >= size; ras--)
|
||||
{
|
||||
if (*ras >= '0' && *ras <= '9')
|
||||
tam += (*ras - '0') * inc;
|
||||
else
|
||||
break;
|
||||
inc *= 10;
|
||||
}
|
||||
if(tam>1024) tam=1024;
|
||||
if (tam > 1024)
|
||||
tam = 1024;
|
||||
|
||||
fwrite(content, tam, 1, stdout);
|
||||
}
|
||||
|
|
|
@ -41,29 +41,28 @@ int numparams;
|
|||
byte decl_struct = 0; /* 1 si se está declarando un struct */
|
||||
byte struct_reserved = 0; /* 1 si se está declarando la estructura reserved */
|
||||
|
||||
|
||||
/* Errores específicos en la ejecución de una DLL */
|
||||
void dll_error(int error, ...)
|
||||
{
|
||||
va_list opparam;
|
||||
|
||||
va_start(opparam, error);
|
||||
printf(translate(35), fichdll);
|
||||
print_translate(35, fichdll);
|
||||
vprintf(translate_dll_error(error - 1), opparam);
|
||||
printf("\n");
|
||||
n_errors++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int EDIV_Export(char *cadena, int nparam, void *hfuncion)
|
||||
{
|
||||
if(decl_struct) {
|
||||
if (decl_struct)
|
||||
{
|
||||
dll_error(6, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(nparam<0) {
|
||||
if (nparam < 0)
|
||||
{
|
||||
dll_error(5, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
@ -74,17 +73,20 @@ int EDIV_Export(char* cadena, int nparam, void* hfuncion)
|
|||
printf("export_function:\t-- ID FUNCION: %d\n"
|
||||
"export_function:\tCadena exportada: %s\n"
|
||||
"export_function:\tN. parametros: %d\n"
|
||||
"export_function:\tOffset de la funcion: 0x%X\n",n_externs,cadena,nparam,(unsigned int)hfuncion);
|
||||
"export_function:\tOffset de la funcion: 0x%X\n",
|
||||
n_externs, cadena, nparam, (unsigned int)hfuncion);
|
||||
#endif
|
||||
|
||||
if(creaobj) {
|
||||
if (creaobj)
|
||||
{
|
||||
dll_error(creaobj, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ob = o;
|
||||
|
||||
if (ob->tipo!=tnone) {
|
||||
if (ob->tipo != tnone)
|
||||
{
|
||||
dll_error(5, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
@ -98,7 +100,6 @@ int EDIV_Export(char* cadena, int nparam, void* hfuncion)
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Entrypoint(int ep, void *hfuncion)
|
||||
{
|
||||
entrypoints[n_entrypoints].tipo = ep;
|
||||
|
@ -107,17 +108,16 @@ int EDIV_Export_Entrypoint(int ep, void* hfuncion)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Priority(int priority)
|
||||
{
|
||||
dlls[numdlls].prioridad = priority;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Const(char *cadena, int valor)
|
||||
{
|
||||
if(decl_struct) {
|
||||
if (decl_struct)
|
||||
{
|
||||
dll_error(6, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
@ -128,17 +128,20 @@ int EDIV_Export_Const(char* cadena, int valor)
|
|||
printf("export_const:\t-- ID OBJETO: %d\n"
|
||||
"export_const:\tCadena exportada: %s\n"
|
||||
"export_const:\tValor: %d\n"
|
||||
"export_const:\tOffset del objeto: 0x%X\n",num_obj-1,cadena,valor,(unsigned int)o);
|
||||
"export_const:\tOffset del objeto: 0x%X\n",
|
||||
num_obj - 1, cadena, valor, (unsigned int)o);
|
||||
#endif
|
||||
|
||||
if(creaobj) {
|
||||
if (creaobj)
|
||||
{
|
||||
dll_error(creaobj, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ob = o;
|
||||
|
||||
if (ob->tipo!=tnone) {
|
||||
if (ob->tipo != tnone)
|
||||
{
|
||||
dll_error(5, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
@ -150,10 +153,10 @@ int EDIV_Export_Const(char* cadena, int valor)
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Global(char *cadena, int valor)
|
||||
{
|
||||
if(decl_struct) {
|
||||
if (decl_struct)
|
||||
{
|
||||
dll_error(6, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
@ -164,17 +167,20 @@ int EDIV_Export_Global(char* cadena, int valor)
|
|||
printf("export_global:\t-- ID OBJETO: %d\n"
|
||||
"export_global:\tCadena exportada: %s\n"
|
||||
"export_global:\tValor: %d\n"
|
||||
"export_global:\tOffset del objeto: 0x%X\n",num_obj-1,cadena,valor,(unsigned int)o);
|
||||
"export_global:\tOffset del objeto: 0x%X\n",
|
||||
num_obj - 1, cadena, valor, (unsigned int)o);
|
||||
#endif
|
||||
|
||||
if(creaobj) {
|
||||
if (creaobj)
|
||||
{
|
||||
dll_error(creaobj, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ob = o;
|
||||
|
||||
if (ob->tipo!=tnone) {
|
||||
if (ob->tipo != tnone)
|
||||
{
|
||||
dll_error(5, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
@ -188,10 +194,10 @@ int EDIV_Export_Global(char* cadena, int valor)
|
|||
return imem++;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Global_Tab(char *cadena, int numregs)
|
||||
{
|
||||
if(decl_struct) {
|
||||
if (decl_struct)
|
||||
{
|
||||
dll_error(6, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
@ -202,17 +208,20 @@ int EDIV_Export_Global_Tab(char* cadena, int numregs)
|
|||
printf("export_global_tab:\t-- ID OBJETO: %d\n"
|
||||
"export_global_tab:\tCadena exportada: %s\n"
|
||||
"export_global_tab:\tN.regs: %d\n"
|
||||
"export_global_tab:\tOffset del objeto: 0x%X\n",num_obj-1,cadena,numregs,(unsigned int)o);
|
||||
"export_global_tab:\tOffset del objeto: 0x%X\n",
|
||||
num_obj - 1, cadena, numregs, (unsigned int)o);
|
||||
#endif
|
||||
|
||||
if(creaobj) {
|
||||
if (creaobj)
|
||||
{
|
||||
dll_error(creaobj, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ob = o;
|
||||
|
||||
if (ob->tipo!=tnone) {
|
||||
if (ob->tipo != tnone)
|
||||
{
|
||||
dll_error(5, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
@ -227,17 +236,18 @@ int EDIV_Export_Global_Tab(char* cadena, int numregs)
|
|||
ob->tglo.totalen = len + 1;
|
||||
|
||||
/* Inicializamos la tabla a 0 */
|
||||
do {
|
||||
do
|
||||
{
|
||||
mem[imem++] = 0;
|
||||
} while (len--);
|
||||
|
||||
return ob->tglo.offset;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Global_Struct(char *cadena, int numregs)
|
||||
{
|
||||
if(decl_struct) {
|
||||
if (decl_struct)
|
||||
{
|
||||
dll_error(6, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
@ -248,17 +258,20 @@ int EDIV_Export_Global_Struct(char* cadena, int numregs)
|
|||
printf("export_global_struct:\t-- ID OBJETO: %d\n"
|
||||
"export_global_struct:\tCadena exportada: %s\n"
|
||||
"export_global_struct:\tN.regs: %d\n"
|
||||
"export_global_struct:\tOffset del objeto: 0x%X\n",num_obj-1,cadena,numregs,(unsigned int)o);
|
||||
"export_global_struct:\tOffset del objeto: 0x%X\n",
|
||||
num_obj - 1, cadena, numregs, (unsigned int)o);
|
||||
#endif
|
||||
|
||||
if(creaobj) {
|
||||
if (creaobj)
|
||||
{
|
||||
dll_error(creaobj, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ob = o;
|
||||
|
||||
if (ob->tipo!=tnone) {
|
||||
if (ob->tipo != tnone)
|
||||
{
|
||||
dll_error(5, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
@ -279,10 +292,10 @@ int EDIV_Export_Global_Struct(char* cadena, int numregs)
|
|||
return imem;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Member_Int(char *cadena, int valor)
|
||||
{
|
||||
if(!decl_struct) {
|
||||
if (!decl_struct)
|
||||
{
|
||||
dll_error(7, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
@ -293,29 +306,34 @@ int EDIV_Export_Member_Int(char* cadena, int valor)
|
|||
printf("export_member_int:\t-- ID OBJETO: %d\n"
|
||||
"export_member_int:\tCadena exportada: %s\n"
|
||||
"export_member_int:\tValor: %d\n"
|
||||
"export_member_int:\tOffset del objeto: 0x%X\n",num_obj-1,cadena,valor,(unsigned int)o);
|
||||
"export_member_int:\tOffset del objeto: 0x%X\n",
|
||||
num_obj - 1, cadena, valor, (unsigned int)o);
|
||||
#endif
|
||||
|
||||
if(creaobj) {
|
||||
if (creaobj)
|
||||
{
|
||||
dll_error(creaobj, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ob2 = o;
|
||||
|
||||
if ((*ob2).tipo!=tnone) {
|
||||
if ((*ob2).tipo != tnone)
|
||||
{
|
||||
dll_error(5, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(ob->tipo==tsglo) { /* int miembro de struct global */
|
||||
if (ob->tipo == tsglo)
|
||||
{ /* int miembro de struct global */
|
||||
(*ob2).tipo = tvglo;
|
||||
(*ob2).vglo.offset = len++;
|
||||
mem[imem] = valor;
|
||||
ob->sglo.len_item++;
|
||||
return imem++;
|
||||
}
|
||||
else { /* int miembro de struct local */
|
||||
else
|
||||
{ /* int miembro de struct local */
|
||||
if (struct_reserved)
|
||||
indexa_variable(v_reserved, cadena, iloc);
|
||||
(*ob2).tipo = tvloc;
|
||||
|
@ -326,10 +344,10 @@ int EDIV_Export_Member_Int(char* cadena, int valor)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Member_Str(char *cadena, int tamano)
|
||||
{
|
||||
if(!decl_struct) {
|
||||
if (!decl_struct)
|
||||
{
|
||||
dll_error(7, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
@ -340,31 +358,37 @@ int EDIV_Export_Member_Str(char* cadena, int tamano)
|
|||
printf("export_member_str:\t-- ID OBJETO: %d\n"
|
||||
"export_member_str:\tCadena exportada: %s\n"
|
||||
"export_member_str:\tTamano: %d\n"
|
||||
"export_member_str:\tOffset del objeto: 0x%X\n",num_obj-1,cadena,tamano,(unsigned int)o);
|
||||
"export_member_str:\tOffset del objeto: 0x%X\n",
|
||||
num_obj - 1, cadena, tamano, (unsigned int)o);
|
||||
#endif
|
||||
|
||||
if(creaobj) {
|
||||
if (creaobj)
|
||||
{
|
||||
dll_error(creaobj, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ob2 = o;
|
||||
|
||||
if ((*ob2).tipo!=tnone) {
|
||||
if ((*ob2).tipo != tnone)
|
||||
{
|
||||
dll_error(5, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(ob->tipo==tsglo) { /* string miembro de struct global */
|
||||
if (ob->tipo == tsglo)
|
||||
{ /* string miembro de struct global */
|
||||
|
||||
(*ob2).tipo = tcglo;
|
||||
(*ob2).cglo.offset = len + 1;
|
||||
|
||||
if (((*ob2).cglo.totalen=tamano)<0) {
|
||||
if (((*ob2).cglo.totalen = tamano) < 0)
|
||||
{
|
||||
dll_error(8, cadena);
|
||||
return 0;
|
||||
}
|
||||
if ((*ob2).cglo.totalen>0xFFFFF) {
|
||||
if ((*ob2).cglo.totalen > 0xFFFFF)
|
||||
{
|
||||
dll_error(8, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
@ -377,16 +401,19 @@ int EDIV_Export_Member_Str(char* cadena, int tamano)
|
|||
|
||||
return (*ob2).cglo.offset;
|
||||
}
|
||||
else { /* string miembro de struct local */
|
||||
else
|
||||
{ /* string miembro de struct local */
|
||||
|
||||
(*ob2).tipo = tcloc;
|
||||
(*ob2).cloc.offset = len + 1;
|
||||
|
||||
if (((*ob2).cloc.totalen=tamano)<0) {
|
||||
if (((*ob2).cloc.totalen = tamano) < 0)
|
||||
{
|
||||
dll_error(8, cadena);
|
||||
return 0;
|
||||
}
|
||||
if ((*ob2).cloc.totalen>0xFFFFF) {
|
||||
if ((*ob2).cloc.totalen > 0xFFFFF)
|
||||
{
|
||||
dll_error(8, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
@ -401,10 +428,10 @@ int EDIV_Export_Member_Str(char* cadena, int tamano)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Member_Tab(char *cadena, int numregs)
|
||||
{
|
||||
if(!decl_struct) {
|
||||
if (!decl_struct)
|
||||
{
|
||||
dll_error(7, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
@ -415,22 +442,26 @@ int EDIV_Export_Member_Tab(char* cadena, int numregs)
|
|||
printf("export_member_tab:\t-- ID OBJETO: %d\n"
|
||||
"export_member_tab:\tCadena exportada: %s\n"
|
||||
"export_member_tab:\tN.regs: %d\n"
|
||||
"export_member_tab:\tOffset del objeto: 0x%X\n",num_obj-1,cadena,numregs,(unsigned int)o);
|
||||
"export_member_tab:\tOffset del objeto: 0x%X\n",
|
||||
num_obj - 1, cadena, numregs, (unsigned int)o);
|
||||
#endif
|
||||
|
||||
if(creaobj) {
|
||||
if (creaobj)
|
||||
{
|
||||
dll_error(creaobj, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ob2 = o;
|
||||
|
||||
if ((*ob2).tipo!=tnone) {
|
||||
if ((*ob2).tipo != tnone)
|
||||
{
|
||||
dll_error(5, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(ob->tipo==tsglo) { /* array miembro de struct global */
|
||||
if (ob->tipo == tsglo)
|
||||
{ /* array miembro de struct global */
|
||||
(*ob2).tipo = ttglo;
|
||||
(*ob2).tglo.offset = len;
|
||||
(*ob2).tglo.len1 = numregs;
|
||||
|
@ -444,7 +475,8 @@ int EDIV_Export_Member_Tab(char* cadena, int numregs)
|
|||
|
||||
return (*ob2).tglo.offset;
|
||||
}
|
||||
else { /* array miembro de struct local */
|
||||
else
|
||||
{ /* array miembro de struct local */
|
||||
if (struct_reserved)
|
||||
indexa_variable(v_reserved, cadena, iloc);
|
||||
(*ob2).tipo = ttloc;
|
||||
|
@ -462,10 +494,10 @@ int EDIV_Export_Member_Tab(char* cadena, int numregs)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_EndStruct()
|
||||
{
|
||||
if(!decl_struct) {
|
||||
if (!decl_struct)
|
||||
{
|
||||
dll_error(9);
|
||||
return 0;
|
||||
}
|
||||
|
@ -476,27 +508,35 @@ int EDIV_Export_EndStruct()
|
|||
|
||||
member = NULL;
|
||||
|
||||
if(ob->tipo==tsglo) { /* cierra estructura global */
|
||||
if (ob->sglo.len_item==0) {
|
||||
if (ob->tipo == tsglo)
|
||||
{ /* cierra estructura global */
|
||||
if (ob->sglo.len_item == 0)
|
||||
{
|
||||
dll_error(10);
|
||||
return 0;
|
||||
}
|
||||
if (ob->sglo.totalitems>1) {
|
||||
if (ob->sglo.totalitems > 1)
|
||||
{
|
||||
len = (ob->sglo.totalitems - 1) * ob->sglo.len_item - 1;
|
||||
do {
|
||||
do
|
||||
{
|
||||
mem[imem] = mem[imem - ob->sglo.len_item];
|
||||
imem++;
|
||||
} while (len--);
|
||||
}
|
||||
}
|
||||
else { /* cierra estructura local */
|
||||
if (ob->sloc.len_item==0) {
|
||||
else
|
||||
{ /* cierra estructura local */
|
||||
if (ob->sloc.len_item == 0)
|
||||
{
|
||||
dll_error(10);
|
||||
return 0;
|
||||
}
|
||||
if (ob->sloc.totalitems>1) {
|
||||
if (ob->sloc.totalitems > 1)
|
||||
{
|
||||
len = (ob->sloc.totalitems - 1) * ob->sloc.len_item - 1;
|
||||
do {
|
||||
do
|
||||
{
|
||||
loc[iloc] = loc[iloc - ob->sloc.len_item];
|
||||
iloc++;
|
||||
} while (len--);
|
||||
|
@ -509,10 +549,10 @@ int EDIV_Export_EndStruct()
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Local(char *cadena, int valor)
|
||||
{
|
||||
if(decl_struct) {
|
||||
if (decl_struct)
|
||||
{
|
||||
dll_error(6, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
@ -523,17 +563,20 @@ int EDIV_Export_Local(char* cadena, int valor)
|
|||
printf("export_local:\t-- ID OBJETO: %d\n"
|
||||
"export_local:\tCadena exportada: %s\n"
|
||||
"export_local:\tValor: %d\n"
|
||||
"export_local:\tOffset del objeto: 0x%X\n",num_obj-1,cadena,valor,(unsigned int)o);
|
||||
"export_local:\tOffset del objeto: 0x%X\n",
|
||||
num_obj - 1, cadena, valor, (unsigned int)o);
|
||||
#endif
|
||||
|
||||
if(creaobj) {
|
||||
if (creaobj)
|
||||
{
|
||||
dll_error(creaobj, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ob = o;
|
||||
|
||||
if (ob->tipo!=tnone) {
|
||||
if (ob->tipo != tnone)
|
||||
{
|
||||
dll_error(5, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
@ -547,10 +590,10 @@ int EDIV_Export_Local(char* cadena, int valor)
|
|||
return iloc++;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Local_Tab(char *cadena, int numregs)
|
||||
{
|
||||
if(decl_struct) {
|
||||
if (decl_struct)
|
||||
{
|
||||
dll_error(6, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
@ -561,17 +604,20 @@ int EDIV_Export_Local_Tab(char* cadena, int numregs)
|
|||
printf("export_local_tab:\t-- ID OBJETO: %d\n"
|
||||
"export_local_tab:\tCadena exportada: %s\n"
|
||||
"export_local_tab:\tN.regs: %d\n"
|
||||
"export_local_tab:\tOffset del objeto: 0x%X\n",num_obj-1,cadena,numregs,(unsigned int)o);
|
||||
"export_local_tab:\tOffset del objeto: 0x%X\n",
|
||||
num_obj - 1, cadena, numregs, (unsigned int)o);
|
||||
#endif
|
||||
|
||||
if(creaobj) {
|
||||
if (creaobj)
|
||||
{
|
||||
dll_error(creaobj, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ob = o;
|
||||
|
||||
if (ob->tipo!=tnone) {
|
||||
if (ob->tipo != tnone)
|
||||
{
|
||||
dll_error(5, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
@ -586,17 +632,18 @@ int EDIV_Export_Local_Tab(char* cadena, int numregs)
|
|||
ob->tloc.totalen = len + 1;
|
||||
|
||||
/* Inicializamos la tabla a 0 */
|
||||
do {
|
||||
do
|
||||
{
|
||||
loc[iloc++] = 0;
|
||||
} while (len--);
|
||||
|
||||
return ob->tloc.offset;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Local_Struct(char *cadena, int numregs)
|
||||
{
|
||||
if(decl_struct) {
|
||||
if (decl_struct)
|
||||
{
|
||||
dll_error(6, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
@ -607,26 +654,31 @@ int EDIV_Export_Local_Struct(char* cadena, int numregs)
|
|||
printf("export_local_struct:\t-- ID OBJETO: %d\n"
|
||||
"export_local_struct:\tCadena exportada: %s\n"
|
||||
"export_local_struct:\tN.regs: %d\n"
|
||||
"export_local_struct:\tOffset del objeto: 0x%X\n",num_obj-1,cadena,numregs,(unsigned int)o);
|
||||
"export_local_struct:\tOffset del objeto: 0x%X\n",
|
||||
num_obj - 1, cadena, numregs, (unsigned int)o);
|
||||
#endif
|
||||
|
||||
if(creaobj) {
|
||||
if (creaobj)
|
||||
{
|
||||
dll_error(creaobj, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ob = o;
|
||||
|
||||
if (ob->tipo!=tnone) {
|
||||
if (ob->tipo != tnone)
|
||||
{
|
||||
dll_error(5, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
||||
decl_struct = 1;
|
||||
if(!strcmp(cadena,"reserved")) {
|
||||
if (!strcmp(cadena, "reserved"))
|
||||
{
|
||||
struct_reserved = 1;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
indexa_variable(v_local, cadena, iloc);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#else
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
|
||||
#include "shared.h"
|
||||
|
@ -153,6 +154,35 @@ char *translate(int num)
|
|||
return e[idioma][num];
|
||||
}
|
||||
|
||||
void print_translate(int num, ...)
|
||||
{
|
||||
va_list arg_ptr;
|
||||
const char *message = translate(num);
|
||||
size_t msglen = strlen(message);
|
||||
char *strbuf = malloc(msglen + 1);
|
||||
|
||||
va_start(arg_ptr, message);
|
||||
vsprintf(strbuf, message, arg_ptr);
|
||||
va_end(arg_ptr);
|
||||
|
||||
printf("%s", strbuf);
|
||||
free(strbuf);
|
||||
}
|
||||
|
||||
const char *get_translate(int num, ...)
|
||||
{
|
||||
va_list arg_ptr;
|
||||
const char *message = translate(num);
|
||||
size_t msglen = strlen(message);
|
||||
char *strbuf = malloc(msglen + 1);
|
||||
|
||||
va_start(arg_ptr, message);
|
||||
vsprintf(strbuf, message, arg_ptr);
|
||||
va_end(arg_ptr);
|
||||
|
||||
return strbuf;
|
||||
}
|
||||
|
||||
static char *ediv_strlwr(char *str)
|
||||
{
|
||||
unsigned char *p = (unsigned char *)str;
|
||||
|
|
|
@ -36,174 +36,275 @@ void listado_objetos (void)
|
|||
FILE *sta;
|
||||
char nombretab[256];
|
||||
int n, o, l;
|
||||
char *msg_37 = get_translate(27, fichero_prg);
|
||||
|
||||
strcpy(nombretab, nombreprog);
|
||||
strcat(nombretab, ".tab");
|
||||
|
||||
if((sta=fopen(nombretab,"w"))==NULL) {
|
||||
printf(translate(36),nombretab);
|
||||
if ((sta = fopen(nombretab, "w")) == NULL)
|
||||
{
|
||||
print_translate(36, nombretab);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fprintf(sta,translate(37),fichero_prg);
|
||||
fprintf(sta, msg_37);
|
||||
free(msg_37);
|
||||
|
||||
for (n=1;n<=8;n++) fprintf(sta,"[%u]: %u\n",n,mem[n]); fprintf(sta,"\n");
|
||||
for (n = 1; n <= 8; n++)
|
||||
fprintf(sta, "[%u]: %u\n", n, mem[n]);
|
||||
fprintf(sta, "\n");
|
||||
|
||||
for (n=0;n<num_obj;n++) {
|
||||
switch(obj[n].tipo) {
|
||||
case tnone: fprintf(sta,"%5u\ttnone: %s",n,obj[n].name);
|
||||
if (obj[n].usado) fprintf(sta," (*) usado\n"); else fprintf(sta,"\n");
|
||||
for (n = 0; n < num_obj; n++)
|
||||
{
|
||||
switch (obj[n].tipo)
|
||||
{
|
||||
case tnone:
|
||||
fprintf(sta, "%5u\ttnone: %s", n, obj[n].name);
|
||||
if (obj[n].usado)
|
||||
fprintf(sta, " (*) usado\n");
|
||||
else
|
||||
fprintf(sta, "\n");
|
||||
break;
|
||||
case tcons: fprintf(sta,"%5u\ttcons: %s",n,obj[n].name);
|
||||
if (obj[n].usado) fprintf(sta," (*) usado\n"); else fprintf(sta,"\n");
|
||||
case tcons:
|
||||
fprintf(sta, "%5u\ttcons: %s", n, obj[n].name);
|
||||
if (obj[n].usado)
|
||||
fprintf(sta, " (*) usado\n");
|
||||
else
|
||||
fprintf(sta, "\n");
|
||||
fprintf(sta, "\tvalor=%u\n", obj[n].cons.valor);
|
||||
break;
|
||||
case tvglo: fprintf(sta,"%5u\ttvglo: %s",n,obj[n].name);
|
||||
if (obj[n].usado) fprintf(sta," (*) usado\n"); else fprintf(sta,"\n");
|
||||
case tvglo:
|
||||
fprintf(sta, "%5u\ttvglo: %s", n, obj[n].name);
|
||||
if (obj[n].usado)
|
||||
fprintf(sta, " (*) usado\n");
|
||||
else
|
||||
fprintf(sta, "\n");
|
||||
fprintf(sta, "\toffset=%u\n", o = obj[n].vglo.offset);
|
||||
if (obj[n].member) fprintf(sta,"\tmember of %s\n",(*obj[n].member).name);
|
||||
else fprintf(sta,"\tvalor=%u\n",mem[o]);
|
||||
if (obj[n].member)
|
||||
fprintf(sta, "\tmember of %s\n", (*obj[n].member).name);
|
||||
else
|
||||
fprintf(sta, "\tvalor=%u\n", mem[o]);
|
||||
break;
|
||||
case ttglo: fprintf(sta,"%5u\tttglo: %s",n,obj[n].name);
|
||||
if (obj[n].usado) fprintf(sta," (*) usado\n"); else fprintf(sta,"\n");
|
||||
case ttglo:
|
||||
fprintf(sta, "%5u\tttglo: %s", n, obj[n].name);
|
||||
if (obj[n].usado)
|
||||
fprintf(sta, " (*) usado\n");
|
||||
else
|
||||
fprintf(sta, "\n");
|
||||
fprintf(sta, "\toffset=%u\n", o = obj[n].tglo.offset);
|
||||
fprintf(sta, "\tlen1=%u\n", obj[n].tglo.len1);
|
||||
fprintf(sta, "\tlen2=%u\n", obj[n].tglo.len2);
|
||||
fprintf(sta, "\tlen3=%u\n", obj[n].tglo.len3);
|
||||
fprintf(sta, "\ttotalen=%u\n", obj[n].tglo.totalen);
|
||||
if (obj[n].member) fprintf(sta,"\tmember of %s\n",(*obj[n].member).name);
|
||||
if (obj[n].member)
|
||||
fprintf(sta, "\tmember of %s\n", (*obj[n].member).name);
|
||||
break;
|
||||
case tpbgl: case tpwgl: case tpcgl:
|
||||
case tpigl: fprintf(sta,"%5u\ttp?gl: %s",n,obj[n].name);
|
||||
if (obj[n].usado) fprintf(sta," (*) usado\n"); else fprintf(sta,"\n");
|
||||
case tpbgl:
|
||||
case tpwgl:
|
||||
case tpcgl:
|
||||
case tpigl:
|
||||
fprintf(sta, "%5u\ttp?gl: %s", n, obj[n].name);
|
||||
if (obj[n].usado)
|
||||
fprintf(sta, " (*) usado\n");
|
||||
else
|
||||
fprintf(sta, "\n");
|
||||
fprintf(sta, "\toffset=%u\n", o = obj[n].tglo.offset);
|
||||
fprintf(sta, "\tlen1=%u\n", obj[n].tglo.len1);
|
||||
fprintf(sta, "\tlen2=%u\n", obj[n].tglo.len2);
|
||||
fprintf(sta, "\tlen3=%u\n", obj[n].tglo.len3);
|
||||
fprintf(sta, "\ttotalen=%u\n", obj[n].tglo.totalen);
|
||||
if (obj[n].member) fprintf(sta,"\tmember of %s\n",(*obj[n].member).name);
|
||||
if (obj[n].member)
|
||||
fprintf(sta, "\tmember of %s\n", (*obj[n].member).name);
|
||||
break;
|
||||
case tsglo: fprintf(sta,"%5u\ttsglo: %s",n,obj[n].name);
|
||||
if (obj[n].usado) fprintf(sta," (*) usado\n"); else fprintf(sta,"\n");
|
||||
case tsglo:
|
||||
fprintf(sta, "%5u\ttsglo: %s", n, obj[n].name);
|
||||
if (obj[n].usado)
|
||||
fprintf(sta, " (*) usado\n");
|
||||
else
|
||||
fprintf(sta, "\n");
|
||||
fprintf(sta, "\toffset=%u\n", o = obj[n].sglo.offset);
|
||||
fprintf(sta, "\titems1=%u\n", obj[n].sglo.items1);
|
||||
fprintf(sta, "\titems2=%u\n", obj[n].sglo.items2);
|
||||
fprintf(sta, "\titems3=%u\n", obj[n].sglo.items3);
|
||||
fprintf(sta, "\ttotalitems=%u\n", l = obj[n].sglo.totalitems);
|
||||
fprintf(sta, "\tlen_item=%u\n", obj[n].sglo.len_item);
|
||||
if (obj[n].member) fprintf(sta,"\tmember of %s\n",(*obj[n].member).name);
|
||||
if (obj[n].member)
|
||||
fprintf(sta, "\tmember of %s\n", (*obj[n].member).name);
|
||||
break;
|
||||
case tpsgl: fprintf(sta,"%5u\ttpsgl: %s",n,obj[n].name);
|
||||
if (obj[n].usado) fprintf(sta," (*) usado\n"); else fprintf(sta,"\n");
|
||||
case tpsgl:
|
||||
fprintf(sta, "%5u\ttpsgl: %s", n, obj[n].name);
|
||||
if (obj[n].usado)
|
||||
fprintf(sta, " (*) usado\n");
|
||||
else
|
||||
fprintf(sta, "\n");
|
||||
fprintf(sta, "\toffset=%u\n", o = obj[n].sglo.offset);
|
||||
fprintf(sta, "\titems1=%u\n", obj[n].sglo.items1);
|
||||
fprintf(sta, "\titems2=%u\n", obj[n].sglo.items2);
|
||||
fprintf(sta, "\titems3=%u\n", obj[n].sglo.items3);
|
||||
fprintf(sta, "\ttotalitems=%u\n", l = obj[n].sglo.totalitems);
|
||||
fprintf(sta, "\tlen_item=%u\n", obj[n].sglo.len_item);
|
||||
if (obj[n].member) fprintf(sta,"\tmember of %s\n",(*obj[n].member).name);
|
||||
if (obj[n].member)
|
||||
fprintf(sta, "\tmember of %s\n", (*obj[n].member).name);
|
||||
break;
|
||||
case tvloc: fprintf(sta,"%5u\ttvloc: %s",n,obj[n].name);
|
||||
if (obj[n].usado) fprintf(sta," (*) usado\n"); else fprintf(sta,"\n");
|
||||
case tvloc:
|
||||
fprintf(sta, "%5u\ttvloc: %s", n, obj[n].name);
|
||||
if (obj[n].usado)
|
||||
fprintf(sta, " (*) usado\n");
|
||||
else
|
||||
fprintf(sta, "\n");
|
||||
fprintf(sta, "\toffset=%u\n", o = obj[n].vloc.offset);
|
||||
if (obj[n].member) fprintf(sta,"\tmember of %s\n",(*obj[n].member).name);
|
||||
else fprintf(sta,"\tvalor=%u\n",loc[o]);
|
||||
if (obj[n].member)
|
||||
fprintf(sta, "\tmember of %s\n", (*obj[n].member).name);
|
||||
else
|
||||
fprintf(sta, "\tvalor=%u\n", loc[o]);
|
||||
break;
|
||||
case ttloc: fprintf(sta,"%5u\tttloc: %s",n,obj[n].name);
|
||||
if (obj[n].usado) fprintf(sta," (*) usado\n"); else fprintf(sta,"\n");
|
||||
case ttloc:
|
||||
fprintf(sta, "%5u\tttloc: %s", n, obj[n].name);
|
||||
if (obj[n].usado)
|
||||
fprintf(sta, " (*) usado\n");
|
||||
else
|
||||
fprintf(sta, "\n");
|
||||
fprintf(sta, "\toffset=%u\n", o = obj[n].tloc.offset);
|
||||
fprintf(sta, "\tlen1=%u\n", obj[n].tloc.len1);
|
||||
fprintf(sta, "\tlen2=%u\n", obj[n].tloc.len2);
|
||||
fprintf(sta, "\tlen3=%u\n", obj[n].tloc.len3);
|
||||
fprintf(sta, "\ttotalen=%u\n", obj[n].tloc.totalen);
|
||||
if (obj[n].member) fprintf(sta,"\tmember of %s\n",(*obj[n].member).name);
|
||||
if (obj[n].member)
|
||||
fprintf(sta, "\tmember of %s\n", (*obj[n].member).name);
|
||||
break;
|
||||
case tpblo: case tpwlo: case tpclo:
|
||||
case tpilo: fprintf(sta,"%5u\ttp?lo: %s",n,obj[n].name);
|
||||
if (obj[n].usado) fprintf(sta," (*) usado\n"); else fprintf(sta,"\n");
|
||||
case tpblo:
|
||||
case tpwlo:
|
||||
case tpclo:
|
||||
case tpilo:
|
||||
fprintf(sta, "%5u\ttp?lo: %s", n, obj[n].name);
|
||||
if (obj[n].usado)
|
||||
fprintf(sta, " (*) usado\n");
|
||||
else
|
||||
fprintf(sta, "\n");
|
||||
fprintf(sta, "\toffset=%u\n", o = obj[n].tloc.offset);
|
||||
fprintf(sta, "\tlen1=%u\n", obj[n].tloc.len1);
|
||||
fprintf(sta, "\tlen2=%u\n", obj[n].tloc.len2);
|
||||
fprintf(sta, "\tlen3=%u\n", obj[n].tloc.len3);
|
||||
fprintf(sta, "\ttotalen=%u\n", obj[n].tloc.totalen);
|
||||
if (obj[n].member) fprintf(sta,"\tmember of %s\n",(*obj[n].member).name);
|
||||
if (obj[n].member)
|
||||
fprintf(sta, "\tmember of %s\n", (*obj[n].member).name);
|
||||
break;
|
||||
case tsloc: fprintf(sta,"%5u\ttsloc: %s",n,obj[n].name);
|
||||
if (obj[n].usado) fprintf(sta," (*) usado\n"); else fprintf(sta,"\n");
|
||||
case tsloc:
|
||||
fprintf(sta, "%5u\ttsloc: %s", n, obj[n].name);
|
||||
if (obj[n].usado)
|
||||
fprintf(sta, " (*) usado\n");
|
||||
else
|
||||
fprintf(sta, "\n");
|
||||
fprintf(sta, "\toffset=%u\n", o = obj[n].sloc.offset);
|
||||
fprintf(sta, "\titems1=%u\n", obj[n].sloc.items1);
|
||||
fprintf(sta, "\titems2=%u\n", obj[n].sloc.items2);
|
||||
fprintf(sta, "\titems3=%u\n", obj[n].sloc.items3);
|
||||
fprintf(sta, "\ttotalitems=%u\n", l = obj[n].sloc.totalitems);
|
||||
fprintf(sta, "\tlen_item=%u\n", obj[n].sloc.len_item);
|
||||
if (obj[n].member) fprintf(sta,"\tmember of %s\n",(*obj[n].member).name);
|
||||
if (obj[n].member)
|
||||
fprintf(sta, "\tmember of %s\n", (*obj[n].member).name);
|
||||
break;
|
||||
case tpslo: fprintf(sta,"%5u\ttpslo: %s",n,obj[n].name);
|
||||
if (obj[n].usado) fprintf(sta," (*) usado\n"); else fprintf(sta,"\n");
|
||||
case tpslo:
|
||||
fprintf(sta, "%5u\ttpslo: %s", n, obj[n].name);
|
||||
if (obj[n].usado)
|
||||
fprintf(sta, " (*) usado\n");
|
||||
else
|
||||
fprintf(sta, "\n");
|
||||
fprintf(sta, "\toffset=%u\n", o = obj[n].sloc.offset);
|
||||
fprintf(sta, "\titems1=%u\n", obj[n].sloc.items1);
|
||||
fprintf(sta, "\titems2=%u\n", obj[n].sloc.items2);
|
||||
fprintf(sta, "\titems3=%u\n", obj[n].sloc.items3);
|
||||
fprintf(sta, "\ttotalitems=%u\n", l = obj[n].sloc.totalitems);
|
||||
fprintf(sta, "\tlen_item=%u\n", obj[n].sloc.len_item);
|
||||
if (obj[n].member) fprintf(sta,"\tmember of %s\n",(*obj[n].member).name);
|
||||
if (obj[n].member)
|
||||
fprintf(sta, "\tmember of %s\n", (*obj[n].member).name);
|
||||
break;
|
||||
case tproc: fprintf(sta,"%5u\ttproc: %s",n,obj[n].name);
|
||||
if (obj[n].usado) fprintf(sta," (*) usado\n"); else fprintf(sta,"\n");
|
||||
case tproc:
|
||||
fprintf(sta, "%5u\ttproc: %s", n, obj[n].name);
|
||||
if (obj[n].usado)
|
||||
fprintf(sta, " (*) usado\n");
|
||||
else
|
||||
fprintf(sta, "\n");
|
||||
fprintf(sta, "\ttipo=%u\n", (int)(obj[n].proc.bloque));
|
||||
fprintf(sta, "\toffset=%u\n", obj[n].proc.offset);
|
||||
fprintf(sta, "\tnum_par=%u\n", obj[n].proc.num_par);
|
||||
break;
|
||||
case tfext: fprintf(sta,"%5u\ttfext: %s",n,obj[n].name);
|
||||
if (obj[n].usado) fprintf(sta," (*) usado\n"); else fprintf(sta,"\n");
|
||||
case tfext:
|
||||
fprintf(sta, "%5u\ttfext: %s", n, obj[n].name);
|
||||
if (obj[n].usado)
|
||||
fprintf(sta, " (*) usado\n");
|
||||
else
|
||||
fprintf(sta, "\n");
|
||||
fprintf(sta, "\tcodigo=%u\n", obj[n].fext.codigo);
|
||||
fprintf(sta, "\tnum_par=%u\n", obj[n].fext.num_par);
|
||||
break;
|
||||
case tbglo: fprintf(sta,"%5u\ttbglo: %s",n,obj[n].name);
|
||||
if (obj[n].usado) fprintf(sta," (*) usado\n"); else fprintf(sta,"\n");
|
||||
case tbglo:
|
||||
fprintf(sta, "%5u\ttbglo: %s", n, obj[n].name);
|
||||
if (obj[n].usado)
|
||||
fprintf(sta, " (*) usado\n");
|
||||
else
|
||||
fprintf(sta, "\n");
|
||||
fprintf(sta, "\toffset=%u\n", o = obj[n].bglo.offset);
|
||||
fprintf(sta, "\tlen1=%u\n", obj[n].bglo.len1);
|
||||
fprintf(sta, "\tlen2=%u\n", obj[n].bglo.len2);
|
||||
fprintf(sta, "\tlen3=%u\n", obj[n].bglo.len3);
|
||||
fprintf(sta, "\ttotalen=%u\n", obj[n].bglo.totalen);
|
||||
if (obj[n].member) fprintf(sta,"\tmember of %s\n",(*obj[n].member).name);
|
||||
if (obj[n].member)
|
||||
fprintf(sta, "\tmember of %s\n", (*obj[n].member).name);
|
||||
break;
|
||||
case tbloc: fprintf(sta,"%5u\ttbloc: %s",n,obj[n].name);
|
||||
if (obj[n].usado) fprintf(sta," (*) usado\n"); else fprintf(sta,"\n");
|
||||
case tbloc:
|
||||
fprintf(sta, "%5u\ttbloc: %s", n, obj[n].name);
|
||||
if (obj[n].usado)
|
||||
fprintf(sta, " (*) usado\n");
|
||||
else
|
||||
fprintf(sta, "\n");
|
||||
fprintf(sta, "\toffset=%u\n", o = obj[n].bglo.offset);
|
||||
fprintf(sta, "\tlen1=%u\n", obj[n].bglo.len1);
|
||||
fprintf(sta, "\tlen2=%u\n", obj[n].bglo.len2);
|
||||
fprintf(sta, "\tlen3=%u\n", obj[n].bglo.len3);
|
||||
fprintf(sta, "\ttotalen=%u\n", obj[n].bglo.totalen);
|
||||
if (obj[n].member) fprintf(sta,"\tmember of %s\n",(*obj[n].member).name);
|
||||
if (obj[n].member)
|
||||
fprintf(sta, "\tmember of %s\n", (*obj[n].member).name);
|
||||
break;
|
||||
case twglo: fprintf(sta,"%5u\ttwglo: %s",n,obj[n].name);
|
||||
if (obj[n].usado) fprintf(sta," (*) usado\n"); else fprintf(sta,"\n");
|
||||
case twglo:
|
||||
fprintf(sta, "%5u\ttwglo: %s", n, obj[n].name);
|
||||
if (obj[n].usado)
|
||||
fprintf(sta, " (*) usado\n");
|
||||
else
|
||||
fprintf(sta, "\n");
|
||||
fprintf(sta, "\toffset=%u\n", o = obj[n].bglo.offset);
|
||||
fprintf(sta, "\tlen1=%u\n", obj[n].bglo.len1);
|
||||
fprintf(sta, "\tlen2=%u\n", obj[n].bglo.len2);
|
||||
fprintf(sta, "\tlen3=%u\n", obj[n].bglo.len3);
|
||||
fprintf(sta, "\ttotalen=%u\n", obj[n].bglo.totalen);
|
||||
if (obj[n].member) fprintf(sta,"\tmember of %s\n",(*obj[n].member).name);
|
||||
if (obj[n].member)
|
||||
fprintf(sta, "\tmember of %s\n", (*obj[n].member).name);
|
||||
break;
|
||||
case twloc: fprintf(sta,"%5u\ttwloc: %s",n,obj[n].name);
|
||||
if (obj[n].usado) fprintf(sta," (*) usado\n"); else fprintf(sta,"\n");
|
||||
case twloc:
|
||||
fprintf(sta, "%5u\ttwloc: %s", n, obj[n].name);
|
||||
if (obj[n].usado)
|
||||
fprintf(sta, " (*) usado\n");
|
||||
else
|
||||
fprintf(sta, "\n");
|
||||
fprintf(sta, "\toffset=%u\n", o = obj[n].bglo.offset);
|
||||
fprintf(sta, "\tlen1=%u\n", obj[n].bglo.len1);
|
||||
fprintf(sta, "\tlen2=%u\n", obj[n].bglo.len2);
|
||||
fprintf(sta, "\tlen3=%u\n", obj[n].bglo.len3);
|
||||
fprintf(sta, "\ttotalen=%u\n", obj[n].bglo.totalen);
|
||||
if (obj[n].member) fprintf(sta,"\tmember of %s\n",(*obj[n].member).name);
|
||||
if (obj[n].member)
|
||||
fprintf(sta, "\tmember of %s\n", (*obj[n].member).name);
|
||||
break;
|
||||
}
|
||||
fprintf(sta,translate(38),(unsigned int)obj[n].bloque,(unsigned int)obj[n].anterior);
|
||||
|
||||
char *msg_38 = get_translate(38, (unsigned int)obj[n].bloque, (unsigned int)obj[n].anterior);
|
||||
fprintf(sta, msg_38);
|
||||
free(msg_38);
|
||||
fprintf(sta, "\n");
|
||||
}
|
||||
|
||||
fclose(sta);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Graba el fichero ensamblador
|
||||
*/
|
||||
|
@ -216,150 +317,448 @@ void listado_ensamblador (void)
|
|||
strcpy(nombreeml, nombreprog);
|
||||
strcat(nombreeml, ".eml");
|
||||
|
||||
if((sta=fopen(nombreeml,"w"))==NULL) {
|
||||
printf(translate(36),nombreeml);
|
||||
if ((sta = fopen(nombreeml, "w")) == NULL)
|
||||
{
|
||||
print_translate(36, nombreeml);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fprintf(sta,translate(39),fichero_prg);
|
||||
char *msg_39 = get_translate(39, fichero_prg);
|
||||
fprintf(sta, msg_39);
|
||||
free(msg_39);
|
||||
|
||||
while (i<imem) { switch ((byte)mem[i]) {
|
||||
case lnop: fprintf(sta,"%5u\tnop",i); break;
|
||||
case lcar: fprintf(sta,"%5u\tcar %u",i,mem[i+1]); i++; break;
|
||||
case lasi: fprintf(sta,"%5u\tasi",i); break;
|
||||
case lori: fprintf(sta,"%5u\tori",i); break;
|
||||
case lxor: fprintf(sta,"%5u\txor",i); break;
|
||||
case land: fprintf(sta,"%5u\tand",i); break;
|
||||
case ligu: fprintf(sta,"%5u\tigu",i); break;
|
||||
case ldis: fprintf(sta,"%5u\tdis",i); break;
|
||||
case lmay: fprintf(sta,"%5u\tmay",i); break;
|
||||
case lmen: fprintf(sta,"%5u\tmen",i); break;
|
||||
case lmei: fprintf(sta,"%5u\tmei",i); break;
|
||||
case lmai: fprintf(sta,"%5u\tmai",i); break;
|
||||
case ladd: fprintf(sta,"%5u\tadd",i); break;
|
||||
case lsub: fprintf(sta,"%5u\tsub",i); break;
|
||||
case lmul: fprintf(sta,"%5u\tmul",i); break;
|
||||
case ldiv: fprintf(sta,"%5u\tdiv",i); break;
|
||||
case lmod: fprintf(sta,"%5u\tmod",i); break;
|
||||
case lneg: fprintf(sta,"%5u\tneg",i); break;
|
||||
case lptr: fprintf(sta,"%5u\tptr",i); break;
|
||||
case lnot: fprintf(sta,"%5u\tnot",i); break;
|
||||
case laid: fprintf(sta,"%5u\taid",i); break;
|
||||
case lcid: fprintf(sta,"%5u\tcid",i); break;
|
||||
case lrng: fprintf(sta,"%5u\trng %u",i,mem[i+1]); i++; break;
|
||||
case ljmp: fprintf(sta,"%5u\tjmp %u",i,mem[i+1]); i++; break;
|
||||
case ljpf: fprintf(sta,"%5u\tjpf %u",i,mem[i+1]); i++; break;
|
||||
case lfun: fprintf(sta,"%5u\tfun %u",i,mem[i+1]); i++; break;
|
||||
case lcal: fprintf(sta,"%5u\tcal %u",i,mem[i+1]); i++; break;
|
||||
case lret: fprintf(sta,"%5u\tret",i); break;
|
||||
case lasp: fprintf(sta,"%5u\tasp",i); break;
|
||||
case lfrm: fprintf(sta,"%5u\tfrm",i); break;
|
||||
case lcbp: fprintf(sta,"%5u\tcbp %u",i,mem[i+1]); i++; break;
|
||||
case lcpa: fprintf(sta,"%5u\tcpa",i); break;
|
||||
case ltyp: fprintf(sta,"\n%5u\ttyp %u",i,mem[i+1]); i++; break;
|
||||
case lpri: fprintf(sta,"%5u\tpri %u",i,mem[i+1]); i++; break;
|
||||
case lcse: fprintf(sta,"%5u\tcse %u",i,mem[i+1]); i++; break;
|
||||
case lcsr: fprintf(sta,"%5u\tcsr %u",i,mem[i+1]); i++; break;
|
||||
case lshr: fprintf(sta,"%5u\tshr",i); break;
|
||||
case lshl: fprintf(sta,"%5u\tshl",i); break;
|
||||
case lipt: fprintf(sta,"%5u\tipt",i); break;
|
||||
case lpti: fprintf(sta,"%5u\tpti",i); break;
|
||||
case ldpt: fprintf(sta,"%5u\tdpt",i); break;
|
||||
case lptd: fprintf(sta,"%5u\tptd",i); break;
|
||||
case lada: fprintf(sta,"%5u\tada",i); break;
|
||||
case lsua: fprintf(sta,"%5u\tsua",i); break;
|
||||
case lmua: fprintf(sta,"%5u\tmua",i); break;
|
||||
case ldia: fprintf(sta,"%5u\tdia",i); break;
|
||||
case lmoa: fprintf(sta,"%5u\tmoa",i); break;
|
||||
case lana: fprintf(sta,"%5u\tana",i); break;
|
||||
case lora: fprintf(sta,"%5u\tora",i); break;
|
||||
case lxoa: fprintf(sta,"%5u\txoa",i); break;
|
||||
case lsra: fprintf(sta,"%5u\tsra",i); break;
|
||||
case lsla: fprintf(sta,"%5u\tsla",i); break;
|
||||
case lpar: fprintf(sta,"%5u\tpar %u",i,mem[i+1]); i++; break;
|
||||
case lrtf: fprintf(sta,"%5u\trtf",i); break;
|
||||
case lclo: fprintf(sta,"%5u\tclo %u",i,mem[i+1]); i++; break;
|
||||
case lfrf: fprintf(sta,"%5u\tfrf",i); break;
|
||||
case limp: fprintf(sta,"%5u\timp %u",i,mem[i+1]); i++; break;
|
||||
case lext: fprintf(sta,"%5u\text %u",i,mem[i+1]); i++; break;
|
||||
case lchk: fprintf(sta,"%5u\tchk",i); break;
|
||||
case ldbg: fprintf(sta,"%5u\tdbg",i); break;
|
||||
while (i < imem)
|
||||
{
|
||||
switch ((byte)mem[i])
|
||||
{
|
||||
case lnop:
|
||||
fprintf(sta, "%5u\tnop", i);
|
||||
break;
|
||||
case lcar:
|
||||
fprintf(sta, "%5u\tcar %u", i, mem[i + 1]);
|
||||
i++;
|
||||
break;
|
||||
case lasi:
|
||||
fprintf(sta, "%5u\tasi", i);
|
||||
break;
|
||||
case lori:
|
||||
fprintf(sta, "%5u\tori", i);
|
||||
break;
|
||||
case lxor:
|
||||
fprintf(sta, "%5u\txor", i);
|
||||
break;
|
||||
case land:
|
||||
fprintf(sta, "%5u\tand", i);
|
||||
break;
|
||||
case ligu:
|
||||
fprintf(sta, "%5u\tigu", i);
|
||||
break;
|
||||
case ldis:
|
||||
fprintf(sta, "%5u\tdis", i);
|
||||
break;
|
||||
case lmay:
|
||||
fprintf(sta, "%5u\tmay", i);
|
||||
break;
|
||||
case lmen:
|
||||
fprintf(sta, "%5u\tmen", i);
|
||||
break;
|
||||
case lmei:
|
||||
fprintf(sta, "%5u\tmei", i);
|
||||
break;
|
||||
case lmai:
|
||||
fprintf(sta, "%5u\tmai", i);
|
||||
break;
|
||||
case ladd:
|
||||
fprintf(sta, "%5u\tadd", i);
|
||||
break;
|
||||
case lsub:
|
||||
fprintf(sta, "%5u\tsub", i);
|
||||
break;
|
||||
case lmul:
|
||||
fprintf(sta, "%5u\tmul", i);
|
||||
break;
|
||||
case ldiv:
|
||||
fprintf(sta, "%5u\tdiv", i);
|
||||
break;
|
||||
case lmod:
|
||||
fprintf(sta, "%5u\tmod", i);
|
||||
break;
|
||||
case lneg:
|
||||
fprintf(sta, "%5u\tneg", i);
|
||||
break;
|
||||
case lptr:
|
||||
fprintf(sta, "%5u\tptr", i);
|
||||
break;
|
||||
case lnot:
|
||||
fprintf(sta, "%5u\tnot", i);
|
||||
break;
|
||||
case laid:
|
||||
fprintf(sta, "%5u\taid", i);
|
||||
break;
|
||||
case lcid:
|
||||
fprintf(sta, "%5u\tcid", i);
|
||||
break;
|
||||
case lrng:
|
||||
fprintf(sta, "%5u\trng %u", i, mem[i + 1]);
|
||||
i++;
|
||||
break;
|
||||
case ljmp:
|
||||
fprintf(sta, "%5u\tjmp %u", i, mem[i + 1]);
|
||||
i++;
|
||||
break;
|
||||
case ljpf:
|
||||
fprintf(sta, "%5u\tjpf %u", i, mem[i + 1]);
|
||||
i++;
|
||||
break;
|
||||
case lfun:
|
||||
fprintf(sta, "%5u\tfun %u", i, mem[i + 1]);
|
||||
i++;
|
||||
break;
|
||||
case lcal:
|
||||
fprintf(sta, "%5u\tcal %u", i, mem[i + 1]);
|
||||
i++;
|
||||
break;
|
||||
case lret:
|
||||
fprintf(sta, "%5u\tret", i);
|
||||
break;
|
||||
case lasp:
|
||||
fprintf(sta, "%5u\tasp", i);
|
||||
break;
|
||||
case lfrm:
|
||||
fprintf(sta, "%5u\tfrm", i);
|
||||
break;
|
||||
case lcbp:
|
||||
fprintf(sta, "%5u\tcbp %u", i, mem[i + 1]);
|
||||
i++;
|
||||
break;
|
||||
case lcpa:
|
||||
fprintf(sta, "%5u\tcpa", i);
|
||||
break;
|
||||
case ltyp:
|
||||
fprintf(sta, "\n%5u\ttyp %u", i, mem[i + 1]);
|
||||
i++;
|
||||
break;
|
||||
case lpri:
|
||||
fprintf(sta, "%5u\tpri %u", i, mem[i + 1]);
|
||||
i++;
|
||||
break;
|
||||
case lcse:
|
||||
fprintf(sta, "%5u\tcse %u", i, mem[i + 1]);
|
||||
i++;
|
||||
break;
|
||||
case lcsr:
|
||||
fprintf(sta, "%5u\tcsr %u", i, mem[i + 1]);
|
||||
i++;
|
||||
break;
|
||||
case lshr:
|
||||
fprintf(sta, "%5u\tshr", i);
|
||||
break;
|
||||
case lshl:
|
||||
fprintf(sta, "%5u\tshl", i);
|
||||
break;
|
||||
case lipt:
|
||||
fprintf(sta, "%5u\tipt", i);
|
||||
break;
|
||||
case lpti:
|
||||
fprintf(sta, "%5u\tpti", i);
|
||||
break;
|
||||
case ldpt:
|
||||
fprintf(sta, "%5u\tdpt", i);
|
||||
break;
|
||||
case lptd:
|
||||
fprintf(sta, "%5u\tptd", i);
|
||||
break;
|
||||
case lada:
|
||||
fprintf(sta, "%5u\tada", i);
|
||||
break;
|
||||
case lsua:
|
||||
fprintf(sta, "%5u\tsua", i);
|
||||
break;
|
||||
case lmua:
|
||||
fprintf(sta, "%5u\tmua", i);
|
||||
break;
|
||||
case ldia:
|
||||
fprintf(sta, "%5u\tdia", i);
|
||||
break;
|
||||
case lmoa:
|
||||
fprintf(sta, "%5u\tmoa", i);
|
||||
break;
|
||||
case lana:
|
||||
fprintf(sta, "%5u\tana", i);
|
||||
break;
|
||||
case lora:
|
||||
fprintf(sta, "%5u\tora", i);
|
||||
break;
|
||||
case lxoa:
|
||||
fprintf(sta, "%5u\txoa", i);
|
||||
break;
|
||||
case lsra:
|
||||
fprintf(sta, "%5u\tsra", i);
|
||||
break;
|
||||
case lsla:
|
||||
fprintf(sta, "%5u\tsla", i);
|
||||
break;
|
||||
case lpar:
|
||||
fprintf(sta, "%5u\tpar %u", i, mem[i + 1]);
|
||||
i++;
|
||||
break;
|
||||
case lrtf:
|
||||
fprintf(sta, "%5u\trtf", i);
|
||||
break;
|
||||
case lclo:
|
||||
fprintf(sta, "%5u\tclo %u", i, mem[i + 1]);
|
||||
i++;
|
||||
break;
|
||||
case lfrf:
|
||||
fprintf(sta, "%5u\tfrf", i);
|
||||
break;
|
||||
case limp:
|
||||
fprintf(sta, "%5u\timp %u", i, mem[i + 1]);
|
||||
i++;
|
||||
break;
|
||||
case lext:
|
||||
fprintf(sta, "%5u\text %u", i, mem[i + 1]);
|
||||
i++;
|
||||
break;
|
||||
case lchk:
|
||||
fprintf(sta, "%5u\tchk", i);
|
||||
break;
|
||||
case ldbg:
|
||||
fprintf(sta, "%5u\tdbg", i);
|
||||
break;
|
||||
|
||||
case lcar2: fprintf(sta,"%5u\tcar2 %u %u",i,mem[i+1],mem[i+2]); i+=2; break;
|
||||
case lcar3: fprintf(sta,"%5u\tcar3 %u %u %u",i,mem[i+1],mem[i+2],mem[i+3]); i+=3; break;
|
||||
case lcar4: fprintf(sta,"%5u\tcar4 %u %u %u %u",i,mem[i+1],mem[i+2],mem[i+3],mem[i+4]); i+=4; break;
|
||||
case lasiasp: fprintf(sta,"%5u\tasiasp",i); break;
|
||||
case lcaraid: fprintf(sta,"%5u\tcaraid %u",i,mem[i+1]); i++; break;
|
||||
case lcarptr: fprintf(sta,"%5u\tcarptr %u",i,mem[i+1]); i++; break;
|
||||
case laidptr: fprintf(sta,"%5u\taidptr",i); break;
|
||||
case lcaraidptr: fprintf(sta,"%5u\tcaraidptr %u",i,mem[i+1]); i++; break;
|
||||
case lcaraidcpa: fprintf(sta,"%5u\tcaraidcpa %u",i,mem[i+1]); i++; break;
|
||||
case laddptr: fprintf(sta,"%5u\taddptr",i); break;
|
||||
case lfunasp: fprintf(sta,"%5u\tfunasp %u",i,mem[i+1]); i++; break;
|
||||
case lcaradd: fprintf(sta,"%5u\tcaradd %u",i,mem[i+1]); i++; break;
|
||||
case lcaraddptr: fprintf(sta,"%5u\tcaraddptr %u",i,mem[i+1]); i++; break;
|
||||
case lcarmul: fprintf(sta,"%5u\tcarmul %u",i,mem[i+1]); i++; break;
|
||||
case lcarmuladd: fprintf(sta,"%5u\tcarmuladd %u",i,mem[i+1]); i++; break;
|
||||
case lcarasiasp: fprintf(sta,"%5u\tcarasiasp %u",i,mem[i+1]); i++; break;
|
||||
case lcarsub: fprintf(sta,"%5u\tcarsub %u",i,mem[i+1]); i++; break;
|
||||
case lcardiv: fprintf(sta,"%5u\tcardiv %u",i,mem[i+1]); i++; break;
|
||||
case lcar2:
|
||||
fprintf(sta, "%5u\tcar2 %u %u", i, mem[i + 1], mem[i + 2]);
|
||||
i += 2;
|
||||
break;
|
||||
case lcar3:
|
||||
fprintf(sta, "%5u\tcar3 %u %u %u", i, mem[i + 1], mem[i + 2], mem[i + 3]);
|
||||
i += 3;
|
||||
break;
|
||||
case lcar4:
|
||||
fprintf(sta, "%5u\tcar4 %u %u %u %u", i, mem[i + 1], mem[i + 2], mem[i + 3], mem[i + 4]);
|
||||
i += 4;
|
||||
break;
|
||||
case lasiasp:
|
||||
fprintf(sta, "%5u\tasiasp", i);
|
||||
break;
|
||||
case lcaraid:
|
||||
fprintf(sta, "%5u\tcaraid %u", i, mem[i + 1]);
|
||||
i++;
|
||||
break;
|
||||
case lcarptr:
|
||||
fprintf(sta, "%5u\tcarptr %u", i, mem[i + 1]);
|
||||
i++;
|
||||
break;
|
||||
case laidptr:
|
||||
fprintf(sta, "%5u\taidptr", i);
|
||||
break;
|
||||
case lcaraidptr:
|
||||
fprintf(sta, "%5u\tcaraidptr %u", i, mem[i + 1]);
|
||||
i++;
|
||||
break;
|
||||
case lcaraidcpa:
|
||||
fprintf(sta, "%5u\tcaraidcpa %u", i, mem[i + 1]);
|
||||
i++;
|
||||
break;
|
||||
case laddptr:
|
||||
fprintf(sta, "%5u\taddptr", i);
|
||||
break;
|
||||
case lfunasp:
|
||||
fprintf(sta, "%5u\tfunasp %u", i, mem[i + 1]);
|
||||
i++;
|
||||
break;
|
||||
case lcaradd:
|
||||
fprintf(sta, "%5u\tcaradd %u", i, mem[i + 1]);
|
||||
i++;
|
||||
break;
|
||||
case lcaraddptr:
|
||||
fprintf(sta, "%5u\tcaraddptr %u", i, mem[i + 1]);
|
||||
i++;
|
||||
break;
|
||||
case lcarmul:
|
||||
fprintf(sta, "%5u\tcarmul %u", i, mem[i + 1]);
|
||||
i++;
|
||||
break;
|
||||
case lcarmuladd:
|
||||
fprintf(sta, "%5u\tcarmuladd %u", i, mem[i + 1]);
|
||||
i++;
|
||||
break;
|
||||
case lcarasiasp:
|
||||
fprintf(sta, "%5u\tcarasiasp %u", i, mem[i + 1]);
|
||||
i++;
|
||||
break;
|
||||
case lcarsub:
|
||||
fprintf(sta, "%5u\tcarsub %u", i, mem[i + 1]);
|
||||
i++;
|
||||
break;
|
||||
case lcardiv:
|
||||
fprintf(sta, "%5u\tcardiv %u", i, mem[i + 1]);
|
||||
i++;
|
||||
break;
|
||||
|
||||
case lptrwor: fprintf(sta,"%5u\tptrwor",i); break;
|
||||
case lasiwor: fprintf(sta,"%5u\tasiwor",i); break;
|
||||
case liptwor: fprintf(sta,"%5u\tiptwor",i); break;
|
||||
case lptiwor: fprintf(sta,"%5u\tptiwor",i); break;
|
||||
case ldptwor: fprintf(sta,"%5u\tdptwor",i); break;
|
||||
case lptdwor: fprintf(sta,"%5u\tptdwor",i); break;
|
||||
case ladawor: fprintf(sta,"%5u\tadawor",i); break;
|
||||
case lsuawor: fprintf(sta,"%5u\tsuawor",i); break;
|
||||
case lmuawor: fprintf(sta,"%5u\tmuawor",i); break;
|
||||
case ldiawor: fprintf(sta,"%5u\tdiawor",i); break;
|
||||
case lmoawor: fprintf(sta,"%5u\tmoawor",i); break;
|
||||
case lanawor: fprintf(sta,"%5u\tanawor",i); break;
|
||||
case lorawor: fprintf(sta,"%5u\torawor",i); break;
|
||||
case lxoawor: fprintf(sta,"%5u\txoawor",i); break;
|
||||
case lsrawor: fprintf(sta,"%5u\tsrawor",i); break;
|
||||
case lslawor: fprintf(sta,"%5u\tslawor",i); break;
|
||||
case lcpawor: fprintf(sta,"%5u\tcpawor",i); break;
|
||||
case lptrwor:
|
||||
fprintf(sta, "%5u\tptrwor", i);
|
||||
break;
|
||||
case lasiwor:
|
||||
fprintf(sta, "%5u\tasiwor", i);
|
||||
break;
|
||||
case liptwor:
|
||||
fprintf(sta, "%5u\tiptwor", i);
|
||||
break;
|
||||
case lptiwor:
|
||||
fprintf(sta, "%5u\tptiwor", i);
|
||||
break;
|
||||
case ldptwor:
|
||||
fprintf(sta, "%5u\tdptwor", i);
|
||||
break;
|
||||
case lptdwor:
|
||||
fprintf(sta, "%5u\tptdwor", i);
|
||||
break;
|
||||
case ladawor:
|
||||
fprintf(sta, "%5u\tadawor", i);
|
||||
break;
|
||||
case lsuawor:
|
||||
fprintf(sta, "%5u\tsuawor", i);
|
||||
break;
|
||||
case lmuawor:
|
||||
fprintf(sta, "%5u\tmuawor", i);
|
||||
break;
|
||||
case ldiawor:
|
||||
fprintf(sta, "%5u\tdiawor", i);
|
||||
break;
|
||||
case lmoawor:
|
||||
fprintf(sta, "%5u\tmoawor", i);
|
||||
break;
|
||||
case lanawor:
|
||||
fprintf(sta, "%5u\tanawor", i);
|
||||
break;
|
||||
case lorawor:
|
||||
fprintf(sta, "%5u\torawor", i);
|
||||
break;
|
||||
case lxoawor:
|
||||
fprintf(sta, "%5u\txoawor", i);
|
||||
break;
|
||||
case lsrawor:
|
||||
fprintf(sta, "%5u\tsrawor", i);
|
||||
break;
|
||||
case lslawor:
|
||||
fprintf(sta, "%5u\tslawor", i);
|
||||
break;
|
||||
case lcpawor:
|
||||
fprintf(sta, "%5u\tcpawor", i);
|
||||
break;
|
||||
|
||||
case lptrchr: fprintf(sta,"%5u\tptrchr",i); break;
|
||||
case lasichr: fprintf(sta,"%5u\tasichr",i); break;
|
||||
case liptchr: fprintf(sta,"%5u\tiptchr",i); break;
|
||||
case lptichr: fprintf(sta,"%5u\tptichr",i); break;
|
||||
case ldptchr: fprintf(sta,"%5u\tdptchr",i); break;
|
||||
case lptdchr: fprintf(sta,"%5u\tptdchr",i); break;
|
||||
case ladachr: fprintf(sta,"%5u\tadachr",i); break;
|
||||
case lsuachr: fprintf(sta,"%5u\tsuachr",i); break;
|
||||
case lmuachr: fprintf(sta,"%5u\tmuachr",i); break;
|
||||
case ldiachr: fprintf(sta,"%5u\tdiachr",i); break;
|
||||
case lmoachr: fprintf(sta,"%5u\tmoachr",i); break;
|
||||
case lanachr: fprintf(sta,"%5u\tanachr",i); break;
|
||||
case lorachr: fprintf(sta,"%5u\torachr",i); break;
|
||||
case lxoachr: fprintf(sta,"%5u\txoachr",i); break;
|
||||
case lsrachr: fprintf(sta,"%5u\tsrachr",i); break;
|
||||
case lslachr: fprintf(sta,"%5u\tslachr",i); break;
|
||||
case lcpachr: fprintf(sta,"%5u\tcpachr",i); break;
|
||||
case lptrchr:
|
||||
fprintf(sta, "%5u\tptrchr", i);
|
||||
break;
|
||||
case lasichr:
|
||||
fprintf(sta, "%5u\tasichr", i);
|
||||
break;
|
||||
case liptchr:
|
||||
fprintf(sta, "%5u\tiptchr", i);
|
||||
break;
|
||||
case lptichr:
|
||||
fprintf(sta, "%5u\tptichr", i);
|
||||
break;
|
||||
case ldptchr:
|
||||
fprintf(sta, "%5u\tdptchr", i);
|
||||
break;
|
||||
case lptdchr:
|
||||
fprintf(sta, "%5u\tptdchr", i);
|
||||
break;
|
||||
case ladachr:
|
||||
fprintf(sta, "%5u\tadachr", i);
|
||||
break;
|
||||
case lsuachr:
|
||||
fprintf(sta, "%5u\tsuachr", i);
|
||||
break;
|
||||
case lmuachr:
|
||||
fprintf(sta, "%5u\tmuachr", i);
|
||||
break;
|
||||
case ldiachr:
|
||||
fprintf(sta, "%5u\tdiachr", i);
|
||||
break;
|
||||
case lmoachr:
|
||||
fprintf(sta, "%5u\tmoachr", i);
|
||||
break;
|
||||
case lanachr:
|
||||
fprintf(sta, "%5u\tanachr", i);
|
||||
break;
|
||||
case lorachr:
|
||||
fprintf(sta, "%5u\torachr", i);
|
||||
break;
|
||||
case lxoachr:
|
||||
fprintf(sta, "%5u\txoachr", i);
|
||||
break;
|
||||
case lsrachr:
|
||||
fprintf(sta, "%5u\tsrachr", i);
|
||||
break;
|
||||
case lslachr:
|
||||
fprintf(sta, "%5u\tslachr", i);
|
||||
break;
|
||||
case lcpachr:
|
||||
fprintf(sta, "%5u\tcpachr", i);
|
||||
break;
|
||||
|
||||
case lstrcpy: fprintf(sta,"%5u\tstrcpy",i); break;
|
||||
case lstrfix: fprintf(sta,"%5u\tstrfix",i); break;
|
||||
case lstrcat: fprintf(sta,"%5u\tstrcat",i); break;
|
||||
case lstradd: fprintf(sta,"%5u\tstradd",i); break;
|
||||
case lstrdec: fprintf(sta,"%5u\tstrdec",i); break;
|
||||
case lstrsub: fprintf(sta,"%5u\tstrsub",i); break;
|
||||
case lstrlen: fprintf(sta,"%5u\tstrlen",i); break;
|
||||
case lstrigu: fprintf(sta,"%5u\tstrigu",i); break;
|
||||
case lstrdis: fprintf(sta,"%5u\tstrdis",i); break;
|
||||
case lstrmay: fprintf(sta,"%5u\tstrmay",i); break;
|
||||
case lstrmen: fprintf(sta,"%5u\tstrmen",i); break;
|
||||
case lstrmei: fprintf(sta,"%5u\tstrmei",i); break;
|
||||
case lstrmai: fprintf(sta,"%5u\tstrmai",i); break;
|
||||
case lcpastr: fprintf(sta,"%5u\tcpastr",i); break;
|
||||
case lstrcpy:
|
||||
fprintf(sta, "%5u\tstrcpy", i);
|
||||
break;
|
||||
case lstrfix:
|
||||
fprintf(sta, "%5u\tstrfix", i);
|
||||
break;
|
||||
case lstrcat:
|
||||
fprintf(sta, "%5u\tstrcat", i);
|
||||
break;
|
||||
case lstradd:
|
||||
fprintf(sta, "%5u\tstradd", i);
|
||||
break;
|
||||
case lstrdec:
|
||||
fprintf(sta, "%5u\tstrdec", i);
|
||||
break;
|
||||
case lstrsub:
|
||||
fprintf(sta, "%5u\tstrsub", i);
|
||||
break;
|
||||
case lstrlen:
|
||||
fprintf(sta, "%5u\tstrlen", i);
|
||||
break;
|
||||
case lstrigu:
|
||||
fprintf(sta, "%5u\tstrigu", i);
|
||||
break;
|
||||
case lstrdis:
|
||||
fprintf(sta, "%5u\tstrdis", i);
|
||||
break;
|
||||
case lstrmay:
|
||||
fprintf(sta, "%5u\tstrmay", i);
|
||||
break;
|
||||
case lstrmen:
|
||||
fprintf(sta, "%5u\tstrmen", i);
|
||||
break;
|
||||
case lstrmei:
|
||||
fprintf(sta, "%5u\tstrmei", i);
|
||||
break;
|
||||
case lstrmai:
|
||||
fprintf(sta, "%5u\tstrmai", i);
|
||||
break;
|
||||
case lcpastr:
|
||||
fprintf(sta, "%5u\tcpastr", i);
|
||||
break;
|
||||
|
||||
case lnul: fprintf(sta,"%5u\tnul",i); break;
|
||||
case lnul:
|
||||
fprintf(sta, "%5u\tnul", i);
|
||||
break;
|
||||
|
||||
case lextasp: fprintf(sta,"%5u\textasp %u",i,mem[i+1]); i++; break;
|
||||
case lextasp:
|
||||
fprintf(sta, "%5u\textasp %u", i, mem[i + 1]);
|
||||
i++;
|
||||
break;
|
||||
|
||||
default: fprintf(sta,"***"); break;
|
||||
} fprintf(sta,"\n"); i++; }
|
||||
default:
|
||||
fprintf(sta, "***");
|
||||
break;
|
||||
}
|
||||
fprintf(sta, "\n");
|
||||
i++;
|
||||
}
|
||||
fclose(sta);
|
||||
}
|
||||
|
|
|
@ -34,14 +34,15 @@
|
|||
void ltlex_error(int error)
|
||||
{
|
||||
if (error == 1)
|
||||
printf(translate(40),translate_ltlex_error(error));
|
||||
print_translate(40, translate_ltlex_error(error));
|
||||
else
|
||||
printf(translate(41),"ltlex.def",linea,translate_ltlex_error(error));
|
||||
printf(translate(42));
|
||||
print_translate(41, "ltlex.def", linea, translate_ltlex_error(error));
|
||||
print_translate(42);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void analiza_ltlex(void){
|
||||
void analiza_ltlex(void)
|
||||
{
|
||||
|
||||
byte *_buf, *buf; /* Buffer del texto y puntero al carácter actual */
|
||||
byte cont = 1; /* 0 indica final del archivo */
|
||||
|
@ -74,52 +75,71 @@ void analiza_ltlex(void){
|
|||
|
||||
linea = 1;
|
||||
|
||||
do {
|
||||
switch (*buf++) {
|
||||
do
|
||||
{
|
||||
switch (*buf++)
|
||||
{
|
||||
/* Fin de fichero */
|
||||
case 0:
|
||||
cont=0; break;
|
||||
cont = 0;
|
||||
break;
|
||||
/* Ignoramos los espacios */
|
||||
case ' ':
|
||||
case tab:
|
||||
break;
|
||||
/* Salta de linea */
|
||||
case cr:
|
||||
if(*buf==lf) buf++;
|
||||
if (*buf == lf)
|
||||
buf++;
|
||||
case lf:
|
||||
linea++;
|
||||
break;
|
||||
/* Los ; indican línea de comentario */
|
||||
case ';':
|
||||
while (*buf!=cr && *buf!=lf) buf++; break;
|
||||
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')
|
||||
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')
|
||||
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 */
|
||||
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) {
|
||||
}
|
||||
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++;
|
||||
|
@ -127,26 +147,38 @@ void analiza_ltlex(void){
|
|||
}
|
||||
else
|
||||
buf++;
|
||||
while (*buf!=' ' && *buf!=tab && *buf!=cr) {
|
||||
if (lower[*buf]) ltlex_error(4);
|
||||
while (*buf != ' ' && *buf != tab && *buf != cr)
|
||||
{
|
||||
if (lower[*buf])
|
||||
ltlex_error(4);
|
||||
if (e->siguiente == 0)
|
||||
if (num_nodos++==max_nodos) ltlex_error(3);
|
||||
else e=e->siguiente=ilex_simb++;
|
||||
else {
|
||||
if (num_nodos++ == max_nodos)
|
||||
ltlex_error(3);
|
||||
else
|
||||
e = e->siguiente = ilex_simb++;
|
||||
else
|
||||
{
|
||||
e = e->siguiente;
|
||||
while (e->caracter != *buf && e->alternativa)
|
||||
e = e->alternativa;
|
||||
if (e->caracter!=*buf) {
|
||||
if (num_nodos++==max_nodos) ltlex_error(3);
|
||||
else e=e->alternativa=ilex_simb++;
|
||||
if (e->caracter != *buf)
|
||||
{
|
||||
if (num_nodos++ == max_nodos)
|
||||
ltlex_error(3);
|
||||
else
|
||||
e = e->alternativa = ilex_simb++;
|
||||
}
|
||||
}
|
||||
e->caracter = *buf++;
|
||||
}
|
||||
e->token = t;
|
||||
} break;
|
||||
}} while (cont);
|
||||
|
||||
e_free(_buf); _buf=NULL;
|
||||
fclose(def); def=NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} while (cont);
|
||||
|
||||
e_free(_buf);
|
||||
_buf = NULL;
|
||||
fclose(def);
|
||||
def = NULL;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,8 @@ void get_rawname(char* completo, char* rawname)
|
|||
int i;
|
||||
|
||||
for (i = strlen(completo) - 1; i > 0; i--)
|
||||
if(completo[i]=='\\' || completo[i]=='/') {
|
||||
if (completo[i] == '\\' || completo[i] == '/')
|
||||
{
|
||||
p = &completo[i + 1];
|
||||
break;
|
||||
}
|
||||
|
@ -54,21 +55,17 @@ void get_rawname(char* completo, char* rawname)
|
|||
i = strlen(rawname);
|
||||
|
||||
#ifdef _WIN32
|
||||
if (rawname[i-4]=='.' && (rawname[i-3]=='d' || rawname[i-3]=='D')
|
||||
&& (rawname[i-2]=='l' || rawname[i-2]=='L')
|
||||
&& (rawname[i-1]=='l' || rawname[i-1]=='L'))
|
||||
if (rawname[i - 4] == '.' && (rawname[i - 3] == 'd' || rawname[i - 3] == 'D') && (rawname[i - 2] == 'l' || rawname[i - 2] == 'L') && (rawname[i - 1] == 'l' || rawname[i - 1] == 'L'))
|
||||
|
||||
rawname[i - 4] = 0;
|
||||
|
||||
#else
|
||||
if(rawname[i-3]=='.' && (rawname[i-2]=='s' || rawname[i-2]=='S')
|
||||
&& (rawname[i-1]=='o' || rawname[i-1]=='O'))
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
/* compara prioridades de dos dlls, para el qsort descendente */
|
||||
int compara(const void *_a, const void *_b)
|
||||
{
|
||||
|
@ -84,7 +81,6 @@ int compara2(const void* _a, const void* _b)
|
|||
return dlls[a].prioridad < dlls[b].prioridad ? 1 : (dlls[a].prioridad > dlls[b].prioridad ? -1 : 0);
|
||||
}
|
||||
|
||||
|
||||
void dll_func()
|
||||
{
|
||||
char dllkey[256] = "dll_priority:";
|
||||
|
@ -124,8 +120,7 @@ void dll_func()
|
|||
/* Busca las DLLs que hay en el directorio */
|
||||
buscafich = _findfirst(mask, &fichero_dll);
|
||||
if (buscafich == -1)
|
||||
printf(translate(43)); /* no hay dlls */
|
||||
|
||||
print_translate(43); /* no hay dlls */
|
||||
|
||||
#ifdef _DEBUG
|
||||
printf("dbg: DLL encontrada: %s\n", fichero_dll.name);
|
||||
|
@ -141,7 +136,8 @@ void dll_func()
|
|||
carga = 0;
|
||||
|
||||
if (carga)
|
||||
if(!leedll()) {
|
||||
if (!leedll())
|
||||
{
|
||||
dlls[numdlls].prioridad = 0;
|
||||
/* guarda el nombre de fichero en la tabla de DLLs */
|
||||
dlls[0].nombre = e_malloc(strlen(rawname) + 1);
|
||||
|
@ -155,8 +151,10 @@ void dll_func()
|
|||
}
|
||||
|
||||
/* hace lo mismo con el resto */
|
||||
while(1) {
|
||||
if(_findnext(buscafich,&fichero_dll)==0) {
|
||||
while (1)
|
||||
{
|
||||
if (_findnext(buscafich, &fichero_dll) == 0)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
printf("dbg: DLL encontrada: %s\n", fichero_dll.name);
|
||||
#endif
|
||||
|
@ -166,12 +164,17 @@ void dll_func()
|
|||
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()) {
|
||||
if (ini)
|
||||
if (iniparser_getint(ini, dllkey, 0) <= P_NUNCA)
|
||||
carga = 0;
|
||||
if (carga)
|
||||
if (!leedll())
|
||||
{
|
||||
dlls[numdlls].nombre = e_malloc(strlen(rawname) + 1);
|
||||
strcpy(dlls[numdlls].nombre, rawname);
|
||||
dlls[numdlls].usado = 0;
|
||||
if(ini) dlls[numdlls].prioridad=iniparser_getint(ini,dllkey,dlls[numdlls].prioridad);
|
||||
if (ini)
|
||||
dlls[numdlls].prioridad = iniparser_getint(ini, dllkey, dlls[numdlls].prioridad);
|
||||
numdlls++;
|
||||
}
|
||||
}
|
||||
|
@ -181,17 +184,21 @@ void dll_func()
|
|||
|
||||
#else /* si estamos en Linux */
|
||||
|
||||
if(ini) dir=iniparser_getstr(ini,"dll:nixdll");
|
||||
if(!dir) dir="so";
|
||||
if (ini)
|
||||
dir = iniparser_getstr(ini, "dll:nixdll");
|
||||
if (!dir)
|
||||
dir = "so";
|
||||
|
||||
directorio = opendir(dir);
|
||||
if(!directorio) {
|
||||
printf(translate(44),dir); /* no hay directorio so/ */
|
||||
if (!directorio)
|
||||
{
|
||||
print_translate(44, dir); /* no hay directorio so/ */
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Busca las .so */
|
||||
while ((fichero_dll = readdir(directorio)) != 0) {
|
||||
while ((fichero_dll = readdir(directorio)) != 0)
|
||||
{
|
||||
/* Salta los directorios actual '.' y padre ".." */
|
||||
if (strcmp(fichero_dll->d_name, ".") == 0)
|
||||
continue;
|
||||
|
@ -199,7 +206,8 @@ void dll_func()
|
|||
if (strcmp(fichero_dll->d_name, "..") == 0)
|
||||
continue;
|
||||
|
||||
if(fichero_dll->d_type==DT_REG) {
|
||||
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);
|
||||
|
@ -211,13 +219,16 @@ void dll_func()
|
|||
strcpy(dllkey, "dll_priority:");
|
||||
strcat(dllkey, rawname);
|
||||
|
||||
if (ini) {
|
||||
if (ini)
|
||||
{
|
||||
if (iniparser_getint(ini, dllkey, 0) <= P_NUNCA)
|
||||
carga = 0;
|
||||
}
|
||||
|
||||
if(carga) {
|
||||
if(!leedll()) {
|
||||
if (carga)
|
||||
{
|
||||
if (!leedll())
|
||||
{
|
||||
dlls[numdlls].nombre = e_malloc(strlen(rawname) + 1);
|
||||
strcpy(dlls[numdlls].nombre, rawname);
|
||||
dlls[numdlls].usado = 0;
|
||||
|
@ -234,7 +245,7 @@ void dll_func()
|
|||
#endif
|
||||
|
||||
if (numdlls == 0)
|
||||
printf(translate(43)); /* no hay librerias */
|
||||
print_translate(43); /* no hay librerias */
|
||||
|
||||
nuevo_orden = e_malloc(numdlls * 4);
|
||||
for (i = 0; i < numdlls; i++)
|
||||
|
@ -247,10 +258,8 @@ void dll_func()
|
|||
for (i = 0; i < numdlls; i++)
|
||||
printf("dbg: %d - %s - prioridad: %d\n", i, dlls[i].nombre, dlls[i].prioridad);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
void dll_func2()
|
||||
{
|
||||
int i = numdlls;
|
||||
|
@ -261,30 +270,36 @@ void dll_func2()
|
|||
for (i = 0; i < numdlls; i++)
|
||||
nuevo_orden[i] = i;
|
||||
|
||||
for(numdlls=0;numdlls<i;numdlls++) {
|
||||
if((dlls[numdlls].prioridad>P_NUNCA) && (dlls[numdlls].usado || dlls[numdlls].prioridad>=P_SIEMPRE)) {
|
||||
for (numdlls = 0; numdlls < i; numdlls++)
|
||||
{
|
||||
if ((dlls[numdlls].prioridad > P_NUNCA) && (dlls[numdlls].usado || dlls[numdlls].prioridad >= P_SIEMPRE))
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
printf("dbg: Se requiere %s (id=%d)\n", dlls[numdlls].nombre, numdlls);
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
if(ini) dir=iniparser_getstr(ini,"dll:windll");
|
||||
if(!dir) dir="dll";
|
||||
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";
|
||||
if (ini)
|
||||
dir = iniparser_getstr(ini, "dll:nixdll");
|
||||
if (!dir)
|
||||
dir = "so";
|
||||
sprintf(fichdll, "%s/%s.so", dir, dlls[numdlls].nombre);
|
||||
#endif
|
||||
|
||||
if(leedll()) {
|
||||
printf(translate(45),dlls[numdlls].nombre); /* error al cargar libreria */
|
||||
if (leedll())
|
||||
{
|
||||
print_translate(45, dlls[numdlls].nombre); /* error al cargar libreria */
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int leedll()
|
||||
{
|
||||
TYPEOF_ExportaFuncs *ExportaFuncs;
|
||||
|
@ -294,8 +309,9 @@ int leedll()
|
|||
/* Carga la DLL */
|
||||
hDLL = LoadDLL(fichdll);
|
||||
|
||||
if(hDLL==NULL) {
|
||||
printf(translate(46),fichdll); /* no puedo cargar libreria */
|
||||
if (hDLL == NULL)
|
||||
{
|
||||
print_translate(46, fichdll); /* no puedo cargar libreria */
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -303,8 +319,9 @@ int leedll()
|
|||
ExportaFuncs = NULL;
|
||||
ExportaFuncs = (TYPEOF_ExportaFuncs *)GetDLLProcAddress(hDLL, "ExportaFuncs");
|
||||
|
||||
if(ExportaFuncs==NULL) {
|
||||
printf(translate(47),fichdll); /* exportafuncs no encontrado */
|
||||
if (ExportaFuncs == NULL)
|
||||
{
|
||||
print_translate(47, fichdll); /* exportafuncs no encontrado */
|
||||
FreeDLL(hDLL);
|
||||
return 1;
|
||||
}
|
||||
|
@ -324,8 +341,9 @@ int leedll()
|
|||
/* Carga la DLL */
|
||||
hDLL = dlopen(fichdll, RTLD_NOW);
|
||||
|
||||
if(!hDLL) {
|
||||
printf(translate(46),fichdll,dlerror()); /* no puedo cargar libreria */
|
||||
if (!hDLL)
|
||||
{
|
||||
print_translate(46, fichdll, dlerror()); /* no puedo cargar libreria */
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -335,8 +353,9 @@ int leedll()
|
|||
|
||||
ExportaFuncs = (TYPEOF_ExportaFuncs *)dlsym(hDLL, "ExportaFuncs");
|
||||
|
||||
if((errordll=dlerror())!=NULL) {
|
||||
printf(translate(47),fichdll,errordll); /* exportafuncs no encontrado */
|
||||
if ((errordll = dlerror()) != NULL)
|
||||
{
|
||||
print_translate(47, fichdll, errordll); /* exportafuncs no encontrado */
|
||||
dlclose(hDLL);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -49,13 +49,14 @@
|
|||
#define TRANSLATE_RUNTIME_ERROR 7
|
||||
#define TRANSLATE_CRITICAL_ERROR 8
|
||||
|
||||
|
||||
int idioma;
|
||||
|
||||
/* comunes */
|
||||
int detecta_idioma();
|
||||
char *translate(int num);
|
||||
char *translate_dll_error(int num);
|
||||
const char *get_translate(int num, ...);
|
||||
void print_translate(int num, ...);
|
||||
|
||||
/* compilador */
|
||||
char *translate_error(int num);
|
||||
|
|
|
@ -79,9 +79,7 @@ int offset;
|
|||
return 0;
|
||||
}*/
|
||||
|
||||
|
||||
// Errores específicos en la ejecución de una DLL
|
||||
|
||||
void dll_error(int error, ...)
|
||||
{
|
||||
va_list opparam;
|
||||
|
@ -89,11 +87,11 @@ void dll_error(int error, ...)
|
|||
|
||||
va_start(opparam, error);
|
||||
|
||||
sprintf(mensaje,translate(3), fichdll);
|
||||
vsprintf(mensaje,translate_dll_error(error),opparam);
|
||||
sprintf(mensaje, get_translate(3, fichdll));
|
||||
vsprintf(mensaje, get_translate(translate_dll_error(error)), opparam);
|
||||
|
||||
#ifdef _WIN32
|
||||
MessageBox(0,mensaje,translate(4),MB_ICONERROR);
|
||||
MessageBox(0,mensaje,print_translate((4),MB_ICONERROR);
|
||||
#else
|
||||
printf("%s\n", mensaje);
|
||||
#endif
|
||||
|
@ -104,11 +102,10 @@ void dll_error(int error, ...)
|
|||
exit(-1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int EDIV_Export(char *cadena, int nparam, void *hfuncion)
|
||||
{
|
||||
if(decl_struct) {
|
||||
if (decl_struct)
|
||||
{
|
||||
dll_error(6, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
@ -119,7 +116,8 @@ int EDIV_Export(char* cadena, int nparam, void* hfuncion)
|
|||
printf("export_function:\t-- ID FUNCION: %d\n"
|
||||
"export_function:\tCadena exportada: %s\n"
|
||||
"export_function:\tN. parametros: %d\n"
|
||||
"export_function:\tOffset de la funcion: 0x%X\n",n_externs,cadena,nparam,(unsigned int)hfuncion);
|
||||
"export_function:\tOffset de la funcion: 0x%X\n",
|
||||
n_externs, cadena, nparam, (unsigned int)hfuncion);
|
||||
#endif
|
||||
|
||||
/* if(creaobj) {
|
||||
|
@ -161,7 +159,6 @@ int EDIV_Export(char* cadena, int nparam, void* hfuncion)
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Entrypoint(int ep, void *hfuncion)
|
||||
{
|
||||
entrypoints[n_entrypoints].tipo = ep;
|
||||
|
@ -170,17 +167,16 @@ int EDIV_Export_Entrypoint(int ep, void* hfuncion)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Priority(int priority)
|
||||
{
|
||||
dlls[numdlls].prioridad = priority;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Const(char *cadena, int valor)
|
||||
{
|
||||
if(decl_struct) {
|
||||
if (decl_struct)
|
||||
{
|
||||
dll_error(6, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
@ -215,10 +211,10 @@ int EDIV_Export_Const(char* cadena, int valor)
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Global(char *cadena, int valor)
|
||||
{
|
||||
if(decl_struct) {
|
||||
if (decl_struct)
|
||||
{
|
||||
dll_error(6, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
@ -251,10 +247,10 @@ int EDIV_Export_Global(char* cadena, int valor)
|
|||
return dimem++;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Global_Tab(char *cadena, int numregs)
|
||||
{
|
||||
if(decl_struct) {
|
||||
if (decl_struct)
|
||||
{
|
||||
dll_error(6, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
@ -298,10 +294,10 @@ int EDIV_Export_Global_Tab(char* cadena, int numregs)
|
|||
return offset;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Global_Struct(char *cadena, int numregs)
|
||||
{
|
||||
if(decl_struct) {
|
||||
if (decl_struct)
|
||||
{
|
||||
dll_error(6, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
@ -345,10 +341,10 @@ int EDIV_Export_Global_Struct(char* cadena, int numregs)
|
|||
return dimem;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Member_Int(char *cadena, int valor)
|
||||
{
|
||||
if(!decl_struct) {
|
||||
if (!decl_struct)
|
||||
{
|
||||
dll_error(7, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
@ -393,10 +389,10 @@ int EDIV_Export_Member_Int(char* cadena, int valor)
|
|||
return len++;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Member_Str(char *cadena, int tamano)
|
||||
{
|
||||
if(!decl_struct) {
|
||||
if (!decl_struct)
|
||||
{
|
||||
dll_error(7, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
@ -471,13 +467,12 @@ int EDIV_Export_Member_Str(char* cadena, int tamano)
|
|||
len += tamano;
|
||||
|
||||
return offset;
|
||||
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Member_Tab(char *cadena, int numregs)
|
||||
{
|
||||
if(!decl_struct) {
|
||||
if (!decl_struct)
|
||||
{
|
||||
dll_error(7, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
@ -537,10 +532,10 @@ int EDIV_Export_Member_Tab(char* cadena, int numregs)
|
|||
return offset;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_EndStruct()
|
||||
{
|
||||
if(!decl_struct) {
|
||||
if (!decl_struct)
|
||||
{
|
||||
dll_error(9);
|
||||
return 0;
|
||||
}
|
||||
|
@ -579,20 +574,23 @@ int EDIV_Export_EndStruct()
|
|||
// iloc+=ob->sloc.totalitems*ob->sloc.len_item;
|
||||
}
|
||||
*/
|
||||
if(len==0) dll_error(10);
|
||||
if (len == 0)
|
||||
dll_error(10);
|
||||
|
||||
if(slocal) diloc+=len*nregs;
|
||||
else dimem+=len*nregs;
|
||||
if (slocal)
|
||||
diloc += len * nregs;
|
||||
else
|
||||
dimem += len * nregs;
|
||||
|
||||
decl_struct = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Local(char *cadena, int valor)
|
||||
{
|
||||
if(decl_struct) {
|
||||
if (decl_struct)
|
||||
{
|
||||
dll_error(6, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
@ -625,10 +623,10 @@ int EDIV_Export_Local(char* cadena, int valor)
|
|||
return diloc++;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Local_Tab(char *cadena, int numregs)
|
||||
{
|
||||
if(decl_struct) {
|
||||
if (decl_struct)
|
||||
{
|
||||
dll_error(6, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
@ -673,10 +671,10 @@ int EDIV_Export_Local_Tab(char* cadena, int numregs)
|
|||
return offset;
|
||||
}
|
||||
|
||||
|
||||
int EDIV_Export_Local_Struct(char *cadena, int numregs)
|
||||
{
|
||||
if(decl_struct) {
|
||||
if (decl_struct)
|
||||
{
|
||||
dll_error(6, cadena);
|
||||
return 0;
|
||||
}
|
||||
|
@ -721,7 +719,6 @@ int EDIV_Export_Local_Struct(char* cadena, int numregs)
|
|||
return diloc;
|
||||
}
|
||||
|
||||
|
||||
////////////////
|
||||
/// Call_Entrypoint
|
||||
//////////////
|
||||
|
@ -730,11 +727,14 @@ int Call_Entrypoint(int ep, ...)
|
|||
{
|
||||
va_list opparam;
|
||||
int i, c = 0;
|
||||
for(i=0;i<n_entrypoints;i++) {
|
||||
if(entrypoints[i].tipo==ep) {
|
||||
for (i = 0; i < n_entrypoints; i++)
|
||||
{
|
||||
if (entrypoints[i].tipo == ep)
|
||||
{
|
||||
c++;
|
||||
va_start(opparam, ep);
|
||||
switch(ep) {
|
||||
switch (ep)
|
||||
{
|
||||
|
||||
// void funcion(void)
|
||||
case EDIV_set_video_mode:
|
||||
|
@ -812,7 +812,6 @@ int Call_Entrypoint(int ep, ...)
|
|||
funcion_ep(_imem, _nombreprg, _lin, _dbg);
|
||||
}
|
||||
#endif /* DBG */
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,13 +63,13 @@ void error(int num, ...)
|
|||
char mensaje[256];
|
||||
|
||||
va_start(opparam, num);
|
||||
sprintf(mensaje,translate(0), num);
|
||||
sprintf(mensaje, get_translate(0), num);
|
||||
vsprintf(mensaje, translate_runtime_error(num - 100), opparam);
|
||||
|
||||
#ifdef _WIN32
|
||||
ventanuka = GetActiveWindow();
|
||||
//MessageBox(
|
||||
MessageBox(ventanuka,mensaje,translate(1),MB_ICONERROR);
|
||||
MessageBox(ventanuka, mensaje, print_translate(1), MB_ICONERROR);
|
||||
#else
|
||||
printf("%s\n", mensaje);
|
||||
#endif
|
||||
|
@ -77,7 +77,6 @@ void error(int num, ...)
|
|||
stub_quit(num);
|
||||
}
|
||||
|
||||
|
||||
/* critical_error ( numero, parametros [...] )
|
||||
*
|
||||
* Interrumpe el programa con un mensaje de error. No es posible trazar.
|
||||
|
@ -91,11 +90,11 @@ void critical_error(int num, ...)
|
|||
char mensaje[256];
|
||||
|
||||
va_start(opparam, num);
|
||||
sprintf(mensaje,translate(0), num);
|
||||
sprintf(mensaje, get_translate(0), num);
|
||||
vsprintf(mensaje, translate_critical_error(num), opparam);
|
||||
|
||||
#ifdef WIN32
|
||||
MessageBox(0,mensaje,translate(2),MB_ICONERROR);
|
||||
MessageBox(0, mensaje, print_translate(2), MB_ICONERROR);
|
||||
#else
|
||||
printf("%s\n", mensaje);
|
||||
#endif
|
||||
|
@ -103,7 +102,6 @@ void critical_error(int num, ...)
|
|||
stub_quit(num);
|
||||
}
|
||||
|
||||
|
||||
/* custom_error (tipo, mensaje)
|
||||
*
|
||||
* Permite a las DLLs generar sus propios errores, para que no dependan de los
|
||||
|
@ -122,7 +120,7 @@ void critical_error(int num, ...)
|
|||
void custom_error(tipoerror tipo, char *mensaje)
|
||||
{
|
||||
#ifdef WIN32
|
||||
MessageBox(0,mensaje,translate(tipo),MB_ICONERROR);
|
||||
MessageBox(0, mensaje, print_translate(tipo), MB_ICONERROR);
|
||||
#else
|
||||
printf("%s\n", mensaje);
|
||||
#endif
|
||||
|
|
|
@ -18,21 +18,19 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
|
||||
/**** ¡¡¡ OJO CON LAS COMAS !!! ****/
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
|
||||
#include "shared.h"
|
||||
#include "language.h"
|
||||
|
||||
|
||||
int detecta_idioma_iso(char *lang)
|
||||
{
|
||||
int i;
|
||||
|
@ -44,18 +42,20 @@ int detecta_idioma_iso(char* lang)
|
|||
"ca", // catalán
|
||||
"eu" // euskera
|
||||
};
|
||||
if(lang==NULL) return DEFAULT_LANGUAGE;
|
||||
if(strlen(lang)>2) lang[2]=0;
|
||||
if (lang == NULL)
|
||||
return DEFAULT_LANGUAGE;
|
||||
if (strlen(lang) > 2)
|
||||
lang[2] = 0;
|
||||
strlwr(lang);
|
||||
for (i = 0; i < NUM_LANGUAGES; i++)
|
||||
if (lang[0] == getid[i][0])
|
||||
if (lang[1] == getid[i][1])
|
||||
break;
|
||||
if(i==NUM_LANGUAGES) i=DEFAULT_LANGUAGE;
|
||||
if (i == NUM_LANGUAGES)
|
||||
i = DEFAULT_LANGUAGE;
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
int detecta_idioma()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
|
@ -72,17 +72,20 @@ int detecta_idioma()
|
|||
|
||||
lang = GetSystemDefaultLangID() & 0xff;
|
||||
for (i = 0; i < NUM_LANGUAGES; i++)
|
||||
if(lang==getid[i]) break;
|
||||
if(i==NUM_LANGUAGES) i=DEFAULT_LANGUAGE;
|
||||
if (lang == getid[i])
|
||||
break;
|
||||
if (i == NUM_LANGUAGES)
|
||||
i = DEFAULT_LANGUAGE;
|
||||
return i;
|
||||
#else
|
||||
char *langcfg = getenv("LANG");
|
||||
if(langcfg==NULL) return DEFAULT_LANGUAGE;
|
||||
else return detecta_idioma_iso(langcfg);
|
||||
if (langcfg == NULL)
|
||||
return DEFAULT_LANGUAGE;
|
||||
else
|
||||
return detecta_idioma_iso(langcfg);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
char *translate(int id_cadena)
|
||||
{
|
||||
static char *msg[NUM_LANGUAGES][5] = {
|
||||
|
@ -94,7 +97,6 @@ char* translate(int id_cadena)
|
|||
return msg[idioma][id_cadena];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* NOTA: los huecos vacíos (184..199) son de errores no usados en DIV2, por favor
|
||||
* aprovechadlos para añadir nuevos errores.
|
||||
|
@ -110,10 +112,8 @@ char* translate_runtime_error(int num)
|
|||
};
|
||||
|
||||
return e[idioma][num];
|
||||
|
||||
}
|
||||
|
||||
|
||||
char *translate_critical_error(int num)
|
||||
{
|
||||
static char *e[NUM_LANGUAGES][10] = {
|
||||
|
@ -126,7 +126,6 @@ char* translate_critical_error(int num)
|
|||
return e[idioma][num];
|
||||
}
|
||||
|
||||
|
||||
char *translate_dll_error(int num)
|
||||
{
|
||||
static char *e[NUM_LANGUAGES][10] = {
|
||||
|
@ -138,3 +137,31 @@ char* translate_dll_error(int num)
|
|||
return e[idioma][num];
|
||||
}
|
||||
|
||||
void print_translate(int num, ...)
|
||||
{
|
||||
va_list arg_ptr;
|
||||
const char *message = translate(num);
|
||||
size_t msglen = strlen(message);
|
||||
char *strbuf = malloc(msglen + 1);
|
||||
|
||||
va_start(arg_ptr, message);
|
||||
vsprintf(strbuf, message, arg_ptr);
|
||||
va_end(arg_ptr);
|
||||
|
||||
printf("%s", strbuf);
|
||||
free(strbuf);
|
||||
}
|
||||
|
||||
const char *get_translate(int num, ...)
|
||||
{
|
||||
va_list arg_ptr;
|
||||
const char *message = translate(num);
|
||||
size_t msglen = strlen(message);
|
||||
char *strbuf = malloc(msglen + 1);
|
||||
|
||||
va_start(arg_ptr, message);
|
||||
vsprintf(strbuf, message, arg_ptr);
|
||||
va_end(arg_ptr);
|
||||
|
||||
return strbuf;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue