...">
📜 ⬆️ ⬇️

My personal WTF

Died screw. When restoring found a piece of code year 2000 or even earlier.
First thought: "How young and naive we were ..."

#include <iostream>
#include <map>

class HTML {
ostream * out;
public:
HTML(ostream &s=cout) {out=&s;(*out).setf(ios::binary);}
template<class T> void write(T s) {(*out)<<s;}
void writeln(char*str) {write(str);write("<br>\n");}
void writeintag(char*tag,char*text,char*param=NULL)
{write("<");write(tag);if(param)write(param);write(">");
write(text);write("</");write(tag);write(">");}
void type(char*mime)
{write("Content-type: ");write(mime);}
void start(char*title=NULL,char*bodyspec=NULL)
{write("\n\n<html>\n<head>\n");if(title)writeintag("title",title);
write("\n</head>\n<body");if(bodyspec){write(" ");write(bodyspec);}write(">\n");}
void end()
{write("</body>\n</html>\n");}
void form_start(char*action,char*method="GET",char*type=NULL)
{write("<form method=");write(method);if(type){write(" enctype=");
write(type);}write(">\n");}
void form_end()
{write("</font>");}
template<class T1,class T2> void select(char*name,const map<T1,T2> &m) {
map<T1,T2>::const_iterator p;
write("<select name="); write(name); write(">\n");
for (p=m.begin(); p!=m.end(); p++) {
write("<option value="); write(p->first);
write(">"); write(p->second); write("\n");
}
write("</select>\n");
}

};


Some time passed, in the area of ​​2002 a code was found:

package HTML;
sub Start {
return "Content-type: text/html\n\n";
}
sub InTags {
my $t=shift;
return "<$t>".join(" ",@_)."</$t>";
}
sub H1 {
return InTags("h1",@_);
}
sub H2 {
return InTags("h2",@_);
}
...

')

Source: https://habr.com/ru/post/39923/


All Articles