Terttu pasianssi jatkuu

Olen jatkanut Tertun koodaamista, ja pasianssi näyttäisi vielä menevän läpi. Olen miettinyt ohjelman sorsien julkaisemista, ja aloitankin laittamalla tähän valittuja paloja… Seuraava on osa pääohjelmaa. Varsinainen ydin ei seuraavassa vielä näy (vuodelta 1998). Lisäilen koodia, jos päätän jatkaa julkaisua..

Kaikki oikeudet tietenkin pidätetään.

Viimeinen versio ohjelmasta löytyy seuraavasta linkistä: moijari.com:5002


#include <stdarg.h>

struct htmlrepl { /* JariK 20140202 */
  unsigned char *orig;
  unsigned char *new;
} htmlrepls[] ={
  /* 0xc3+0x80- ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ */
  "À","&Agrave;",  "Á","&Aacute;",  "Â","&Acirc;",  "Ã","&Atilde;",  "Ä","&Auml;",
  "Å","&Aring;",
  "È","&Egrave;",  "É","&Eacute;",  "Ê","&Ecirc;",                   "Ë","&Euml;",
  "Ì","&Igrave;",  "Í","&Iacute;",  "Î","&Icirc;",                   "Ï","&Iuml;",
  "Ò","&Ograve;",  "Ó","&Oacute;",  "Ô","&Ocirc;",  "Õ","&Otilde;",  "Ö","&Ouml;",
  "Ù","&Ugrave;",  "Ú","&Uacute;",  "Û","&Ucirc;",                   "Ü","&Uuml;",
                   "Ý","&Yacute;",                                   "Ÿ","&Yuml;",
  "à","&agrave;",  "á","&aacute;",  "â","&acirc;",  "ã","&atilde;",  "ä","&auml;",
  "å","&aring;",
  "è","&egrave;",  "é","&eacute;",  "ê","&ecirc;",                   "ë","&euml;",
  "ì","&igrave;",  "í","&iacute;",  "î","&icirc;",                   "ï","&iuml;",
  "ò","&ograve;",  "ó","&oacute;",  "ô","&ocirc;",  "õ","&otilde;",  "ö","&ouml;",
  "ù","&ugrave;",  "ú","&uacute;",  "û","&ucirc;",                   "ü","&uuml;",
                   "ý","&yacute;",                                   "ÿ","&yuml;",
};

unsigned char html1[8192],html2[8192],*html;

void html_printf(const char *format, ...)
{
  int c,done;
  va_list args;
  unsigned char buffer[128],string[10],*b,*h;

  va_start(args, format);
  vsnprintf(buffer, sizeof buffer, format, args);
  va_end(args);

  b=buffer;
  h=html+strlen(html);

  while(*b!='\0') {
    done=0;
    if(*b==0xc3) {
      for(c=0;c<sizeof(htmlrepls)/sizeof(htmlrepls[0]);c++) {
	if(!strncmp(b,htmlrepls[c].orig,strlen(htmlrepls[c].orig))) {
	  strcpy(h,htmlrepls[c].new);
	  h+=strlen(h);
	  b+=strlen(htmlrepls[c].orig);
	  done=1;
	}
      }
    }
    if(!done) {
      *h++=*b++;
      *h='\0';
    }
  }
}
Published
Categorized as terttu