1 /*=============================================================================
\r
5 ===============================================================================
\r
6 / Copyright (C) 1997-2007 Sota. All rights reserved.
\r
8 / Redistribution and use in source and binary forms, with or without
\r
9 / modification, are permitted provided that the following conditions
\r
12 / 1. Redistributions of source code must retain the above copyright
\r
13 / notice, this list of conditions and the following disclaimer.
\r
14 / 2. Redistributions in binary form must reproduce the above copyright
\r
15 / notice, this list of conditions and the following disclaimer in the
\r
16 / documentation and/or other materials provided with the distribution.
\r
18 / THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
\r
19 / IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
\r
20 / OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
\r
21 / IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
\r
22 / INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
\r
23 / BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
\r
24 / USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
\r
25 / ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
\r
26 / (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
\r
27 / THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
28 /============================================================================*/
\r
34 //#include <winsock.h>
\r
35 #include <winsock2.h>
\r
36 #include <windowsx.h>
\r
42 /*===== ローカルなワーク =====*/
\r
44 static JRE2 m_jreData;
\r
45 static HINSTANCE m_hDll = NULL;
\r
46 static LPJRE2OPEN m_lpJre2Open = NULL;
\r
47 static LPJRE2COMPILE m_lpJre2Compile = NULL;
\r
48 static LPJRE2GETMATCHINFO m_lpJre2MatchInfo = NULL;
\r
49 static LPJRE2CLOSE m_lpJre2Close = NULL;
\r
50 static LPJREGETVERSION m_lpJreGetVersion = NULL;
\r
51 static LPGETJREMESSAGE m_lpGetJreMessage = NULL;
\r
55 /*----- 正規表現ライブラリをロードする ----------------------------------------
\r
63 *----------------------------------------------------------------------------*/
\r
70 // JRE32.DLLはUTF-8に非対応
\r
71 #ifdef DISABLE_JRE32DLL
\r
75 if((m_hDll = LoadLibrary("jre32.dll")) != NULL)
\r
77 m_lpJre2Open = (LPJRE2OPEN)GetProcAddress(m_hDll, "Jre2Open");
\r
78 m_lpJre2Compile = (LPJRE2COMPILE)GetProcAddress(m_hDll, "Jre2Compile");
\r
79 m_lpJre2MatchInfo = (LPJRE2GETMATCHINFO)GetProcAddress(m_hDll, "Jre2GetMatchInfo");
\r
80 m_lpJre2Close = (LPJRE2CLOSE)GetProcAddress(m_hDll, "Jre2Close");
\r
81 m_lpJreGetVersion = (LPJREGETVERSION)GetProcAddress(m_hDll, "JreGetVersion");
\r
82 m_lpGetJreMessage = (LPGETJREMESSAGE)GetProcAddress(m_hDll, "GetJreMessage");
\r
84 if((m_lpJre2Open != NULL) &&
\r
85 (m_lpJre2Compile != NULL) &&
\r
86 (m_lpJre2MatchInfo != NULL) &&
\r
87 (m_lpJre2Close != NULL) &&
\r
88 (m_lpJreGetVersion != NULL) &&
\r
89 (m_lpJreGetVersion != NULL))
\r
91 memset(&m_jreData, 0, sizeof(JRE2));
\r
92 m_jreData.dwSize = sizeof(JRE2);
\r
93 m_jreData.wTranslate = 1;
\r
95 if((*m_lpJre2Open)(&m_jreData) == TRUE)
\r
106 /*----- 正規表現ライブラリをリリースする --------------------------------------
\r
113 *----------------------------------------------------------------------------*/
\r
115 void ReleaseJre(void)
\r
118 FreeLibrary(m_hDll);
\r
125 /*----- 正規表現ライブラリが使えるかどうかを返す ------------------------------
\r
131 * int 正規表現ライブラリが使えるかどうか
\r
133 *----------------------------------------------------------------------------*/
\r
135 int AskJreUsable(void)
\r
147 /*----- 正規表現ライブラリのバージョンを返す a---------------------------------
\r
154 *----------------------------------------------------------------------------*/
\r
156 int GetJreVersion(void)
\r
162 Ver = (*m_lpJreGetVersion)();
\r
168 /*----- 正規表現検索式をコンパイルする ----------------------------------------
\r
176 *----------------------------------------------------------------------------*/
\r
178 int JreCompileStr(char *Str)
\r
184 Sts = (*m_lpJre2Compile)(&m_jreData, Str);
\r
190 /*----- 文字列が一致するかどうかを返す ----------------------------------------
\r
194 * UINT nStart : 検索開始位置
\r
199 *----------------------------------------------------------------------------*/
\r
201 char *JreGetStrMatchInfo(char *Str, UINT nStart)
\r
208 m_jreData.nStart = nStart;
\r
209 if((*m_lpJre2MatchInfo)(&m_jreData, Str) == TRUE)
\r
210 Ret = Str + m_jreData.nPosition;
\r