New template tokens: @echopath, @echoname, @echotype

This commit is contained in:
Stas Degteff
2005-09-27 17:23:59 +00:00
parent d799a4d70a
commit 4280e1d7ba
3 changed files with 59 additions and 13 deletions

View File

@@ -385,6 +385,41 @@ char* TokenXlat(int mode, char* input, GMsg* msg, GMsg* oldmsg, int __origarea)
if(tokenxchg(dst, "@origin",
HandleRandomLine(strxcpy(buf, AA->Origin(), sizeof(buf)), sizeof(buf))))
continue;
if (strnieql(dst, "@echo", 5))
{
if (tokenxchg(dst, "@echotype", AA->basetype()))
continue;
char echopath[GMAXPATH];
char echoname[GMAXPATH];
strcpy(echopath, AA->path());
echoname[0] = NUL;
size_t slashpos;
size_t pathlen = strlen(echopath);
for (slashpos = pathlen-1; slashpos < pathlen; slashpos--)
if (isslash(echopath[slashpos])) break;
if (slashpos < pathlen)
{
strcpy(echoname, &echopath[slashpos+1]);
echopath[slashpos+1] = NUL;
}
else
{
strcpy(echoname, echopath);
echopath[0] = NUL;
}
if (tokenxchg(dst, "@echopath", echopath))
continue;
if (tokenxchg(dst, "@echoname", echoname))
continue;
}
dst++;
}
}