/************************************************************************* * * HTCd - Copyright (C) 1998-2006 Henrik Rydberg * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include #include static const charset htcmask("{}\\%&*$;"); static const charset htmlmask("<&>\""); static void Mask(mstream& out,const charset& mask,const sref& msg) { sref q,p=msg; while(p.nempty()) { p=p.adv(q=p.left_first_of(mask)); out<num) { out.put('\n'); col=0; } else out.put(body[i]); } } TOK_IMPL(htmlize) { sref first,rest=env[0]; while(Splitln(first,rest)) { Mask(out,htmlmask,first); out<<"
\n"; } } TOK_IMPL(lf2crlf) { LF2CRLF(out,env[0]); } TOK_IMPL(crlf2lf) { CRLF2LF(out,env[0]); } ////////////////////////////////////////////////////////// TOK_IMPL(twocolumn) { int num=atoi(env[0]); int page=atoi(env[1]); sref head=env[2],mid=env[3],foot=env[4],body=env[5]; int row=0,col=0,pg=1; out<=num) { row=0; col++; if(col>=2) { col=0; pg++; } else if(pg==page) { out<data); decode64(sw,buffer); } else decode64(out,buffer); } ////////////////////////////////////////////////////////// TOK_IMPL(strip) { sref s=env[0],a=env[1]; for(int i=0;i=0) s.replace(p,a.size(),b); } out<0) out.put(' '); } TOK_IMPL(right) { int pad=atoi(env[1])-env[0].size(); while(pad-->0) out.put(' '); out<0) { p=e.adv(s); if(n==env.req->lang) out<..\n" "%\n" "%Encodes a sequence of variables in\n" "%x-www-form-urlencoded format (RFC HTTP)\n" ); /////////////////////////////////////////////// TOK_ADD(strip,"xx",tok_t::PUBLIC, "%Strip text from special characters\n" "%Syntax: \\stip{text}{chars}\n" ); TOK_ADD(replace,"xxx",tok_t::PUBLIC, "%Replace text\n" "%Syntax: \\replace{text}{string}{subst}\n" "%\n" "%Replaces each occurence of string in text with subst.\n" ); /////////////////////////////////////////////// TOK_ADD(left,"xx",tok_t::PUBLIC, "%Left-adjust text\n" "%Syntax: \\left{text}{n}\n" "%\n" "%Outputs n characters, padding with spaces to the right.\n" "%\n" "%Writes out the full text if longer than n.\n" ); TOK_ADD(right,"xx",tok_t::PUBLIC, "%Right-adjust text\n" "%Syntax: \\right{text}{n}\n" "%\n" "%Outputs n characters, padding with spaces to the left.\n" "%\n" "%Writes out the full text if longer than n.\n" ); /////////////////////////////////////////////// TOK_ADD(sub,"xxx",tok_t::PUBLIC, "%Substring\n" "%Syntax: \\sub{string}{pos}{n}\n" "%\n" "%Gets a substring of n characters, beginning at pos, from string.\n" "%\n" "%Negative pos values wraps to end.\n" "%Negative n values wraps to 1+size.\n" ); /////////////////////////////////////////////// TOK_ADD(file2mime,"x",tok_t::PUBLIC, "%Get MIME type\n" "%Syntax: \\file2mime{path}\n" "%\n" "%Looks up the MIME type mapped to the extension of path.\n" "%\n" "%Defaults to application/octet-stream if not found.\n" ); /////////////////////////////////////////////// TOK_ADD(minilang,"x",tok_t::PUBLIC, "%Parse lang only\n" "%Syntax: \\minilang{body}\n" "%\n" "%This function is used to enable lang in html files,\n" "%which otherwise are not parsed.\n" ); }