Advertisement
Guest User

Untitled

a guest
Mar 26th, 2010
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Var _FEIP_FileHandle
  2. Var _FEIP_Line
  3. Var _FEIP_LineLength
  4. Var _FEIP_CharNum
  5. Var _FEIP_Char
  6. Var _FEIP_Bom
  7.  
  8. !macro ForEachINIPair SECTION KEY VALUE
  9.     !ifdef _ForEachINIPair_Open
  10.         !error "There is already a ForEachINIPair clause open!"
  11.     !endif
  12.     !define _ForEachINIPair_Open
  13.     ${If} $_FEIP_FileHandle == ""
  14.         FileOpen $_FEIP_FileHandle $LauncherFile r
  15.         FileReadByte $_FEIP_FileHandle $_FEIP_Bom
  16.         FileReadByte $_FEIP_FileHandle $_FEIP_Line
  17.         IntOp $_FEIP_Line $_FEIP_Line * 256
  18.         Intop $_FEIP_Bom $_FEIP_Line + $_FEIP_Bom
  19.         ${If} $_FEIP_Bom = 0xfeff ;65279
  20. !ifndef NSIS_UNICODE
  21.             Messagebox MB_ICONEXCLAMATION "$LauncherFile is a utf-16LE file !!!$\nConvert this file to ANSI or re-compile the script with Unicode NSIS !"
  22.             abort
  23. !endif
  24.                     StrCpy $_FEIP_Bom 1
  25.         ${Else}
  26.             StrCpy $_FEIP_Bom 0
  27.         ${EndIf}
  28.     ${EndIf}
  29.     FileSeek $_FEIP_FileHandle 0
  30.     ${Do}
  31.         ClearErrors
  32.         ${if} $_FEIP_Bom = 1
  33. !ifdef NSIS_UNICODE
  34.             FileReadUTF16LE $_FEIP_FileHandle $_FEIP_Line
  35. !endif
  36.         ${Else}
  37.             FileRead $_FEIP_FileHandle $_FEIP_Line
  38.         ${EndIf}
  39.         ${TrimNewLines} $_FEIP_Line $_FEIP_Line
  40.         ${If} ${Errors} ; end of file
  41.         ${OrIf} $_FEIP_Line == "[${SECTION}]" ; right section
  42.             ${ExitDo}
  43.         ${EndIf}
  44.     ${Loop}
  45.  
  46.     ${IfNot} ${Errors} ; right section
  47.         ${Do}
  48.             ${if} $_FEIP_Bom = 1
  49. !ifdef NSIS_UNICODE
  50.                 FileReadUTF16LE $_FEIP_FileHandle $_FEIP_Line
  51. !endif
  52.             ${Else}
  53.                 FileRead $_FEIP_FileHandle $_FEIP_Line
  54.             ${EndIf}
  55.  
  56.             StrCpy $_FEIP_LineLength $_FEIP_Line 1
  57.             ${If} ${Errors} ; end of file
  58.             ${OrIf} $_FEIP_LineLength == '[' ; new section
  59.                 ${ExitDo} ; finished
  60.             ${EndIf}
  61.  
  62.             ${If} $_FEIP_LineLength == ';' ; a comment line
  63.                 ${Continue}
  64.             ${EndIf}
  65.  
  66.             StrLen $_FEIP_LineLength $_FEIP_Line
  67.             StrCpy $_FEIP_CharNum '0'
  68.             ${Do}
  69.                 StrCpy $_FEIP_Char $_FEIP_Line 1 $_FEIP_CharNum
  70.                 ${IfThen} $_FEIP_Char == '=' ${|} ${ExitDo} ${|}
  71.                 IntOp $_FEIP_CharNum $_FEIP_CharNum + 1
  72.             ${LoopUntil} $_FEIP_CharNum > $_FEIP_LineLength
  73.  
  74.             ${TrimNewLines} $_FEIP_Line $_FEIP_Line
  75.  
  76.             ${If} $_FEIP_Char == '='
  77.                 StrCpy ${KEY} $_FEIP_Line $_FEIP_CharNum
  78.                 IntOp $_FEIP_CharNum $_FEIP_CharNum + 1
  79.                 StrCpy ${VALUE} $_FEIP_Line "" $_FEIP_CharNum
  80. !macroend
  81.  
  82. !macro NextINIPair
  83.     !ifndef _ForEachINIPair_Open
  84.         !error "There isn't a ForEachINIPair clause open!"
  85.     !endif
  86.     !undef _ForEachINIPair_Open
  87.             ${EndIf}
  88.         ${Loop}
  89.     ${EndIf}
  90.     ;FileClose $_FEIP_FileHandle
  91. !macroend
  92.  
  93. !define ForEachINIPair '!insertmacro ForEachINIPair'
  94. !define NextINIPair '!insertmacro NextINIPair'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement