- UID
- 5244
- 积分
- 1648
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-5-18
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
Compress Lisp Files

- [FONT=courier new]
- Option Explicit
- Dim lngDataCount As Long
- Dim lngBufferStart As Long
- Dim lngMxBuffSize As Long
- Dim strBuffer As String
- Dim lngBuffOffset As Long
- Dim lngBuffSize As Long
- Dim strDatContrl As String
- Dim bytDataCntrlChar As Byte
- Dim lngCntr As Long
- Dim bytCntrlPos As Byte
- Dim lngCompLen As Long
- Dim lngCompPos As Long
- Dim lngBytCompLen As Long
- Dim lngControlPos As Long
- Dim bytCntrlBitPos As Byte
- Dim lngDataPos As Long
- Dim lngDecompStart As Long
- Dim lngDecompLen As Long
- Public Function LispCompress(strCompName As String) As String
- lngMxBuffSize = 55535
- lngBytCompLen = 255
- lngBufferStart = 0
- strDatContrl = ""
- bytDataCntrlChar = 0
- bytCntrlPos = 0
- lngCntr = 0
- If Len(strCompName) > 4 Then
- LispCompress = Left(strCompName, 4)
- For lngDataCount = 5 To Len(strCompName)
- If lngDataCount > lngMxBuffSize Then
- lngBuffSize = lngMxBuffSize
- lngBufferStart = lngDataCount - lngMxBuffSize
- Else
- lngBuffSize = lngDataCount - 1
- lngBufferStart = 1
- End If
- strBuffer = Mid(strCompName, lngBufferStart, lngBuffSize)
- If Len(strCompName) - lngDataCount < lngBytCompLen Then lngBytCompLen = Len(strCompName) - lngDataCount
- lngCompPos = 0
- For lngCompLen = 3 To lngBytCompLen Step 3
- If lngCompLen > lngBytCompLen Then
- lngCompLen = lngBytCompLen
- End If
- lngCompPos = InStr(1, strBuffer, Mid(strCompName, lngDataCount, lngCompLen), 0)
- If lngCompPos = 0 Then
- If lngCompLen > 3 Then
- While lngCompPos = 0
- lngCompPos = InStr(1, strBuffer, Mid(strCompName, lngDataCount, lngCompLen - 1), 0)
- If lngCompPos = 0 Then lngCompLen = lngCompLen - 1
- Wend
- End If
- lngCompLen = lngCompLen - 1
- Exit For
- End If
- Next
- If lngCompLen > lngBytCompLen And lngCompPos > 0 Then
- lngCompLen = lngBytCompLen
- lngCompPos = InStr(1, strBuffer, Mid(strCompName, lngDataCount, lngCompLen), 0)
- End If
- If lngCompPos > 0 Then
- lngBuffOffset = lngBuffSize - lngCompPos + 1
- LispCompress = LispCompress & Chr((lngBuffOffset And &HFF00) / &H100) & Chr(lngBuffOffset And &HFF) & Chr(lngCompLen)
- lngDataCount = lngDataCount + lngCompLen - 1
- bytDataCntrlChar = bytDataCntrlChar + 2 ^ bytCntrlPos
- Else
- LispCompress = LispCompress & Mid(strCompName, lngDataCount, 1)
- End If
- bytCntrlPos = bytCntrlPos + 1
- If bytCntrlPos = 8 Then
- strDatContrl = strDatContrl & Chr(bytDataCntrlChar)
- bytDataCntrlChar = 0
- bytCntrlPos = 0
- End If
- lngCntr = lngCntr + 1
- If lngCntr / 1000 = Int(lngCntr / 1000) Then
- DoEvents
- End If
- Next
- If bytCntrlPos <> 0 Then strDatContrl = strDatContrl & Chr(bytDataCntrlChar)
- LispCompress = Chr((lngCntr And &H8F000000) / &H1000000) & Chr((lngCntr And &HFF0000) / &H10000) & Chr((lngCntr And &HFF00) / &H100) & Chr(lngCntr And &HFF) & Chr((Len(strDatContrl) And &H8F000000) / &H1000000) & Chr((Len(strDatContrl) And &HFF0000) / &H10000) & Chr((Len(strDatContrl) And &HFF00) / &H100) & Chr(Len(strDatContrl) And &HFF) & strDatContrl & LispCompress
- Else
- LispCompress = strCompName
- End If
- End Function
- [/FONT]

- [FONT=courier new]
- Public Function LispUncompress(strUnComName As String) As String
- If Len(strUnComName) > 4 Then
- lngCntr = Asc(Left(strUnComName, 1)) * &H1000000 + Asc(Mid(strUnComName, 2, 1)) * &H10000 + Asc(Mid(strUnComName, 3, 1)) * &H100 + Asc(Mid(strUnComName, 4, 1))
- lngDataCount = Asc(Mid(strUnComName, 5, 1)) * &H1000000 + Asc(Mid(strUnComName, 6, 1)) * &H10000 + Asc(Mid(strUnComName, 7, 1)) * &H100 + Asc(Mid(strUnComName, 8, 1)) + 9
- LispUncompress = Mid(strUnComName, lngDataCount, 4)
- lngDataCount = lngDataCount + 4
- bytCntrlBitPos = 0
- lngControlPos = 9
- For lngDataPos = 1 To lngCntr
- If 2 ^ bytCntrlBitPos = (Asc(Mid(strUnComName, lngControlPos, 1)) And 2 ^ bytCntrlBitPos) Then
- lngDecompStart = Len(LispUncompress) - (CLng(Asc(Mid(strUnComName, lngDataCount, 1))) * &H100 + CLng(Asc(Mid(strUnComName, lngDataCount + 1, 1)))) + 1
- lngDecompLen = Asc(Mid(strUnComName, lngDataCount + 2, 1))
- LispUncompress = LispUncompress & Mid(LispUncompress, lngDecompStart, lngDecompLen)
- lngDataCount = lngDataCount + 3
- Else
- LispUncompress = LispUncompress & Mid(strUnComName, lngDataCount, 1)
- lngDataCount = lngDataCount + 1
- End If
- bytCntrlBitPos = bytCntrlBitPos + 1
- If bytCntrlBitPos = 8 Then
- bytCntrlBitPos = 0
- lngControlPos = lngControlPos + 1
- End If
- Next
- Else
- LispUncompress = strUnComName
- End If
- End Function[/FONT]
|
|