summaryrefslogtreecommitdiff
path: root/gs/src/gsnotify.c
diff options
context:
space:
mode:
authorHenry Stiles <henry.stiles@artifex.com>1999-10-03 08:21:45 +0000
committerHenry Stiles <henry.stiles@artifex.com>1999-10-03 08:21:45 +0000
commitee50b36ccabde111c6d77c5f9892213d53060a18 (patch)
tree35f7e38774b082c4cdbe4f4fad881903862a83c2 /gs/src/gsnotify.c
parent0ea97dbf2a40bc347a20134197643bc1daef6de8 (diff)
This is the first gs593 integration it is *NOT* a release. Normally
each file is checked in with an associated log entry, in order to check in all of the code simultaneously we batch all of the file name's modified and change descriptions here (Note: Aladdin code changes are documented in gs/doc/News.htm) - pcstate.h - removes show enumeration from pcl state. - pctop.c, pxtop.c - gs_grestore_no_wraparound()'s is now gs_grestore_only(). - pxgstate.c - ENUM_RETURN_CONST_STRING_PTR() now takes a gs string argument instead of the string's data as it did previously. - plmain.c - - The library no longer initializes io devices. Adds gs_iodev_init() to main() procedure. Also, gs_c_param_list_rewrite() is renamed to gs_c_param_list_write_more(). - pcltop.mak - adds pipe.dev for operating system pipe support. - pctext.c, pglabel.c, pxfont.c, plfont.c - extensive modifications to support the text api (gstext.h) - use gs_text_enum_t instead of gs_show_enum. - removes enumeration allocation, this is now done by the text "begin" functions. - update "next_char" procs and "encode char" procs to take a glyph argument and the character argument is now passed by value (pcl nor xl make use of the glyph argument). - char_path_n_init() replaced with gs_charpath_begin(). - gs_show_n_init() replaced with gs_show_begin(). - gs_show_next() is now handled by gs_process_text(). - gs_release_text() added. - gs_xyshow_n_init() replace with gs_xyshow_begin(). Passing of x and y coordinates modified to support the new interface. Unfortunately, we need to transform the coordinates into the space of the font scaling matrix, that is the current ctm for xl when the the text is processed. This differs from postscript which appears to have the regular user->device matrix in the graphics state during processing. - (plfont.c) - gs_notify_init() is now part of the pfont initialization procedure, related TODO: cut over to gs_font_alloc() and gs_font_base_alloc(). - all gs files - removes uninitialized rcs identifiers. KNOWN PROBLEMS: occassional pxl and pcl crashes in gdev_mem_set_line_ptrs() when running in color due to null base (data) pointer. git-svn-id: http://svn.ghostscript.com/ghostpcl/trunk/ghostpcl@985 06663e23-700e-0410-b217-a244a6096597
Diffstat (limited to 'gs/src/gsnotify.c')
-rw-r--r--gs/src/gsnotify.c115
1 files changed, 115 insertions, 0 deletions
diff --git a/gs/src/gsnotify.c b/gs/src/gsnotify.c
new file mode 100644
index 000000000..33b3b7d89
--- /dev/null
+++ b/gs/src/gsnotify.c
@@ -0,0 +1,115 @@
+/* Copyright (C) 1999 Aladdin Enterprises. All rights reserved.
+
+ This file is part of Aladdin Ghostscript.
+
+ Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author
+ or distributor accepts any responsibility for the consequences of using it,
+ or for whether it serves any particular purpose or works at all, unless he
+ or she says so in writing. Refer to the Aladdin Ghostscript Free Public
+ License (the "License") for full details.
+
+ Every copy of Aladdin Ghostscript must include a copy of the License,
+ normally in a plain ASCII text file named PUBLIC. The License grants you
+ the right to copy, modify and redistribute Aladdin Ghostscript, but only
+ under certain conditions described in the License. Among other things, the
+ License requires that the copyright notice and this notice be preserved on
+ all copies.
+ */
+
+
+/* Notification machinery implementation */
+#include "gx.h"
+#include "gserrors.h"
+#include "gsstruct.h"
+#include "gsnotify.h"
+
+/* GC descriptors */
+private_st_gs_notify_registration();
+public_st_gs_notify_list();
+
+/* Initialize a notification list. */
+void
+gs_notify_init(gs_notify_list_t *nlist, gs_memory_t *mem)
+{
+ nlist->first = 0;
+ nlist->memory = mem;
+}
+
+/* Register a client. */
+int
+gs_notify_register(gs_notify_list_t *nlist, gs_notify_proc_t proc,
+ void *proc_data)
+{
+ gs_notify_registration_t *nreg =
+ gs_alloc_struct(nlist->memory, gs_notify_registration_t,
+ &st_gs_notify_registration, "gs_notify_register");
+
+ if (nreg == 0)
+ return_error(gs_error_VMerror);
+ nreg->proc = proc;
+ nreg->proc_data = proc_data;
+ nreg->next = nlist->first;
+ nlist->first = nreg;
+ return 0;
+}
+
+/*
+ * Unregister a client. Return 1 if the client was registered, 0 if not.
+ * If proc_data is 0, unregister all registrations of that proc; otherwise,
+ * unregister only the registration of that procedure with that proc_data.
+ */
+int
+gs_notify_unregister(gs_notify_list_t *nlist, gs_notify_proc_t proc,
+ void *proc_data)
+{
+ gs_notify_registration_t **prev = &nlist->first;
+ gs_notify_registration_t *cur;
+ bool found = 0;
+
+ while ((cur = *prev) != 0)
+ if (cur->proc == proc &&
+ (proc_data == 0 || cur->proc_data == proc_data)
+ ) {
+ *prev = cur->next;
+ gs_free_object(nlist->memory, cur, "gs_notify_unregister");
+ found = 1;
+ } else
+ prev = &cur->next;
+ return found;
+}
+
+/*
+ * Notify the clients on a list. If an error occurs, return the first
+ * error code, but notify all clients regardless.
+ */
+int
+gs_notify_all(gs_notify_list_t *nlist, void *event_data)
+{
+ gs_notify_registration_t *cur;
+ gs_notify_registration_t *next;
+ int ecode = 0;
+
+ for (next = nlist->first; (cur = next) != 0;) {
+ int code;
+
+ next = cur->next;
+ code = cur->proc(cur->proc_data, event_data);
+ if (code < 0 && ecode == 0)
+ ecode = code;
+ }
+ return ecode;
+}
+
+/* Release a notification list. */
+void
+gs_notify_release(gs_notify_list_t *nlist)
+{
+ gs_memory_t *mem = nlist->memory;
+
+ while (nlist->first) {
+ gs_notify_registration_t *next = nlist->first->next;
+
+ gs_free_object(mem, nlist->first, "gs_notify_release");
+ nlist->first = next;
+ }
+}