inet_ntoa is not thread safe

April 24th, 2012 ubergeek No comments

Seriously. I’ve been in the industry for 20 years, and still the most innocuous bits of code that I’ve used for years come back to bite me. Most of my time has been spent in Windows world where it seems that the function call IS threadsafe as the following excerpt would suggest from the MSDN website.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms738564%28v=vs.85%29.aspx

The string returned is guaranteed to be valid only until the next Windows Sockets function call is made within the same thread. Therefore, the data should be copied before another Windows Sockets call is made.

Fair enough, but, BSD (Mac OS/X) and Linux systems behave differently and the inet_ntoa function uses a small, static buffer to handle all calls to this function, causing many fruity errors that only start to appear when handling multiple connections.

http://www.educatedguesswork.org/2009/02/well_thats_an_unpleasant_surpr.html

Says all you need to know…

Categories: Uncategorized Tags:

Zotac ZBOX Intel Graphics Resolution

January 3rd, 2012 ubergeek No comments

How to increase the screen resolution on a Zotac Z-Box.

After a solid week of fumbling around in the dark trying to increase the on board HDMI screen resolution on my new Zotac Z-Box running Ubuntu Linux I have finally found the answer so thought I would share my findings.

By default the HDMI connection appears as a laptop screen and has a fairly limited resolution set. To alter this you simply need to hold the DELETE key down whilst booting and enter the BIOS setup.

The set default screen resolution in this BIOS. You can change the setting here to be the highest (1366×780) and then save your settings and reboot. After reboot your screen resolution should be automatically picked up by the display manager in Ubuntu and it is simply a matter of selecting this new resolution!

Categories: Uncategorized Tags:

Wix: Running a Batch File In Your Wix Script

November 17th, 2011 ubergeek 5 comments

Here’s a really simple tutorial about running batch files from a Wix installation package. I have spent days of my life trying to work out how to run a batch file from my Wix msi installation. All of the examples online stop short of actually being useful and are written by users with lots of experience and they miss out the important steps. Here is a short, concise, and hopefully easy to follow guide to running a batch file in a WiX installation script.

The basic premise is as follows:
1) WiX installer copies files to hard disk location specified during install script.
2) The included batch file is placed in a known child folder in the install path.
3) How do you run the batch file using the TargetPath that it has just been installed to.

The biggest issue that I came across was specifying the full path/folder to the batch file to run. To do this you must include the batch file as part of your Installation hierarchy as follows:


<Directory Id='TARGETDIR' Name='SourceDir'>
  <Directory Id='ProgramFilesFolder' Name='PFiles'>
    <Directory Id='MyInstallFolder' Name='XXX'>
    </Directory>
  </Directory>
</Directory>

Next step is to identify the list of files that are to be included. For the sake of this example I have just used the single batch file that we are wanting to run. The following code picks up the Batch file from the location specified by the ‘Source’ attribute and puts it in the location ‘C:\Program Files\XXX’


<DirectoryRef Id="MyInstallFolder">
  <Component Id="BatchComponents" Guid="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX">
    <File Id='my_batch_script' Name='MyBatch.bat' DiskId='1' Source='' />
  </Component>
</DirectoryRef>

OK, we’ve now setup the script to include a single batch file and we’ve also told it where to put the batch file on the target machine. We now need to setup a CustomAction using the CAQuietExec function. This customer action will execute the batch file and we can specify the TargetPath using the following code.


<CustomAction Id="BatchCmd" Property="BatchRun" Value=""[#my_batch_script]"" Execute="immediate"/>
<CustomAction Id="BatchRun" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="deferred" Return="check" Impersonate="yes"/>

The value in bold sets the path to be the same as the target path for the batch file and you link the BatchCmd CustomAction to the BatchRun CustomAction by using the same id in the Property field.

Finally we now need to tell the installer to run the batch file for us.


<InstallExecuteSequence>
  <Custom Action="BatchCmd" Before="BatchRun">NOT INSTALLED</Custom>
  <Custom Action="BatchRun" After="InstallFiles">NOT INSTALLED</Custom>
</InstallExecuteSequence>

That’s it. When your script runs it will run the batch file after it has installed it. You can change the ‘NOT INSTALLED’ string to other values to specify whether the batch file runs on install/un-install/other.

Hope this helps because it took me ages to find a simple example for running a batch file from WiX Installer

Categories: Uncategorized Tags:

Visual Basic 6 Multiline Comment

May 24th, 2011 ubergeek No comments

OK, every now and then as software developers you come across a legacy system written in VB6 that requires a bit of maintenance. For the most part Visual Basic 6 is fairly easy to use but, it has a few annoying features.

Multiline comments in Visual Basic 6 are not supported – in C++ it’s a simple case of using /* and */ to block quote some code. After searching through lots of forums on this subject I can confirm that the following method will allow multi-line comments.

In your VB 6 IDE you need to enabled the ‘EDIT’ toolbar. (View->Toolbars->Edit). Then select all the lines of code that you wish to comment out and hit the ‘Comment Block‘ icon on the edit toolbar. Hey presto, all the selected lines of code are now commented.

You can also perform this in reverse with the ‘UnComment Block’ command from the same toolbar.

Categories: Uncategorized Tags:

iPhone and British Summertime

March 28th, 2011 ubergeek No comments

I, like many millions of people worldwide have to get up on Monday mornings to goto work. I rely on my iPhone to wake me up in the mornings. This morning my iPhone did not go off.

If you set a recurring alarm on your iPhone you will probably have noticed that you also did not get woken up this morning if you live in the UK because of a bug in Apple’s firmware for the iPhone. There are a few workarounds but, the best one is to switch to a phone that actually works, try the Samsung Galaxy S and kick the iPhone into touch.

Categories: Uncategorized Tags:

CFileDialog Crashes On Windows XP

February 10th, 2011 ubergeek No comments

Microsoft Visual Studio CFileDialog Crash

Microsoft Visual Studio CFileDialog Crash

Spent ages and ages trying to workout why a simple bit of code using the Microsoft CFileDialog was working fine on Vista and Windows 7 but, crashing on XP. Having trawled through forum after forum trying to locate the problem I can confirm that it is to do with the final parameter in the CFileDialog Constructor.

The final parameter is a default BOOLEAN parameter called bVistaStyle. This defaults to TRUE but, on Windows XP it is overriden and becomes FALSE during the contructor.

The killer was a call to GetFolderPath() that should not be called after the dialog has been dismissed by the user. The Microsoft documentation even states this:

http://msdn.microsoft.com/en-US/library/xz5y6xhy(v=VS.80).aspx

The question is why they would have this as a public function when the standard usage dictates that this dialog is called with .DoModal()….
If bVistaStyle is set to TRUE this function degrades gracefully however, this flag is ignored on XP and this function will cause an access violation if used after the dialog has been dismissed.

The Solution:
Use GetPathName() instead to get the fully qualified path name and perform a _splitpath_s on the resulting filename to exract the path.

Categories: Uncategorized Tags:

Eclipse CDT. No source available for “ntdll!LdrAccessResource() ”

December 11th, 2009 mark 7 comments

eclipse
Recently I tried to run a version of the libx264 test harness x264.exe via the eclipse IDE. The binaries for both the library and the exe had both previously been built using MSys/MingW on the command line. I started Eclipse, created a new project, imported the code and then tried to run the application in the debugger and got the following error:

No source available for “ntdll!LdrAccessResource() “
Read more…

Categories: Uncategorized Tags:

JQuery Overlay Does not Work in Page Served via AJAX

November 12th, 2009 ubergeek 3 comments

jquery-logoOK – I’ve finally found the solution.  As mentioned on many forums across the web.  If you are using AJAX to serve up pages which contain any kind of JQuery ui functionality (JQuery Tabs, jQuery Overlay, JQuery Expose, etc. etc.) they will not work on the loaded page because most implementations rely on the main window load function to initialise the functionality.
Read more…

Categories: Uncategorized Tags:

Uploading Large Files via FTP using the BTHomeHub 2

November 5th, 2009 ubergeek 2 comments
The BTHomeHub 2

The BTHomeHub 2

Having just upgraded my home broadband from a 3 year old Voyager 2091 ADSL modem to a brand new BTHomeHub 2 I noticed a problem when uploading large files via my FTP Client – FileZilla.

I was attempting to upload a 500MB home video to my server and after a period of time the router just completely reset itself, it simply powered down and rebooted. The time between resets seems random, however, I have yet to completely upload a whole file using the new BTHomeHub 2.
Read more…

Categories: Uncategorized Tags:

Free Media Server For Mac

October 4th, 2009 ubergeek No comments

tvmobili-v128After months of fruitless searching I have finally found the answer to media streaming from Apple Macs.  Windows users have long been able to stream content for free using TVersity and other similar media streamers that you can download for free.
Read more…

Categories: Uncategorized Tags: