
type BREGEXP
	outp As *Byte			' result string start ptr 
	outendp As *Byte		' result string end ptr 
	splitctr As Long		' split result counter 
	splitp As **Byte		' split result pointer ptr 
	rsv1 As Long			' reserved for external use
	parap As *Byte			' パターン文字列へのポインタ
	paraendp As *Byte		' 同、NULL 終端文字へのポインタ
	transtblp As *Byte		'（BTrans のときに有効）変換テーブルへのポインタ
	startp As **Byte		' パターンマッチした文字列へのポインタ
	endp As **Byte			' 同、NULL 終端文字へのポインタ
	nparens As Long			' パターン中の () の数（$1, $2, を調べるときに使用） 
End Type

Declare Function BMatch cdecl Lib"bregonig.dll" (str As *Byte, target As *Byte, targetendp As *Byte, _
								rxp As **BREGEXP, msg As *Byte) As Long
Declare Function BSubst cdecl Lib"bregonig.DLL" (str As *Byte, target As *Byte, targetendp As *Byte, _
								rxp As **BREGEXP, msg As *Byte) As Long
Declare Function BTrans cdecl Lib"bregonig.DLL" (str As *Byte, target As *Byte, targetendp As *Byte, _
								rxp As **BREGEXP, msg As *Byte) As Long
Declare Function BSplit cdecl Lib"bregonig.DLL" (str As *Byte, target As *Byte, targetendp As *Byte, _
						limit As Long, rxp As **BREGEXP, msg As *Byte) As Long
Declare Sub BRegfree cdecl Lib"bregonig.DLL" (rx As *BREGEXP)

Declare Function BRegexpVersion cdecl Lib"bregonig.DLL" () As *Byte


Type SURE
	no As Long
	name[100] As Byte
	mail[100] As Byte
	date[100] As Byte
	comm[2048] As Byte
	titl[100] As Byte
End Type

Function ReadRes(hFile As HANDLE, sure As *SURE) As Long
	Dim msg[255] As Byte
	Dim rxp As *BREGEXP
	Dim c As Long
	Dim szTarget[2048] As Byte

	'c = GetLine(hFile, szTarget)
	wsprintf(szTarget, "デフォルトの名無しさん<>sage<>2007/06/10(日) 06:16:39 <> ところでCP3とCP4って言語仕様変わった部分ある？ <>")

	c= BSplit("/<>/",szTarget,szTarget+lstrlen(szTarget),0,VarPtr(rxp),msg)

	memcpy(sure->name, rxp->splitp[0], rxp->splitp[1]-rxp->splitp[0])
	sure->name[rxp->splitp[1]-rxp->splitp[0]] = 0

	memcpy(sure->mail, rxp->splitp[2], rxp->splitp[3]-rxp->splitp[2])
	sure->mail[rxp->splitp[3]-rxp->splitp[2]] = 0

	memcpy(sure->date, rxp->splitp[4], rxp->splitp[5]-rxp->splitp[4])
	sure->date[rxp->splitp[5]-rxp->splitp[4]] = 0

	memcpy(sure->comm, rxp->splitp[6], rxp->splitp[7]-rxp->splitp[6])
	sure->comm[rxp->splitp[7]-rxp->splitp[6]] = 0

	memcpy(sure->titl, rxp->splitp[8], rxp->splitp[9]-rxp->splitp[8])
	sure->titl[rxp->splitp[9]-rxp->splitp[8]] = 0

	If rxp <> NULL Then BRegfree(rxp)
End Function


#N88BASIC
Sub TestPrint(sure As *SURE)
	Dim buf[3000] As Byte
	wsprintf(buf, Ex"%4d 名前：%s[%s] 投稿日：%s\r\n%s\r\n",sure->no, sure->name,sure->mail,sure->date,sure->comm)
	Print MakeStr(buf)
End Sub
Print MakeStr(BRegexpVersion())
Dim s As SURE
ReadRes(0, VarPtr(s))
s.no = 324
TestPrint(VarPtr(s))
