⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dll.txt

📁 遗传算法工具箱 希望高手指点 GATOOLS
💻 TXT
📖 第 1 页 / 共 2 页
字号:
/* Copyright (C) 1994-1996, Russell Lang.  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.
*/

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

This file, dll.txt, describes how to use the Ghostscript Dynamic
Link Library.

For an overview of Ghostscript and a list of the documentation files, see
README.  

==================================
DLL.TXT   1996-09-05
==================================

For the OS/2, Win16 and Win32 platforms, Ghostscript is compiled
as a dynamic link library.  

To provide the interface described in use.txt, a smaller EXE loads 
this Ghostscript DLL.  
This EXE provides image windows and if necessary, a text window.  
The source for the EXE is in dp*.* for OS/2 and dw*.* for Windows.
Refer to these source files for examples of DLL usage.

This document document describes the DLL interface.

The Win16 DLL (GSDLL16.DLL) is a large memory model DLL with far 
static data.  Due to the limitations of 16 bit MS-Windows, the DLL 
can be used by only one program at a time.  

The Win32 DLL (GSDLL32.DLL) has MULTIPLE NONSHARED data segments.
Under Win32s it can be used by only one program at a time.
Under Windows 95 or NT it can be called by multiple programs.

The OS/2 DLL (GSDLL2.DLL) has MULTIPLE NONSHARED data segments and
can be called by multiple programs.

The interface to the DLL consists of 8 main functions, 1 provided 
by the caller and the other 7 by the DLL.  Some other platform
dependant functions are provided by the DLL for display devices.

=============
DLL functions
=============
The seven functions provided by the DLL are:
  int GSDLLAPI gsdll_revision(char **product, char **copyright, 
        long *gs_revision, long *gs_revisiondate)
  int GSDLLAPI gsdll_init(GSDLL_CALLBACK callback, HWND hwnd, 
        int argc, char *argv[]);
  int GSDLLAPI gsdll_execute_begin(void);
  int GSDLLAPI gsdll_execute_cont(const char *str, int len);
  int GSDLLAPI gsdll_execute_end(void);
  int GSDLLAPI gsdll_exit(void);
  int GSDLLAPI gsdll_lock_device(unsigned char *device, int flag);

For OS/2, GSDLLAPI is defined as
  #define GSDLLAPI
For Win32 and Win16, GSDLLAPI is defined as
  #define GSDLLAPI CALLBACK _export

----------------
gsdll_revision()
----------------
This returns the revision numbers and strings of the Ghostscript DLL.
This function may be called before gsdll_init().
An example:
  char *product;
  char *copyright;
  long revision;
  long revisiondate;
  gsdll_revision(&product, &copyright, &revision, &revisiondate);
NULL pointers may be used if you do not want a particular value.

It is recommended that this function be called before gsdll_init()
to make sure that the correct version of the Ghostscript DLL
has been loaded.

------------
gsdll_init()
------------
The function gsdll_init() must be called after loading
the DLL and before executing any ghostscript commands.
The arguments are the address of the callback function,
a parent window handle, the count of arguments and an 
array of pointers to the arguments.
For example
  char *argv[5];
  argv[0] = "gswin.exe";
  argv[1] = "-Ic:\\gs;c:\gs\\fonts";
  argv[2] = "-dNOPAUSE",
  argv[3] = "-sDEVICE=djet500",
  argv[4] = NULL;
  };
  argc = 4;
  code = gsdll_init(gsdll_callback, hwnd, argc, argv);

hwnd is used as the parent window handle for any windows
created by Ghostscript.
hwnd may be NULL if the caller does not have any windows, but
if NULL you should avoid using devices which may open windows.

If the return code is zero then there is no error.
gsdll_execute_begin() or gsdll_exit() may now be called.

If the return value is non-zero then gsdll_exit() must not be called.  

A return value of GSDLL_INIT_QUIT indicates that one of the
command line files or arguments called 'quit', or that GS
was reading stdin and reached EOF.  This is not an error.
gsdll_exit() must not be called.

A return value of GSDLL_INIT_IN_USE indicates that the DLL is
in use by another application (Windows 3.1 only).
The DLL should be immediately unloaded (or the caller terminated).  
gsdll_exit() must not be called.


---------------------
gsdll_execute_begin()
---------------------
This must be called after gsdll_init() and before gsdll_execute_cont();


--------------------
gsdll_execute_cont()
--------------------
After successfully calling gsdll_init() and gsdll_execute_begin(), 
commands may be given to Ghostscript with gsdll_execute_cont().  
Examples are:
  char *command = "1 2 add == flush\n";
  code = gsdll_execute_cont(command, strlen(command));
  command = "qu"
  code = gsdll_execute_cont(command, strlen(command));
  command = "it\n"
  code = gsdll_execute_cont(command, strlen(command));
return code is zero if there are no errors.
return code is less than zero if an error has occured.
return code is less than or equal to -100 if "quit" has been 
  executed or a fatal error has occured.
  gsdll_exit() must then be called - do not call gsdll_execute_end().
gsdll_execute_cont does not flush stdio - if you want to see output from
Ghostscript you must do this explicitly as shown in the example above.

When executing a string with gsdll_execute_cont, currentfile is the
input from gsdll_execute_cont.  Reading from %stdin will use the 
callback.


-------------------
gsdll_execute_end()
-------------------
If gsdll_execute_cont() did not return an error, then gsdll_execute_end()
must be called after gsdll_execute_cont() and before gsdll_exit();


----------
gsdll_exit
----------
To terminate the Ghostscript DLL, gsdll_exit() is called.
This must be called if a fatal error has occured (see return
value of gsdll_execute_cont).
After calling gsdll_exit(), there are two options:
1. Unload the DLL, either by terminating the application or by 
calling DosFreeModule (OS/2) or FreeLibrary (MS-Windows).
2. Call gsdll_init() again to restart Ghostscript.


-----------------
gsdll_lock_device
-----------------
Since the caller may be multithreaded, a lock is needed to control 
access to the display device.  This is accessed via the following 
function.

int gsdll_lock_device(unsigned char *device, int flag);
 /* Lock the device if flag = TRUE */
 /* Unlock the device if flag = FALSE */
 /* device is a pointer to Ghostscript os2dll or mswindll device */
 /* from GSDLL_DEVICE message. */
 /* Return value is the lock count. */

To lock the device use
  gsdll_lock_device(device, 1);
To unlock the device use
  gsdll_lock_device(device, 0);

Locking the device prevents the Ghostscript DLL from closing 
the device or changing the device size or depth.  
Ghostscript may draw into the device bitmap or update the palette 
entries while the device is locked by the caller.

This function is typically used to lock the device while
repainting a window, or copying the device bitmap to the clipboard.

Under OS/2, Win95 and WinNT, this lock is implemented using
a mutual exclusion semaphore (mutex).  The return value is 
the lock count, which will be either 0 or 1, for unlocked and 
locked respectively.
This function will block until the device is locked by the caller.

Under Win16 or Win32s, gsdll_lock_device will always return 
immediately, giving a lock count as the return value.  If
a lock value of 2 or more is returned, beware!
Access to the device should be controlled by checking the 
windows message queue only when the bitmap is not being accessed.

=================
Callback function
=================
A callback function must be provided by the caller and given
as an argument to gsdll_init().
The callback function is called by the DLL for stdio and to notify 
the caller about device events.

The function provided by the caller has the following prototype:
  int gsdll_callback(int message, char *str, unsigned long count);
The pascal calling convention is not used.

An example callback function is:
    int 
    gsdll_callback(int message, char *str, unsigned long count)
    {
    char *p;
        switch (message) {
            case GSDLL_STDIN:
                p = fgets(str, count, stdin);
                if (p)
                    return strlen(str);
                else
                    return 0;
            case GSDLL_STDOUT:
                if (str != (char *)NULL)
                    fwrite(str, 1, count, stdout);
                return count;
            case GSDLL_DEVICE:
                fprintf(stdout,"Callback: DEVICE %p %s\n", str,
                    count ? "open" : "close");
                break;
            case GSDLL_SYNC:
                fprintf(stdout,"Callback: SYNC %p\n", str);
                break;
            case GSDLL_PAGE:
                fprintf(stdout,"Callback: PAGE %p\n", str);
                break;
            case GSDLL_SIZE:
                fprintf(stdout,"Callback: SIZE %p width=%d height=%d\n", str,
                    (int)(count & 0xffff), (int)((count>>16) & 0xffff) );
                break;
            case GSDLL_POLL:
		return 0; /* no error */
            default:
                fprintf(stdout,"Callback: Unknown message=%d\n",message);
                break;
        }
        return 0;
    }


The messages used by the callback are:
  #define GSDLL_STDIN 1   /* get count characters to str from stdin */
                          /* return number of characters read */
  #define GSDLL_STDOUT 2  /* put count characters from str to stdout*/
                          /* return number of characters written */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -