Advertisement
Guest User

htmlC

a guest
Sep 17th, 2010
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.53 KB | None | 0 0
  1. // HTML CREATE BY sergiolopezsanz@hotmail.es
  2. // PROTECTED BY GPLv3
  3. // Need header string.h
  4. // http://daemonfreedom.blogspot.com
  5.  
  6.  
  7. //HTML MACROS
  8. #define MAX_TITLE 80
  9. #define MAX_SIMPLE 10000
  10. #define MAX_LINK 300
  11. #define MAX_HEADER 500
  12. #define MAX_IMAGE 300
  13.  
  14. #define H_SIMPLE   0
  15. #define H_BOLD     1
  16. #define H_ITALICS  2
  17. #define H_LABELED  3
  18. #define H_STRESSED 4
  19. //END HTML MACROS
  20.  
  21. //JS MACROS
  22. #define MAX_JS_TEXT 1000
  23. #define MAX_JS_SPAM 255
  24. //END JS MACROS
  25.  
  26. class htmlCreate
  27. {
  28.    
  29.     // This is the main class
  30.    
  31.     private:
  32.    
  33.         char a1[7];
  34.         char a2[7];
  35.         char a3[7];
  36.        
  37.         char b1[8];
  38.         char b2[8];
  39.         char b3[8];
  40.        
  41.        
  42.         char te0[MAX_TITLE];
  43.         char te1[8];
  44.         char te2[9];
  45.        
  46.         char po0[MAX_SIMPLE];
  47.         char po1[4];
  48.         char po2[5];
  49.         char po3[9];
  50.         char po4[10];
  51.         char po5[5];
  52.         char po6[9];
  53.         char po7[6];
  54.         char po8[7];
  55.         char po9[4];
  56.         char po10[5];
  57.        
  58.         char ee0[MAX_LINK];
  59.         char ee1[10];
  60.         char ee2[3];
  61.         char ee3[5];
  62.        
  63.         char eo0[MAX_HEADER];
  64.         char eo1[5];
  65.         char eo2[6];
  66.         char eo3[5];
  67.         char eo4[6];
  68.         char eo5[5];
  69.         char eo6[6];
  70.         char eo7[5];
  71.         char eo8[6];
  72.         char eo9[5];
  73.         char eo10[6];
  74.         char eo11[5];
  75.         char eo12[6];
  76.        
  77.         char in0[MAX_IMAGE];
  78.         char in1[12];
  79.         char in2[8];
  80.         char in3[3];
  81.        
  82.        
  83.     public:
  84.    
  85.         htmlCreate()
  86.         {
  87.             strncpy(a1, "<html>", 7);
  88.             strncpy(a2, "<head>", 7);
  89.             strncpy(a3, "<body>", 7);
  90.            
  91.             strncpy(b1, "</html>", 8);
  92.             strncpy(b2, "</head>", 8);
  93.             strncpy(b3, "</body>", 8);
  94.            
  95.             strncpy(te1, "<title>", 8);
  96.             strncpy(te2, "</title>", 9);
  97.            
  98.             strncpy(po1, "<p>", 4);
  99.             strncpy(po2, "</p>", 5);
  100.             strncpy(po3, "<strong>", 9);
  101.             strncpy(po4, "</strong>", 10);
  102.             strncpy(po5, "<em>", 5);
  103.             strncpy(po6, "</em>", 6);
  104.             strncpy(po7, "<del>", 6);
  105.             strncpy(po8, "</del>", 7);
  106.             strncpy(po9, "<u>", 4);
  107.             strncpy(po10, "</u>", 5);
  108.            
  109.             strncpy(ee1, "<a href=\"", 10);
  110.             strncpy(ee2, "\">", 3);
  111.             strncpy(ee3, "</a>", 5);
  112.            
  113.             strncpy(eo1, "<h1>", 5);
  114.             strncpy(eo2, "</h1>", 6);
  115.             strncpy(eo3, "<h2>", 5);
  116.             strncpy(eo4, "</h2>", 6);
  117.             strncpy(eo5, "<h3>", 5);
  118.             strncpy(eo6, "</h3>", 6);
  119.             strncpy(eo7, "<h4>", 5);
  120.             strncpy(eo8, "</h4>", 6);
  121.             strncpy(eo9, "<h5>", 5);
  122.             strncpy(eo10, "</h5>", 6);
  123.             strncpy(eo11, "<h6>", 5);
  124.             strncpy(eo12, "</h6>", 6);
  125.            
  126.             strncpy(in1, "<img scr=\"", 12);
  127.             strncpy(in2, "\" alt=\"", 8);
  128.             strncpy(in3, "\">", 3);
  129.            
  130.         }
  131.        
  132.         char * htmlStart()     { return a1; }
  133.         char * htmlBodyStart() { return a2; }
  134.         char * htmlHeadStart() { return a3; }
  135.        
  136.         char * htmlEnd()       { return b1; }
  137.         char * htmlHeadEnd()   { return b2; }
  138.         char * htmlBodyEnd()   { return b3; }
  139.        
  140.        
  141.         const char * htmlTitle(const char * title) { strncpy (te0, te1, 8); strcat(te0, title); strcat(te0, te2); return te0; }
  142.        
  143.         const char * htmlSimpleText(int id, const char * text)
  144.         {
  145.             switch (id)
  146.             {
  147.                 default: break;
  148.                 case 0: strncpy(po0, po1, 4); strcat(po0, text); strcat(po0, po2); return po0; break;
  149.                 case 1: strncpy(po0, po1, 4); strcat(po0, po3); strcat(po0, text); strcat (po0, po4); strcat (po0, po2); return po0; break;
  150.                 case 2: strncpy(po0, po1, 4); strcat(po0, po5); strcat(po0, text); strcat (po0, po6); strcat (po0, po2); return po0; break;
  151.                 case 3: strncpy(po0, po1, 4); strcat(po0, po7); strcat(po0, text); strcat (po0, po8); strcat (po0, po2); return po0; break;
  152.                 case 4: strncpy(po0, po1, 4); strcat(po0, po9); strcat(po0, text); strcat (po0, po10); strcat (po0, po2); return po0; break;
  153.             }
  154.             return "null";
  155.         }  
  156.        
  157.         const char * htmlLink(const char * www, const char * name)
  158.         {
  159.                 strncpy(ee0, ee1, 10); strcat(ee0, www); strcat(ee0, ee2); strcat(ee0, name); strcat(ee0, ee3); return ee0;
  160.         }
  161.        
  162.         const char * htmlHeader(int op, char * text)
  163.         {
  164.             switch(op)
  165.             {
  166.                 default: break;
  167.                 case 1: strncpy(eo0, eo1, 6); strcat(eo0, text); strcat(eo0, eo2); return eo0; break;
  168.                 case 2: strncpy(eo0, eo3, 6); strcat(eo0, text); strcat(eo0, eo4); return eo0; break;
  169.                 case 3: strncpy(eo0, eo5, 6); strcat(eo0, text); strcat(eo0, eo6); return eo0; break;
  170.                 case 4: strncpy(eo0, eo7, 6); strcat(eo0, text); strcat(eo0, eo8); return eo0; break;
  171.                 case 5: strncpy(eo0, eo9, 6); strcat(eo0, text); strcat(eo0, eo10); return eo0; break;
  172.                 case 6: strncpy(eo0, eo11, 6); strcat(eo0, text); strcat(eo0, eo12); return eo0; break;
  173.             }
  174.             return "null";
  175.         }
  176.        
  177.         const char * htmlImage(const char * source, const char * alt)
  178.         {
  179.             strncpy(in0, po1, 5); strcat(in0, in1); strcat(in0, source); strcat(in0, in2); strcat(in0, alt); strcat(in0, in3); strcat(in0, po2); return in0;
  180.         }      
  181. };
  182.  
  183. class htmlScriptJS : public htmlCreate
  184. {
  185.     // This subclass is used to add JavaScript scripts to documents
  186.    
  187.     private:
  188.    
  189.         char ios[31];
  190.         char ioe[10];
  191.        
  192.         char jst[MAX_JS_TEXT];
  193.         char jsts[17];
  194.         char jste[4];
  195.        
  196.         char jss[MAX_JS_SPAM];
  197.         char jsss[8];
  198.         char jsse[4];
  199.    
  200.    
  201.     public:
  202.    
  203.         htmlScriptJS()
  204.         {
  205.             strncpy(ios, "<script language=\"javascript\">", 31);
  206.             strncpy(ioe, "</script>", 10);
  207.            
  208.             strncpy(jsts, "document.write(\'", 17);
  209.             strncpy(jste, "\');", 4);
  210.            
  211.             strncpy(jsss, "alert(\'", 8);
  212.             strncpy(jsse, "\');", 4);
  213.         }
  214.        
  215.         const char * jsStart() { return ios; }  // Start JS
  216.         const char * jsEnd()   { return ioe; }  // End   JS
  217.        
  218.         const char * jsText(const char * text)
  219.         {
  220.             strncpy(jst, jsts, 17); strcat(jst, text); strcat(jst, jste); return jst;
  221.         }
  222.        
  223.         const char * jsSpam(const char * text)
  224.         {
  225.             strncpy(jss, jsss, 8); strcat(jss, text); strcat(jss, jsse); return jss;
  226.         }
  227. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement