MT Decode URL : Source
| Name: | MT Decode URL
|
| Event Class: | XUVJ
|
| Event ID: | dURL
|
| Resource: | AEVTXUVJdURL
|
Source
--- This source is written in HyperTalk for CompileIt!
global theAEEvent:R,theReply:R, handerRefCon:LongInt
global myCounter:LongInt, myLen:LongInt, myWCounter:LongInt
codeResource "osax"
pascal function DecodeURL:I theAEEvent:R, theReply:R, handerRefCon:L
put NewPtr(8) into myDescPtr
put AEGetParamDesc(theAEEvent@,keyDirectObject,typeChar,myDescPtr@) into err
if err <> 0 then
DisposPtr myDescPtr
return err
end if
put myDescPtr@.dataHandle into myStrHandle
put GetHandleSize(myStrHandle) into myLen
---
if myLen < 3 then
if theReply@.descriptorType <> typeNull then
put AEPutParamDesc(theReply@, keyDirectObject,myDescPtr@) into err
end if
put AEDisposeDesc(myDescPtr@) into xerr
DisposPtr myDescPtr
return 0
end if
---
put 0 into myCounter
put 0 into myWCounter
put myLen - 1 into myLen
put myLen - 1 into sLimit
repeat
if myCounter > myLen then
exit repeat
end if
put CharToNum(myStrHandle@@.charType[myCounter]) into tgX
if tgX = 43 then
put NumToChar(32) into myStrHandle@@.charType[myWCounter]
add 1 to myCounter
add 1 to myWCounter
next repeat
else if tgX = 37 and (myCounter < sLimit) then
put CharToNum(myStrHandle@@.charType[myCounter+1]) into tgy
put CharToNum(myStrHandle@@.charType[myCounter+2]) into tgz
put HexToDexer(tgy) into digA
put HexToDexer(tgz) into digB
if tgy <> digA and tgz <> digB then
put (digA*16)+digB into zzz
put NumToChar(zzz) into myStrHandle@@.charType[myWCounter]
add 3 to myCounter
add 1 to myWCounter
next repeat
else
put NumToChar(tgX) into myStrHandle@@.charType[myWCounter]
add 1 to myCounter
add 1 to myWCounter
next repeat
end if
else
put NumToChar(tgX) into myStrHandle@@.charType[myWCounter]
add 1 to myCounter
add 1 to myWCounter
next repeat
end if
end repeat
----
SetHandleSize myStrHandle,myWCounter
put MemError() into err
if err = 0 and theReply@.descriptorType <> typeNull then
put AEPutParamDesc(theReply@, keyDirectObject,myDescPtr@) into err
end if
put AEDisposeDesc(myDescPtr@) into xerr
DisPosPtr myDescPtr
return err
end DecodeURL
function HexToDexer tgNm
if 48 <= tgNm and tgNm <= 57 then
return (tgNm-48)
else if 65 <= tgNm and tgNm <= 70 then
return (tgNm-55)
else if 97 <= tgNm and tgNm <= 102 then
return (tgNm-87)
end if
return tgNm
end HexToDexer
Tanaka's osax : Source
Tanaka's osax