aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
ModeNameSize
-rwxr-xr-xadam2flash.pl4511logstatsplain
d---------config787logstatsplain
-rwxr-xr-xconfigtest.pl676logstatsplain
-rwxr-xr-xdownload.pl2807logstatsplain
-rw-r--r--flash.sh2596logstatsplain
-rwxr-xr-xgen_busybox_config.pl344logstatsplain
-rw-r--r--gen_busybox_menuconfig.pl1745logstatsplain
-rwxr-xr-xgen_deps.pl1236logstatsplain
-rwxr-xr-xgen_menuconfig.pl2479logstatsplain
-rwxr-xr-xipkg28372logstatsplain
-rwxr-xr-xmake-ipkg-dir.sh749logstatsplain
-rwxr-xr-xpatch-kernel.sh1378logstatsplain
-rwxr-xr-xrstrip.sh566logstatsplain
-rwxr-xr-xtimestamp.pl979logstatsplain
; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
/* 
 * html.c:
 *
 * Copyright (c) 2008 James McKenzie <james@fishsoup.dhs.org>,
 * All rights reserved.
 *
 */

static char rcsid[] = "$Id$";

/* 
 * $Log$
 * Revision 1.14  2008/03/07 12:37:04  james
 * *** empty log message ***
 *
 * Revision 1.13  2008/03/06 16:49:39  james
 * *** empty log message ***
 *
 * Revision 1.12  2008/03/06 16:49:05  james
 * *** empty log message ***
 *
 * Revision 1.11  2008/03/03 06:04:42  james
 * *** empty log message ***
 *
 * Revision 1.10  2008/03/02 10:37:56  james
 * *** empty log message ***
 *
 * Revision 1.9  2008/02/27 09:42:22  james
 * *** empty log message ***
 *
 * Revision 1.8  2008/02/27 01:52:38  james
 * *** empty log message ***
 *
 * Revision 1.7  2008/02/27 01:52:08  james
 * *** empty log message ***
 *
 * Revision 1.6  2008/02/20 23:42:05  staffcvs
 * *** empty log message ***
 *
 * Revision 1.5  2008/02/20 23:31:48  staffcvs
 * *** empty log message ***
 *
 * Revision 1.4  2008/02/20 22:54:22  staffcvs
 * *** empty log message ***
 *
 * Revision 1.3  2008/02/20 20:16:07  james
 * *** empty log message ***
 *
 * Revision 1.2  2008/02/04 02:05:06  james
 * *** empty log message ***
 *
 * Revision 1.1  2008/02/03 23:31:25  james
 * *** empty log message ***
 *
 */

#include "project.h"


#define V(i) (((i)==0)?0x80:(((i)==1)?0xc0:0xff))
#define COLOR(r,g,b,i) ((((r)?(V(i)):0) << 0)| (((g)?(V(i)):0) << 8)| (((b)?(V(i)):0) << 16))

static int colormap[] = {
  [CRT_COLOR_BLACK] = COLOR (0, 0, 0, 0),
  [CRT_COLOR_RED] = COLOR (0, 0, 1, 0),
  [CRT_COLOR_GREEN] = COLOR (0, 1, 0, 0),
  [CRT_COLOR_YELLOW] = COLOR (0, 1, 1, 0),
  [CRT_COLOR_BLUE] = COLOR (1, 0, 0, 0),
  [CRT_COLOR_MAGENTA] = COLOR (1, 0, 1, 0),
  [CRT_COLOR_CYAN] = COLOR (1, 1, 0, 0),
  [CRT_COLOR_WHITE] = COLOR (1, 1, 1, 1),
  [CRT_COLOR_BLACK | CRT_COLOR_INTENSITY] = COLOR (1, 1, 1, 0),
  [CRT_COLOR_RED | CRT_COLOR_INTENSITY] = COLOR (0, 0, 1, 2),
  [CRT_COLOR_GREEN | CRT_COLOR_INTENSITY] = COLOR (0, 1, 0, 2),
  [CRT_COLOR_YELLOW | CRT_COLOR_INTENSITY] = COLOR (0, 1, 1, 2),
  [CRT_COLOR_BLUE | CRT_COLOR_INTENSITY] = COLOR (1, 0, 0, 2),
  [CRT_COLOR_MAGENTA | CRT_COLOR_INTENSITY] = COLOR (1, 0, 1, 2),
  [CRT_COLOR_CYAN | CRT_COLOR_INTENSITY] = COLOR (1, 1, 0, 2),
  [CRT_COLOR_WHITE | CRT_COLOR_INTENSITY] = COLOR (1, 1, 1, 2),
};


static void
html_entity (FILE * f, int c)
{
  switch (c) {
  case 32:
    fprintf (f, "&nbsp;");
    break;
  case 38:
    fprintf (f, "&amp;");
    break;
  case 60:
    fprintf (f, "&lt;");
    break;
  case 62:
    fprintf (f, "&gt;");
    break;
  default:

    if ((c >= 32) && (c < 127)) {
      fputc (c, f);
    } else if (c > 127) {
      fprintf (f, "&#x%04x;", c);
    } else {
      fputc (' ', f);
    }
  }
}

static void
html_render (FILE * f, CRT_CA c)
{
  int fg, bg;

  if (c.attr & CRT_ATTR_REVERSE) {
    fg = CRT_COLOR_BG (c.color);
    bg = CRT_COLOR_FG (c.color);
  } else {
    fg = CRT_COLOR_FG (c.color);
    bg = CRT_COLOR_BG (c.color);
    if (c.attr & CRT_ATTR_BOLD)
      fg |= CRT_COLOR_INTENSITY;
  }
#ifdef CSS
  fprintf (f, "<span style='color: #%06x; background-color: #%06x'>",
           colormap[fg], colormap[bg]);
#else
  fprintf (f, "<td bgcolor='#%06x'><font color='#%06x'>", colormap[bg],
           colormap[fg]);
  fprintf (f, "<tt>");
#endif

  if (c.attr & CRT_ATTR_UNDERLINE)
    fprintf (f, "<ul>");
  if (c.attr & CRT_ATTR_BOLD)
    fprintf (f, "<b>");

  html_entity (f, c.chr);

  if (c.attr & CRT_ATTR_BOLD)
    fprintf (f, "</b>");
  if (c.attr & CRT_ATTR_UNDERLINE)
    fprintf (f, "</ul>");
  if (c.attr & CRT_ATTR_REVERSE) {
    fprintf (f, "</font>");
  }
#ifdef CSS
  fprintf (f, "</span>");
#else
  fprintf (f, "</tt>");
  fprintf (f, "</td>");
#endif
}

static void
html_draw (FILE * f, CRT * c)
{
  CRT_Pos p;
  int o;

#ifdef CSS
  fprintf (f, "<pre>");
#else
  fprintf (f, "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n");
#endif
  for (p.y = 0; p.y < c->size.y; ++p.y) {
    o = CRT_ADDR (p.y, 0);
#ifndef CSS
    fprintf (f, "<tr>");
#endif
    for (p.x = 0; p.x < c->size.x; ++p.x, ++o) {
      html_render (f, c->screen[o]);
    }
#ifdef CSS
    fprintf (f, "\n");
#else
    fprintf (f, "</tr>\n");
#endif
  }
#ifdef CSS
  fprintf (f, "</pre>\n");
#else
  fprintf (f, "</table>");
#endif
}


static int
html_one_shot (ANSI * a, CRT * c)
{
  html_draw (a->file, c);
  return 0;
}


static void
ansi_free (ANSI * a)
{
  free (a);
}

ANSI *
ansi_new_html (FILE * f)
{
  ANSI *ret;

  ret = malloc (sizeof (ANSI));
  memset (ret, 0, sizeof (ANSI));

  ret->file = f;
  ret->close = ansi_free;
  ret->one_shot = html_one_shot;

  return ret;
}