~ubuntu-branches/ubuntu/oneiric/ghostscript/oneiric

« back to all changes in this revision

Viewing changes to psi/dwdll.c

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2011-07-15 16:49:55 UTC
  • mfrom: (1.1.23 upstream)
  • Revision ID: james.westby@ubuntu.com-20110715164955-uga6qibao6kez05c
Tags: 9.04~dfsg~20110715-0ubuntu1
* New upstream release
   - GIT snapshot from Jult, 12 2011.
* debian/patches/020110406~a54df2d.patch,
  debian/patches/020110408~0791cc8.patch,
  debian/patches/020110408~507cbee.patch,
  debian/patches/020110411~4509a49.patch,
  debian/patches/020110412~78bb9a6.patch,
  debian/patches/020110418~a05ab8a.patch,
  debian/patches/020110420~20b6c78.patch,
  debian/patches/020110420~4ddefa2.patch: Removed upstream patches.
* debian/rules: Generate ABI version number (variable "abi") correctly,
  cutting off repackaging and pre-release parts.
* debian/rules: Added ./lcms2/ directory to DEB_UPSTREAM_REPACKAGE_EXCLUDES.
* debian/copyright: Added lcms2/* to the list of excluded files.
* debian/symbols.common: Updated for new upstream source. Applied patch
  which dpkg-gensymbols generated for debian/libgs9.symbols to this file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* Copyright (C) 2001-2006 Artifex Software, Inc.
2
2
   All Rights Reserved.
3
 
  
 
3
 
4
4
   This software is provided AS-IS with no warranty, either express or
5
5
   implied.
6
6
 
11
11
   San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
12
12
*/
13
13
 
14
 
/* $Id: dwdll.c 12103 2011-02-02 17:18:09Z ray $ */
 
14
/* $Id$ */
15
15
 
16
16
/* dwdll.c */
17
17
 
46
46
 
47
47
    /* Don't load if already loaded */
48
48
    if (gsdll->hmodule)
49
 
        return 0;
 
49
        return 0;
50
50
 
51
51
    /* First try to load DLL from the same directory as EXE */
52
52
    GetModuleFileName(GetModuleHandle(NULL), fullname, sizeof(fullname));
53
53
    if ((p = strrchr(fullname,'\\')) != (char *)NULL)
54
 
        p++;
 
54
        p++;
55
55
    else
56
 
        p = fullname;
 
56
        p = fullname;
57
57
    *p = '\0';
58
58
    strcat(fullname, name);
59
59
    gsdll->hmodule = LoadLibrary(fullname);
60
60
 
61
61
    /* Next try to load DLL with name in registry or environment variable */
62
62
    if (gsdll->hmodule < (HINSTANCE)HINSTANCE_ERROR) {
63
 
        length = sizeof(fullname);
64
 
        if (gp_getenv("GS_DLL", fullname, &length) == 0)
65
 
            gsdll->hmodule = LoadLibrary(fullname);
 
63
        length = sizeof(fullname);
 
64
        if (gp_getenv("GS_DLL", fullname, &length) == 0)
 
65
            gsdll->hmodule = LoadLibrary(fullname);
66
66
    }
67
67
 
68
68
    /* Finally try the system search path */
70
70
        gsdll->hmodule = LoadLibrary(name);
71
71
 
72
72
    if (gsdll->hmodule < (HINSTANCE)HINSTANCE_ERROR) {
73
 
        /* Failed */
74
 
        DWORD err = GetLastError();
75
 
        sprintf(fullname, "Can't load DLL, LoadLibrary error code %ld", err);
76
 
        strncpy(last_error, fullname, len-1);
77
 
        gsdll->hmodule = (HINSTANCE)0;
78
 
        return 1;
 
73
        /* Failed */
 
74
        DWORD err = GetLastError();
 
75
        sprintf(fullname, "Can't load DLL, LoadLibrary error code %ld", err);
 
76
        strncpy(last_error, fullname, len-1);
 
77
        gsdll->hmodule = (HINSTANCE)0;
 
78
        return 1;
79
79
    }
80
80
 
81
81
    /* DLL is now loaded */
82
82
    /* Get pointers to functions */
83
 
    gsdll->revision = (PFN_gsapi_revision) GetProcAddress(gsdll->hmodule, 
84
 
        "gsapi_revision");
 
83
    gsdll->revision = (PFN_gsapi_revision) GetProcAddress(gsdll->hmodule,
 
84
        "gsapi_revision");
85
85
    if (gsdll->revision == NULL) {
86
 
        strncpy(last_error, "Can't find gsapi_revision\n", len-1);
87
 
        unload_dll(gsdll);
88
 
        return 1;
 
86
        strncpy(last_error, "Can't find gsapi_revision\n", len-1);
 
87
        unload_dll(gsdll);
 
88
        return 1;
89
89
    }
90
90
    /* check DLL version */
91
91
    if (gsdll->revision(&rv, sizeof(rv)) != 0) {
92
 
        sprintf(fullname, "Unable to identify Ghostscript DLL revision - it must be newer than needed.\n");
93
 
        strncpy(last_error, fullname, len-1);
94
 
        unload_dll(gsdll);
95
 
        return 1;
 
92
        sprintf(fullname, "Unable to identify Ghostscript DLL revision - it must be newer than needed.\n");
 
93
        strncpy(last_error, fullname, len-1);
 
94
        unload_dll(gsdll);
 
95
        return 1;
96
96
    }
97
97
    if (rv.revision != GSREVISION) {
98
 
        sprintf(fullname, "Wrong version of DLL found.\n  Found version %ld\n  Need version  %ld\n", rv.revision, GSREVISION);
99
 
        strncpy(last_error, fullname, len-1);
100
 
        unload_dll(gsdll);
101
 
        return 1;
 
98
        sprintf(fullname, "Wrong version of DLL found.\n  Found version %ld\n  Need version  %ld\n", rv.revision, GSREVISION);
 
99
        strncpy(last_error, fullname, len-1);
 
100
        unload_dll(gsdll);
 
101
        return 1;
102
102
    }
103
103
 
104
104
    /* continue loading other functions */
105
 
    gsdll->new_instance = (PFN_gsapi_new_instance) GetProcAddress(gsdll->hmodule, 
106
 
        "gsapi_new_instance");
 
105
    gsdll->new_instance = (PFN_gsapi_new_instance) GetProcAddress(gsdll->hmodule,
 
106
        "gsapi_new_instance");
107
107
    if (gsdll->new_instance == NULL) {
108
 
        strncpy(last_error, "Can't find gsapi_new_instance\n", len-1);
109
 
        unload_dll(gsdll);
110
 
        return 1;
 
108
        strncpy(last_error, "Can't find gsapi_new_instance\n", len-1);
 
109
        unload_dll(gsdll);
 
110
        return 1;
111
111
    }
112
112
 
113
 
    gsdll->delete_instance = (PFN_gsapi_delete_instance) GetProcAddress(gsdll->hmodule, 
114
 
        "gsapi_delete_instance");
 
113
    gsdll->delete_instance = (PFN_gsapi_delete_instance) GetProcAddress(gsdll->hmodule,
 
114
        "gsapi_delete_instance");
115
115
    if (gsdll->delete_instance == NULL) {
116
 
        strncpy(last_error, "Can't find gsapi_delete_instance\n", len-1);
117
 
        unload_dll(gsdll);
118
 
        return 1;
 
116
        strncpy(last_error, "Can't find gsapi_delete_instance\n", len-1);
 
117
        unload_dll(gsdll);
 
118
        return 1;
119
119
    }
120
120
 
121
 
    gsdll->set_stdio = (PFN_gsapi_set_stdio) GetProcAddress(gsdll->hmodule, 
122
 
        "gsapi_set_stdio");
 
121
    gsdll->set_stdio = (PFN_gsapi_set_stdio) GetProcAddress(gsdll->hmodule,
 
122
        "gsapi_set_stdio");
123
123
    if (gsdll->set_stdio == NULL) {
124
 
        strncpy(last_error, "Can't find gsapi_set_stdio\n", len-1);
125
 
        unload_dll(gsdll);
126
 
        return 1;
 
124
        strncpy(last_error, "Can't find gsapi_set_stdio\n", len-1);
 
125
        unload_dll(gsdll);
 
126
        return 1;
127
127
    }
128
128
 
129
 
    gsdll->set_poll = (PFN_gsapi_set_poll) GetProcAddress(gsdll->hmodule, 
130
 
        "gsapi_set_poll");
 
129
    gsdll->set_poll = (PFN_gsapi_set_poll) GetProcAddress(gsdll->hmodule,
 
130
        "gsapi_set_poll");
131
131
    if (gsdll->set_poll == NULL) {
132
 
        strncpy(last_error, "Can't find gsapi_set_poll\n", len-1);
133
 
        unload_dll(gsdll);
134
 
        return 1;
 
132
        strncpy(last_error, "Can't find gsapi_set_poll\n", len-1);
 
133
        unload_dll(gsdll);
 
134
        return 1;
135
135
    }
136
136
 
137
 
    gsdll->set_display_callback = (PFN_gsapi_set_display_callback) 
138
 
        GetProcAddress(gsdll->hmodule, "gsapi_set_display_callback");
 
137
    gsdll->set_display_callback = (PFN_gsapi_set_display_callback)
 
138
        GetProcAddress(gsdll->hmodule, "gsapi_set_display_callback");
139
139
    if (gsdll->set_display_callback == NULL) {
140
 
        strncpy(last_error, "Can't find gsapi_set_display_callback\n", len-1);
141
 
        unload_dll(gsdll);
142
 
        return 1;
 
140
        strncpy(last_error, "Can't find gsapi_set_display_callback\n", len-1);
 
141
        unload_dll(gsdll);
 
142
        return 1;
143
143
    }
144
144
 
145
 
    gsdll->init_with_args = (PFN_gsapi_init_with_args) 
146
 
        GetProcAddress(gsdll->hmodule, "gsapi_init_with_args");
 
145
    gsdll->init_with_args = (PFN_gsapi_init_with_args)
 
146
        GetProcAddress(gsdll->hmodule, "gsapi_init_with_args");
147
147
    if (gsdll->init_with_args == NULL) {
148
 
        strncpy(last_error, "Can't find gsapi_init_with_args\n", len-1);
149
 
        unload_dll(gsdll);
150
 
        return 1;
 
148
        strncpy(last_error, "Can't find gsapi_init_with_args\n", len-1);
 
149
        unload_dll(gsdll);
 
150
        return 1;
151
151
    }
152
152
 
153
 
    gsdll->run_string = (PFN_gsapi_run_string) GetProcAddress(gsdll->hmodule, 
154
 
        "gsapi_run_string");
 
153
    gsdll->run_string = (PFN_gsapi_run_string) GetProcAddress(gsdll->hmodule,
 
154
        "gsapi_run_string");
155
155
    if (gsdll->run_string == NULL) {
156
 
        strncpy(last_error, "Can't find gsapi_run_string\n", len-1);
157
 
        unload_dll(gsdll);
158
 
        return 1;
 
156
        strncpy(last_error, "Can't find gsapi_run_string\n", len-1);
 
157
        unload_dll(gsdll);
 
158
        return 1;
159
159
    }
160
160
 
161
 
    gsdll->exit = (PFN_gsapi_exit) GetProcAddress(gsdll->hmodule, 
162
 
        "gsapi_exit");
 
161
    gsdll->exit = (PFN_gsapi_exit) GetProcAddress(gsdll->hmodule,
 
162
        "gsapi_exit");
163
163
    if (gsdll->exit == NULL) {
164
 
        strncpy(last_error, "Can't find gsapi_exit\n", len-1);
165
 
        unload_dll(gsdll);
166
 
        return 1;
 
164
        strncpy(last_error, "Can't find gsapi_exit\n", len-1);
 
165
        unload_dll(gsdll);
 
166
        return 1;
167
167
    }
168
168
 
169
 
    gsdll->set_visual_tracer = (PFN_gsapi_set_visual_tracer) 
 
169
    gsdll->set_visual_tracer = (PFN_gsapi_set_visual_tracer)
170
170
        GetProcAddress(gsdll->hmodule, "gsapi_set_visual_tracer");
171
171
    if (gsdll->set_visual_tracer == NULL) {
172
 
        strncpy(last_error, "Can't find gsapi_set_visual_tracer\n", len-1);
173
 
        unload_dll(gsdll);
174
 
        return 1;
 
172
        strncpy(last_error, "Can't find gsapi_set_visual_tracer\n", len-1);
 
173
        unload_dll(gsdll);
 
174
        return 1;
175
175
    }
176
176
 
177
177
    return 0;
192
192
    gsdll->set_visual_tracer = NULL;
193
193
 
194
194
    if (gsdll->hmodule != (HINSTANCE)NULL)
195
 
            FreeLibrary(gsdll->hmodule);
 
195
            FreeLibrary(gsdll->hmodule);
196
196
    gsdll->hmodule = NULL;
197
197
}
198
 
 
199