2002-03-29 22:58:53 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
* Purpose ...............: MBSE BBS functions for TURBODIESEL
|
|
|
|
*
|
|
|
|
*****************************************************************************
|
2007-02-13 14:28:43 +00:00
|
|
|
* Copyright (C) 1997-2007
|
2002-03-29 22:58:53 +00:00
|
|
|
*
|
|
|
|
* Michiel Broek FIDO: 2:280/2802
|
|
|
|
* Beekmansbos 10
|
|
|
|
* 1971 BV IJmuiden
|
|
|
|
* the Netherlands
|
|
|
|
*
|
|
|
|
* This file is part of MBSE BBS.
|
|
|
|
*
|
|
|
|
* This BBS is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
* later version.
|
|
|
|
*
|
|
|
|
* MBSE BBS is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with MBSE BBS; see the file COPYING. If not, write to the Free
|
2003-08-15 20:05:34 +00:00
|
|
|
* Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
2002-03-29 22:58:53 +00:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2002-06-30 12:48:44 +00:00
|
|
|
#include "../config.h"
|
2004-02-21 14:24:03 +00:00
|
|
|
#include "mbselib.h"
|
2002-03-29 22:58:53 +00:00
|
|
|
#include "diesel.h"
|
|
|
|
|
2004-02-21 14:24:03 +00:00
|
|
|
|
2002-04-03 20:29:12 +00:00
|
|
|
static int firstrandom = TRUE;
|
|
|
|
|
2002-03-29 22:58:53 +00:00
|
|
|
|
2002-03-31 13:09:23 +00:00
|
|
|
void MacroVars( const char *codes, const char *fmt, ...)
|
|
|
|
{
|
2005-02-03 20:44:17 +00:00
|
|
|
char *tmp1, *tmp2, *vs, vc;
|
|
|
|
va_list ap;
|
|
|
|
int j, dieselrc, vd;
|
|
|
|
double vf;
|
|
|
|
|
|
|
|
tmp1 = calloc(MAXSTR, sizeof(char));
|
|
|
|
tmp2 = calloc(MAXSTR, sizeof(char));
|
|
|
|
|
|
|
|
va_start(ap,fmt);
|
|
|
|
for (j = 0; (codes[j] != '\0') && (fmt[j] != '\0') ; j++ ){
|
|
|
|
tmp1[0] = '\0';
|
|
|
|
switch (fmt[j]) {
|
|
|
|
case 's': /* string */
|
2002-03-31 13:09:23 +00:00
|
|
|
vs = va_arg(ap, char *);
|
2007-02-13 14:28:43 +00:00
|
|
|
snprintf(tmp1, MAXSTR -1, "@(setvar,%c,\"%s\")",codes[j], clencode(vs));
|
2002-03-31 13:09:23 +00:00
|
|
|
break;
|
2005-02-03 20:44:17 +00:00
|
|
|
case 'd': /* int */
|
2002-03-31 13:09:23 +00:00
|
|
|
vd = va_arg(ap, int);
|
2005-08-28 09:42:08 +00:00
|
|
|
snprintf(tmp1, MAXSTR -1, "@(setvar,%c,%d)",codes[j],vd);
|
2002-03-31 13:09:23 +00:00
|
|
|
break;
|
2005-02-03 20:44:17 +00:00
|
|
|
case 'c': /* char */
|
2002-05-02 17:19:49 +00:00
|
|
|
vc = va_arg(ap, int);
|
2005-08-28 09:42:08 +00:00
|
|
|
snprintf(tmp1, MAXSTR -1, "@(setvar,%c,%c)",codes[j],vc);
|
2002-03-31 13:09:23 +00:00
|
|
|
break;
|
2007-02-13 14:28:43 +00:00
|
|
|
case 'f': /* float */
|
2002-03-31 13:09:23 +00:00
|
|
|
vf = va_arg(ap, double);
|
2005-08-28 09:42:08 +00:00
|
|
|
snprintf(tmp1, MAXSTR -1, "@(setvar,%c,%f)",codes[j],vf);
|
2002-03-31 13:09:23 +00:00
|
|
|
break;
|
2005-02-03 20:44:17 +00:00
|
|
|
}
|
|
|
|
dieselrc = diesel(tmp1,tmp2);
|
2007-02-13 14:28:43 +00:00
|
|
|
if (dieselrc) {
|
2005-02-03 20:44:17 +00:00
|
|
|
Syslog('!', "MacroVars error %d argument %d, macro %c type %c", dieselrc, j, codes[j], fmt[j]);
|
|
|
|
Syslogp('!', printable(tmp1, 0));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
va_end(ap);
|
|
|
|
|
|
|
|
free(tmp1);
|
|
|
|
free(tmp2);
|
2002-03-31 13:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MacroClear(void)
|
|
|
|
{
|
|
|
|
int dieselrc;
|
|
|
|
char tmp1[] = "@(CLEAR)", *tmp2;
|
|
|
|
|
|
|
|
tmp2 = calloc(10,sizeof(char));
|
|
|
|
dieselrc = diesel(tmp1, tmp2);
|
|
|
|
if (dieselrc)
|
|
|
|
Syslog('!', "MacroClear error %d", dieselrc);
|
|
|
|
free(tmp2);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char *ParseMacro( const char *line, int *dieselrc)
|
|
|
|
{
|
2002-04-10 20:29:57 +00:00
|
|
|
static char res[MAXSTR];
|
2007-02-13 14:28:43 +00:00
|
|
|
const char *i;
|
|
|
|
char *tmp1, *tmp2, *tmp3;
|
2002-03-31 13:09:23 +00:00
|
|
|
int j, l;
|
|
|
|
char code;
|
|
|
|
|
|
|
|
res[0]='\0';
|
|
|
|
*dieselrc=0;
|
|
|
|
|
|
|
|
if ( *line == '#' )
|
|
|
|
return res;
|
|
|
|
|
2002-04-10 20:29:57 +00:00
|
|
|
tmp1 = calloc(MAXSTR, sizeof(char));
|
|
|
|
tmp2 = calloc(MAXSTR, sizeof(char));
|
|
|
|
tmp3 = calloc(MAXSTR, sizeof(char));
|
2002-03-31 13:09:23 +00:00
|
|
|
|
|
|
|
tmp1[0]='\0';
|
|
|
|
|
2007-02-13 14:28:43 +00:00
|
|
|
for (i = line; i[0] != '\0'; i++) {
|
2002-03-31 13:09:23 +00:00
|
|
|
if ( (i[0] == '@') && isalpha(i[1]) ){
|
|
|
|
l=2;
|
|
|
|
i++;
|
|
|
|
if (i[0] != '@') {
|
|
|
|
if ((code = i[0]) != '\0' )
|
|
|
|
i++;
|
|
|
|
while (( i[0] == '_') || ( i[0] == '>') || ( i[0] == '<') ){
|
|
|
|
l++;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
i--;
|
2005-08-28 13:34:43 +00:00
|
|
|
snprintf(tmp2, MAXSTR, "@(GETVAR,%c)",code);
|
2002-03-31 13:09:23 +00:00
|
|
|
if (!diesel(tmp2,tmp3)==0){
|
2005-08-28 13:34:43 +00:00
|
|
|
snprintf(tmp3, MAXSTR, "%c%c",'@',code);
|
2002-03-31 13:09:23 +00:00
|
|
|
}
|
|
|
|
if (l>2){
|
|
|
|
if ( *i != '>')
|
|
|
|
l=-l;
|
2005-08-28 13:34:43 +00:00
|
|
|
snprintf(&tmp1[strlen(tmp1)], MAXSTR, "%*.*s", l, l, tmp3);
|
2002-03-31 13:09:23 +00:00
|
|
|
}else{
|
2005-08-28 13:34:43 +00:00
|
|
|
snprintf(&tmp1[strlen(tmp1)], MAXSTR, "%s", tmp3);
|
2002-03-31 13:09:23 +00:00
|
|
|
}
|
|
|
|
}else{
|
|
|
|
tmp1[(j=strlen(tmp1))]='@';
|
|
|
|
tmp1[j+1]='\0';
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
tmp1[(j=strlen(tmp1))]=i[0];
|
|
|
|
tmp1[j+1]='\0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
i = tmp1;
|
2005-08-28 13:34:43 +00:00
|
|
|
snprintf(tmp2, MAXSTR, "%s", tmp1);
|
2002-03-31 13:09:23 +00:00
|
|
|
|
|
|
|
if ((tmp1[0]=='@') && (tmp1[1]=='{')){
|
|
|
|
i++;
|
|
|
|
i++;
|
|
|
|
for (j=2; ((tmp1[j]!='}') && (tmp1[j]!='\0'));j++){
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
if ( (tmp1[j]=='}') ){
|
|
|
|
i++;
|
|
|
|
res[0]='\0';
|
|
|
|
if (j>2)
|
2005-08-28 13:34:43 +00:00
|
|
|
snprintf(res, MAXSTR, "%.*s",j-2, &tmp1[2]);
|
2002-03-31 13:09:23 +00:00
|
|
|
if ((diesel(res,tmp3)!=0) || (atoi(tmp3)==0))
|
2005-08-28 13:34:43 +00:00
|
|
|
snprintf(tmp2, MAXSTR, "@!%s",i);
|
2002-03-31 13:09:23 +00:00
|
|
|
else
|
2005-08-28 13:34:43 +00:00
|
|
|
snprintf(tmp2, MAXSTR, "%s",i);
|
2002-03-31 13:09:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
*dieselrc=diesel(tmp2, res);
|
|
|
|
|
|
|
|
free(tmp1);
|
|
|
|
free(tmp2);
|
|
|
|
free(tmp3);
|
|
|
|
while (isspace(res[strlen(res) - 1])) {
|
|
|
|
res[strlen(res) - 1] = EOS;
|
|
|
|
}
|
|
|
|
if ((res[0] == '@') && (res[1] =='!' ))
|
|
|
|
res[0]='\0';
|
2007-02-13 14:28:43 +00:00
|
|
|
|
|
|
|
cldecode(res);
|
2002-03-31 13:09:23 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-03-29 22:58:53 +00:00
|
|
|
|
2002-04-03 20:29:12 +00:00
|
|
|
/*
|
|
|
|
* Add random fortune cookie to the macrovars
|
|
|
|
*/
|
2002-05-11 15:30:34 +00:00
|
|
|
void Cookie(int);
|
|
|
|
void Cookie(int HtmlMode)
|
2002-04-03 20:29:12 +00:00
|
|
|
{
|
|
|
|
FILE *olf;
|
2002-05-11 15:30:34 +00:00
|
|
|
char *fname, outbuf[256];
|
2005-10-11 20:49:41 +00:00
|
|
|
int recno, records;
|
2002-04-03 20:29:12 +00:00
|
|
|
|
2002-04-27 11:38:59 +00:00
|
|
|
MacroVars("F", "s", "");
|
2002-04-03 20:29:12 +00:00
|
|
|
fname = calloc(PATH_MAX, sizeof(char));
|
2005-08-28 09:42:08 +00:00
|
|
|
snprintf(fname, PATH_MAX -1, "%s/etc/oneline.data", getenv("MBSE_ROOT"));
|
2002-04-03 20:29:12 +00:00
|
|
|
|
|
|
|
if ((olf = fopen(fname, "r")) == NULL) {
|
2002-04-27 11:38:59 +00:00
|
|
|
WriteError("Can't open %s", fname);
|
2002-04-03 20:29:12 +00:00
|
|
|
free(fname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
fread(&olhdr, sizeof(olhdr), 1, olf);
|
|
|
|
fseek(olf, 0, SEEK_END);
|
|
|
|
records = (ftell(olf) - olhdr.hdrsize) / olhdr.recsize;
|
|
|
|
|
|
|
|
if (firstrandom) {
|
|
|
|
srand(getpid());
|
|
|
|
firstrandom = FALSE;
|
|
|
|
}
|
2002-04-27 21:06:51 +00:00
|
|
|
recno = (1+(int) (1.0 * records * rand() / (RAND_MAX + 1.0))) - 1;
|
2002-04-03 20:29:12 +00:00
|
|
|
|
|
|
|
if (fseek(olf, olhdr.hdrsize + (recno * olhdr.recsize), SEEK_SET) == 0) {
|
|
|
|
if (fread(&ol, olhdr.recsize, 1, olf) == 1) {
|
2002-05-11 15:30:34 +00:00
|
|
|
if (HtmlMode) {
|
2005-08-28 09:42:08 +00:00
|
|
|
html_massage(ol.Oneline, outbuf, 255);
|
2002-05-11 15:30:34 +00:00
|
|
|
MacroVars("F", "s", outbuf);
|
|
|
|
} else {
|
|
|
|
MacroVars("F", "s", ol.Oneline);
|
|
|
|
}
|
2002-04-03 20:29:12 +00:00
|
|
|
} else {
|
2002-04-27 11:38:59 +00:00
|
|
|
WriteError("Can't read record %d from %s", recno, fname);
|
2002-04-03 20:29:12 +00:00
|
|
|
}
|
|
|
|
} else {
|
2002-04-27 11:38:59 +00:00
|
|
|
WriteError("Can't seek record %d in %s", recno, fname);
|
2002-04-03 20:29:12 +00:00
|
|
|
}
|
|
|
|
fclose(olf);
|
|
|
|
free(fname);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-04-10 20:29:57 +00:00
|
|
|
/*
|
|
|
|
* Translate ISO 8859-1 characters to named character entities
|
|
|
|
*/
|
2005-08-28 09:42:08 +00:00
|
|
|
void html_massage(char *inbuf, char *outbuf, size_t size)
|
2002-04-10 20:29:57 +00:00
|
|
|
{
|
|
|
|
char *inptr = inbuf;
|
|
|
|
char *outptr = outbuf;
|
|
|
|
|
|
|
|
memset(outbuf, 0, sizeof(outbuf));
|
|
|
|
|
|
|
|
while (*inptr) {
|
|
|
|
|
|
|
|
switch ((unsigned char)*inptr) {
|
|
|
|
|
2005-08-28 09:42:08 +00:00
|
|
|
case '"': snprintf(outptr, size, """); break;
|
|
|
|
case '&': snprintf(outptr, size, "&"); break;
|
|
|
|
case '<': snprintf(outptr, size, "<"); break;
|
|
|
|
case '>': snprintf(outptr, size, ">"); break;
|
|
|
|
case 160: snprintf(outptr, size, " "); break;
|
|
|
|
case 161: snprintf(outptr, size, "¡"); break;
|
|
|
|
case 162: snprintf(outptr, size, "¢"); break;
|
|
|
|
case 163: snprintf(outptr, size, "£"); break;
|
|
|
|
case 164: snprintf(outptr, size, "¤"); break;
|
|
|
|
case 165: snprintf(outptr, size, "¥"); break;
|
|
|
|
case 166: snprintf(outptr, size, "¦"); break;
|
|
|
|
case 167: snprintf(outptr, size, "§"); break;
|
|
|
|
case 168: snprintf(outptr, size, "¨"); break;
|
|
|
|
case 169: snprintf(outptr, size, "©"); break;
|
|
|
|
case 170: snprintf(outptr, size, "ª"); break;
|
|
|
|
case 171: snprintf(outptr, size, "«"); break;
|
|
|
|
case 172: snprintf(outptr, size, "¬"); break;
|
|
|
|
case 173: snprintf(outptr, size, "­"); break;
|
|
|
|
case 174: snprintf(outptr, size, "®"); break;
|
|
|
|
case 175: snprintf(outptr, size, "¯"); break;
|
|
|
|
case 176: snprintf(outptr, size, "°"); break;
|
|
|
|
case 177: snprintf(outptr, size, "&plumin;"); break;
|
|
|
|
case 178: snprintf(outptr, size, "²"); break;
|
|
|
|
case 179: snprintf(outptr, size, "³"); break;
|
|
|
|
case 180: snprintf(outptr, size, "´"); break;
|
|
|
|
case 181: snprintf(outptr, size, "µ"); break;
|
|
|
|
case 182: snprintf(outptr, size, "¶"); break;
|
|
|
|
case 183: snprintf(outptr, size, "·"); break;
|
|
|
|
case 184: snprintf(outptr, size, "¸"); break;
|
|
|
|
case 185: snprintf(outptr, size, "&supl;"); break;
|
|
|
|
case 186: snprintf(outptr, size, "º"); break;
|
|
|
|
case 187: snprintf(outptr, size, "»"); break;
|
|
|
|
case 188: snprintf(outptr, size, "¼"); break;
|
|
|
|
case 189: snprintf(outptr, size, "½"); break;
|
|
|
|
case 190: snprintf(outptr, size, "¾"); break;
|
|
|
|
case 191: snprintf(outptr, size, "¿"); break;
|
|
|
|
case 192: snprintf(outptr, size, "À"); break;
|
|
|
|
case 193: snprintf(outptr, size, "Á"); break;
|
|
|
|
case 194: snprintf(outptr, size, "Â"); break;
|
|
|
|
case 195: snprintf(outptr, size, "Ã"); break;
|
|
|
|
case 196: snprintf(outptr, size, "Ä"); break;
|
|
|
|
case 197: snprintf(outptr, size, "Å"); break;
|
|
|
|
case 198: snprintf(outptr, size, "Æ"); break;
|
|
|
|
case 199: snprintf(outptr, size, "Ç"); break;
|
|
|
|
case 200: snprintf(outptr, size, "È"); break;
|
|
|
|
case 201: snprintf(outptr, size, "É"); break;
|
|
|
|
case 202: snprintf(outptr, size, "Ê"); break;
|
|
|
|
case 203: snprintf(outptr, size, "Ë"); break;
|
|
|
|
case 204: snprintf(outptr, size, "Ì"); break;
|
|
|
|
case 205: snprintf(outptr, size, "Í"); break;
|
|
|
|
case 206: snprintf(outptr, size, "Î"); break;
|
|
|
|
case 207: snprintf(outptr, size, "Ï"); break;
|
|
|
|
case 208: snprintf(outptr, size, "Ð"); break;
|
|
|
|
case 209: snprintf(outptr, size, "Ñ"); break;
|
|
|
|
case 210: snprintf(outptr, size, "Ò"); break;
|
|
|
|
case 211: snprintf(outptr, size, "Ó"); break;
|
|
|
|
case 212: snprintf(outptr, size, "Ô"); break;
|
|
|
|
case 213: snprintf(outptr, size, "Õ"); break;
|
|
|
|
case 214: snprintf(outptr, size, "Ö"); break;
|
|
|
|
case 215: snprintf(outptr, size, "×"); break;
|
|
|
|
case 216: snprintf(outptr, size, "Ø"); break;
|
|
|
|
case 217: snprintf(outptr, size, "Ù"); break;
|
|
|
|
case 218: snprintf(outptr, size, "Ú"); break;
|
|
|
|
case 219: snprintf(outptr, size, "Û"); break;
|
|
|
|
case 220: snprintf(outptr, size, "Ü"); break;
|
|
|
|
case 221: snprintf(outptr, size, "Ý"); break;
|
|
|
|
case 222: snprintf(outptr, size, "Þ"); break;
|
|
|
|
case 223: snprintf(outptr, size, "ß"); break;
|
|
|
|
case 224: snprintf(outptr, size, "à"); break;
|
|
|
|
case 225: snprintf(outptr, size, "á"); break;
|
|
|
|
case 226: snprintf(outptr, size, "â"); break;
|
|
|
|
case 227: snprintf(outptr, size, "ã"); break;
|
|
|
|
case 228: snprintf(outptr, size, "ä"); break;
|
|
|
|
case 229: snprintf(outptr, size, "å"); break;
|
|
|
|
case 230: snprintf(outptr, size, "æ"); break;
|
|
|
|
case 231: snprintf(outptr, size, "ç"); break;
|
|
|
|
case 232: snprintf(outptr, size, "è"); break;
|
|
|
|
case 233: snprintf(outptr, size, "é"); break;
|
|
|
|
case 234: snprintf(outptr, size, "ê"); break;
|
|
|
|
case 235: snprintf(outptr, size, "ë"); break;
|
|
|
|
case 236: snprintf(outptr, size, "ì"); break;
|
|
|
|
case 237: snprintf(outptr, size, "í"); break;
|
|
|
|
case 238: snprintf(outptr, size, "î"); break;
|
|
|
|
case 239: snprintf(outptr, size, "ï"); break;
|
|
|
|
case 240: snprintf(outptr, size, "ð"); break;
|
|
|
|
case 241: snprintf(outptr, size, "ñ"); break;
|
|
|
|
case 242: snprintf(outptr, size, "ò"); break;
|
|
|
|
case 243: snprintf(outptr, size, "ó"); break;
|
|
|
|
case 244: snprintf(outptr, size, "ô"); break;
|
|
|
|
case 245: snprintf(outptr, size, "õ"); break;
|
|
|
|
case 246: snprintf(outptr, size, "ö"); break;
|
|
|
|
case 247: snprintf(outptr, size, "÷"); break;
|
|
|
|
case 248: snprintf(outptr, size, "ø"); break;
|
|
|
|
case 249: snprintf(outptr, size, "ù"); break;
|
|
|
|
case 250: snprintf(outptr, size, "ú"); break;
|
|
|
|
case 251: snprintf(outptr, size, "û"); break;
|
|
|
|
case 252: snprintf(outptr, size, "ü"); break;
|
|
|
|
case 253: snprintf(outptr, size, "ý"); break;
|
|
|
|
case 254: snprintf(outptr, size, "þ"); break;
|
|
|
|
case 255: snprintf(outptr, size, "ÿ"); break;
|
2002-04-10 20:29:57 +00:00
|
|
|
default: *outptr++ = *inptr; *outptr = '\0'; break;
|
|
|
|
}
|
|
|
|
while (*outptr)
|
|
|
|
outptr++;
|
|
|
|
|
|
|
|
inptr++;
|
|
|
|
}
|
|
|
|
*outptr = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FILE *OpenMacro(const char *filename, int Language, int htmlmode)
|
2002-03-29 22:58:53 +00:00
|
|
|
{
|
|
|
|
FILE *pLang, *fi = NULL;
|
2002-04-10 20:29:57 +00:00
|
|
|
char *temp, *aka, linebuf[1024], outbuf[1024];
|
2002-03-29 22:58:53 +00:00
|
|
|
|
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
2002-04-10 20:29:57 +00:00
|
|
|
aka = calloc(81, sizeof(char));
|
2002-03-29 22:58:53 +00:00
|
|
|
temp[0] = '\0';
|
|
|
|
|
|
|
|
if (Language != '\0') {
|
|
|
|
/*
|
|
|
|
* Maybe a valid language character, try to load the language
|
|
|
|
*/
|
2005-08-28 09:42:08 +00:00
|
|
|
snprintf(temp, PATH_MAX -1, "%s/etc/language.data", getenv("MBSE_ROOT"));
|
2002-03-29 22:58:53 +00:00
|
|
|
if ((pLang = fopen(temp, "rb")) == NULL) {
|
|
|
|
WriteError("mbdiesel: Can't open language file: %s", temp);
|
|
|
|
} else {
|
|
|
|
fread(&langhdr, sizeof(langhdr), 1, pLang);
|
|
|
|
|
|
|
|
while (fread(&lang, langhdr.recsize, 1, pLang) == 1) {
|
|
|
|
if ((lang.LangKey[0] == Language) && (lang.Available)) {
|
2005-08-28 09:42:08 +00:00
|
|
|
snprintf(temp, PATH_MAX -1, "%s/%s", lang.MacroPath, filename);
|
2002-03-29 22:58:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(pLang);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Try to open the selected language
|
|
|
|
*/
|
|
|
|
if (temp[0] != '\0')
|
|
|
|
fi = fopen(temp, "r");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If no selected language is loaded, try default language
|
|
|
|
*/
|
|
|
|
if (fi == NULL) {
|
2002-05-18 13:49:55 +00:00
|
|
|
Syslog('-', "Macro file \"%s\" for language %c not found, trying default", filename, Language);
|
2005-08-28 09:42:08 +00:00
|
|
|
snprintf(temp, PATH_MAX -1, "%s/%s", CFG.bbs_macros, filename);
|
2002-03-29 22:58:53 +00:00
|
|
|
fi = fopen(temp,"r");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fi == NULL)
|
2002-03-31 20:07:04 +00:00
|
|
|
WriteError("OpenMacro(%s, %c): not found", filename, Language);
|
2002-03-31 15:04:34 +00:00
|
|
|
else {
|
2005-08-28 09:42:08 +00:00
|
|
|
snprintf(temp, PATH_MAX -1, "%s-%s", OsName(), OsCPU());
|
2002-04-10 20:29:57 +00:00
|
|
|
if (CFG.aka[0].point)
|
2005-08-28 09:42:08 +00:00
|
|
|
snprintf(aka, 80, "%d:%d/%d.%d@%s", CFG.aka[0].zone, CFG.aka[0].net, CFG.aka[0].node, CFG.aka[0].point, CFG.aka[0].domain);
|
2002-04-10 20:29:57 +00:00
|
|
|
else
|
2005-08-28 09:42:08 +00:00
|
|
|
snprintf(aka, 80, "%d:%d/%d@%s", CFG.aka[0].zone, CFG.aka[0].net, CFG.aka[0].node, CFG.aka[0].domain);
|
2002-04-10 20:29:57 +00:00
|
|
|
|
|
|
|
if (htmlmode) {
|
2002-05-18 13:49:55 +00:00
|
|
|
MacroVars("O", "s", temp);
|
2005-08-28 13:34:43 +00:00
|
|
|
snprintf(linebuf, 1024, "%s", CFG.sysop);
|
|
|
|
html_massage(linebuf, outbuf, 1024);
|
2002-05-18 13:49:55 +00:00
|
|
|
MacroVars("U", "s", outbuf);
|
2005-08-28 13:34:43 +00:00
|
|
|
snprintf(linebuf, 1024, "%s", CFG.location);
|
|
|
|
html_massage(linebuf, outbuf, 1024);
|
2002-04-10 20:29:57 +00:00
|
|
|
MacroVars("L", "s", outbuf);
|
2005-08-28 13:34:43 +00:00
|
|
|
snprintf(linebuf, 1024, "%s", CFG.bbs_name);
|
|
|
|
html_massage(linebuf, outbuf, 1024);
|
2002-04-10 20:29:57 +00:00
|
|
|
MacroVars("N", "s", outbuf);
|
2005-08-28 13:34:43 +00:00
|
|
|
snprintf(linebuf, 1024, "%s", CFG.sysop_name);
|
|
|
|
html_massage(linebuf, outbuf, 1024);
|
2002-04-10 20:29:57 +00:00
|
|
|
MacroVars("S", "s", outbuf);
|
2005-08-28 13:34:43 +00:00
|
|
|
snprintf(linebuf, 1024, "%s", CFG.comment);
|
|
|
|
html_massage(linebuf, outbuf, 1024);
|
2002-04-10 20:29:57 +00:00
|
|
|
MacroVars("T", "s", outbuf);
|
|
|
|
} else {
|
2002-05-18 13:49:55 +00:00
|
|
|
MacroVars("L", "s", CFG.location);
|
|
|
|
MacroVars("N", "s", CFG.bbs_name);
|
|
|
|
MacroVars("O", "s", temp);
|
|
|
|
MacroVars("S", "s", CFG.sysop_name);
|
|
|
|
MacroVars("T", "s", CFG.comment);
|
|
|
|
MacroVars("U", "s", CFG.sysop);
|
2002-04-10 20:29:57 +00:00
|
|
|
}
|
2002-05-18 13:49:55 +00:00
|
|
|
MacroVars("H", "s", CFG.www_url);
|
|
|
|
MacroVars("M", "s", CFG.sysdomain);
|
|
|
|
MacroVars("V", "s", VERSION);
|
|
|
|
MacroVars("Y", "s", aka);
|
|
|
|
MacroVars("Z", "d", 0);
|
2002-05-11 15:30:34 +00:00
|
|
|
Cookie(htmlmode);
|
2002-03-31 15:04:34 +00:00
|
|
|
}
|
2002-03-29 22:58:53 +00:00
|
|
|
|
2002-04-10 20:29:57 +00:00
|
|
|
free(aka);
|
2002-03-29 22:58:53 +00:00
|
|
|
free(temp);
|
|
|
|
return fi;
|
|
|
|
}
|
|
|
|
|
|
|
|
|