From 45138380ceb9ba3712d01ccfaf08adb2abcd526f Mon Sep 17 00:00:00 2001
From: "Mirar (Pontus Hagland)" <pike@sort.mirar.org>
Date: Thu, 1 May 1997 14:38:41 +0200
Subject: [PATCH] colortable, take 3; an object

Rev: src/modules/Image/colortable.c:1.1
---
 .gitattributes                 |   1 +
 src/modules/Image/colortable.c | 104 +++++++++++++++++++++++++++++++++
 2 files changed, 105 insertions(+)
 create mode 100644 src/modules/Image/colortable.c

diff --git a/.gitattributes b/.gitattributes
index adcf3d1147..d27c86aae2 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -40,6 +40,7 @@ testfont binary
 /src/modules/Gz/zlibmod.c foreign_ident
 /src/modules/Image/blit.c foreign_ident
 /src/modules/Image/blit_layer_include.h foreign_ident
+/src/modules/Image/colortable.c foreign_ident
 /src/modules/Image/dct.c foreign_ident
 /src/modules/Image/font.c foreign_ident
 /src/modules/Image/image.c foreign_ident
diff --git a/src/modules/Image/colortable.c b/src/modules/Image/colortable.c
new file mode 100644
index 0000000000..89bdf2a924
--- /dev/null
+++ b/src/modules/Image/colortable.c
@@ -0,0 +1,104 @@
+#include <config.h>
+
+/* $Id: colortable.c,v 1.1 1997/05/01 12:38:41 mirar Exp $ */
+
+/*
+**! module Image
+**! class colortable
+**!
+**!	This object keeps colortable information,
+**!	mostly for image re-coloring (quantization).
+**!
+**! see also: Image, Image.image, Image.font
+*/
+
+
+#include "global.h"
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <netinet/in.h>
+#include <errno.h>
+
+#include "config.h"
+
+#include "stralloc.h"
+#include "types.h"
+#include "pike_macros.h"
+#include "object.h"
+#include "constants.h"
+#include "interpret.h"
+#include "svalue.h"
+#include "array.h"
+#include "threads.h"
+#include "builtin_functions.h"
+
+#include "image.h"
+
+
+struct program *colortable_program;
+
+#define THIS (*(struct colortable **)(fp->current_storage))
+#define THISOBJ (fp->current_object)
+
+#if 0
+
+/***************** init & exit *********************************/
+
+static inline void free_colortable_struct(struct colortable *colortable)
+{
+   if (colortable)
+   {
+      if (colortable->mem)
+      {
+#ifdef HAVE_MMAP
+	 munmap(colortable->mem,colortable->mmaped_size);
+#else
+	 free(colortable->mem);
+#endif
+      }
+      free(colortable);
+   }
+}
+
+static void init_colortable_struct(struct object *o)
+{
+  THIS=NULL;
+}
+
+static void exit_colortable_struct(struct object *obj)
+{
+   free_colortable_struct(THIS);
+   THIS=NULL;
+}
+
+/***************** global init etc *****************************/
+
+/*
+
+*/
+
+void init_colortable_programs(void)
+{
+   start_new_program();
+   add_storage(sizeof(struct colortable*));
+
+   set_init_callback(init_colortable_struct);
+   set_exit_callback(exit_colortable_struct);
+  
+   colortable_program=end_program();
+   add_program_constant("colortable",colortable_program, 0);
+}
+
+void exit_colortable(void) 
+{
+  if(colortable_program)
+  {
+    free_program(colortable_program);
+    colortable_program=0;
+  }
+}
+
+
+#endif
-- 
GitLab