Index: kit/CHANGELOG
diff -u kit/CHANGELOG:1.9 kit/CHANGELOG:removed
--- kit/CHANGELOG:1.9	Sat Sep  5 00:11:21 1998
+++ kit/CHANGELOG	Mon Jan  8 05:10:00 2007
@@ -1,51 +0,0 @@
-CHANGELOG for magicpoint
-$Id: CHANGELOG,v 1.9 1998/09/04 15:11:21 onoe Exp $
-
-Fri Sep  5 1998  onoe@sm.sony.co.jp
-	* handle key inputs from invoked terminal as pressed on Xserver,
-	  even if the Xserver is running on a remote host.
-
-Mon Aug 26 1998  itojun@iijlab.net
-	* new copyright. (BSDish copyright without clause 3)
-
-Mon Aug 25 1998  itojun@iijlab.net
-	* print.c: better x11/freetype/vflib -> postscript font mapping.
-
-Mon Aug 23 1998  kato@wide.ad.jp
-	* embedded image support (added mgpembed.pl and embed.c)
-
-Mon Aug 22 1998  itojun@iijlab.net
-	* added contrib/xmindpath, MindPath PocketPoint user-level driver.
-
-Fri Jul 10 11:57:59 JST 1998  itojun@iijlab.net
-	* cache gs-generated image file.
-	  Suggested by: luigi@FreeBSD.org
-
-Mon Jul  6 11:38:32 JST 1998  itojun@iijlab.net
-	* capable of handling GB2312 and KSC5601 encoding.
-	  they must be encoded by using iso-2022 like escape sequences.
-	  EUC-cn or EUC-kr does not work.
-	* -x option is added.
-
-Thu Jul  2 18:04:16 JST 1998  itojun@iijlab.net
-	* eliminate gsview.
-	* revamp "xfont" directive. (see SYNTAX for detail)
-
-Thu Jun 25 13:10:28 JST 1998  itojun@iijlab.net
-	* print.c: color postscript support by "mgp2ps -c".
-
-changes between 1.02a and 1.03a:
-	* To allow color name that has space inbetween ("dark blue"), 
-	  color name after directives SHOULD come with doublequote.
-	  Therefore,
-		%fore blue
-	  should be
-		%fore "blue"
-	  At this moment, doublequote can be ommitted for backward
-	  compatibility.  We may require to have doublequote in the future.
-	  Font names and other string parameter obeys the same rule.
-	* %image is now capable of rendering encapsulated postscript files
-	  (*.eps).
-		%image foo.eps
-	  should work fine.
-	  By using -X option, you can specify device name for ghostscript.
Index: kit/SYNTAX
diff -u kit/SYNTAX:1.41 kit/SYNTAX:1.42
--- kit/SYNTAX:1.41	Fri May 20 01:30:03 2005
+++ kit/SYNTAX	Sun Jan  7 18:41:53 2007
@@ -1,4 +1,4 @@
-$Id: SYNTAX,v 1.41 2005/05/19 16:30:03 nishida Exp $
+$Id: SYNTAX,v 1.42 2007/01/07 09:41:53 nishida Exp $
 
 placement restriction for directives:
 		.mgprc		preamble	main pages
@@ -219,6 +219,9 @@
 		raise the baseline of the image in the line.	
 		Percentage is against the height of the image. 
 		"100" means the height of the image.
+        -rotate degrees
+		degrees is angel measure counter clockwise, supported values are
+		0, -90, 90, -180, 180, 270
 
 	TODO: supersede %image by %newimage?
 	TODO: option for auto resize mode (fit image into the room left on
Index: kit/ctlwords.pl
diff -u kit/ctlwords.pl:1.2 kit/ctlwords.pl:removed
--- kit/ctlwords.pl:1.2	Sat Sep  5 06:05:08 1998
+++ kit/ctlwords.pl	Mon Jan  8 05:10:00 2007
@@ -1,12 +0,0 @@
-#! /usr/bin/perl
-$counter = 0;	# 0 origin
-print "/* generated by ctlwords.awk. do not edit by hand. */\n";
-
-while (<>) {
-	next if (!/^\/\*CTL\*\//);
-	next if ($_ !~ /(CTL_[A-Z0-9]+)/);
-
-	$word = $1;
-	print "#define $word\t$counter\n";
-	$counter++;
-}
Index: kit/draw.c
diff -u kit/draw.c:1.230 kit/draw.c:1.231
--- kit/draw.c:1.230	Fri Dec 29 03:12:06 2006
+++ kit/draw.c	Sun Jan  7 18:41:53 2007
@@ -26,7 +26,7 @@
  * SUCH DAMAGE.
  */
 /*
- * $Id: draw.c,v 1.230 2006/12/28 18:12:06 nishida Exp $
+ * $Id: draw.c,v 1.231 2007/01/07 09:41:53 nishida Exp $
  */
 
 #include "mgp.h"
@@ -101,8 +101,8 @@
 
 static void back_gradation __P((struct render_state *, struct ctrl_grad *));
 #if 1  /* by h.kakugawa@computer.org */
-static void image_load __P((struct render_state *, char *, int, int, int, int, int, int, int));
-static void image_load_ps __P((struct render_state *, char *, int, int, int, int, int, int, int));
+static void image_load __P((struct render_state *, char *, int, int, int, int, int, int, int, int));
+static void image_load_ps __P((struct render_state *, char *, int, int, int, int, int, int, int, int));
 #else
 static void image_load __P((struct render_state *, char *, int, int, int, int, int, int));
 static void image_load_ps __P((struct render_state *, char *, int, int, int, int, int, int));
@@ -661,7 +661,7 @@
 #if 1  /* by h.kakugawa@computer.org */
 			image_load_ps(state, cp->ctm_fname, cp->ctm_numcolor,
 				cp->ctm_ximagesize, cp->ctm_yimagesize, 0,
-				cp->ctm_zoomflag, 0, cp->ctm_raise);
+				cp->ctm_zoomflag, 0, cp->ctm_raise, cp->ctm_rotate);
 #else
 			image_load_ps(state, cp->ctm_fname, cp->ctm_numcolor,
 				cp->ctm_ximagesize, cp->ctm_yimagesize, 0,
@@ -671,7 +671,7 @@
 #if 1  /* by h.kakugawa@computer.org */
 			image_load(state, cp->ctm_fname, cp->ctm_numcolor,
 				cp->ctm_ximagesize, cp->ctm_yimagesize, 0,
-				cp->ctm_zoomflag, 0, cp->ctm_raise);
+				cp->ctm_zoomflag, 0, cp->ctm_raise, cp->ctm_rotate);
 #else
 			image_load(state, cp->ctm_fname, cp->ctm_numcolor,
 				cp->ctm_ximagesize, cp->ctm_yimagesize, 0,
@@ -3018,8 +3018,106 @@
 	XFlush(display);
 }
 
+
+/* !TODO: move rotation code into some library */
+/* rotate image by 90 degrees (counter clockwise) */
+static void rotate_image_p90(image)
+	Image *image;
+{
+	unsigned int row, column, pl = image->pixlen;
+	unsigned int new_height = image->width, new_width = image->height, new_linelen = new_width * pl;
+	byte *src, *tgt, *col_head;
+	Pixel d;
+	/* allocate buffer for new image */
+	byte *rot_data = lmalloc(new_linelen * new_height);
+
+	/* do the rotation */
+	for (row = 0, src = image->data, col_head = rot_data + (new_height - 1) * new_linelen; 
+			row < image->height; 
+			row++, col_head += pl) {
+		for (column = 0, tgt = col_head; 
+				column < image->width; 
+				column++, src += pl, tgt -= new_linelen) {
+			d = memToVal(src, pl);
+			valToMem(d, tgt, pl);
+		}
+	}
+
+	/* swap to rotated image, exchange height and width
+	   and point to rotated data */
+	image->height = new_height;
+	image->width = new_width;
+	lfree(image->data);
+	image->data = rot_data;
+}
+
+
+/* rotate image by -90 degrees (clockwise) */
+static void rotate_image_m90(image)
+Image *image;
+{
+	unsigned int row, column, pl = image->pixlen;
+	unsigned int new_height = image->width, new_width = image->height, new_linelen = new_width * pl;
+	byte *src, *tgt;
+	Pixel d;
+	/* allocate buffer for new image */
+	byte *rot_data = lmalloc(new_linelen * new_height);
+
+	/* do the rotation */
+	for (row = 0, src = image->data; row < image->height; row++) {
+		for (column = 0, tgt = rot_data + new_linelen - (row + 1) * pl; 
+				column < image->width; 
+				column++, src += pl, tgt += new_linelen) {
+			d = memToVal(src, pl);
+			valToMem(d, tgt, pl);
+		}
+	}
+
+	/* swap to rotated image, exchange height and width
+	   and point to rotated data */
+	image->height = new_height;
+	image->width = new_width;
+	lfree(image->data);
+	image->data = rot_data;
+
+	return;
+}
+
+
+/* rotate image by 180 degrees */
+static void rotate_image_180(image)
+	Image *image;
+{
+	unsigned int row, column, pl = image->pixlen;
+	unsigned int new_height = image->height, new_width = image->width, new_linelen = new_width * pl;
+	byte *src, *tgt;
+	Pixel d;
+	/* allocate buffer for new image */
+	byte *rot_data = lmalloc(new_linelen * new_height);
+
+	/* do the rotation */
+	for (row = 0, src = image->data; row < image->height; row++) {
+		for (column = 0, tgt = rot_data + (new_height - row) * new_linelen - pl; 
+				column < image->width; 
+				column++, src += pl, tgt -= pl) {
+			d = memToVal(src, pl);
+			valToMem(d, tgt, pl);
+		}
+	}
+
+	/* swap to rotated image, exchange height and width
+	   and point to rotated data */
+	image->height = new_height;
+	image->width = new_width;
+	lfree(image->data);
+	image->data = rot_data;
+
+	return;
+}
+
+
 static void
-image_load(state, filename, numcolor, ximagesize, yimagesize, backflag, zoomflag, centerflag, raise)
+image_load(state, filename, numcolor, ximagesize, yimagesize, backflag, zoomflag, centerflag, raise, rotate)
 	struct render_state *state;
 	char *filename;
 	int numcolor;
@@ -3028,6 +3126,8 @@
 	int backflag;
 	int zoomflag;
 	int centerflag;
+	int raise;
+	int rotate;
 {
 	Image *image, *myimage;
 	Pixmap mypixmap;
@@ -3051,6 +3151,29 @@
 		fprintf(stderr, "failed to load image file\n");
 		cleanup(-1);
 	}
+	switch (rotate) {
+		case 0:
+			/* Do nothing */
+			break;
+	
+		case -90:
+		case 270:
+			rotate_image_m90(myimage);
+			break;
+
+		case 90:
+			rotate_image_p90(myimage);
+			break;
+
+		case -180:
+		case 180:
+			rotate_image_180(myimage);
+			break;
+
+		default:
+			fprintf(stderr, "rotation by %d degrees not supported.\n", rotate);
+			cleanup(-1);
+	}
 	width = myimage->width;
 	height = myimage->height;
 
@@ -3184,7 +3307,7 @@
 }
 
 static void
-image_load_ps(state, filename, numcolor, ximagesize, yimagesize, backflag, zoomflag, centerflag, raise)
+image_load_ps(state, filename, numcolor, ximagesize, yimagesize, backflag, zoomflag, centerflag, raise, rotate)
 	struct render_state *state;
 	char *filename;
 	int numcolor;
@@ -3193,6 +3316,8 @@
 	int backflag;
 	int zoomflag;
 	int centerflag;
+	int raise;
+	int rotate;
 {
 	int x1, y1, x2, y2;
 	static Cursor curs;
@@ -3273,7 +3398,7 @@
 			filename, gsdevice, imagefile);
 	}
 	image_load(state, imagefile, numcolor, 100, 100, backflag,
-		Z_NORMAL | (Z_NORMAL << Z_YSHIFT), centerflag, raise);
+		Z_NORMAL | (Z_NORMAL << Z_YSHIFT), centerflag, raise, rotate);
 	/* XXX: unlink imagefile in /tmp */
 	if ((p = strrchr(imagefile, '/')) != NULL)
 		p++;
@@ -3379,7 +3504,7 @@
 		if (icon_y == 0) icon_y = 1;
 		tmp_color = fore_color[caching];
 		fore_color[caching] = cp->ctic_color;
-		image_load(state, cp->ctic_value, 0, icon_x, icon_y, 0, 0, 1, 0);
+		image_load(state, cp->ctic_value, 0, icon_x, icon_y, 0, 0, 1, 0, 0);
 		fore_color[caching] = tmp_color;
 		break;
 
@@ -4761,7 +4886,7 @@
 		case CTL_BIMAGE: 
 			image_load(state, ctl->ctm_fname, ctl->ctm_numcolor,
 						ctl->ctm_ximagesize, ctl->ctm_yimagesize, 1,
-						ctl->ctm_zoomflag, 0, 0);
+						ctl->ctm_zoomflag, 0, 0, ctl->ctm_rotate);
 			break;
 		case CTL_BGRAD:
 			back_gradation(state, &ctl->ct_val.ctrl_grad);
Index: kit/grammar.y
diff -u kit/grammar.y:1.46 kit/grammar.y:1.47
--- kit/grammar.y:1.46	Sun May 28 18:59:34 2006
+++ kit/grammar.y	Sun Jan  7 18:41:53 2007
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  */
 /*
- * $Id: grammar.y,v 1.46 2006/05/28 09:59:34 nishida Exp $
+ * $Id: grammar.y,v 1.47 2007/01/07 09:41:53 nishida Exp $
  */
 /*
  * partly derived from lbl libpcap source code, which has the following
@@ -357,6 +357,7 @@
 	ct->ctm_yimagesize = 100;
 	ct->ctm_zoomflag = Z_NORMAL | (Z_NORMAL << Z_YSHIFT);
 	ct->ctm_raise = 0;
+	ct->ctm_rotate = 0;
 
 	for (p = arg; p; p = p->ct_next) {
 		if (p->ctc_value[0] != '-')
@@ -409,6 +410,9 @@
 		} else if (strcmp(p->ctc_value, "-raise") == 0 && p->ct_next) {
 			p = p->ct_next;
 			ct->ctm_raise = atoi(p->ctc_value);
+		} else if (strcmp(p->ctc_value, "-rotate") == 0 && p->ct_next) {
+			p = p->ct_next;
+			ct->ctm_rotate = atoi(p->ctc_value);
 		} else {
 			yyerror("invalid argument %s specified for newimage",
 				p->ctc_value);
Index: kit/mgp.h
diff -u kit/mgp.h:1.142 kit/mgp.h:1.143
--- kit/mgp.h:1.142	Sun May 28 15:01:31 2006
+++ kit/mgp.h	Sun Jan  7 18:41:53 2007
@@ -26,7 +26,7 @@
  * SUCH DAMAGE.
  */
 /*
- * $Id: mgp.h,v 1.142 2006/05/28 06:01:31 nishida Exp $
+ * $Id: mgp.h,v 1.143 2007/01/07 09:41:53 nishida Exp $
  */
 
 #include <stdio.h>
@@ -246,6 +246,7 @@
 	u_int ct_yimagesize;
 	u_int ct_zoomflag;
 	u_int ct_raise;
+	u_int ct_rotate; /* +/-180, +/-90, 0, 270 */
 #define Z_XMASK		0x0f
 #define Z_YMASK		0xf0
 #define Z_YSHIFT	4
@@ -344,6 +345,7 @@
 #define ctm_yimagesize	ct_val.ctrl_image.ct_yimagesize
 #define ctm_zoomflag	ct_val.ctrl_image.ct_zoomflag
 #define ctm_raise	ct_val.ctrl_image.ct_raise
+#define ctm_rotate	ct_val.ctrl_image.ct_rotate
 #define ctd_colors	ct_val.ctrl_grad.colors
 #define ctd_g_colors	ct_val.ctrl_grad.ct_g_colors
 #define ctd_numcolor	ct_val.ctrl_grad.ct_numcolor
Index: kit/print.c
diff -u kit/print.c:1.106 kit/print.c:1.108
--- kit/print.c:1.106	Wed Jul 28 22:36:28 2004
+++ kit/print.c	Sun Jan  7 19:30:46 2007
@@ -26,7 +26,7 @@
  * SUCH DAMAGE.
  */
 /*
- * $Id: print.c,v 1.106 2004/07/28 13:36:28 nishida Exp $
+ * $Id: print.c,v 1.108 2007/01/07 10:30:46 nishida Exp $
  */
 /*
  * Paper size selection code is based on psutil.c by Angus J. C. Duggan
@@ -298,7 +298,7 @@
 static void text_remember __P((char *, int, int, int, int));
 static void icon_remember __P((int, int, int, u_long));
 static void image_remember __P((struct ctrl *, struct imagepool *));
-static void image_load_print __P((char *, int, int, int, int, int));
+static void image_load_print __P((char *, int, int, int, int, int, int));
 static void print_usage __P((char *));
 static void setpencolor __P((u_long));
 static void print_full_image __P((XImage *, Visual *));
@@ -1136,7 +1136,12 @@
 		break;
 	}
 	fprintf(fp, "/xpos xpos %d add def\n", tabxprefix ? tabxprefix:xprefix);
+#if 0
 	fprintf(fp, "xpos yypos ymax sub moveto\n");
+#else
+	/* XXX, put a litte margin for text drawing. very ugly */
+	fprintf(fp, "xpos yypos ymax sub charsize 10 div add moveto\n");
+#endif
 
 	for (i = 0; i < ntextpool; i++) {
 		if (textpool[i].text) {
@@ -1212,7 +1217,7 @@
 		if (cp1) {
 			image_load_print(cp1->ctm_fname, cp1->ctm_numcolor,
 				cp1->ctm_ximagesize, cp1->ctm_yimagesize, 0,
-				cp1->ctm_zoomflag);
+				cp1->ctm_zoomflag, cp1->ctm_rotate);
 		}
         fprintf(fp, "/xpos xpos%d def xpos ypos moveto\n",
 	        imagepool[i].target_text);
@@ -1237,8 +1242,8 @@
 	int ixoff, iyoff;
 	int paintit;
 
-	iyoff = (csize - isize) / 3;	/*XXX*/
-	ixoff = tp->xoffset + iyoff;
+	iyoff = (csize - isize) / 6;	/*XXX*/
+	ixoff = tp->xoffset + (csize - isize) / 2;  /* XXX */
 
 	paintit = (painticon || colorps);
 
@@ -1246,7 +1251,7 @@
 	case 0:
 		/* XXX: image is not supported yet */
 		break;
-	case 1:
+	case 1: /* this is box */
 		fprintf(fp, "currentpoint ");
 		if (paintit)
 			fprintf(fp, "currentpoint newpath moveto ");
@@ -1260,7 +1265,7 @@
 		fprintf(fp, "stroke moveto\n");
 		fprintf(fp, "%d 0 rmoveto\n", ixoff * 2 + isize);
 		break;
-	case 2:
+	case 2: /* this is arc */
 		fprintf(fp, "currentpoint ");
 		if (paintit)
 			fprintf(fp, "currentpoint newpath moveto ");
@@ -1606,6 +1611,105 @@
 	ntextpool++;
 }
 
+
+/* !TODO: move rotation code into some library */
+/* rotate image by 90 degrees (counter clockwise) */
+static void rotate_image_p90(image)
+	Image *image;
+{
+	unsigned int row, column, pl = image->pixlen;
+	unsigned int new_height = image->width, new_width = image->height, new_linelen = new_width * pl;
+	byte *src, *tgt, *col_head;
+	Pixel d;
+	/* allocate buffer for new image */
+	byte *rot_data = lmalloc(new_linelen * new_height);
+
+	/* do the rotation */
+	for (row = 0, src = image->data, col_head = rot_data + (new_height - 1) * new_linelen; 
+			row < image->height; 
+			row++, col_head += pl) {
+		for (column = 0, tgt = col_head; 
+				column < image->width; 
+				column++, src += pl, tgt -= new_linelen) {
+			d = memToVal(src, pl);
+			valToMem(d, tgt, pl);
+		}
+	}
+
+	/* swap to rotated image, exchange height and width
+	   and point to rotated data */
+	image->height = new_height;
+	image->width = new_width;
+	lfree(image->data);
+	image->data = rot_data;
+}
+
+
+/* rotate image by -90 degrees (clockwise) */
+static void rotate_image_m90(image)
+Image *image;
+{
+	unsigned int row, column, pl = image->pixlen;
+	unsigned int new_height = image->width, new_width = image->height, new_linelen = new_width * pl;
+	byte *src, *tgt;
+	Pixel d;
+	/* allocate buffer for new image */
+	byte *rot_data = lmalloc(new_linelen * new_height);
+
+	/* do the rotation */
+	for (row = 0, src = image->data; row < image->height; row++) {
+		for (column = 0, tgt = rot_data + new_linelen - (row + 1) * pl; 
+				column < image->width; 
+				column++, src += pl, tgt += new_linelen) {
+			d = memToVal(src, pl);
+			valToMem(d, tgt, pl);
+		}
+	}
+
+	/* swap to rotated image, exchange height and width
+	   and point to rotated data */
+	image->height = new_height;
+	image->width = new_width;
+	lfree(image->data);
+	image->data = rot_data;
+
+	return;
+}
+
+
+/* rotate image by 180 degrees */
+static void rotate_image_180(image)
+	Image *image;
+{
+	unsigned int row, column, pl = image->pixlen;
+	unsigned int new_height = image->height, new_width = image->width, new_linelen = new_width * pl;
+	byte *src, *tgt;
+	Pixel d;
+	/* allocate buffer for new image */
+	byte *rot_data = lmalloc(new_linelen * new_height);
+
+	/* do the rotation */
+	for (row = 0, src = image->data; row < image->height; row++) {
+		for (column = 0, tgt = rot_data + (new_height - row) * new_linelen - pl; 
+				column < image->width; 
+				column++, src += pl, tgt -= pl) {
+			d = memToVal(src, pl);
+			valToMem(d, tgt, pl);
+		}
+	}
+
+	/* swap to rotated image, exchange height and width
+	   and point to rotated data */
+	image->height = new_height;
+	image->width = new_width;
+	lfree(image->data);
+	image->data = rot_data;
+
+	return;
+}
+
+
+
 static void
 image_remember(cp, pool)
 	struct ctrl *cp;
@@ -1628,6 +1732,29 @@
 			fprintf(stderr, "failed to open %s\n", cp->ctm_fname);
 			exit(1);
 		}
+		switch (cp->ctm_rotate) {
+			case 0:
+				/* Do nothing */
+				break;
+		
+			case -90:
+			case 270:
+				rotate_image_m90(myimage);
+				break;
+
+			case 90:
+				rotate_image_p90(myimage);
+				break;
+
+			case -180:
+			case 180:
+				rotate_image_180(myimage);
+				break;
+
+			default:
+				fprintf(stderr, "rotation by %d degrees not supported.\n", rotate);
+				cleanup(-1);
+		}
 		width = myimage->width;
 		height = myimage->height;
 		freeImage(myimage);
@@ -1654,6 +1781,29 @@
 		fprintf(stderr, "failed to open %s\n", cp->ctm_fname);
 		exit(1);
 	}
+	switch (cp->ctm_rotate) {
+		case 0:
+			/* Do nothing */
+			break;
+	
+		case -90:
+		case 270:
+			rotate_image_m90(myimage);
+			break;
+
+		case 90:
+			rotate_image_p90(myimage);
+			break;
+
+		case -180:
+		case 180:
+			rotate_image_180(myimage);
+			break;
+
+		default:
+			fprintf(stderr, "rotation by %d degrees not supported.\n", rotate);
+			cleanup(-1);
+	}
 	pool->xsiz = myimage->width;
 	pool->ysiz = myimage->height;
 	freeImage(myimage);
@@ -1662,13 +1812,14 @@
 }
 
 static void
-image_load_print(filename, numcolor, ximagesize, yimagesize, backflag, zoomflag)
+image_load_print(filename, numcolor, ximagesize, yimagesize, backflag, zoomflag, rotate)
 	char *filename;
 	int numcolor;
 	int ximagesize;
 	int yimagesize;
 	int backflag;
 	int zoomflag;
+	int rotate;
 {
 	Image *myimage, *image;
 	Pixmap mypixmap;
@@ -1707,6 +1858,29 @@
 
 	if ((myimage = loadImage(filename, verbose)) == NULL)
 		exit(-1);	/* fail to load image data */
+	switch (rotate) {
+		case 0:
+			/* Do nothing */
+			break;
+	
+		case -90:
+		case 270:
+			rotate_image_m90(myimage);
+			break;
+
+		case 90:
+			rotate_image_p90(myimage);
+			break;
+
+		case -180:
+		case 180:
+			rotate_image_180(myimage);
+			break;
+
+		default:
+			fprintf(stderr, "rotation by %d degrees not supported.\n", rotate);
+			cleanup(-1);
+	}
 	width = myimage->width;
 	height = myimage->height;
 
Index: kit/image/gif.h
diff -u kit/image/gif.h:1.2 kit/image/gif.h:removed
--- kit/image/gif.h:1.2	Mon Dec 28 17:23:03 1998
+++ kit/image/gif.h	Mon Jan  8 05:10:01 2007
@@ -1,72 +0,0 @@
-/* gif.h:
- *
- * gifin.h
- * kirk johnson
- * november 1989
- * external interface to gifin.c
- *
- * Copyright 1989 Kirk L. Johnson (see the included file
- * "kljcpyrght.h" for complete copyright information)
- */
-
-/*
- * gifin return codes
- */
-#define GIFIN_SUCCESS       0   /* success */
-#define GIFIN_DONE          1   /* no more images */
-
-#define GIFIN_ERR_BAD_SD   -1   /* bad screen descriptor */
-#define GIFIN_ERR_BAD_SEP  -2   /* bad image separator */
-#define GIFIN_ERR_BAD_SIG  -3   /* bad signature */
-#define GIFIN_ERR_EOD      -4   /* unexpected end of raster data */
-#define GIFIN_ERR_EOF      -5   /* unexpected end of input stream */
-#define GIFIN_ERR_FAO      -6   /* file already open */
-#define GIFIN_ERR_IAO      -7   /* image already open */
-#define GIFIN_ERR_NFO      -8   /* no file open */
-#define GIFIN_ERR_NIO      -9   /* no image open */
-
-/*
- * colormap indices 
- */
-
-#define GIF_RED  0
-#define GIF_GRN  1
-#define GIF_BLU  2
-
-/*
- * typedef BYTE for convenience
- */
-
-typedef unsigned char BYTE;
-
-static int gifin_open_file();
-static int gifin_open_image();
-static int gifin_get_pixel();
-#if 0
-static int gifin_close_image();
-#endif
-static int gifin_close_file();
-static int gifin_load_cmap();
-static int gifin_skip_extension();
-static int gifin_read_data_block();
-static int gifin_push_string();
-static void gifin_add_string();
-static void gifin_fatal();
-
-/* #defines, typedefs, and such
- */
-
-#define GIF_SIG      "GIF87a"
-#define GIF_SIG_89   "GIF89a"
-#define GIF_SIG_LEN  6          /* GIF signature length */
-#define GIF_SD_SIZE  7          /* GIF screen descriptor size */
-#define GIF_ID_SIZE  9          /* GIF image descriptor size */
-
-#define GIF_SEPARATOR   ','     /* GIF image separator */
-#define GIF_EXTENSION   '!'     /* GIF extension block marker */
-#define GIF_TERMINATOR  ';'     /* GIF terminator */
-
-#define STAB_SIZE  4096         /* string table size */
-#define PSTK_SIZE  4096         /* pixel stack size */
-
-#define NULL_CODE  -1           /* string table null code */
Index: kit/sample/cloud.gif
Index: kit/sample/dad.gif
Index: kit/sample/dns-jp.mgp
diff -u kit/sample/dns-jp.mgp:1.5 kit/sample/dns-jp.mgp:removed
--- kit/sample/dns-jp.mgp:1.5	Fri Sep  4 21:33:18 1998
+++ kit/sample/dns-jp.mgp	Mon Jan  8 05:10:01 2007
@@ -1,130 +0,0 @@
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%
-%%	This file is automatically created from the file
-%%	main.pre modified at Fri Jan 23 14:31:24 1998
-%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%
-%include "default.mgp"
-%% "noop" cancels definitions in default.mgp
-%default 1 left, size 7, fore "light yellow", back "blue4", font "standard", ccolor "white", vgap 35
-%default 2 noop
-%default 3 fore "white", bar "gray70", vgap 10
-%default 4 noop
-%tab 1 noop
-%tab 2 noop
-%tab 3 noop
-%%%
-%page
-%nodefault
-%fore "red", back "blue4", size 9, vgap 15
-%center, fore "yellow", font "thick"
-%ccolor "white"
-
-
-
-Root DNS `M' $B$K$D$$$F(B
-
-%size 6, fore "red", font "thick"
-$B2CF#(B   $BO/(B
-
-%size 5, fore "white", font "standard"
-$BEl5~Bg3XBg7?7W;;5!%;%s%?!<(B
-
-
-%font "typewriter"
-kato@wide.ad.jp
-%font "standard"
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%page
-
-%back "blue4"
-  $B7P0^(B (1)
-%fore "red", size 6, font "thick"
-   $B!y(B Root DNS
-%fore "white", size 5, font "standard"
-       $B!&(B $B#9Bf$G1?MQ(B
-%fore "white", size 5, font "standard"
-          $B!](B $B#8Bf$,(B US
-          $B!](B Stockholm $B$K#1Bf(B
-%fore "white", size 5, font "standard"
-       $B!&(B $B:GBg$G#1#3Bf(B
-%fore "white", size 5, font "standard"
-          $B!](B $B%Q%1%C%HD9$N@)Ls(B
-%fore "red", size 6, font "thick"
-   $B!y(B Root DNS $B$N1?MQ4p=`(B
-%fore "white", size 5, font "standard"
-       $B!&(B RFC 2010
-       $B!&(B gTLD $B$H$N4X78(B
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%page
-
-%back "blue4"
-  $B7P0^(B (2)
-%fore "red", size 6, font "thick"
-   $B!y(B IEPG $B$G3HD%$r8!F$(B
-   $B!y(B $B%h!<%m%C%QCO0h(B
-%fore "white", size 5, font "standard"
-       $B!&(B LINX $B$K?7@_(B : 1997 $BG/(B 4 $B7n(B
-%fore "white", size 5, font "standard"
-          $B!](B RIPE/NCC $B$,4IM}(B
-          $B!](B `K'
-%fore "red", size 6, font "thick"
-   $B!y(B $B%"%8%"B@J?MNCO0h(B
-%fore "white", size 5, font "standard"
-       $B!&(B NSPIXP-2 $B!'(B 1997 $BG/(B 8 $B7n(B
-%fore "white", size 5, font "standard"
-          $B!](B WIDE $B$,4IM}(B
-          $B!](B `M'
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%page
-
-%back "blue4"
-  `M'
-%fore "red", size 6, font "thick"
-   $B!y(B $B9=@.(B
-%fore "white", size 5, font "standard"
-       $B!&(B $B#2Bf$N(B PentiumPro 200MHz
-       $B!&(B Primary/Backup$B!"(B $B<+F0@Z$jBX$((B
-%fore "red", size 6, font "thick"
-   $B!y(B Root-only $B%5!<%P(B
-%fore "white", size 5, font "standard"
-       $B!&(B 
-%cont, font "typewriter"
-202.12.27.33
-%font "standard"
-       $B!&(B 400 $B!A(B 500 query/sec
-%fore "red", size 6, font "thick"
-   $B!y(B $B1?MQ4IM}(B
-%fore "white", size 5, font "standard"
-       $B!&(B WIDE $B$*$h$S(B ISP $BM-;V(B
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%page
-
-%back "blue4"
-  $B$*4j$$(B
-%fore "red", size 6, font "thick"
-   $B!y(B $B:G?7$N(B root.cache $B$NF~$l49$((B
-%fore "white", size 5, font "standard"
-       $B!&(B 
-%cont, font "typewriter"
-1997082200
-%fore "red", size 6, font "thick"
-   $B!y(B Named $B$N99?7(B
-%fore "white", size 5, font "standard"
-       $B!&(B 4.9.6/8.8.1
-%fore "red", size 6, font "thick"
-   $B!y(B $BM7$P$J$$$G!'(B
-%fore "white", size 5, font "standard"
-       $B!&(B 
-%cont, font "typewriter"
-ping/traceroute
-%font "standard"
-       $B!&(B 
-%cont, font "typewriter"
-telnet/spray/...
-%fore "red", size 6, font "thick"
-   $B!y(B Thanks to
-%fore "white", size 5, font "standard"
-       $B!&(B $BF|K\(B Cisco/$BB?$/$N(B ISP
-       $B!&(B `M' $B4IM}%0%k!<%W(B
Index: kit/sample/mgp-old1.gif
Index: kit/sample/mgp-old2.gif
Index: kit/sample/mgp-old3.gif
Index: kit/sample/mgp1.gif
Index: kit/sample/mgp2.gif
Index: kit/sample/mgp3.gif
Index: kit/sample/v6header.gif
