Narasimha Vedal...'s profileA Glitch in Code Saves N...BlogLists Tools Help

A Glitch in Code Saves None Department

Bioethical Debugging, Trusted Computing and everything in between.

iFIRE.exe

Fed up with crashing Search and Replace tool from Funduc guys, I've written my own command line tool. S&R crashes when working on unicode files. I've written iFIRE tool to work on files with different encodings. You can specify search replace terms on command line, or write them all in a script file and pass that to the tool. If you want this tool, you can request me via mail narasimha (dot) vedala (at) gmail (dot) com

Below is the help output from the tool (format of the text sucks, sorry for that):

=========================================================

Fast Inline Re(gex)place Engine (iFIRE) [command line]
Performs a regular expressions search and/or replace in files.
Copyright (c) Narasimha Vedala 2008

iFIRE.exe [drive:][path]filename [/UNI | /CP:nnnn] [/CT:culturestring] [/NOCULTURE]  [/S:"<searchpattern>"] [/R:"<replacepattern>"] [/I] [/SL|/ML] [/O] [/Q][/SCRIPT:fullpath to script file] [/SCRIPTCP:nnnn - codepage of script file]

  [drive:][path]filename
              Specifies files to be searched and replaced.
  /?          Displays this help
  /S:         Regex search pattern. Refer to .NET documentation for regular expressions
              This option is ignored if /SCRIPT: file is specified
  /R:         Regex replacement pattern/string. Refer to .NET documentation
              This option is ignored if /SCRIPT: file is specified
  /I          Ignore case
  /UNI        Specifies that file given is in Unicode format (Little-Endian)
              This is same as specifying /CP:1200
  /CP:nnnn    Codepage (Encoding) of the file. Should be a valid codepage number supported by .NET
               Defaults to 1252 Western-European (Windows). See Quick Reference below.
  /CT:culture Culture info to be used by Regex
  /NOCULTURE  Regular expression search and replace is culture invariant
  /SL         Single line pattern matching. See .NET RegexOptions documentation
  /ML         Multiline pattern matching. See .NET RegexOptions documentation
  /O          Console output only.  File is not modified
  /Q          Quiet operation. No noise output to the console

  /SCRIPT:        Full path to Search and Replace script file
  /SCRIPTCP:nnnn  Search and Replace script file's codepage. For example:-
                  If script has Chinese Traditional characters, then specify /SCRIPTCP:950
                  Refer to .NET documentation for codepage numbers. Some are given below for reference
  Quick Reference:     name     --     culture     --  codepage
                  Portugues Brazil     -- pt-BR    --  1252
                  Chinese Simplified   -- zh-Hans  --  936
                  Chinese Traditional  -- zh-Hant  --  950
                  French (France)      -- fr-FR    --  1252
                  German (Germany)     -- de-DE    --  1252
                  Italian (Italy)      -- it-IT    --  1252
                  Japanese (Japan)     -- ja-JP    --  932
                  Korean (Korea)       -- ko-KR    --  949
                  Russian (Russia)     -- ru-RU    --  1251
                  Spanish (Spain)      -- es-ES    --  1252
                  English (US)         -- en-US    --  1252

  Script file: Writing script file is easy. Place each search replace term on single line as shown below. </CODE< p>

              [SEARCH -i]your search pattern here[REPLACE]your replace string/pattern here
              -i above means case-insensitive. It is optional. Comments start with // on new line.
  Usage Examples:
               iFIRE.exe C:\TEMP\TestFile.txt /script:"C:\TEMP\SearchReplaceScript.ifxr" /scriptcp:1252
               iFIRE.exe C:\TEMP\UnicodeTestFile.txt /CP:1200 /S:"Ifneon\s+Technologies" /R:"Infineon Technologies" /i
               iFIRE.exe C:\TEMP\UnicodeTestJapaneseFile.txt /uni /script:"C:\TEMP\SearchReplaceJPScript.ifxr"

/scriptcp:932
 

Advanced Usage:
               Case insensitive search for some languages require culture [locale] information. You can provide it
               on the command line. Example assumes that replace script file has Japanese characters to be searched for.
               iFIRE.exe C:\TEMP\TestJapaneseFile.rc /cp:932 /ct:ja-JP /script:"C:\TEMP\SearchReplaceJPScript.ifxr" /scriptcp:932

Vista Aero design philosophy or a bug?

As far as I know, from Windows 2000 onwards, calling MessageBox API with MB_OK, MB_OKCANCEL shows the message dialog with [X] (close, cross)button enabled, while, using MB_YESNO shows it with [X] button disabled. I thought Design Philosophy behind this would be, X button is more or less to dismiss the dialog (which is same as canceling it). While, NO would not exactly mean canceling the dialog and hence X button is disabled.

Here is the interesting (or buggy?) part: On Vista, same MessageBox API with MB_YESNO shows dialog with [X] button disabled in non-aero or classic look, while, turning on the AERO effect, we see this [X] button enabled. Nothing happens when we click on it.

Is this a bug or Aero design philosophy? only Microsoft can answer.

Vista Windows Update - proxy problem solved

Proxy servers in our company are pretty old. Windows Update on Vista gives 0x80072eef and other related errors and it was just not working. My previous post explains how to solve this. Basically the lmCompatabilityLevel setting in Vista is higher than what old proxy server support (authentication schemes). Setting this value appropriately makes Windows Update work (you must restart). (Before doing update you must clean update directories: Stop Windows Update Service --delete WINDOWS\SoftwareDistribution folder and WindowsUpdate.log file -- start Windows Update Service.)

Getting NETMassDownloader to work behind proxy

After struggling for few minutes, I added code to NETMassDownloader to provide proxy credentials.

Steps:

Download NETMassDownloader source from CodePlex. Open the solution in Visual Studio.

In DownloadLibrary project open PDBWebClient.cs. In the constructor add the following code:

  public PDBWebClient()
  {
//...
//...
  base.Proxy = new System.Net.WebProxy(new Uri("webproxyUri"));
  base.Proxy.Credentials = new System.Net.NetworkCredential("username", "password", "domain");
 }
Build the solution and run it. It should work without hitches.
 
Blogs I read