- strcpy(outbuf, "");
- len = strlen(inbuf);
- while (len > 0) {
- pos = (-1);
- for (i=len; i>=0; --i) {
- if ((inbuf[i]=='<')&&(inbuf[i+1]=='?')) pos = i;
- }
- if (pos < 0) {
- wprintf("%s", inbuf);
- strcpy(inbuf, "");
- len = 0;
- }
- else {
- strncpy(outbuf, inbuf, pos);
- outbuf[pos] = 0;
- wprintf("%s", outbuf);
- memmove(inbuf, &inbuf[pos], len - pos +1);
- len -= pos;
- pos = 1;
- for (i=len; i>=0; --i) {
- if (inbuf[i]=='>') pos = i;
- }
- strncpy(key, &inbuf[2], pos-2);
- key[pos-2] = 0;
- print_value_of(key, pos-2);
- pos++;
- memmove(inbuf, &inbuf[pos], len - pos + 1);
- len -= pos;
+ NewTemplate = (WCTemplate *) malloc(sizeof(WCTemplate));
+ NewTemplate->Data = NewStrBufPlain(NULL, statbuf.st_size);
+ NewTemplate->nTokensUsed = 0;
+ NewTemplate->TokenSpace = 0;
+ NewTemplate->Tokens = NULL;
+ if (StrBufReadBLOB(NewTemplate->Data, &fd, 1, statbuf.st_size, &Err) < 0) {
+ close(fd);
+ FreeWCTemplate(NewTemplate);
+ wprintf(_("ERROR: reading template "));
+ wprintf("'%s' - %s<br />\n",
+ (const char*)templatename, strerror(errno));
+ return NULL;
+ }
+ close(fd);
+
+ pS = pch = ChrPtr(NewTemplate->Data);
+ pE = pS + StrLength(NewTemplate->Data);
+ while (pch < pE) {
+ const char *pts, *pte;
+ int InQuotes = 0;
+ int InDoubleQuotes = 0;
+ pos = (-1);
+ for (; pch < pE; pch ++) {
+ if ((*pch=='<')&&(*(pch + 1)=='?'))
+ break;
+ }
+ if (pch >= pE)
+ continue;
+ pts = pch;
+ for (; pch < pE - 1; pch ++) {
+ if (*pch == '"')
+ InDoubleQuotes = ! InDoubleQuotes;
+ else if (*pch == '\'')
+ InQuotes = ! InQuotes;
+ else if ((!InQuotes && !InDoubleQuotes) &&
+ ((*pch!='\\')&&(*(pch + 1)=='>'))) {
+ pch ++;
+ break;