Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /branches/ttcomtester/teraterm/teraterm/ttplug.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 9129 - (hide annotations) (download) (as text)
Sat Jan 16 05:21:37 2021 UTC (3 years, 2 months ago) by zmatsuo
Original Path: trunk/teraterm/teraterm/ttplug.c
File MIME type: text/x-csrc
File size: 8672 byte(s)
VS2005 による Windows 95 のサポート方法を変更

- 各々のソースファイル内の Windows 95 サポート用コードを不要にする
  - ファイルのinclude + 関数呼出をやめる
    - #include "compat_w95.h" を削除
    - DoCover_IsDebuggerPresent() 呼び出しを削除
  - 代わりにファイル(common/compat_w95_vs2005.c)をリンク
- VSプロジェクトファイル
  - プロジェクトから compat_w95.h を削除
  - VS2005プロジェクトに compat_w95_vs2005.c を追加
    - VS2005以外では Windows 95 で動作するバイナリが生成できないので追加は不要
- cmake
  - SUPPORT_OLD_WINDOWS=ON 時、compat_w95_vs2005.c をリンクするよう修正
  - なるべく target_* を使用するよう修正
1 doda 6806 /*
2     * Copyright (C) 1994-1998 T. Teranishi
3     * (C) Robert O'Callahan
4 nmaya 9048 * (C) 2004- TeraTerm Project
5 doda 6806 * All rights reserved.
6     *
7 doda 6841 * Redistribution and use in source and binary forms, with or without
8     * modification, are permitted provided that the following conditions
9     * are met:
10 doda 6806 *
11 doda 6841 * 1. Redistributions of source code must retain the above copyright
12     * notice, this list of conditions and the following disclaimer.
13     * 2. Redistributions in binary form must reproduce the above copyright
14     * notice, this list of conditions and the following disclaimer in the
15     * documentation and/or other materials provided with the distribution.
16     * 3. The name of the author may not be used to endorse or promote products
17     * derived from this software without specific prior written permission.
18 doda 6806 *
19 doda 6841 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
20     * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21     * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22     * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23     * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24     * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25     * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26     * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27     * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28     * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 doda 6806 */
30 maya 3227 #include "teraterm.h"
31     #include "tttypes.h"
32     #include "ttlib.h"
33    
34     // #include <windows.h>
35     #include <stdlib.h>
36     #include <stdio.h>
37     #include <string.h>
38     /* for _findXXXX() functions */
39     #include <io.h>
40     #include "ttwinman.h"
41     #include "ttplugin.h"
42     #include "ttplug.h"
43     #undef TTXOpenTCP
44     #undef TTXCloseTCP
45     #undef TTXOpenFile
46     #undef TTXCloseFile
47     #undef TTXGetUIHooks
48     #undef TTXGetSetupHooks
49    
50 doda 4087 #define MAXNUMEXTENSIONS 32
51 maya 3227 static HANDLE LibHandle[MAXNUMEXTENSIONS];
52     static int NumExtensions = 0;
53     static TTXExports * * Extensions;
54    
55     typedef struct _ExtensionList {
56     TTXExports * exports;
57     struct _ExtensionList * next;
58     } ExtensionList;
59    
60     static int compareOrder(const void * e1, const void * e2) {
61     TTXExports * * exports1 = (TTXExports * *)e1;
62     TTXExports * * exports2 = (TTXExports * *)e2;
63    
64     return (*exports1)->loadOrder - (*exports2)->loadOrder;
65     }
66    
67     static void loadExtension(ExtensionList * * extensions, char const * fileName) {
68     char buf[1024];
69     DWORD err;
70     char uimsg[MAX_UIMSG];
71 zmatsuo 9129 const char *sub_message;
72 maya 3227
73     if (NumExtensions>=MAXNUMEXTENSIONS) return;
74     LibHandle[NumExtensions] = LoadLibrary(fileName);
75     if (LibHandle[NumExtensions] != NULL) {
76 zmatsuo 7536 #if defined(_MSC_VER)
77     const char *TTXBIND = "_TTXBind@8";
78     #else
79     const char *TTXBIND = "TTXBind@8";
80     #endif
81     TTXBindProc bind = (TTXBindProc)GetProcAddress(LibHandle[NumExtensions], TTXBIND);
82 maya 3227 if (bind==NULL)
83     bind = (TTXBindProc)GetProcAddress(LibHandle[NumExtensions], "TTXBind");
84     if (bind != NULL) {
85     ExtensionList * newExtension =
86     (ExtensionList *)malloc(sizeof(ExtensionList));
87    
88     newExtension->exports = (TTXExports *)malloc(sizeof(TTXExports));
89     memset(newExtension->exports, 0, sizeof(TTXExports));
90     newExtension->exports->size = sizeof(TTXExports);
91 doda 6801 if (bind(TTVERSION,(TTXExports *)newExtension->exports)) {
92 maya 3227 newExtension->next = *extensions;
93     *extensions = newExtension;
94     NumExtensions++;
95     return;
96     } else {
97     free(newExtension->exports);
98     free(newExtension);
99     }
100     }
101     FreeLibrary(LibHandle[NumExtensions]);
102     }
103    
104     err = GetLastError();
105 zmatsuo 9129 #if 0
106     switch(err) {
107     case 31:
108     sub_message = "Unresolved dll entry";
109     break;
110     case 1114:
111     sub_message = "tls entry exists";
112     break;
113     case 2:
114     sub_message = "Reject load by plugin";
115     break;
116     default:
117     sub_message = "unknown";
118     break;
119     }
120     #endif
121 doda 6787 // �����t�@�C�����������b�Z�[�W�����������s�����������A�������_����������
122     // �������������������������A���b�Z�[�W���p���������������B�v�����B
123 maya 3227 get_lang_msg("MSG_TT_ERROR", uimsg, sizeof(uimsg), "Tera Term: Error", ts.UILanguageFile);
124     get_lang_msg("MSG_LOAD_EXT_ERROR", ts.UIMsg, sizeof(ts.UIMsg), "Cannot load extension %s (%d)", ts.UILanguageFile);
125     _snprintf_s(buf, sizeof(buf), _TRUNCATE, ts.UIMsg, fileName, err);
126     MessageBox(NULL, buf, uimsg, MB_OK | MB_ICONEXCLAMATION);
127     }
128    
129 doda 6801 void PASCAL TTXInit(PTTSet ts, PComVar cv) {
130 maya 3227 ExtensionList * extensionList = NULL;
131     int i;
132    
133     // ���������������L�������������ATTX���L���������B
134     //if (getenv("TERATERM_EXTENSIONS") != NULL) {
135     if (1) {
136     char buf[1024];
137     struct _finddata_t searchData;
138 zmatsuo 7896 intptr_t searchHandle;
139 maya 3227
140 doda 6791 _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%s\\TTX*.DLL", ts->HomeDir);
141 maya 3227
142 doda 6791 searchHandle = _findfirst(buf, &searchData);
143 maya 3227 if (searchHandle != -1L) {
144 doda 6791 do {
145     _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%s\\%s", ts->HomeDir, searchData.name);
146     loadExtension(&extensionList, buf);
147     } while (_findnext(searchHandle, &searchData)==0);
148 maya 3227 _findclose(searchHandle);
149     }
150    
151     if (NumExtensions==0) return;
152    
153     Extensions = (TTXExports * *)malloc(sizeof(TTXExports *)*NumExtensions);
154     for (i = 0; i < NumExtensions; i++) {
155     ExtensionList * old;
156    
157     Extensions[i] = extensionList->exports;
158     old = extensionList;
159     extensionList = extensionList->next;
160     free(old);
161     }
162    
163     qsort(Extensions, NumExtensions, sizeof(Extensions[0]), compareOrder);
164    
165     for (i = 0; i < NumExtensions; i++) {
166     if (Extensions[i]->TTXInit != NULL) {
167     Extensions[i]->TTXInit(ts, cv);
168     }
169     }
170     }
171     }
172    
173 doda 6801 void PASCAL TTXInternalOpenTCP(TTXSockHooks * hooks) {
174 maya 3227 int i;
175    
176     for (i = 0; i < NumExtensions; i++) {
177     if (Extensions[i]->TTXOpenTCP != NULL) {
178     Extensions[i]->TTXOpenTCP(hooks);
179     }
180     }
181     }
182    
183 doda 6801 void PASCAL TTXInternalCloseTCP(TTXSockHooks * hooks) {
184 maya 3227 int i;
185    
186     for (i = NumExtensions - 1; i >= 0; i--) {
187     if (Extensions[i]->TTXCloseTCP != NULL) {
188     Extensions[i]->TTXCloseTCP(hooks);
189     }
190     }
191     }
192    
193 doda 6801 void PASCAL TTXInternalOpenFile(TTXFileHooks * hooks) {
194 maya 3227 int i;
195    
196     for (i = 0; i < NumExtensions; i++) {
197     if (Extensions[i]->TTXOpenFile != NULL) {
198     Extensions[i]->TTXOpenFile(hooks);
199     }
200     }
201     }
202    
203 doda 6801 void PASCAL TTXInternalCloseFile(TTXFileHooks * hooks) {
204 maya 3227 int i;
205    
206     for (i = NumExtensions - 1; i >= 0; i--) {
207     if (Extensions[i]->TTXCloseFile != NULL) {
208     Extensions[i]->TTXCloseFile(hooks);
209     }
210     }
211     }
212    
213 doda 6801 void PASCAL TTXInternalGetUIHooks(TTXUIHooks * hooks) {
214 maya 3227 int i;
215    
216     for (i = 0; i < NumExtensions; i++) {
217     if (Extensions[i]->TTXGetUIHooks != NULL) {
218     Extensions[i]->TTXGetUIHooks(hooks);
219     }
220     }
221     }
222    
223 doda 6801 void PASCAL TTXInternalGetSetupHooks(TTXSetupHooks * hooks) {
224 maya 3227 int i;
225    
226     for (i = NumExtensions - 1; i >= 0; i--) {
227     if (Extensions[i]->TTXGetSetupHooks != NULL) {
228     Extensions[i]->TTXGetSetupHooks(hooks);
229     }
230     }
231     }
232    
233 doda 6801 void PASCAL TTXSetWinSize(int rows, int cols) {
234 maya 3227 int i;
235    
236     for (i = 0; i < NumExtensions; i++) {
237     if (Extensions[i]->TTXSetWinSize != NULL) {
238     Extensions[i]->TTXSetWinSize(rows, cols);
239     }
240     }
241     }
242    
243 doda 6801 void PASCAL TTXModifyMenu(HMENU menu) {
244 maya 3227 int i;
245    
246     for (i = 0; i < NumExtensions; i++) {
247     if (Extensions[i]->TTXModifyMenu != NULL) {
248     Extensions[i]->TTXModifyMenu(menu);
249     }
250     }
251     }
252    
253 doda 6801 void PASCAL TTXModifyPopupMenu(HMENU menu) {
254 maya 3227 int i;
255    
256     for (i = 0; i < NumExtensions; i++) {
257     if (Extensions[i]->TTXModifyPopupMenu != NULL) {
258     Extensions[i]->TTXModifyPopupMenu(menu);
259     }
260     }
261     }
262    
263 doda 6801 BOOL PASCAL TTXProcessCommand(HWND hWin, WORD cmd) {
264 maya 3227 int i;
265    
266     for (i = NumExtensions - 1; i >= 0; i--) {
267     if (Extensions[i]->TTXProcessCommand != NULL) {
268     if (Extensions[i]->TTXProcessCommand(hWin,cmd)) {
269     return TRUE;
270     }
271     }
272     }
273    
274     return FALSE;
275     }
276    
277 doda 6801 void PASCAL TTXEnd(void) {
278 maya 3227 int i;
279    
280     if (NumExtensions==0) return;
281    
282     for (i = NumExtensions - 1; i >= 0; i--) {
283     if (Extensions[i]->TTXEnd != NULL) {
284     Extensions[i]->TTXEnd();
285     }
286     }
287    
288     for (i=0; i<NumExtensions; i++)
289     FreeLibrary(LibHandle[i]);
290    
291     for (i = 0; i < NumExtensions; i++) {
292     free(Extensions[i]);
293     }
294    
295     free(Extensions);
296     NumExtensions = 0;
297     }
298    
299 doda 6801 void PASCAL TTXSetCommandLine(PCHAR cmd, int cmdlen, PGetHNRec rec) {
300 maya 3227 int i;
301    
302     for (i = 0; i < NumExtensions; i++) {
303     if (Extensions[i]->TTXSetCommandLine != NULL) {
304     Extensions[i]->TTXSetCommandLine(cmd, cmdlen, rec);
305     }
306     }
307     }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26