forked from github/server
Skripting. Neues Message-Handling für NR und CR. Under Development, und per NEW_MESSAGES define gekapselt
This commit is contained in:
parent
6acbbe1321
commit
8e63635098
|
@ -66,7 +66,7 @@ LINK32=link.exe
|
|||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /Za /W4 /Gm /ZI /Od /I ".." /I "../util" /I "../common" /D "_CONSOLE" /D "_MBCS" /D "WIN32" /D "_DEBUG" /D "BETA_CODE" /FR /YX"stdafx.h" /FD /c
|
||||
# ADD CPP /nologo /Za /W4 /Gm /ZI /Od /I ".." /I "../util" /I "../common" /D "_CONSOLE" /D "_MBCS" /D "WIN32" /D "_DEBUG" /FR /YX"stdafx.h" /FD /c
|
||||
# ADD BASE RSC /l 0x407 /d "_DEBUG"
|
||||
# ADD RSC /l 0x407 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
|
|
|
@ -64,7 +64,7 @@ LIB32=link.exe -lib
|
|||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD CPP /nologo /Za /W4 /Z7 /Od /I "../util" /I "../kernel" /I "../.." /I ".." /D "_WINDOWS" /D "WIN32" /D "_DEBUG" /D "BETA_CODE" /FR /YX"stdafx.h" /FD /c
|
||||
# ADD CPP /nologo /Za /W4 /Z7 /Od /I "../util" /I "../kernel" /I "../.." /I ".." /D "_WINDOWS" /D "WIN32" /D "_DEBUG" /FR /YX"stdafx.h" /FD /c
|
||||
# ADD BASE RSC /l 0x407
|
||||
# ADD RSC /l 0x407
|
||||
BSC32=bscmake.exe
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
* $Id: creport.c,v 1.9 2001/02/19 14:19:24 corwin Exp $
|
||||
* $Id: creport.c,v 1.10 2001/02/24 12:50:47 enno Exp $
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2000
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
|
@ -56,7 +56,9 @@
|
|||
|
||||
/* util includes */
|
||||
#include <goodies.h>
|
||||
|
||||
#ifdef NEW_MESSAGES
|
||||
#include <crmessage.h>
|
||||
#endif
|
||||
/* libc includes */
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
@ -88,14 +90,6 @@ cr_output_str_list(FILE * F, const char *title, const strlist * S, faction * f)
|
|||
}
|
||||
}
|
||||
|
||||
#define CTMAXHASH 511
|
||||
struct crtype {
|
||||
struct crtype * nexthash;
|
||||
messagetype * mt;
|
||||
} * crtypes[CTMAXHASH];
|
||||
|
||||
struct crtype * free_crtypes;
|
||||
|
||||
#include "objtypes.h"
|
||||
|
||||
static void
|
||||
|
@ -123,20 +117,33 @@ print_curses(FILE * F, void * obj, typ_t typ, attrib *a, int self)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef OLD_MESSAGES
|
||||
#define CTMAXHASH 511
|
||||
struct crtype {
|
||||
struct crtype * nexthash;
|
||||
struct message_type * mt;
|
||||
} * crtypes[CTMAXHASH];
|
||||
|
||||
static struct crtype * free_crtypes;
|
||||
#endif
|
||||
|
||||
void
|
||||
creport_cleanup(void)
|
||||
{
|
||||
#ifdef OLD_MESSAGES
|
||||
while (free_crtypes) {
|
||||
struct crtype * ct = free_crtypes->nexthash;
|
||||
free_crtypes = ct;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef OLD_MESSAGES
|
||||
static void
|
||||
render_message(FILE * f, faction * receiver, message * m)
|
||||
render_message(FILE * f, faction * receiver, struct message * m)
|
||||
{
|
||||
int i;
|
||||
messagetype * mt = m->type;
|
||||
struct message_type * mt = m->type;
|
||||
struct entry * e = mt->entries;
|
||||
|
||||
if (m->receiver && receiver!=m->receiver) return;
|
||||
|
@ -204,7 +211,7 @@ render_message(FILE * f, faction * receiver, message * m)
|
|||
}
|
||||
|
||||
static void
|
||||
render_messages(FILE * f, void * receiver, message * msgs)
|
||||
render_messages(FILE * f, void * receiver, struct message * msgs)
|
||||
{
|
||||
message * m;
|
||||
for (m=msgs;m;m=m->next) {
|
||||
|
@ -213,7 +220,7 @@ render_messages(FILE * f, void * receiver, message * msgs)
|
|||
}
|
||||
|
||||
static void
|
||||
cr_output_messages(FILE * F, message * msgs, faction * f)
|
||||
cr_output_messages(FILE * F, struct message * msgs, faction * f)
|
||||
{
|
||||
message * m;
|
||||
if (!msgs) return;
|
||||
|
@ -245,7 +252,7 @@ cr_output_messages(FILE * F, message * msgs, faction * f)
|
|||
render_messages(F, f, msgs);
|
||||
}
|
||||
|
||||
extern void rendercr(FILE * f, messagetype * mt, const locale * lang);
|
||||
extern void rendercr(FILE * f, struct messagetype * mt, const locale * lang);
|
||||
|
||||
static void
|
||||
report_crtypes(FILE * f, locale * lang)
|
||||
|
@ -276,6 +283,27 @@ reset_crtypes(void)
|
|||
}
|
||||
}
|
||||
|
||||
#else
|
||||
static void
|
||||
render_messages(FILE * F, faction * f, message_list *msgs)
|
||||
{
|
||||
char buffer[1024];
|
||||
struct mlist* m = msgs->begin;
|
||||
while (m) {
|
||||
if (cr_render(m->msg, f->locale, buffer)==0) fputs(buffer, F);
|
||||
else log_error(("could not render cr-message %p\n", m->msg));
|
||||
m = m->next;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
cr_output_messages(FILE * F, message_list *msgs, faction * f)
|
||||
{
|
||||
render_messages(F, f, msgs);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* prints a building */
|
||||
static void
|
||||
cr_output_buildings(FILE * F, building * b, unit * u, int fno, faction *f)
|
||||
|
@ -714,7 +742,9 @@ report_computer(FILE * F, faction * f)
|
|||
fflush(stdout);
|
||||
}
|
||||
else printf(" - schreibe Computerreport\n");
|
||||
#ifdef OLD_MESSAGES
|
||||
assert(crtypes[0]==NULL);
|
||||
#endif
|
||||
fprintf(F, "VERSION %d\n", C_REPORT_VERSION);
|
||||
fprintf(F, "\"%s\";Spiel\n", global.gamename);
|
||||
fprintf(F, "\"%s\";Konfiguration\n", "Standard");
|
||||
|
@ -992,6 +1022,10 @@ report_computer(FILE * F, faction * f)
|
|||
}
|
||||
} /* region traversal */
|
||||
}
|
||||
#ifdef OLD_MESSAGES
|
||||
report_crtypes(F, f->locale);
|
||||
reset_crtypes();
|
||||
#else
|
||||
/* TODO */
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ LIB32=link.exe -lib
|
|||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD CPP /nologo /Za /W4 /Z7 /Od /I "../kernel" /I "../util" /I "../.." /I ".." /D "_WINDOWS" /D "WIN32" /D "_DEBUG" /D "BETA_CODE" /FR /YX"stdafx.h" /FD /c
|
||||
# ADD CPP /nologo /Za /W4 /Z7 /Od /I "../kernel" /I "../util" /I "../.." /I ".." /D "_WINDOWS" /D "WIN32" /D "_DEBUG" /FR /YX"stdafx.h" /FD /c
|
||||
# ADD BASE RSC /l 0x407
|
||||
# ADD RSC /l 0x407
|
||||
BSC32=bscmake.exe
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
* $Id: report.c,v 1.16 2001/02/12 23:44:30 enno Exp $
|
||||
* $Id: report.c,v 1.17 2001/02/24 12:50:47 enno Exp $
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2000
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
|
@ -65,7 +65,10 @@
|
|||
/* util includes */
|
||||
#include <goodies.h>
|
||||
#include <base36.h>
|
||||
|
||||
#ifdef NEW_MESSAGES
|
||||
#include <nrmessage.h>
|
||||
#include <util/message.h>
|
||||
#endif
|
||||
/* libc includes */
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
|
@ -721,14 +724,18 @@ rpunit(FILE * F, const faction * f, const unit * u, int indent, int mode)
|
|||
}
|
||||
|
||||
static void
|
||||
rp_messages(FILE * F, message * msgs, faction * viewer, int indent, boolean centered, boolean categorized)
|
||||
rp_messages(FILE * F, message_list * msgs, faction * viewer, int indent, boolean centered, boolean categorized)
|
||||
{
|
||||
messageclass * category;
|
||||
if (!msgs) return;
|
||||
for (category=msgclasses; category; category=category->next) {
|
||||
int k = 0;
|
||||
message * m;
|
||||
for (m=msgs; m; m=m->next) {
|
||||
#ifdef NEW_MESSAGES
|
||||
struct mlist * m = msgs->begin;
|
||||
#else
|
||||
message_list * m = msgs;
|
||||
#endif
|
||||
while (m) {
|
||||
boolean debug = viewer->options & want(O_DEBUG);
|
||||
if (m->type->section!=category) continue;
|
||||
#ifdef MSG_LEVELS
|
||||
|
@ -772,6 +779,7 @@ rp_messages(FILE * F, message * msgs, faction * viewer, int indent, boolean cent
|
|||
}
|
||||
rpsnr(F, s, 2);
|
||||
}
|
||||
m=m->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1547,7 +1555,7 @@ rpline(FILE * F)
|
|||
}
|
||||
|
||||
int
|
||||
fcompare(const void *a, const void *b)
|
||||
fcompare(const void * a, const void * b)
|
||||
{
|
||||
faction * f1 = *(faction**)a;
|
||||
faction * f2 = *(faction**)b;
|
||||
|
@ -2567,7 +2575,6 @@ struct fsee {
|
|||
} * see;
|
||||
} * fsee[FMAXHASH];
|
||||
|
||||
|
||||
void
|
||||
reports(void)
|
||||
{
|
||||
|
|
|
@ -64,7 +64,7 @@ LIB32=link.exe -lib
|
|||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD CPP /nologo /Za /W4 /Z7 /Od /I "../kernel" /I "../util" /I "../.." /I ".." /D "_WINDOWS" /D "WIN32" /D "_DEBUG" /D "BETA_CODE" /FR /YX"stdafx.h" /FD /c
|
||||
# ADD CPP /nologo /Za /W4 /Z7 /Od /I "../kernel" /I "../util" /I "../.." /I ".." /D "_WINDOWS" /D "WIN32" /D "_DEBUG" /FR /YX"stdafx.h" /FD /c
|
||||
# ADD BASE RSC /l 0x407
|
||||
# ADD RSC /l 0x407
|
||||
BSC32=bscmake.exe
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
* $Id: battle.c,v 1.18 2001/02/18 19:07:31 katze Exp $
|
||||
* $Id: battle.c,v 1.19 2001/02/24 12:50:47 enno Exp $
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2000
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
|
@ -196,7 +196,7 @@ fleeregion(const unit * u)
|
|||
}
|
||||
|
||||
static void
|
||||
brecord(faction * f, region * r, message * m)
|
||||
brecord(faction * f, region * r, struct message * m)
|
||||
{
|
||||
if (!f->battles || f->battles->r!=r) {
|
||||
struct bmsg * bm = calloc(1, sizeof(struct bmsg));
|
||||
|
@ -257,7 +257,7 @@ battlerecord(battle * b, const char *s)
|
|||
s = gc_add(strdup(s));
|
||||
for (bf = b->factions;bf;bf=bf->next) {
|
||||
faction * f = bf->faction;
|
||||
message * m = new_message(f, "msg_battle%s:string", s);
|
||||
struct message * m = new_message(f, "msg_battle%s:string", s);
|
||||
brecord(f, b->region, m);
|
||||
}
|
||||
}
|
||||
|
@ -532,7 +532,7 @@ reportcasualties(battle * b, fighter * fig)
|
|||
fbattlerecord(fig->unit->faction, fig->unit->region, " ");
|
||||
for (bf = b->factions;bf;bf=bf->next) {
|
||||
faction * f = bf->faction;
|
||||
message * m = new_message(f, "casualties%u:unit%r:runto%i:run%i:alive%i:fallen",
|
||||
struct message * m = new_message(f, "casualties%u:unit%r:runto%i:run%i:alive%i:fallen",
|
||||
fig->unit, fig->run_to, fig->run_number, fig->alive, fig->unit->number - fig->alive - fig->run_number);
|
||||
brecord(f, fig->unit->region, m);
|
||||
}
|
||||
|
@ -678,11 +678,7 @@ weapon_effskill(troop t, troop enemy, const weapon * w, boolean attacking, boole
|
|||
/* Burgenbonus, Pferdebonus */
|
||||
if (riding(t) && (wtype==NULL || !fval(wtype, WTF_MISSILE))) {
|
||||
skill += 2;
|
||||
#ifdef BETA_CODE
|
||||
if (wtype) skill = skillmod(urace(tu)->attribs, tu, tu->region, wtype->skill, skill, SMF_RIDING);
|
||||
#else
|
||||
if (tu->race == RC_TROLL) skill--;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (t.index<tf->elvenhorses) {
|
||||
|
@ -2196,7 +2192,7 @@ aftermath(battle * b)
|
|||
}
|
||||
#ifdef SHOW_KILLS
|
||||
if (df->hits + df->kills) {
|
||||
message * m = new_message(du->faction, "killsandhits%u:unit%i:hits%i:kills", du, df->hits, df->kills);
|
||||
struct message * m = new_message(du->faction, "killsandhits%u:unit%i:hits%i:kills", du, df->hits, df->kills);
|
||||
brecord(du->faction, b->region, m);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
* $Id: eressea.c,v 1.21 2001/02/22 21:46:44 enno Exp $
|
||||
* $Id: eressea.c,v 1.22 2001/02/24 12:50:48 enno Exp $
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2000
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
|
@ -422,7 +422,11 @@ ffindhash(int no)
|
|||
void
|
||||
stripfaction (faction * f)
|
||||
{
|
||||
#ifdef OLD_MESSAGES
|
||||
free_messages(f->msgs);
|
||||
#else
|
||||
/* TODO */
|
||||
#endif
|
||||
/* TODO: free msgs */
|
||||
freestrlist(f->mistakes);
|
||||
freelist(f->allies);
|
||||
|
|
|
@ -21,6 +21,13 @@
|
|||
#ifndef ERESSEA_H
|
||||
#define ERESSEA_H
|
||||
|
||||
#ifndef NEW_MESSAGES
|
||||
#define OLD_MESSAGES
|
||||
#define message_type messagetype
|
||||
#define message_list message
|
||||
#define report_section message
|
||||
#endif
|
||||
|
||||
/* basic types used in the eressea "kernel" */
|
||||
typedef unsigned char order_t;
|
||||
typedef char terrain_t;
|
||||
|
|
|
@ -56,12 +56,11 @@ typedef struct faction {
|
|||
#endif
|
||||
struct unit * units;
|
||||
struct attrib *attribs;
|
||||
|
||||
struct message * msgs;
|
||||
struct message_list * msgs;
|
||||
struct bmsg {
|
||||
struct bmsg * next;
|
||||
struct region * r;
|
||||
struct message * msgs;
|
||||
struct message_list * msgs;
|
||||
} * battles;
|
||||
} faction;
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ LIB32=link.exe -lib
|
|||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD CPP /nologo /Za /W4 /Z7 /Od /I "../util" /I "../.." /I ".." /D "_WINDOWS" /D "WIN32" /D "_DEBUG" /D "BETA_CODE" /FR /YX"stdafx.h" /FD /c
|
||||
# ADD CPP /nologo /Za /W4 /Z7 /Od /I "../util" /I "../.." /I ".." /D "_WINDOWS" /D "WIN32" /D "_DEBUG" /FR /YX"stdafx.h" /FD /c
|
||||
# ADD BASE RSC /l 0x407
|
||||
# ADD RSC /l 0x407
|
||||
BSC32=bscmake.exe
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
* $Id: message.c,v 1.7 2001/02/14 01:38:50 enno Exp $
|
||||
* $Id: message.c,v 1.8 2001/02/24 12:50:48 enno Exp $
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2000
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
|
@ -19,19 +19,32 @@
|
|||
* permission from the authors.
|
||||
*/
|
||||
|
||||
|
||||
/** defines:
|
||||
*
|
||||
* NEW_MESSAGES - new message-classes
|
||||
*
|
||||
*/
|
||||
#include <config.h>
|
||||
#include "eressea.h"
|
||||
#include "message.h"
|
||||
|
||||
/* kernel includes */
|
||||
#include "plane.h"
|
||||
#include "faction.h"
|
||||
#include "unit.h"
|
||||
#include "item.h"
|
||||
#include "building.h"
|
||||
|
||||
/* util includes */
|
||||
#include <goodies.h>
|
||||
#include <base36.h>
|
||||
#ifdef NEW_MESSAGES
|
||||
#include <message.h>
|
||||
#include <nrmessage.h>
|
||||
#include <crmessage.h>
|
||||
#endif
|
||||
|
||||
/* libc includes */
|
||||
#include <stddef.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -41,13 +54,13 @@
|
|||
|
||||
typedef struct warning {
|
||||
struct warning * next;
|
||||
const messageclass * section;
|
||||
const struct messageclass * section;
|
||||
int level;
|
||||
} warning;
|
||||
|
||||
typedef struct msg_setting {
|
||||
struct msg_setting *next;
|
||||
const messagetype *type;
|
||||
const struct message_type *type;
|
||||
int level;
|
||||
} msg_setting;
|
||||
|
||||
|
@ -116,6 +129,200 @@ translate_regions(const char *st, faction * f)
|
|||
return s;
|
||||
}
|
||||
|
||||
#ifdef NEW_MESSAGES
|
||||
message *
|
||||
new_message(struct faction * receiver, const char* sig, ...)
|
||||
/* compatibility function, to keep the old function calls valid *
|
||||
* all old messagetypes are converted into a message with ONLY string parameters,
|
||||
* this function will convert given parameters to a string representation
|
||||
* based on the signature - like render() once did */
|
||||
{
|
||||
const message_type * mtype;
|
||||
va_list marker;
|
||||
const char * signature = strchr(sig, '%');
|
||||
char buffer[128];
|
||||
int i=0;
|
||||
const char * c = sig;
|
||||
const char * args[16];
|
||||
|
||||
strncpy(buffer, sig, signature-sig);
|
||||
buffer[signature-sig] = '\0';
|
||||
mtype = mt_find(buffer);
|
||||
|
||||
if (!mtype) {
|
||||
fprintf(stderr, "trying to create message of unknown type \"%s\"\n", buffer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while(*c!='%') buffer[i++] = *(c++);
|
||||
buffer[i] = 0;
|
||||
|
||||
va_start(marker, sig);
|
||||
while (*c) {
|
||||
char type;
|
||||
char *p = buffer;
|
||||
assert(*c=='%');
|
||||
type = *(++c);
|
||||
/*
|
||||
case 'f': (*ep)->type = IT_FACTION; break;
|
||||
case 'u': (*ep)->type = IT_UNIT; break;
|
||||
case 'r': (*ep)->type = IT_REGION; break;
|
||||
case 'h': (*ep)->type = IT_SHIP; break;
|
||||
case 'b': (*ep)->type = IT_BUILDING; break;
|
||||
case 'X': (*ep)->type = IT_RESOURCETYPE; break;
|
||||
case 'x': (*ep)->type = IT_RESOURCE; break;
|
||||
case 't': (*ep)->type = IT_SKILL; break;
|
||||
case 's': (*ep)->type = IT_STRING; break;
|
||||
case 'i': (*ep)->type = IT_INT; break;
|
||||
case 'd': (*ep)->type = IT_DIRECTION; break;
|
||||
case 'S': (*ep)->type = IT_FSPECIAL; break;
|
||||
*/
|
||||
c+=2;
|
||||
while (*c && isalnum(*(unsigned char*)c)) *(p++) = *(c++);
|
||||
*p = '\0';
|
||||
for (i=0;i!=mtype->nparameters;++i) {
|
||||
if (!strcmp(buffer, mtype->pnames[i])) break;
|
||||
}
|
||||
assert(i!=mtype->nparameters || !"unknown parameter");
|
||||
|
||||
switch(type) {
|
||||
case 's':
|
||||
args[i] = va_arg(marker, const char *);
|
||||
break;
|
||||
case 'i':
|
||||
args[i] = strdup(itoa10(va_arg(marker, int)));
|
||||
break;
|
||||
case 'f':
|
||||
args[i] = factionname(va_arg(marker, const struct faction*));
|
||||
break;
|
||||
case 'u':
|
||||
args[i] = unitname(va_arg(marker, const struct unit*));
|
||||
break;
|
||||
case 'r':
|
||||
args[i] = rname(va_arg(marker, const struct region*), receiver->locale);
|
||||
break;
|
||||
case 'h':
|
||||
args[i] = shipname(va_arg(marker, const struct ship*));
|
||||
break;
|
||||
case 'b':
|
||||
args[i] = buildingname(va_arg(marker, const struct building*));
|
||||
break;
|
||||
case 'X':
|
||||
args[i] = resourcename(va_arg(marker, const resource_type *), 0);
|
||||
break;
|
||||
case 'x':
|
||||
args[i] = resourcename(oldresourcetype[(resource_t)va_arg(marker, resource_t)], 0);
|
||||
break;
|
||||
case 't':
|
||||
args[i] = skillnames[va_arg(marker, skill_t)];
|
||||
break;
|
||||
case 'd':
|
||||
args[i] = directions[i];
|
||||
break;
|
||||
case 'S':
|
||||
default:
|
||||
args[i] = NULL;
|
||||
}
|
||||
}
|
||||
return msg_create(mtype, (void**)args);
|
||||
}
|
||||
|
||||
static void
|
||||
parse_message(char * b, const struct locale * deflocale)
|
||||
{
|
||||
char *m, *a = NULL, message[8192];
|
||||
char * name;
|
||||
char * language;
|
||||
const struct locale * lang;
|
||||
char * section = NULL;
|
||||
int i, level = 0;
|
||||
char * args[16];
|
||||
boolean f_symbol = false;
|
||||
const struct message_type * mtype;
|
||||
|
||||
/* skip comments */
|
||||
if (b[0]=='#' || b[0]==0) return;
|
||||
|
||||
/* the name of this type */
|
||||
name = b;
|
||||
while (*b && *b!=';') ++b;
|
||||
if (!*b) return;
|
||||
*b++ = 0;
|
||||
|
||||
/* the section for this type */
|
||||
section = b;
|
||||
while (*b && *b!=';' && *b!=':') ++b;
|
||||
if (!strcmp(section, "none")) section=NULL;
|
||||
|
||||
/* if available, the level for this type */
|
||||
if (*b==':') {
|
||||
char * x;
|
||||
*b++ = 0;
|
||||
x = b;
|
||||
while (*b && *b!=';') ++b;
|
||||
level=atoi(x);
|
||||
}
|
||||
*b++ = 0;
|
||||
|
||||
/* the locale */
|
||||
language = b;
|
||||
while (*b && *b!=';') ++b;
|
||||
*b++ = 0;
|
||||
if (strlen(language)==0) lang = deflocale;
|
||||
else {
|
||||
lang = find_locale(language);
|
||||
if (!lang) lang = make_locale(language);
|
||||
}
|
||||
/* parse the message */
|
||||
i = 0;
|
||||
m = message;
|
||||
*m++='\"';
|
||||
while (*b) {
|
||||
switch (*b) {
|
||||
case '{':
|
||||
f_symbol = true;
|
||||
a = ++b;
|
||||
break;
|
||||
case '}':
|
||||
*b++ = '\0';
|
||||
args[i] = strdup(a);
|
||||
sprintf(m, "$%s", args[i]);
|
||||
m+=strlen(m);
|
||||
i++;
|
||||
f_symbol = false;
|
||||
break;
|
||||
case ' ':
|
||||
if (f_symbol) {
|
||||
a = ++b;
|
||||
break;
|
||||
}
|
||||
/* fall-through intended */
|
||||
default:
|
||||
if (!f_symbol) {
|
||||
*m++ = *b++;
|
||||
} else b++;
|
||||
}
|
||||
}
|
||||
strcpy(m, "\"");
|
||||
args[i] = NULL;
|
||||
|
||||
/* add the messagetype */
|
||||
mtype = mt_register(mt_new(name, args));
|
||||
nrt_register(mtype, lang, message);
|
||||
crt_register(mtype, lang);
|
||||
}
|
||||
|
||||
void
|
||||
read_messages(FILE * F, const struct locale * lang)
|
||||
{
|
||||
char buf[8192];
|
||||
while (fgets(buf, sizeof(buf), F)) {
|
||||
buf[strlen(buf)-1] = 0; /* \n weg */
|
||||
parse_message(buf, lang);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
void
|
||||
caddmessage(region * r, faction * f, char *s, msg_t mtype, int level)
|
||||
{
|
||||
|
@ -169,6 +376,8 @@ addmessage(region * r, faction * f, const char *s, msg_t mtype, int level)
|
|||
caddmessage(r, f, gc_add(strdup(translate_regions(s, f))), mtype, level);
|
||||
}
|
||||
|
||||
static messagetype * messagetypes;
|
||||
|
||||
void
|
||||
xmistake(const unit * u, const char *s, const char *comment, int mtype)
|
||||
{
|
||||
|
@ -193,8 +402,6 @@ mistake(const unit * u, const char *command, const char *comment, int mtype)
|
|||
xmistake(u, command, gc_add(strdup(translate_regions(comment, u->faction))), mtype);
|
||||
}
|
||||
|
||||
static messagetype * messagetypes;
|
||||
|
||||
extern unsigned int new_hashstring(const char* s);
|
||||
|
||||
int
|
||||
|
@ -288,7 +495,7 @@ messagetype *
|
|||
find_messagetype(const char * name)
|
||||
{
|
||||
messagetype * mt = messagetypes;
|
||||
while(mt && strcmp(mt->name, name)) mt = mt->next;
|
||||
while(mt && strcmp(mt->name, name)!=0) mt = mt->next;
|
||||
return mt;
|
||||
}
|
||||
|
||||
|
@ -358,56 +565,6 @@ new_message(struct faction * receiver, const char* sig, ...)
|
|||
return m;
|
||||
}
|
||||
|
||||
message *
|
||||
add_message(message** pm, message * m)
|
||||
{
|
||||
if (m==NULL) return NULL;
|
||||
m->next = *pm;
|
||||
return (*pm) = m;
|
||||
}
|
||||
|
||||
void
|
||||
free_messages(message * m)
|
||||
{
|
||||
while (m) {
|
||||
message * x = m;
|
||||
m = x->next;
|
||||
free(x->data);
|
||||
free(x);
|
||||
}
|
||||
}
|
||||
|
||||
messageclass * msgclasses;
|
||||
|
||||
const messageclass *
|
||||
mc_add(const char * name)
|
||||
{
|
||||
messageclass ** mcp = &msgclasses;
|
||||
if (name==NULL) return NULL;
|
||||
for (;*mcp;mcp=&(*mcp)->next) {
|
||||
messageclass * mc = *mcp;
|
||||
if (!strcmp(mc->name, name)) break;
|
||||
}
|
||||
if (!*mcp) {
|
||||
messageclass * mc = calloc(sizeof(messageclass), 1);
|
||||
mc->name = strdup(name);
|
||||
*mcp = mc;
|
||||
}
|
||||
return *mcp;
|
||||
}
|
||||
|
||||
const messageclass *
|
||||
mc_find(const char * name)
|
||||
{
|
||||
messageclass ** mcp = &msgclasses;
|
||||
if (name==NULL) return NULL;
|
||||
for (;*mcp;mcp=&(*mcp)->next) {
|
||||
messageclass * mc = *mcp;
|
||||
if (!strcmp(mc->name, name)) break;
|
||||
}
|
||||
return *mcp;
|
||||
}
|
||||
|
||||
int
|
||||
get_msglevel(const struct warning * warnings, const msglevel * levels, const messagetype * mtype)
|
||||
{
|
||||
|
@ -446,6 +603,87 @@ set_msglevel(struct warning ** warnings, const char * type, int level)
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
msg_level(const message * m)
|
||||
{
|
||||
return m->level;
|
||||
}
|
||||
#endif /* NEW_MESSAGES */
|
||||
|
||||
message *
|
||||
add_message(message_list** pm, message * m)
|
||||
{
|
||||
if (m==NULL) return NULL;
|
||||
#ifdef NEW_MESSAGES
|
||||
else {
|
||||
struct mlist * mnew = malloc(sizeof(struct mlist));
|
||||
if (*pm==NULL) {
|
||||
*pm = malloc(sizeof(message_list));
|
||||
(*pm)->end=&(*pm)->begin;
|
||||
}
|
||||
mnew->msg = m;
|
||||
mnew->next = NULL;
|
||||
*((*pm)->end) = mnew;
|
||||
(*pm)->end=&mnew->next;
|
||||
}
|
||||
#else
|
||||
m->next = *pm;
|
||||
*pm = m;
|
||||
#endif
|
||||
return m;
|
||||
}
|
||||
|
||||
void
|
||||
free_messages(message_list * m)
|
||||
{
|
||||
#ifdef NEW_MESSAGES
|
||||
struct mlist * x = m->begin;
|
||||
while (x) {
|
||||
m->begin = x->next;
|
||||
msg_free(x->msg);
|
||||
free(x);
|
||||
}
|
||||
#else
|
||||
while (m) {
|
||||
message_list * x = m;
|
||||
m = x->next;
|
||||
free(x->data);
|
||||
free(x);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
messageclass * msgclasses;
|
||||
|
||||
const messageclass *
|
||||
mc_add(const char * name)
|
||||
{
|
||||
messageclass ** mcp = &msgclasses;
|
||||
if (name==NULL) return NULL;
|
||||
for (;*mcp;mcp=&(*mcp)->next) {
|
||||
messageclass * mc = *mcp;
|
||||
if (!strcmp(mc->name, name)) break;
|
||||
}
|
||||
if (!*mcp) {
|
||||
messageclass * mc = calloc(sizeof(messageclass), 1);
|
||||
mc->name = strdup(name);
|
||||
*mcp = mc;
|
||||
}
|
||||
return *mcp;
|
||||
}
|
||||
|
||||
const messageclass *
|
||||
mc_find(const char * name)
|
||||
{
|
||||
messageclass ** mcp = &msgclasses;
|
||||
if (name==NULL) return NULL;
|
||||
for (;*mcp;mcp=&(*mcp)->next) {
|
||||
messageclass * mc = *mcp;
|
||||
if (!strcmp(mc->name, name)) break;
|
||||
}
|
||||
return *mcp;
|
||||
}
|
||||
|
||||
void
|
||||
write_msglevels(struct warning * warnings, FILE * F)
|
||||
{
|
||||
|
@ -477,9 +715,3 @@ read_msglevels(struct warning ** w, FILE * F)
|
|||
fscanf(F, "%s", buf);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
msg_level(const message * m)
|
||||
{
|
||||
return m->level;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
* $Id: message.h,v 1.3 2001/02/10 19:24:05 enno Exp $
|
||||
* $Id: message.h,v 1.4 2001/02/24 12:50:48 enno Exp $
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2000
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
|
@ -15,20 +15,30 @@
|
|||
#ifndef MESSAGE_H
|
||||
#define MESSAGE_H
|
||||
|
||||
typedef struct messageclass
|
||||
{
|
||||
struct messageclass * next;
|
||||
const char * name;
|
||||
} messageclass;
|
||||
struct faction;
|
||||
struct warning;
|
||||
|
||||
extern messageclass * msgclasses;
|
||||
extern const messageclass * mc_add(const char * name);
|
||||
extern const messageclass * mc_find(const char * name);
|
||||
struct message;
|
||||
struct messageclass;
|
||||
struct warning;
|
||||
struct msglevel;
|
||||
|
||||
#ifdef NEW_MESSAGES
|
||||
struct message_type;
|
||||
|
||||
typedef struct message_list {
|
||||
struct mlist {
|
||||
struct mlist * next;
|
||||
struct message *msg;
|
||||
} * begin, **end;
|
||||
} message_list;
|
||||
|
||||
#else /* NEW_MESSAGES */
|
||||
|
||||
typedef struct messagetype
|
||||
{
|
||||
struct messagetype * next;
|
||||
const messageclass * section;
|
||||
const struct messageclass * section;
|
||||
int level;
|
||||
char * name;
|
||||
int argc;
|
||||
|
@ -55,39 +65,49 @@ typedef struct messagetype
|
|||
unsigned int hashkey;
|
||||
} messagetype;
|
||||
|
||||
typedef struct msglevel {
|
||||
/* used to set specialized msg-levels */
|
||||
struct msglevel *next;
|
||||
const messagetype *type;
|
||||
int level;
|
||||
} msglevel;
|
||||
|
||||
extern messagetype * find_messagetype(const char * name);
|
||||
extern messagetype * new_messagetype(const char * name, int level, const char * section);
|
||||
extern struct messagetype * find_messagetype(const char * name);
|
||||
extern struct messagetype * new_messagetype(const char * name, int level, const char * section);
|
||||
|
||||
typedef struct message {
|
||||
struct message * next;
|
||||
messagetype * type;
|
||||
struct messagetype * type;
|
||||
void ** data;
|
||||
void * receiver;
|
||||
int level;
|
||||
} message;
|
||||
|
||||
struct faction;
|
||||
struct warning;
|
||||
extern int msg_level(const struct message * msg);
|
||||
|
||||
extern int msg_level(const message * msg);
|
||||
int get_msglevel(const struct warning * warnings, const struct msglevel * levels, const struct messagetype * mtype);
|
||||
|
||||
extern message * add_message(message** pm, message * m);
|
||||
extern message * new_message(struct faction * receiver, const char * signature, ...);
|
||||
void debug_messagetypes(FILE * out);
|
||||
#endif /* NEW_MESSAGES */
|
||||
|
||||
extern void free_messages(message * m);
|
||||
typedef struct messageclass
|
||||
{
|
||||
struct messageclass * next;
|
||||
const char * name;
|
||||
} messageclass;
|
||||
|
||||
typedef struct msglevel {
|
||||
/* used to set specialized msg-levels */
|
||||
struct msglevel *next;
|
||||
const struct message_type *type;
|
||||
int level;
|
||||
} msglevel;
|
||||
|
||||
void write_msglevels(struct warning * warnings, FILE * F);
|
||||
void read_msglevels(struct warning ** w, FILE * F);
|
||||
void set_msglevel(struct warning ** warnings, const char * type, int level);
|
||||
int get_msglevel(const struct warning * warnings, const msglevel * levels, const messagetype * mtype);
|
||||
|
||||
void debug_messagetypes(FILE * out);
|
||||
extern struct message * new_message(struct faction * receiver, const char * signature, ...);
|
||||
extern struct message* add_message(struct message_list** pm, struct message* m);
|
||||
extern void free_messages(struct message_list * m);
|
||||
extern void read_messages(FILE * F, const struct locale * lang);
|
||||
|
||||
/* message sections */
|
||||
extern struct messageclass * msgclasses;
|
||||
extern const struct messageclass * mc_add(const char * name);
|
||||
extern const struct messageclass * mc_find(const char * name);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
* $Id: race.c,v 1.6 2001/02/18 10:06:09 enno Exp $
|
||||
* $Id: race.c,v 1.7 2001/02/24 12:50:48 enno Exp $
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2000
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
|
@ -1925,7 +1925,5 @@ boolean is_undead(const unit *u)
|
|||
extern void
|
||||
init_races(void)
|
||||
{
|
||||
#ifdef BETA_CODE
|
||||
a_add(&race[RC_TROLL].attribs, make_skillmod(NOSKILL, SMF_RIDING, NULL, 0.0, -1));
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
* $Id: region.h,v 1.4 2001/02/10 19:24:05 enno Exp $
|
||||
* $Id: region.h,v 1.5 2001/02/24 12:50:48 enno Exp $
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2000
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
|
@ -68,7 +68,7 @@ typedef struct region {
|
|||
struct plane *planep;
|
||||
char *display;
|
||||
unsigned int flags;
|
||||
struct message *msgs;
|
||||
struct message_list *msgs;
|
||||
struct attrib *attribs;
|
||||
struct region *nexthash;
|
||||
terrain_t terrain;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
* $Id: render.c,v 1.6 2001/02/11 20:56:20 enno Exp $
|
||||
* $Id: render.c,v 1.7 2001/02/24 12:50:48 enno Exp $
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2000
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
|
@ -23,9 +23,11 @@
|
|||
#include "eressea.h"
|
||||
#include "render.h"
|
||||
|
||||
#include "message.h"
|
||||
|
||||
#ifdef OLD_MESSAGES
|
||||
#include "item.h"
|
||||
#include "faction.h"
|
||||
#include "message.h"
|
||||
#include "language.h"
|
||||
#include "goodies.h"
|
||||
#include "region.h"
|
||||
|
@ -531,13 +533,14 @@ render_init(void)
|
|||
}
|
||||
|
||||
void
|
||||
read_messages(FILE * F)
|
||||
read_messages(FILE * F, const struct locale * deflocale)
|
||||
{
|
||||
unused(deflocale);
|
||||
while (fgets(buf, 8192, F)) {
|
||||
char * b = buf;
|
||||
char * name = b;
|
||||
char * language;
|
||||
static locale * lang;
|
||||
struct locale * lang;
|
||||
char * section = NULL;
|
||||
int level = 0;
|
||||
messagetype * mtype;
|
||||
|
@ -730,3 +733,5 @@ spy_message(int spy, unit *u, unit *target)
|
|||
addmessage(0, u->faction, buf, MSG_EVENT, ML_IMPORTANT);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
* $Id: render.h,v 1.2 2001/01/26 16:19:40 enno Exp $
|
||||
* $Id: render.h,v 1.3 2001/02/24 12:50:48 enno Exp $
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2000
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
|
@ -12,8 +12,10 @@
|
|||
* prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#ifdef OLD_MESSAGES
|
||||
struct message;
|
||||
struct locale;
|
||||
|
||||
extern const char * render(const struct message * m, const struct locale * lang);
|
||||
extern void render_init(void);
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
* $Id: save.c,v 1.21 2001/02/22 21:46:44 enno Exp $
|
||||
* $Id: save.c,v 1.22 2001/02/24 12:50:48 enno Exp $
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2000
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
|
@ -2163,7 +2163,6 @@ extern void inittokens(void);
|
|||
extern void create_teleport_plane(void);
|
||||
|
||||
void read_strings(FILE * F);
|
||||
void read_messages(FILE * F);
|
||||
|
||||
const char * messages[] = {
|
||||
"%s/%s/messages.txt",
|
||||
|
@ -2203,7 +2202,7 @@ init_locales(void)
|
|||
sprintf(zText, messages[i], resourcepath(), locales[l]);
|
||||
F = fopen(zText, "r+");
|
||||
if (F) {
|
||||
read_messages(F);
|
||||
read_messages(F, NULL);
|
||||
fclose(F);
|
||||
} else {
|
||||
sprintf(buf, "fopen(%s): ", zText);
|
||||
|
|
|
@ -64,7 +64,7 @@ LIB32=link.exe -lib
|
|||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD CPP /nologo /Za /W4 /Z7 /Od /I "../kernel" /I "../util" /I "../.." /I ".." /D "_WINDOWS" /D "WIN32" /D "_DEBUG" /D "BETA_CODE" /FR /YX"stdafx.h" /FD /c
|
||||
# ADD CPP /nologo /Za /W4 /Z7 /Od /I "../kernel" /I "../util" /I "../.." /I ".." /D "_WINDOWS" /D "WIN32" /D "_DEBUG" /FR /YX"stdafx.h" /FD /c
|
||||
# ADD BASE RSC /l 0x407
|
||||
# ADD RSC /l 0x407
|
||||
BSC32=bscmake.exe
|
||||
|
|
|
@ -64,7 +64,7 @@ LIB32=link.exe -lib
|
|||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD CPP /nologo /Za /W4 /Z7 /Od /I "../kernel" /I "../util" /I "../.." /I ".." /D "_WINDOWS" /D "WIN32" /D "_DEBUG" /D "BETA_CODE" /FR /YX"stdafx.h" /FD /c
|
||||
# ADD CPP /nologo /Za /W4 /Z7 /Od /I "../kernel" /I "../util" /I "../.." /I ".." /D "_WINDOWS" /D "WIN32" /D "_DEBUG" /FR /YX"stdafx.h" /FD /c
|
||||
# ADD BASE RSC /l 0x407
|
||||
# ADD RSC /l 0x407
|
||||
BSC32=bscmake.exe
|
||||
|
|
|
@ -64,7 +64,7 @@ LIB32=link.exe -lib
|
|||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD CPP /nologo /Za /W4 /Z7 /Od /I "../kernel" /I "../util" /I "../.." /I ".." /D "_WINDOWS" /D "WIN32" /D "_DEBUG" /D "BETA_CODE" /FR /YX"stdafx.h" /FD /c
|
||||
# ADD CPP /nologo /Za /W4 /Z7 /Od /I "../kernel" /I "../util" /I "../.." /I ".." /D "_WINDOWS" /D "WIN32" /D "_DEBUG" /FR /YX"stdafx.h" /FD /c
|
||||
# ADD BASE RSC /l 0x407
|
||||
# ADD RSC /l 0x407
|
||||
BSC32=bscmake.exe
|
||||
|
|
|
@ -64,7 +64,7 @@ LIB32=link.exe -lib
|
|||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD CPP /nologo /Za /W4 /Z7 /Od /I "../util" /I "../kernel" /I "../.." /I ".." /D "_WINDOWS" /D "WIN32" /D "_DEBUG" /D "BETA_CODE" /FR /YX"stdafx.h" /FD /c
|
||||
# ADD CPP /nologo /Za /W4 /Z7 /Od /I "../util" /I "../kernel" /I "../.." /I ".." /D "_WINDOWS" /D "WIN32" /D "_DEBUG" /FR /YX"stdafx.h" /FD /c
|
||||
# ADD BASE RSC /l 0x407
|
||||
# ADD RSC /l 0x407
|
||||
BSC32=bscmake.exe
|
||||
|
|
|
@ -0,0 +1,141 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea-pbem.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2001 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
$Id: crmessage.c,v 1.1 2001/02/24 12:50:50 enno Exp $
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "crmessage.h"
|
||||
|
||||
#include "message.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
/** type to string conversion **/
|
||||
typedef struct tsf_list {
|
||||
struct tsf_list * next;
|
||||
const char * name;
|
||||
tostring_f fun;
|
||||
} tsf_list;
|
||||
|
||||
static tsf_list * tostringfs;
|
||||
|
||||
static tostring_f
|
||||
tsf_find(const char * name)
|
||||
{
|
||||
if (name!=NULL) {
|
||||
tsf_list * tsf;
|
||||
for (tsf=tostringfs;tsf;tsf=tsf->next) {
|
||||
if (!strcmp(tsf->name, name)) return tsf->fun;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
tsf_register(const char * name, tostring_f fun)
|
||||
{
|
||||
tsf_list * tsf;
|
||||
for (tsf=tostringfs;tsf;tsf=tsf->next) {
|
||||
if (!strcmp(tsf->name, name)) break;
|
||||
}
|
||||
if (tsf==NULL) {
|
||||
tsf = malloc(sizeof(tsf_list));
|
||||
tsf->fun = fun;
|
||||
tsf->name = name;
|
||||
tsf->next = tostringfs;
|
||||
tostringfs = tsf;
|
||||
}
|
||||
}
|
||||
|
||||
/** crmesssage **/
|
||||
typedef struct crmessage_type {
|
||||
const struct message_type * mtype;
|
||||
const struct locale * lang;
|
||||
tostring_f * renderers;
|
||||
struct crmessage_type * next;
|
||||
} crmessage_type;
|
||||
|
||||
static crmessage_type * messagetypes;
|
||||
|
||||
static crmessage_type *
|
||||
crt_find(const struct locale * lang, const struct message_type * mtype)
|
||||
{
|
||||
crmessage_type * found = NULL;
|
||||
crmessage_type * type = messagetypes;
|
||||
while (type) {
|
||||
if (type->mtype==mtype) {
|
||||
if (found==NULL) found = type;
|
||||
else if (type->lang==NULL) found = type;
|
||||
if (lang==type->lang) break;
|
||||
}
|
||||
type = type->next;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
void
|
||||
crt_register(const struct message_type * mtype, const struct locale * lang)
|
||||
{
|
||||
crmessage_type * crt = messagetypes;
|
||||
while (crt && (crt->lang!=lang || crt->mtype!=mtype)) {
|
||||
crt = crt->next;
|
||||
}
|
||||
if (!crt) {
|
||||
int i;
|
||||
crt = malloc(sizeof(crmessage_type));
|
||||
crt->lang = lang;
|
||||
crt->mtype = mtype;
|
||||
crt->next = messagetypes;
|
||||
messagetypes = crt;
|
||||
crt->renderers = malloc(sizeof(tostring_f)*mtype->nparameters);
|
||||
|
||||
/* TODO: can be scrapped for memory vs. speed */
|
||||
for (i=0;i!=mtype->nparameters;++i) {
|
||||
crt->renderers[i] = tsf_find(mtype->types[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
cr_render(const message * msg, const struct locale * lang, char * buffer)
|
||||
{
|
||||
int i;
|
||||
char * c = buffer;
|
||||
struct crmessage_type * crt = crt_find(lang, msg->type);
|
||||
|
||||
if (crt==NULL) return -1;
|
||||
for (i=0;i!=msg->type->nparameters;++i) {
|
||||
if (crt->renderers[i]==NULL) {
|
||||
strcpy(c, (const char*)msg->parameters[i]);
|
||||
} else {
|
||||
crt->renderers[i](msg->parameters[i], c);
|
||||
}
|
||||
c += strlen(c);
|
||||
sprintf(c, ";%s\n", msg->type->pnames[i]);
|
||||
c += strlen(c);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
cr_string(const void * v, char * buffer)
|
||||
{
|
||||
sprintf(buffer, "\"%s\"", (const char *)v);
|
||||
}
|
||||
|
||||
void
|
||||
cr_int(const void * v, char * buffer)
|
||||
{
|
||||
sprintf(buffer, "%d", (int)v);
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea-pbem.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2001 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
struct locale;
|
||||
struct message;
|
||||
struct message_type;
|
||||
|
||||
typedef void (*tostring_f)(const void * data, char * buffer);
|
||||
extern void tsf_register(const char * name, tostring_f fun);
|
||||
/* registers a new type->string-function */
|
||||
|
||||
extern void cr_string(const void * v, char * buffer);
|
||||
extern void cr_int(const void * v, char * buffer);
|
||||
|
||||
extern void crt_register(const struct message_type * mtype, const struct locale * lang);
|
||||
extern int cr_render(const struct message * msg, const struct locale * lang, char * buffer);
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea-pbem.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2001 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
$Id: message.c,v 1.1 2001/02/24 12:50:50 enno Exp $
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "message.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
message_type *
|
||||
mt_new(const char * name, const char * args[])
|
||||
{
|
||||
int i, nparameters;
|
||||
message_type * mtype = (message_type *)malloc(sizeof(message_type));
|
||||
|
||||
for (nparameters=0;args[nparameters];++nparameters);
|
||||
|
||||
mtype->name = strdup(name);
|
||||
mtype->nparameters = nparameters;
|
||||
mtype->pnames = (char**)malloc(sizeof(char*) * nparameters);
|
||||
mtype->types = (char**)malloc(sizeof(char*) * nparameters);
|
||||
for (i=0;args[i];++i) {
|
||||
const char * x = args[i];
|
||||
const char * spos = strchr(x, ':');
|
||||
if (spos==NULL) {
|
||||
mtype->pnames[i] = strdup(x);
|
||||
mtype->types[i] = NULL;
|
||||
} else {
|
||||
char * cp = strncpy(malloc(spos-x+1), x, spos-x);
|
||||
cp[spos-x] = '\0';
|
||||
mtype->pnames[i] = cp;
|
||||
/* optimierung: Typ-Strings zentral verwalten. */
|
||||
mtype->types[i] = strdup(spos+1);
|
||||
}
|
||||
}
|
||||
return mtype;
|
||||
}
|
||||
|
||||
message_type *
|
||||
mt_new_va(const char * name, ...)
|
||||
{
|
||||
const char * args[16];
|
||||
int i = 0;
|
||||
va_list marker;
|
||||
|
||||
va_start(marker, name);
|
||||
for (;;) {
|
||||
const char * c = va_arg(marker, const char*);
|
||||
args[i++] = c;
|
||||
if (c==NULL) break;
|
||||
}
|
||||
va_end(marker);
|
||||
return mt_new(name, args);
|
||||
}
|
||||
|
||||
message *
|
||||
msg_create(const struct message_type * type, void * args[])
|
||||
{
|
||||
int i;
|
||||
message * msg = (message *)malloc(sizeof(message));
|
||||
msg->type = type;
|
||||
msg->parameters = calloc(sizeof(void*), type->nparameters);
|
||||
for (i=0;i!=type->nparameters;++i) {
|
||||
msg->parameters[i] = args[i];
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
message *
|
||||
msg_create_va(const struct message_type * type, ...)
|
||||
/* sets a messages parameters */
|
||||
{
|
||||
void * args[16];
|
||||
va_list marker;
|
||||
int i;
|
||||
va_start(marker, type);
|
||||
for (i=0;i!=type->nparameters;++i) {
|
||||
args[i] = va_arg(marker, void*);
|
||||
}
|
||||
va_end(marker);
|
||||
return msg_create(type, args);
|
||||
}
|
||||
|
||||
typedef struct messagetype_list {
|
||||
struct messagetype_list * next;
|
||||
const message_type * type;
|
||||
} messagetype_list;
|
||||
|
||||
static messagetype_list * messagetypes;
|
||||
|
||||
const message_type *
|
||||
mt_register(const message_type * type)
|
||||
{
|
||||
messagetype_list * mtl = messagetypes;
|
||||
while (mtl && mtl->type!=type) mtl=mtl->next;
|
||||
if (mtl==NULL) {
|
||||
mtl = malloc(sizeof(messagetype_list));
|
||||
mtl->type = type;
|
||||
mtl->next = messagetypes;
|
||||
messagetypes = mtl;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
const message_type *
|
||||
mt_find(const char * name)
|
||||
{
|
||||
messagetype_list * mtl = messagetypes;
|
||||
while (mtl && strcmp(mtl->type->name, name)!=0) mtl=mtl->next;
|
||||
return mtl?mtl->type:NULL;
|
||||
}
|
||||
|
||||
void
|
||||
msg_free(message *m)
|
||||
{
|
||||
free((void*)m->parameters);
|
||||
free(m);
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea-pbem.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2001 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
struct locale;
|
||||
|
||||
typedef struct message_type {
|
||||
const char * name;
|
||||
int nparameters;
|
||||
const char ** pnames;
|
||||
const char ** types;
|
||||
} message_type;
|
||||
|
||||
typedef struct message {
|
||||
const struct message_type * type;
|
||||
const void ** parameters;
|
||||
} message;
|
||||
|
||||
extern struct message_type * mt_new(const char * name, const char * args[]);
|
||||
extern struct message_type * mt_new_va(const char * name, ...);
|
||||
/* mt_new("simple_sentence", "subject:string", "predicate:string",
|
||||
* "object:string", "lang:locale", NULL); */
|
||||
|
||||
extern struct message * msg_create(const struct message_type * type, void * args[]);
|
||||
extern struct message * msg_create_va(const struct message_type * type, ...);
|
||||
/* msg_create(&mt_simplesentence, "enno", "eats", "chocolate", &locale_de);
|
||||
* parameters must be in the same order as they were for mt_new! */
|
||||
extern void msg_free(struct message *m);
|
||||
/* remove message and associated data from memory */
|
||||
|
||||
/** message_type registry (optional): **/
|
||||
extern const struct message_type * mt_register(const struct message_type *);
|
||||
extern const struct message_type * mt_find(const char *);
|
|
@ -0,0 +1,85 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea-pbem.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2001 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
$Id: nrmessage.c,v 1.1 2001/02/24 12:50:50 enno Exp $
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "nrmessage.h"
|
||||
|
||||
#include "message.h"
|
||||
#include "translation.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
typedef struct nrmessage_type {
|
||||
const struct message_type * mtype;
|
||||
const struct locale * lang;
|
||||
const char * string;
|
||||
const char * vars;
|
||||
struct nrmessage_type * next;
|
||||
} nrmessage_type;
|
||||
|
||||
static nrmessage_type * messagetypes;
|
||||
|
||||
static nrmessage_type *
|
||||
nrt_find(const struct locale * lang, const struct message_type * mtype)
|
||||
{
|
||||
nrmessage_type * found = NULL;
|
||||
nrmessage_type * type = messagetypes;
|
||||
while (type) {
|
||||
if (type->mtype==mtype) {
|
||||
if (found==NULL) found = type;
|
||||
else if (type->lang==NULL) found = type;
|
||||
if (lang==type->lang) break;
|
||||
}
|
||||
type = type->next;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
void
|
||||
nrt_register(const struct message_type * mtype, const struct locale * lang, const char * string)
|
||||
{
|
||||
nrmessage_type * nrt = messagetypes;
|
||||
while (nrt && (nrt->lang!=lang || nrt->mtype!=mtype)) {
|
||||
nrt = nrt->next;
|
||||
}
|
||||
if (!nrt) {
|
||||
int i;
|
||||
char zNames[256];
|
||||
char * c = zNames;
|
||||
nrt = malloc(sizeof(nrmessage_type));
|
||||
nrt->lang = lang;
|
||||
nrt->mtype = mtype;
|
||||
nrt->next = messagetypes;
|
||||
messagetypes = nrt;
|
||||
nrt->string = strdup(string);
|
||||
for (i=0;i!=mtype->nparameters;++i) {
|
||||
if (i!=0) *c++ = ' ';
|
||||
c+= strlen(strcpy(c, mtype->pnames[i]));
|
||||
}
|
||||
nrt->vars = strdup(zNames);
|
||||
/* TODO: really necessary to strdup them all? here? better to extend va_translate! */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
nr_render(const struct message * msg, const struct locale * lang, char * buffer)
|
||||
{
|
||||
struct nrmessage_type * nrt = nrt_find(lang, msg->type);
|
||||
|
||||
if (nrt) {
|
||||
strcpy(buffer, translate(nrt->string, nrt->vars, msg->parameters));
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea-pbem.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2001 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
struct locale;
|
||||
struct message;
|
||||
struct message_type;
|
||||
struct nrmessage_type;
|
||||
|
||||
extern int nr_render(const struct message * msg, const struct locale * lang,
|
||||
char * buffer);
|
||||
extern void nrt_register(const struct message_type * mtype,
|
||||
const struct locale * lang, const char * script);
|
||||
|
||||
/* before:
|
||||
* fogblock;movement:0;de;{unit} konnte von {region} nicht nach {$dir direction} ausreisen, der Nebel war zu dicht.
|
||||
* after:
|
||||
* fogblock:movement:0
|
||||
* $unit($unit) konnte von $region($region) nicht nach $direction($direction) ausreisen, der Nebel war zu dicht.
|
||||
* unit:unit region:region direction:int
|
||||
*/
|
|
@ -0,0 +1,452 @@
|
|||
#include <config.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
/**
|
||||
** simple operand stack
|
||||
**/
|
||||
|
||||
typedef struct opstack {
|
||||
struct opstack * next;
|
||||
void * data;
|
||||
} opstack;
|
||||
|
||||
void *
|
||||
opstack_pop(opstack ** stack)
|
||||
{
|
||||
opstack * os = *stack;
|
||||
void * data;
|
||||
assert(os);
|
||||
data = os->data;
|
||||
*stack = os->next;
|
||||
free(os);
|
||||
return data;
|
||||
}
|
||||
|
||||
void
|
||||
opstack_push(opstack ** stack, void * data)
|
||||
{
|
||||
opstack * os = (opstack*)malloc(sizeof(opstack));
|
||||
os->next = *stack;
|
||||
os->data = data;
|
||||
*stack = os;
|
||||
}
|
||||
|
||||
static opstack * stack;
|
||||
|
||||
#define opush(i) opstack_push(&stack, (void *)(i))
|
||||
#define opop(T) (T)opstack_pop(&stack)
|
||||
|
||||
/**
|
||||
** static buffer malloc
|
||||
**/
|
||||
|
||||
#define BUFSIZE 128*1024
|
||||
static struct {
|
||||
char * begin;
|
||||
char * end;
|
||||
char * last;
|
||||
char * current;
|
||||
} buffer;
|
||||
|
||||
char *
|
||||
balloc(size_t size)
|
||||
{
|
||||
static int init = 0;
|
||||
if (!init) {
|
||||
init = 1;
|
||||
buffer.current = buffer.begin = malloc(BUFSIZE);
|
||||
buffer.end = buffer.begin + BUFSIZE;
|
||||
}
|
||||
if (buffer.current + size > buffer.end) {
|
||||
/* out of memory! */
|
||||
return NULL;
|
||||
}
|
||||
buffer.last = buffer.current;
|
||||
buffer.current +=size;
|
||||
return buffer.last;
|
||||
}
|
||||
|
||||
void
|
||||
bfree(char * c)
|
||||
/* only release this memory if it was part of the last allocation
|
||||
* that's a joke, but who cares.
|
||||
*/
|
||||
{
|
||||
if (c>=buffer.last && c<buffer.current) buffer.current = c;
|
||||
}
|
||||
|
||||
void
|
||||
brelease(void)
|
||||
{
|
||||
buffer.last = buffer.current = buffer.begin;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
** constant values
|
||||
**/
|
||||
|
||||
typedef struct variable {
|
||||
struct variable * next;
|
||||
const char * symbol;
|
||||
const void * value;
|
||||
} variable;
|
||||
|
||||
static variable * variables;
|
||||
|
||||
static void
|
||||
free_variables(void)
|
||||
{
|
||||
variables = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
add_variable(const char * symbol, const void * value)
|
||||
{
|
||||
variable * var = (variable*)balloc(sizeof(variable));
|
||||
|
||||
var->value = value;
|
||||
var->symbol = symbol;
|
||||
|
||||
var->next = variables;
|
||||
variables = var;
|
||||
}
|
||||
|
||||
static variable *
|
||||
find_variable(const char * symbol)
|
||||
{
|
||||
variable * var = variables;
|
||||
while (var) {
|
||||
if (!strcmp(var->symbol, symbol)) break;
|
||||
var = var->next;
|
||||
}
|
||||
return var;
|
||||
}
|
||||
|
||||
/**
|
||||
** constant values
|
||||
**/
|
||||
|
||||
typedef void (*evalfun)(void);
|
||||
typedef struct function {
|
||||
struct function * next;
|
||||
const char * symbol;
|
||||
evalfun parse;
|
||||
} function;
|
||||
|
||||
static function * functions;
|
||||
|
||||
static void
|
||||
free_functions(void)
|
||||
{
|
||||
while (functions) {
|
||||
function * fun = functions;
|
||||
functions = fun->next;
|
||||
free(fun);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
add_function(const char * symbol, evalfun parse)
|
||||
{
|
||||
function * fun = (function*)malloc(sizeof(function));
|
||||
|
||||
fun->parse = parse;
|
||||
fun->symbol = symbol;
|
||||
|
||||
fun->next = functions;
|
||||
functions = fun;
|
||||
}
|
||||
|
||||
static function *
|
||||
find_function(const char * symbol)
|
||||
{
|
||||
function * fun = functions;
|
||||
while (fun) {
|
||||
if (!strcmp(fun->symbol, symbol)) break;
|
||||
fun = fun->next;
|
||||
}
|
||||
return fun;
|
||||
}
|
||||
|
||||
static const char * parse(const char* in);
|
||||
static const char * sample = "\"enno and $bool($if($eq($i,0),\"noone else\",\"$i other people\"))\"";
|
||||
|
||||
static const char *
|
||||
parse_symbol(const char* in)
|
||||
/* in is the symbol name and following text, starting after the $
|
||||
* result goes on the stack
|
||||
*/
|
||||
{
|
||||
char symbol[32];
|
||||
char *cp = symbol; /* current position */
|
||||
|
||||
while (isalnum(*in)) *cp++ = *in++;
|
||||
*cp = '\0';
|
||||
/* symbol will now contain the symbol name */
|
||||
if (*in=='(') {
|
||||
/* it's a function we need to parse
|
||||
* start by reading the parameters
|
||||
*/
|
||||
function * foo;
|
||||
while (*in != ')') {
|
||||
in = parse(++in); /* will push the result on the stack */
|
||||
if (in==NULL) return NULL;
|
||||
}
|
||||
++in;
|
||||
foo = find_function(symbol);
|
||||
if (foo==NULL) return NULL;
|
||||
foo->parse(); /* will pop parameters from stack (reverse order!) and push the result */
|
||||
} else {
|
||||
/* it's a constant (variable is a misnomer, but heck, const was taken;)) */
|
||||
variable * var = find_variable(symbol);
|
||||
if (var==NULL) return NULL;
|
||||
opush(var->value);
|
||||
}
|
||||
return in;
|
||||
}
|
||||
|
||||
static const char *
|
||||
parse_string(const char* in) /* (char*) -> char* */
|
||||
{
|
||||
char * c;
|
||||
char * buffer = balloc(4*1024);
|
||||
const char * ic = in;
|
||||
char * oc = buffer;
|
||||
/* mode flags */
|
||||
boolean f_escape = false;
|
||||
boolean bDone = false;
|
||||
|
||||
while (*ic && !bDone) {
|
||||
if (f_escape) {
|
||||
f_escape = false;
|
||||
switch (*ic) {
|
||||
case 'n':
|
||||
*oc++='\n';
|
||||
break;
|
||||
case 't':
|
||||
*oc++='\t';
|
||||
break;
|
||||
default:
|
||||
*oc++=*ic;
|
||||
}
|
||||
} else {
|
||||
int ch = (unsigned char)(*ic);
|
||||
switch (ch) {
|
||||
case '\\':
|
||||
f_escape = true;
|
||||
++ic;
|
||||
break;
|
||||
case '"':
|
||||
bDone = true;
|
||||
++ic;
|
||||
break;
|
||||
case '$':
|
||||
ic = parse_symbol(++ic);
|
||||
if (ic==NULL) return NULL;
|
||||
c = opop(char*);
|
||||
oc += strlen(strcpy(oc, c));
|
||||
bfree(c);
|
||||
break;
|
||||
default:
|
||||
*oc++=*ic++;
|
||||
}
|
||||
}
|
||||
}
|
||||
*oc++ = '\0';
|
||||
bfree(oc);
|
||||
opush(buffer);
|
||||
return ic;
|
||||
}
|
||||
|
||||
static const char *
|
||||
parse_int(const char * in)
|
||||
{
|
||||
int k = 0;
|
||||
int vz = 1;
|
||||
boolean ok = false;
|
||||
do {
|
||||
switch (*in) {
|
||||
case '+':
|
||||
++in;
|
||||
break;
|
||||
case '-':
|
||||
++in;
|
||||
vz=vz*-1;
|
||||
break;
|
||||
default:
|
||||
ok = true;
|
||||
}
|
||||
} while (!ok);
|
||||
while (isdigit(*in)) {
|
||||
k = k * 10 + (*in++)-'0';
|
||||
}
|
||||
opush(k*vz);
|
||||
return in;
|
||||
}
|
||||
|
||||
|
||||
static const char *
|
||||
parse(const char* in)
|
||||
{
|
||||
while (*in) {
|
||||
switch (*in) {
|
||||
case '"':
|
||||
return parse_string(++in);
|
||||
break;
|
||||
case '$':
|
||||
return parse_symbol(++in);
|
||||
break;
|
||||
default:
|
||||
if (isdigit(*in) || *in=='-' || *in=='+') {
|
||||
return parse_int(in);
|
||||
}
|
||||
else ++in;
|
||||
}
|
||||
}
|
||||
return in;
|
||||
}
|
||||
|
||||
char *
|
||||
translate(const char* format, const char* vars, const void* args[])
|
||||
{
|
||||
int i = 0;
|
||||
char * retval;
|
||||
const char *ic = vars;
|
||||
char symbol[32];
|
||||
char *oc = symbol;
|
||||
|
||||
brelease();
|
||||
free_variables();
|
||||
|
||||
assert(isalnum(*ic));
|
||||
while (*ic) {
|
||||
*oc++ = *ic++;
|
||||
if (!isalnum(*ic)) {
|
||||
const void * x = args[i++];
|
||||
*oc = '\0';
|
||||
oc = symbol;
|
||||
add_variable(strcpy(balloc(strlen(symbol)+1), symbol), x);
|
||||
while (*ic && !isalnum(*ic)) ++ic;
|
||||
}
|
||||
}
|
||||
|
||||
if (parse(format)==NULL) return NULL;
|
||||
retval = strdup(opop(const char*));
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
char *
|
||||
translate_va(const char* format, const char* vars, ...)
|
||||
{
|
||||
char * retval;
|
||||
va_list marker;
|
||||
const char *ic = vars;
|
||||
char symbol[32];
|
||||
char *oc = symbol;
|
||||
|
||||
brelease();
|
||||
free_variables();
|
||||
|
||||
va_start(marker, vars); /* Initialize variable arguments. */
|
||||
assert(isalnum(*ic));
|
||||
while (*ic) {
|
||||
*oc++ = *ic++;
|
||||
if (!isalnum(*ic)) {
|
||||
void * x = va_arg(marker, void *);
|
||||
*oc = '\0';
|
||||
oc = symbol;
|
||||
add_variable(strcpy(balloc(strlen(symbol)+1), symbol), x);
|
||||
while (*ic && !isalnum(*ic)) ++ic;
|
||||
}
|
||||
}
|
||||
va_end(marker); /* Reset variable arguments. */
|
||||
|
||||
if (parse(format)==NULL) return NULL;
|
||||
retval = strdup(opop(const char*));
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static void
|
||||
eval_eq(void) /* (int, int) -> int */
|
||||
{
|
||||
int a = opop(int);
|
||||
int b = opop(int);
|
||||
int rval = (a==b)?1:0;
|
||||
opush(rval);
|
||||
}
|
||||
|
||||
static void
|
||||
eval_add(void) /* (int, int) -> int */
|
||||
{
|
||||
int a = opop(int);
|
||||
int b = opop(int);
|
||||
opush(a+b);
|
||||
}
|
||||
|
||||
static void
|
||||
eval_if(void) /* (int, int) -> int */
|
||||
{
|
||||
void * a = opop(void *);
|
||||
void * b = opop(void *);
|
||||
int cond = opop(int);
|
||||
opush(cond?b:a);
|
||||
}
|
||||
|
||||
#include "base36.h"
|
||||
static void
|
||||
eval_int(void)
|
||||
{
|
||||
int i = opop(int);
|
||||
const char * c = itoa10(i);
|
||||
opush(strcpy(balloc(strlen(c)+1), c));
|
||||
}
|
||||
|
||||
#include "language.h"
|
||||
static void
|
||||
eval_localize(void) /* (locale, string) -> string */
|
||||
{
|
||||
const struct locale *lang = opop(const struct locale *);
|
||||
const char *c = opop(const char *);
|
||||
const char *r = locale_string(lang, c);
|
||||
|
||||
bfree((char*)c);
|
||||
opush(r);
|
||||
}
|
||||
|
||||
struct unit;
|
||||
extern const char * unitname(const struct unit *u);
|
||||
|
||||
static void
|
||||
eval_unit(void) /* unit -> string */
|
||||
{
|
||||
const struct unit * u = opop(const struct unit *);
|
||||
const char * c = u?"unit u":"nobody";
|
||||
size_t len = strlen(c);
|
||||
opush(strcpy(balloc(len+1), c));
|
||||
}
|
||||
|
||||
void
|
||||
translation_init(void)
|
||||
{
|
||||
add_function("eq", &eval_eq);
|
||||
add_function("unit", &eval_unit);
|
||||
add_function("int", &eval_int);
|
||||
add_function("add", &eval_add);
|
||||
add_function("if", &eval_if);
|
||||
add_function("localize", &eval_localize);
|
||||
}
|
||||
|
||||
void
|
||||
translation_done(void)
|
||||
{
|
||||
free_functions();
|
||||
free(buffer.begin);
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea-pbem.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2001 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
extern void translation_init(void);
|
||||
extern void translation_done(void);
|
||||
extern char * translate_va(const char* format, const char* vars, ...);
|
||||
extern char * translate(const char* format, const char* vars, const void* args[]);
|
|
@ -66,7 +66,7 @@ LIB32=link.exe -lib
|
|||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD CPP /nologo /Za /W4 /Z7 /Od /I "../.." /I ".." /D "_WINDOWS" /D "WIN32" /D "_DEBUG" /D "BETA_CODE" /FR /YX"stdafx.h" /FD /c
|
||||
# ADD CPP /nologo /Za /W4 /Z7 /Od /I "../.." /I ".." /D "_WINDOWS" /D "WIN32" /D "_DEBUG" /FR /YX"stdafx.h" /FD /c
|
||||
# ADD BASE RSC /l 0x407
|
||||
# ADD RSC /l 0x407
|
||||
BSC32=bscmake.exe
|
||||
|
@ -220,6 +220,10 @@ SOURCE=.\base36.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\crmessage.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\cvector.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -252,6 +256,14 @@ SOURCE=.\log.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\message.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\nrmessage.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\rand.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -260,6 +272,10 @@ SOURCE=.\resolve.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\translation.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\umlaut.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
|
@ -68,7 +68,7 @@ LINK32=link.exe
|
|||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /Za /W4 /Gm /ZI /Od /I "../common/kernel" /I "../common/gamecode" /I "../common/util" /I "../common" /I ".." /D "_CONSOLE" /D "_MBCS" /D "WIN32" /D "_DEBUG" /D "BETA_CODE" /FR /YX"stdafx.h" /FD /c
|
||||
# ADD CPP /nologo /Za /W4 /Gm /ZI /Od /I "../common/gamecode" /I "../common/kernel" /I "../common/util" /I "../common" /I ".." /D "_CONSOLE" /D "_MBCS" /D "WIN32" /D "_DEBUG" /FR /YX"stdafx.h" /FD /c
|
||||
# ADD BASE RSC /l 0x407 /d "_DEBUG"
|
||||
# ADD RSC /l 0x407 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
|
|
|
@ -66,7 +66,7 @@ LINK32=link.exe
|
|||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /Za /W4 /Gm /ZI /Od /I "../common/kernel" /I "../common/gamecode" /I "../common/util" /I "../common" /I ".." /D "_CONSOLE" /D "_MBCS" /D "WIN32" /D "_DEBUG" /D "BETA_CODE" /FR /YX"stdafx.h" /FD /c
|
||||
# ADD CPP /nologo /Za /W4 /Gm /ZI /Od /I "../common/kernel" /I "../common/gamecode" /I "../common/util" /I "../common" /I ".." /D "_CONSOLE" /D "_MBCS" /D "WIN32" /D "_DEBUG" /FR /YX"stdafx.h" /FD /c
|
||||
# ADD BASE RSC /l 0x407 /d "_DEBUG"
|
||||
# ADD RSC /l 0x407 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
|
|
|
@ -0,0 +1,275 @@
|
|||
#include <config.h>
|
||||
|
||||
#include <message.h>
|
||||
#include <crmessage.h>
|
||||
#include <nrmessage.h>
|
||||
#include <translation.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
static const char * sample = "\"enno and $if($eq($i,0),\"nobody else\",$if($eq($i,1),\"another guy\",\"$int($i) other people\")).\"";
|
||||
|
||||
void
|
||||
test_translation(void)
|
||||
{
|
||||
int x;
|
||||
char * c;
|
||||
|
||||
c = translate_va("\"$name is a godlike $role.\"", "name role", "enno", "coder");
|
||||
if (c) puts(c);
|
||||
free(c);
|
||||
|
||||
for (x=0;x!=4;++x) {
|
||||
c = translate_va(sample, "i", x);
|
||||
if (c) puts(c);
|
||||
free(c);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
test_message(void)
|
||||
{
|
||||
char buffer[1024];
|
||||
struct message_type * mt_example = mt_new_va("example", "subject:string", "number:int", "object:string", NULL);
|
||||
message * msg = msg_create_va(mt_example, "enno", (void*)7, "autos");
|
||||
|
||||
tsf_register("string", &cr_string);
|
||||
tsf_register("int", &cr_int);
|
||||
|
||||
crt_register(mt_example, NULL);
|
||||
nrt_register(mt_example, NULL, "\"$subject hat $int($number) $object\"");
|
||||
cr_render(msg, NULL, buffer);
|
||||
puts(buffer);
|
||||
nr_render(msg, NULL, buffer);
|
||||
puts(buffer);
|
||||
}
|
||||
|
||||
#include <string.h>
|
||||
#include <language.h>
|
||||
|
||||
message *
|
||||
new_message(struct faction * receiver, const char* sig, ...)
|
||||
/* compatibility function, to keep the old function calls valid *
|
||||
* all old messagetypes are converted into a message with ONLY string parameters,
|
||||
* this function will convert given parameters to a string representation
|
||||
* based on the signature - like render() once did */
|
||||
{
|
||||
const message_type * mtype;
|
||||
va_list marker;
|
||||
const char * signature = strchr(sig, '%');
|
||||
char buffer[128];
|
||||
int i=0;
|
||||
const char * c = sig;
|
||||
const char * args[16];
|
||||
|
||||
strncpy(buffer, sig, signature-sig);
|
||||
buffer[signature-sig] = '\0';
|
||||
mtype = mt_find(buffer);
|
||||
|
||||
if (!mtype) {
|
||||
fprintf(stderr, "trying to create message of unknown type \"%s\"\n", buffer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while(*c!='%') buffer[i++] = *(c++);
|
||||
buffer[i] = 0;
|
||||
|
||||
va_start(marker, sig);
|
||||
while (*c) {
|
||||
char type;
|
||||
char *p = buffer;
|
||||
assert(*c=='%');
|
||||
type = *(++c);
|
||||
/*
|
||||
case 'f': (*ep)->type = IT_FACTION; break;
|
||||
case 'u': (*ep)->type = IT_UNIT; break;
|
||||
case 'r': (*ep)->type = IT_REGION; break;
|
||||
case 'h': (*ep)->type = IT_SHIP; break;
|
||||
case 'b': (*ep)->type = IT_BUILDING; break;
|
||||
case 'X': (*ep)->type = IT_RESOURCETYPE; break;
|
||||
case 'x': (*ep)->type = IT_RESOURCE; break;
|
||||
case 't': (*ep)->type = IT_SKILL; break;
|
||||
case 's': (*ep)->type = IT_STRING; break;
|
||||
case 'i': (*ep)->type = IT_INT; break;
|
||||
case 'd': (*ep)->type = IT_DIRECTION; break;
|
||||
case 'S': (*ep)->type = IT_FSPECIAL; break;
|
||||
*/
|
||||
c+=2;
|
||||
while (*c && isalnum(*(unsigned char*)c)) *(p++) = *(c++);
|
||||
*p = '\0';
|
||||
for (i=0;i!=mtype->nparameters;++i) {
|
||||
if (!strcmp(buffer, mtype->pnames[i])) break;
|
||||
}
|
||||
assert(i!=mtype->nparameters || !"unknown parameter");
|
||||
|
||||
switch(type) {
|
||||
case 's':
|
||||
args[i] = va_arg(marker, const char *);
|
||||
break;
|
||||
case 'i':
|
||||
itoa(va_arg(marker, int), buffer, sizeof(buffer));
|
||||
args[i] = strdup(buffer);
|
||||
break;
|
||||
#ifdef ERESSEA_KERNEL
|
||||
case 'f':
|
||||
args[i] = factionname(va_arg(marker, const struct faction*));
|
||||
break;
|
||||
case 'u':
|
||||
args[i] = unitname(va_arg(marker, const struct unit*));
|
||||
break;
|
||||
case 'r':
|
||||
args[i] = rname(va_arg(marker, const struct region*), receiver->lang);
|
||||
break;
|
||||
case 'h':
|
||||
args[i] = shipname(va_arg(marker, const struct ship*));
|
||||
break;
|
||||
case 'b':
|
||||
args[i] = buildingname(va_arg(marker, const struct ship*));
|
||||
break;
|
||||
case 'X':
|
||||
args[i] = resourcename(va_arg(marker, const resource_type *), 0);
|
||||
break;
|
||||
case 'x':
|
||||
args[i] = resourcename(oldresourcetype[(resource_t)va_arg(marker, resource_t)], 0);
|
||||
break;
|
||||
case 't':
|
||||
args[i] = skillnames[va_arg(marker, skill_t)];
|
||||
break;
|
||||
case 'd':
|
||||
args[i] = directions[i];
|
||||
break;
|
||||
case 'S':
|
||||
#endif
|
||||
default:
|
||||
args[i] = NULL;
|
||||
}
|
||||
}
|
||||
return msg_create(mtype, args);
|
||||
}
|
||||
|
||||
static void
|
||||
parse_message(char * b)
|
||||
{
|
||||
char *m, *a, message[8192];
|
||||
char * name;
|
||||
char * language;
|
||||
struct locale * lang;
|
||||
char * section = NULL;
|
||||
int i, level = 0;
|
||||
char * args[16];
|
||||
boolean f_symbol = false;
|
||||
const struct message_type * mtype;
|
||||
|
||||
/* skip comments */
|
||||
if (b[0]=='#' || b[0]==0) return;
|
||||
|
||||
/* the name of this type */
|
||||
name = b;
|
||||
while (*b && *b!=';') ++b;
|
||||
if (!*b) return;
|
||||
*b++ = 0;
|
||||
|
||||
/* the section for this type */
|
||||
section = b;
|
||||
while (*b && *b!=';' && *b!=':') ++b;
|
||||
if (!strcmp(section, "none")) section=NULL;
|
||||
|
||||
/* if available, the level for this type */
|
||||
if (*b==':') {
|
||||
char * x;
|
||||
*b++ = 0;
|
||||
x = b;
|
||||
while (*b && *b!=';') ++b;
|
||||
level=atoi(x);
|
||||
}
|
||||
*b++ = 0;
|
||||
|
||||
/* the locale */
|
||||
language = b;
|
||||
while (*b && *b!=';') ++b;
|
||||
*b++ = 0;
|
||||
lang = find_locale(language);
|
||||
if (!lang) lang = make_locale(language);
|
||||
|
||||
/* parse the message */
|
||||
i = 0;
|
||||
m = message;
|
||||
*m++='\"';
|
||||
while (*b) {
|
||||
switch (*b) {
|
||||
case '{':
|
||||
f_symbol = true;
|
||||
a = ++b;
|
||||
break;
|
||||
case '}':
|
||||
*b++ = '\0';
|
||||
args[i] = strdup(a);
|
||||
sprintf(m, "$%s", args[i]);
|
||||
m+=strlen(m);
|
||||
i++;
|
||||
f_symbol = false;
|
||||
break;
|
||||
case ' ':
|
||||
if (f_symbol) {
|
||||
a = ++b;
|
||||
break;
|
||||
}
|
||||
/* fall-through intended */
|
||||
default:
|
||||
if (!f_symbol) {
|
||||
*m++ = *b++;
|
||||
} else b++;
|
||||
}
|
||||
}
|
||||
strcpy(m, "\"");
|
||||
args[i] = NULL;
|
||||
|
||||
/* add the messagetype */
|
||||
mtype = mt_register(mt_new(name, args));
|
||||
nrt_register(mtype, lang, message);
|
||||
crt_register(mtype, lang);
|
||||
}
|
||||
|
||||
static void
|
||||
read_messages(FILE * F)
|
||||
{
|
||||
char buf[8192];
|
||||
while (fgets(buf, sizeof(buf), F)) {
|
||||
buf[strlen(buf)-1] = 0; /* \n weg */
|
||||
parse_message(buf);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
test_compat()
|
||||
{
|
||||
char buffer[1024];
|
||||
FILE * F = fopen("res/de_DE/messages.txt", "rt");
|
||||
message * msg;
|
||||
if (F) {
|
||||
read_messages(F);
|
||||
fclose(F);
|
||||
}
|
||||
msg = new_message(NULL, "entrise%s:region", "Porzel (8,7)");
|
||||
if (cr_render(msg, NULL, buffer)==0) puts(buffer);
|
||||
if (nr_render(msg, NULL, buffer)==0) puts(buffer);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char**argv)
|
||||
{
|
||||
translation_init();
|
||||
|
||||
test_message();
|
||||
test_translation();
|
||||
test_compat();
|
||||
|
||||
translation_done();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
# Microsoft Developer Studio Project File - Name="translator" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=translator - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "translator.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "translator.mak" CFG="translator - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "translator - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "translator - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "translator - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x407 /d "NDEBUG"
|
||||
# ADD RSC /l 0x407 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "translator - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I ".." /I "../.." /I "../common/util" /D "_CONSOLE" /D "_MBCS" /D "WIN32" /D "_DEBUG" /FR /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x407 /d "_DEBUG"
|
||||
# ADD RSC /l 0x407 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "translator - Win32 Release"
|
||||
# Name "translator - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\translator.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
Loading…
Reference in New Issue