aboutsummaryrefslogtreecommitdiffstats
path: root/util/alevt/alevt-date.1
blob: 69d2f6f92ed74de4b1425120d8cb99a5faa3e91f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
.TH alevt-date 1 "February 07, 2010"
.SH NAME
alevt-date \- print out UTC date.
.SH SYNOPSIS
.B alevt-date
.RI [ options ]
.br
.SH DESCRIPTION
This manual page documents briefly the
.B alevt-date
commands.
.PP
\fBalevt-date\fP is a program to print the UTC date.
.SH OPTIONS
.TP
.B \-d -delta <max_secs>
maximum delta
.TP
.B \-f -format <fmtstr>
time format
.TP
.B \-h -help
print this page
.TP
.B \-s -set
set the system clock
.TP
.B \-t -timeout <seconds>
timeout
.TP
.B \-v -vbi <vbidev>
vbi device /dev/vbi; /dev/vbi0; /dev/video0; /dev/dvb/adapter0/demux0
.TP
.br
.SH SEE ALSO
.BR alevt-cap (1) , alevt (1).
.br
.SH AUTHOR
alevt-date was written by Edgar Toernig <froese@gmx.de>.
.PP
This manual page was written by Uwe Bugla <uwe.bugla@gmx.de>.
8 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; 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 */
/* Copyright 1999 by Paul Ortyl <ortylp@from.pl> */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "lang.h"
#include "export.h"
#include "font.h"
#define WW (W*CW) /* pixel width of window */
#define WH (H*CH) /* pixel hegiht of window */


static inline void draw_char(unsigned char * colour_matrix, int fg, int bg,
    int c, int dbl, int _x, int _y, int sep)
{
  int x,y;
  unsigned char* src= (latin1==LATIN1 ? font1_bits : font2_bits);
  int dest_x=_x*CW;
  int dest_y=_y*CH;
      
  for(y=0;y<(CH<<dbl); y++)
    {
      for(x=0;x<CW; x++)
	{
	  int bitnr, bit, maskbitnr, maskbit;
	  bitnr=(c/32*CH + (y>>dbl))*CW*32+ c%32*CW +x;
	  bit=(*(src+bitnr/8))&(1<<bitnr%8);
	  if (sep)
	    {
	      maskbitnr=(0xa0/32*CH + (y>>dbl))*CW*32+ 0xa0%32*CW +x;
	      maskbit=(*(src+maskbitnr/8))&(1<<maskbitnr%8);
	      *(colour_matrix+WW*(dest_y+y)+dest_x+x)=
		(char)((bit && (!maskbit)) ? fg : bg);
	    }
	  else 
	    *(colour_matrix+WW*(dest_y+y)+dest_x+x)=
	      (char)(bit ? fg : bg);
	}
    }
  return;
}


static void prepare_colour_matrix(/*struct export *e,*/
		      struct fmt_page *pg, 
		      unsigned char *colour_matrix)
{
   int x, y;
   for (y = 0; y < H; ++y)
	{
	  for (x = 0; x < W; ++x)
	    { 
	      if (pg->dbl & (1<<(y-1)))
		{
		  if (pg->data[y-1][x].attr & EA_HDOUBLE)
		     draw_char(colour_matrix, pg->data[y][x].fg, 
			    pg->data[y][x].bg, pg->data[y][x].ch, 
			    (0), 
			    x, y, 
			    ((pg->data[y][x].attr & EA_SEPARATED) ? 1 : 0)
			    );
		}
	      else
		{
		  draw_char(colour_matrix, pg->data[y][x].fg, 
			    pg->data[y][x].bg, pg->data[y][x].ch, 
			    ((pg->data[y][x].attr & EA_DOUBLE) ? 1 : 0), 
			    x, y, 
			    ((pg->data[y][x].attr & EA_SEPARATED) ? 1 : 0)
			    );
		}
	    }
	}
    return;
}


static int ppm_output(struct export *e, char *name, struct fmt_page *pg);

struct export_module export_ppm = // exported module definition
{
    "ppm",			// id
    "ppm",			// extension
    0,				// options
    0,				// size
    0,				// open
    0,				// close
    0,				// option
    ppm_output			// output
};


static int ppm_output(struct export *e, char *name, struct fmt_page *pg)
{
  FILE *fp;
  long n;
  static u8 rgb1[][3]={{0,0,0},
		      {1,0,0},
		      {0,1,0},
		      {1,1,0},
		      {0,0,1},
		      {1,0,1},
		      {0,1,1},
		      {1,1,1}};
  unsigned char *colour_matrix;

  if (!(colour_matrix=malloc(WH*WW))) 
    {
      export_error("cannot allocate memory");
      return 0;
    }

  prepare_colour_matrix(/*e,*/ pg, (unsigned char *)colour_matrix); 
  if (not(fp = fopen(name, "w")))
    {
      free(colour_matrix);
      export_error("cannot create file");
      return -1;
    }
  fprintf(fp,"P6 %d %d 1\n", WW, WH);

  for(n=0;n<WH*WW;n++)
    {
      if (!fwrite(rgb1[(int) *(colour_matrix+n)], 3, 1, fp))
	{
	  export_error("error while writting to file");
	  free(colour_matrix);
	  fclose(fp);
	  return -1;
	}
    }
  free(colour_matrix);
  fclose(fp);
  return 0;
}


#ifdef WITH_PNG

#include <png.h>
static int png_open(struct export *e);
static int png_option(struct export *e, int opt, char *arg);
static int png_output(struct export *e, char *name, struct fmt_page *pg);
static char *png_opts[] =	// module options
{
    "compression=<0-9>",	// set compression level
    0
};

struct png_data			// private data in struct export
{
    int compression;
};

struct export_module export_png =	// exported module definition
{
    "png",			// id
    "png",			// extension
    png_opts,			// options
    sizeof(struct png_data),	// size
    png_open,			// open
    0,				// close
    png_option,			// option
    png_output			// output
};

#define D  ((struct png_data *)e->data)


static int png_open(struct export *e)
{
    D->compression = Z_DEFAULT_COMPRESSION;
    return 0;
}


static int png_option(struct export *e, int opt, char *arg)
{
    switch (opt)
    {
	case 1: // compression=
	    if (*arg >= '0' && *arg <= '9')
		D->compression = *arg - '0';
	    break;
    }
    return 0;
}


static int png_output(struct export *e, char *name, struct fmt_page *pg)
{
  FILE *fp;
  int x;
  png_structp png_ptr;
  png_infop info_ptr;
  png_byte *row_pointers[WH];
  static u8 rgb8[][3]={{  0,  0,  0},
		      {255,  0,  0},
		      {  0,255,  0},
		      {255,255,  0},
		      {  0,  0,255},
		      {255,  0,255},
		      {  0,255,255},
		      {255,255,255}};
  unsigned char *colour_matrix;

  if (!(colour_matrix=malloc(WH*WW))) 
    {
      export_error("cannot allocate memory");
      return -1;
    }
  prepare_colour_matrix(/*e,*/ pg, (unsigned char *)colour_matrix); 
  if (not(fp = fopen(name, "w")))
    {
      free(colour_matrix);
      export_error("cannot create file");
      return -1;
      }
  png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, 
				    NULL, NULL, NULL);
  if (!png_ptr)
    {
      free(colour_matrix);
      fclose(fp);
      export_error("libpng init error");
      return -1;
    }
  info_ptr = png_create_info_struct(png_ptr);
  if (!info_ptr)
    {
      png_destroy_write_struct(&png_ptr,
			       (png_infopp)NULL);
      free(colour_matrix);
      fclose(fp);
      export_error("libpng init error");
      return -1;
    }
  png_init_io(png_ptr, fp);
  png_set_compression_level(png_ptr, D->compression);
  png_set_compression_mem_level(png_ptr, 9);
  png_set_compression_window_bits(png_ptr, 15);
  png_set_IHDR(png_ptr, info_ptr, WW, WH,
	       8, PNG_COLOR_TYPE_PALETTE , PNG_INTERLACE_NONE,
	       PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
  png_set_PLTE(png_ptr, info_ptr,(png_color*) rgb8 , 8);
  png_write_info(png_ptr, info_ptr);
  for(x=0; x<WH; x++)
    { row_pointers[x]=colour_matrix+x*WW; }
  png_write_image(png_ptr, row_pointers);
  png_write_end(png_ptr, info_ptr);
  png_destroy_write_struct(&png_ptr, &info_ptr);
  free(colour_matrix);
  fclose(fp);
  return 0;
}

#endif