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 6806 - (hide annotations) (download) (as text)
Thu Jun 15 00:37:01 2017 UTC (6 years, 9 months ago) by doda
File MIME type: text/x-csrc
File size: 8255 byte(s)
TeraTerm Project としてのライセンス表記を追加

とりあえず Tera Term 本体分。
TeraTerm Project としての copyright 表記の年部分はコミットログを確認して書いたつもりだけど、ミスってたらすみません。

TODO: 過去に取り込んだパッチに関する著作権表記の追加
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     * Redistribution and use in source and binary forms, with or without modification,
8     * are permitted provided that the following conditions are met:
9     *
10     * 1. Redistributions of source code must retain the above copyright notice,
11     * this list of conditions and the following disclaimer.
12     * 2. Redistributions in binary form must reproduce the above copyright notice,
13     * this list of conditions and the following disclaimer in the documentation
14     * and/or other materials provided with the distribution.
15     * 3. The name of the author may not be used to endorse or promote products derived
16     * from this software without specific prior written permission.
17     *
18     * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19     * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20     * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
21     * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
22     * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
23     * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25     * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
26     * OF SUCH DAMAGE.
27     */
28 maya 3227 #include "teraterm.h"
29     #include "tttypes.h"
30     #include "ttlib.h"
31    
32     // #include <windows.h>
33     #include <stdlib.h>
34     #include <stdio.h>
35     #include <string.h>
36     /* for _findXXXX() functions */
37     #include <io.h>
38     #include "ttwinman.h"
39     #include "ttplugin.h"
40     #include "ttplug.h"
41     #undef TTXOpenTCP
42     #undef TTXCloseTCP
43     #undef TTXOpenFile
44     #undef TTXCloseFile
45     #undef TTXGetUIHooks
46     #undef TTXGetSetupHooks
47    
48 doda 4087 #define MAXNUMEXTENSIONS 32
49 maya 3227 static HANDLE LibHandle[MAXNUMEXTENSIONS];
50     static int NumExtensions = 0;
51     static TTXExports * * Extensions;
52    
53     typedef struct _ExtensionList {
54     TTXExports * exports;
55     struct _ExtensionList * next;
56     } ExtensionList;
57    
58     static int compareOrder(const void * e1, const void * e2) {
59     TTXExports * * exports1 = (TTXExports * *)e1;
60     TTXExports * * exports2 = (TTXExports * *)e2;
61    
62     return (*exports1)->loadOrder - (*exports2)->loadOrder;
63     }
64    
65     static void loadExtension(ExtensionList * * extensions, char const * fileName) {
66     char buf[1024];
67     DWORD err;
68     char uimsg[MAX_UIMSG];
69    
70     if (NumExtensions>=MAXNUMEXTENSIONS) return;
71     LibHandle[NumExtensions] = LoadLibrary(fileName);
72     if (LibHandle[NumExtensions] != NULL) {
73     TTXBindProc bind = (TTXBindProc)GetProcAddress(LibHandle[NumExtensions], "_TTXBind@8");
74     if (bind==NULL)
75     bind = (TTXBindProc)GetProcAddress(LibHandle[NumExtensions], "TTXBind");
76     if (bind != NULL) {
77     ExtensionList * newExtension =
78     (ExtensionList *)malloc(sizeof(ExtensionList));
79    
80     newExtension->exports = (TTXExports *)malloc(sizeof(TTXExports));
81     memset(newExtension->exports, 0, sizeof(TTXExports));
82     newExtension->exports->size = sizeof(TTXExports);
83 doda 6801 if (bind(TTVERSION,(TTXExports *)newExtension->exports)) {
84 maya 3227 newExtension->next = *extensions;
85     *extensions = newExtension;
86     NumExtensions++;
87     return;
88     } else {
89     free(newExtension->exports);
90     free(newExtension);
91     }
92     }
93     FreeLibrary(LibHandle[NumExtensions]);
94     }
95    
96     err = GetLastError();
97 doda 6787 // �����t�@�C�����������b�Z�[�W�����������s�����������A�������_����������
98     // �������������������������A���b�Z�[�W���p���������������B�v�����B
99 maya 3227 get_lang_msg("MSG_TT_ERROR", uimsg, sizeof(uimsg), "Tera Term: Error", ts.UILanguageFile);
100     get_lang_msg("MSG_LOAD_EXT_ERROR", ts.UIMsg, sizeof(ts.UIMsg), "Cannot load extension %s (%d)", ts.UILanguageFile);
101     _snprintf_s(buf, sizeof(buf), _TRUNCATE, ts.UIMsg, fileName, err);
102     MessageBox(NULL, buf, uimsg, MB_OK | MB_ICONEXCLAMATION);
103     }
104    
105 doda 6801 void PASCAL TTXInit(PTTSet ts, PComVar cv) {
106 maya 3227 ExtensionList * extensionList = NULL;
107     int i;
108    
109     // ���������������L�������������ATTX���L���������B
110     //if (getenv("TERATERM_EXTENSIONS") != NULL) {
111     if (1) {
112     char buf[1024];
113     struct _finddata_t searchData;
114     long searchHandle;
115    
116 doda 6791 _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%s\\TTX*.DLL", ts->HomeDir);
117 maya 3227
118 doda 6791 searchHandle = _findfirst(buf, &searchData);
119 maya 3227 if (searchHandle != -1L) {
120 doda 6791 do {
121     _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%s\\%s", ts->HomeDir, searchData.name);
122     loadExtension(&extensionList, buf);
123     } while (_findnext(searchHandle, &searchData)==0);
124 maya 3227 _findclose(searchHandle);
125     }
126    
127     if (NumExtensions==0) return;
128    
129     Extensions = (TTXExports * *)malloc(sizeof(TTXExports *)*NumExtensions);
130     for (i = 0; i < NumExtensions; i++) {
131     ExtensionList * old;
132    
133     Extensions[i] = extensionList->exports;
134     old = extensionList;
135     extensionList = extensionList->next;
136     free(old);
137     }
138    
139     qsort(Extensions, NumExtensions, sizeof(Extensions[0]), compareOrder);
140    
141     for (i = 0; i < NumExtensions; i++) {
142     if (Extensions[i]->TTXInit != NULL) {
143     Extensions[i]->TTXInit(ts, cv);
144     }
145     }
146     }
147     }
148    
149 doda 6801 void PASCAL TTXInternalOpenTCP(TTXSockHooks * hooks) {
150 maya 3227 int i;
151    
152     for (i = 0; i < NumExtensions; i++) {
153     if (Extensions[i]->TTXOpenTCP != NULL) {
154     Extensions[i]->TTXOpenTCP(hooks);
155     }
156     }
157     }
158    
159 doda 6801 void PASCAL TTXInternalCloseTCP(TTXSockHooks * hooks) {
160 maya 3227 int i;
161    
162     for (i = NumExtensions - 1; i >= 0; i--) {
163     if (Extensions[i]->TTXCloseTCP != NULL) {
164     Extensions[i]->TTXCloseTCP(hooks);
165     }
166     }
167     }
168    
169 doda 6801 void PASCAL TTXInternalOpenFile(TTXFileHooks * hooks) {
170 maya 3227 int i;
171    
172     for (i = 0; i < NumExtensions; i++) {
173     if (Extensions[i]->TTXOpenFile != NULL) {
174     Extensions[i]->TTXOpenFile(hooks);
175     }
176     }
177     }
178    
179 doda 6801 void PASCAL TTXInternalCloseFile(TTXFileHooks * hooks) {
180 maya 3227 int i;
181    
182     for (i = NumExtensions - 1; i >= 0; i--) {
183     if (Extensions[i]->TTXCloseFile != NULL) {
184     Extensions[i]->TTXCloseFile(hooks);
185     }
186     }
187     }
188    
189 doda 6801 void PASCAL TTXInternalGetUIHooks(TTXUIHooks * hooks) {
190 maya 3227 int i;
191    
192     for (i = 0; i < NumExtensions; i++) {
193     if (Extensions[i]->TTXGetUIHooks != NULL) {
194     Extensions[i]->TTXGetUIHooks(hooks);
195     }
196     }
197     }
198    
199 doda 6801 void PASCAL TTXInternalGetSetupHooks(TTXSetupHooks * hooks) {
200 maya 3227 int i;
201    
202     for (i = NumExtensions - 1; i >= 0; i--) {
203     if (Extensions[i]->TTXGetSetupHooks != NULL) {
204     Extensions[i]->TTXGetSetupHooks(hooks);
205     }
206     }
207     }
208    
209 doda 6801 void PASCAL TTXSetWinSize(int rows, int cols) {
210 maya 3227 int i;
211    
212     for (i = 0; i < NumExtensions; i++) {
213     if (Extensions[i]->TTXSetWinSize != NULL) {
214     Extensions[i]->TTXSetWinSize(rows, cols);
215     }
216     }
217     }
218    
219 doda 6801 void PASCAL TTXModifyMenu(HMENU menu) {
220 maya 3227 int i;
221    
222     for (i = 0; i < NumExtensions; i++) {
223     if (Extensions[i]->TTXModifyMenu != NULL) {
224     Extensions[i]->TTXModifyMenu(menu);
225     }
226     }
227     }
228    
229 doda 6801 void PASCAL TTXModifyPopupMenu(HMENU menu) {
230 maya 3227 int i;
231    
232     for (i = 0; i < NumExtensions; i++) {
233     if (Extensions[i]->TTXModifyPopupMenu != NULL) {
234     Extensions[i]->TTXModifyPopupMenu(menu);
235     }
236     }
237     }
238    
239 doda 6801 BOOL PASCAL TTXProcessCommand(HWND hWin, WORD cmd) {
240 maya 3227 int i;
241    
242     for (i = NumExtensions - 1; i >= 0; i--) {
243     if (Extensions[i]->TTXProcessCommand != NULL) {
244     if (Extensions[i]->TTXProcessCommand(hWin,cmd)) {
245     return TRUE;
246     }
247     }
248     }
249    
250     return FALSE;
251     }
252    
253 doda 6801 void PASCAL TTXEnd(void) {
254 maya 3227 int i;
255    
256     if (NumExtensions==0) return;
257    
258     for (i = NumExtensions - 1; i >= 0; i--) {
259     if (Extensions[i]->TTXEnd != NULL) {
260     Extensions[i]->TTXEnd();
261     }
262     }
263    
264     for (i=0; i<NumExtensions; i++)
265     FreeLibrary(LibHandle[i]);
266    
267     for (i = 0; i < NumExtensions; i++) {
268     free(Extensions[i]);
269     }
270    
271     free(Extensions);
272     NumExtensions = 0;
273     }
274    
275 doda 6801 void PASCAL TTXSetCommandLine(PCHAR cmd, int cmdlen, PGetHNRec rec) {
276 maya 3227 int i;
277    
278     for (i = 0; i < NumExtensions; i++) {
279     if (Extensions[i]->TTXSetCommandLine != NULL) {
280     Extensions[i]->TTXSetCommandLine(cmd, cmdlen, rec);
281     }
282     }
283     }

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