Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /trunk/teraterm/teraterm/ttplug.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6841 - (hide annotations) (download) (as text)
Tue Jul 4 15:02:28 2017 UTC (6 years, 9 months ago) by doda
File MIME type: text/x-csrc
File size: 8251 byte(s)
TeraTerm Project としてのライセンス表記を追加

・Tera Term 本体分を横 80 桁に収まるように改行位置を調整
・ttssh 関連の分を追加
1 doda 6806 /*
2     * Copyright (C) 1994-1998 T. Teranishi
3     * (C) Robert O'Callahan
4     * (C) 2004-2017 TeraTerm Project
5     * 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    
72     if (NumExtensions>=MAXNUMEXTENSIONS) return;
73     LibHandle[NumExtensions] = LoadLibrary(fileName);
74     if (LibHandle[NumExtensions] != NULL) {
75     TTXBindProc bind = (TTXBindProc)GetProcAddress(LibHandle[NumExtensions], "_TTXBind@8");
76     if (bind==NULL)
77     bind = (TTXBindProc)GetProcAddress(LibHandle[NumExtensions], "TTXBind");
78     if (bind != NULL) {
79     ExtensionList * newExtension =
80     (ExtensionList *)malloc(sizeof(ExtensionList));
81    
82     newExtension->exports = (TTXExports *)malloc(sizeof(TTXExports));
83     memset(newExtension->exports, 0, sizeof(TTXExports));
84     newExtension->exports->size = sizeof(TTXExports);
85 doda 6801 if (bind(TTVERSION,(TTXExports *)newExtension->exports)) {
86 maya 3227 newExtension->next = *extensions;
87     *extensions = newExtension;
88     NumExtensions++;
89     return;
90     } else {
91     free(newExtension->exports);
92     free(newExtension);
93     }
94     }
95     FreeLibrary(LibHandle[NumExtensions]);
96     }
97    
98     err = GetLastError();
99 doda 6787 // �����t�@�C�����������b�Z�[�W�����������s�����������A�������_����������
100     // �������������������������A���b�Z�[�W���p���������������B�v�����B
101 maya 3227 get_lang_msg("MSG_TT_ERROR", uimsg, sizeof(uimsg), "Tera Term: Error", ts.UILanguageFile);
102     get_lang_msg("MSG_LOAD_EXT_ERROR", ts.UIMsg, sizeof(ts.UIMsg), "Cannot load extension %s (%d)", ts.UILanguageFile);
103     _snprintf_s(buf, sizeof(buf), _TRUNCATE, ts.UIMsg, fileName, err);
104     MessageBox(NULL, buf, uimsg, MB_OK | MB_ICONEXCLAMATION);
105     }
106    
107 doda 6801 void PASCAL TTXInit(PTTSet ts, PComVar cv) {
108 maya 3227 ExtensionList * extensionList = NULL;
109     int i;
110    
111     // ���������������L�������������ATTX���L���������B
112     //if (getenv("TERATERM_EXTENSIONS") != NULL) {
113     if (1) {
114     char buf[1024];
115     struct _finddata_t searchData;
116     long searchHandle;
117    
118 doda 6791 _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%s\\TTX*.DLL", ts->HomeDir);
119 maya 3227
120 doda 6791 searchHandle = _findfirst(buf, &searchData);
121 maya 3227 if (searchHandle != -1L) {
122 doda 6791 do {
123     _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%s\\%s", ts->HomeDir, searchData.name);
124     loadExtension(&extensionList, buf);
125     } while (_findnext(searchHandle, &searchData)==0);
126 maya 3227 _findclose(searchHandle);
127     }
128    
129     if (NumExtensions==0) return;
130    
131     Extensions = (TTXExports * *)malloc(sizeof(TTXExports *)*NumExtensions);
132     for (i = 0; i < NumExtensions; i++) {
133     ExtensionList * old;
134    
135     Extensions[i] = extensionList->exports;
136     old = extensionList;
137     extensionList = extensionList->next;
138     free(old);
139     }
140    
141     qsort(Extensions, NumExtensions, sizeof(Extensions[0]), compareOrder);
142    
143     for (i = 0; i < NumExtensions; i++) {
144     if (Extensions[i]->TTXInit != NULL) {
145     Extensions[i]->TTXInit(ts, cv);
146     }
147     }
148     }
149     }
150    
151 doda 6801 void PASCAL TTXInternalOpenTCP(TTXSockHooks * hooks) {
152 maya 3227 int i;
153    
154     for (i = 0; i < NumExtensions; i++) {
155     if (Extensions[i]->TTXOpenTCP != NULL) {
156     Extensions[i]->TTXOpenTCP(hooks);
157     }
158     }
159     }
160    
161 doda 6801 void PASCAL TTXInternalCloseTCP(TTXSockHooks * hooks) {
162 maya 3227 int i;
163    
164     for (i = NumExtensions - 1; i >= 0; i--) {
165     if (Extensions[i]->TTXCloseTCP != NULL) {
166     Extensions[i]->TTXCloseTCP(hooks);
167     }
168     }
169     }
170    
171 doda 6801 void PASCAL TTXInternalOpenFile(TTXFileHooks * hooks) {
172 maya 3227 int i;
173    
174     for (i = 0; i < NumExtensions; i++) {
175     if (Extensions[i]->TTXOpenFile != NULL) {
176     Extensions[i]->TTXOpenFile(hooks);
177     }
178     }
179     }
180    
181 doda 6801 void PASCAL TTXInternalCloseFile(TTXFileHooks * hooks) {
182 maya 3227 int i;
183    
184     for (i = NumExtensions - 1; i >= 0; i--) {
185     if (Extensions[i]->TTXCloseFile != NULL) {
186     Extensions[i]->TTXCloseFile(hooks);
187     }
188     }
189     }
190    
191 doda 6801 void PASCAL TTXInternalGetUIHooks(TTXUIHooks * hooks) {
192 maya 3227 int i;
193    
194     for (i = 0; i < NumExtensions; i++) {
195     if (Extensions[i]->TTXGetUIHooks != NULL) {
196     Extensions[i]->TTXGetUIHooks(hooks);
197     }
198     }
199     }
200    
201 doda 6801 void PASCAL TTXInternalGetSetupHooks(TTXSetupHooks * hooks) {
202 maya 3227 int i;
203    
204     for (i = NumExtensions - 1; i >= 0; i--) {
205     if (Extensions[i]->TTXGetSetupHooks != NULL) {
206     Extensions[i]->TTXGetSetupHooks(hooks);
207     }
208     }
209     }
210    
211 doda 6801 void PASCAL TTXSetWinSize(int rows, int cols) {
212 maya 3227 int i;
213    
214     for (i = 0; i < NumExtensions; i++) {
215     if (Extensions[i]->TTXSetWinSize != NULL) {
216     Extensions[i]->TTXSetWinSize(rows, cols);
217     }
218     }
219     }
220    
221 doda 6801 void PASCAL TTXModifyMenu(HMENU menu) {
222 maya 3227 int i;
223    
224     for (i = 0; i < NumExtensions; i++) {
225     if (Extensions[i]->TTXModifyMenu != NULL) {
226     Extensions[i]->TTXModifyMenu(menu);
227     }
228     }
229     }
230    
231 doda 6801 void PASCAL TTXModifyPopupMenu(HMENU menu) {
232 maya 3227 int i;
233    
234     for (i = 0; i < NumExtensions; i++) {
235     if (Extensions[i]->TTXModifyPopupMenu != NULL) {
236     Extensions[i]->TTXModifyPopupMenu(menu);
237     }
238     }
239     }
240    
241 doda 6801 BOOL PASCAL TTXProcessCommand(HWND hWin, WORD cmd) {
242 maya 3227 int i;
243    
244     for (i = NumExtensions - 1; i >= 0; i--) {
245     if (Extensions[i]->TTXProcessCommand != NULL) {
246     if (Extensions[i]->TTXProcessCommand(hWin,cmd)) {
247     return TRUE;
248     }
249     }
250     }
251    
252     return FALSE;
253     }
254    
255 doda 6801 void PASCAL TTXEnd(void) {
256 maya 3227 int i;
257    
258     if (NumExtensions==0) return;
259    
260     for (i = NumExtensions - 1; i >= 0; i--) {
261     if (Extensions[i]->TTXEnd != NULL) {
262     Extensions[i]->TTXEnd();
263     }
264     }
265    
266     for (i=0; i<NumExtensions; i++)
267     FreeLibrary(LibHandle[i]);
268    
269     for (i = 0; i < NumExtensions; i++) {
270     free(Extensions[i]);
271     }
272    
273     free(Extensions);
274     NumExtensions = 0;
275     }
276    
277 doda 6801 void PASCAL TTXSetCommandLine(PCHAR cmd, int cmdlen, PGetHNRec rec) {
278 maya 3227 int i;
279    
280     for (i = 0; i < NumExtensions; i++) {
281     if (Extensions[i]->TTXSetCommandLine != NULL) {
282     Extensions[i]->TTXSetCommandLine(cmd, cmdlen, rec);
283     }
284     }
285     }

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