<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Pantokrator&#039;s Blog &#187; Development</title>
	<atom:link href="http://blog.pantokrator.net/category/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.pantokrator.net</link>
	<description>Nam et ipsa scientia potestas est.</description>
	<lastBuildDate>Sat, 17 Oct 2009 07:02:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Reading URLs protected with HTTP Authentication with Java</title>
		<link>http://blog.pantokrator.net/2008/09/23/reading-urls-protected-with-http-authentication-with-java/</link>
		<comments>http://blog.pantokrator.net/2008/09/23/reading-urls-protected-with-http-authentication-with-java/#comments</comments>
		<pubDate>Tue, 23 Sep 2008 21:35:54 +0000</pubDate>
		<dc:creator>pantokrator</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://blog.pantokrator.net/?p=9</guid>
		<description><![CDATA[In Java, you can use URLConnection class to read from an URL. For example, to read the page from google.com, you can do something like this:

import java.net.*;
import java.io.*;

public class URLConnectionReader {
    public static void main(String[] args) throws Exception {
        URL google = new URL("http://www.google.com/");
  [...]]]></description>
			<content:encoded><![CDATA[<p>In Java, you can use <a id="geiq" title="URLConnection" href="http://java.sun.com/javase/6/docs/api/java/net/URLConnection.html" target="_blank">URLConnection</a> class to read from an URL. For example, to read the page from google.com, you can do something like this:</p>
<blockquote>
<pre>import java.net.*;
import java.io.*;

public class URLConnectionReader {
    public static void main(String[] args) throws Exception {
        URL google = new URL("http://www.google.com/");
        URLConnection gc = google.openConnection();
        BufferedReader in = new BufferedReader(
                                new InputStreamReader(
                                gc.getInputStream()));
        String inputLine;

        while ((inputLine = in.readLine()) != null)
            System.out.println(inputLine);
        in.close();
    }
}</pre>
</blockquote>
<p>If the access to the URL is protected with authentication mechanism, IOException is thrown when you try to read from InputStream associated with URLConnection. In that case, you need to use <a id="q6yv" title="Authenticator" href="http://java.sun.com/javase/6/docs/api/java/net/Authenticator.html" target="_blank">Authenticator</a> class from java.net package, that makes accessing password-protected URLs as easy as can be.</p>
<p><span id="more-10"></span></p>
<p>So, you simply install an Authenticator, with Authenticator.setDefault(). Then, when authentication is necessary, the installed Authenticator&#8217;s getPasswordAuthentication() method is called, and you return a <a id="gixj" title="PasswordAuthentication" href="http://java.sun.com/javase/6/docs/api/java/net/PasswordAuthentication.html" target="_blank">PasswordAuthentication</a> instance with the appropriate username and password.</p>
<p>The example code is shown below.</p>
<blockquote>
<pre>import java.net.*;
import java.io.*;

public class URLConnectionAuthReader {
    public static void main(String[] args) throws Exception {
        String username = "username";
        String password = "password";
        URL authurl = new URL("http://www.protectedurl.com/");

        Authenticator.setDefault(new MyAuthenticator(username, password));
        URLConnection ac = authurl.openConnection();
        BufferedReader in = new BufferedReader(
                                new InputStreamReader(
                                ac.getInputStream()));
        String inputLine;

        while ((inputLine = in.readLine()) != null)
            System.out.println(inputLine);
        in.close();
    }

    protected static class MyAuthenticator extends Authenticator {
        private String username, password;

        public MyAuthenticator(String user, String pwd) {
            username = user;
            password = pwd;
        }

        protected PasswordAuthentication getPasswordAuthentication() {
            return new PasswordAuthentication(username, password.toCharArray());
        }
    }
}</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.pantokrator.net/2008/09/23/reading-urls-protected-with-http-authentication-with-java/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Compiling SDL_image with MSYS/MinGW</title>
		<link>http://blog.pantokrator.net/2006/08/13/compiling-sdl_image-with-msysmingw/</link>
		<comments>http://blog.pantokrator.net/2006/08/13/compiling-sdl_image-with-msysmingw/#comments</comments>
		<pubDate>Sun, 13 Aug 2006 12:40:41 +0000</pubDate>
		<dc:creator>pantokrator</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://blog.pantokrator.net/?p=6</guid>
		<description><![CDATA[1. Introduction
SDL_image is an image loading library that is used with the SDL library, and almost as portable. It allows a programmer to use multiple image formats without having to code all the loading and conversion algorithms themselves. SDL_image supports BMP, GIF, JPG, LBM, PCX, PNG, PNM, TGA, TIFF, XCF, XPM and XV image formats.
SDL_image [...]]]></description>
			<content:encoded><![CDATA[<h2>1. Introduction</h2>
<p>SDL_image is an image loading library that is used with the SDL library, and almost as portable. It allows a programmer to use multiple image formats without having to code all the loading and conversion algorithms themselves. SDL_image supports BMP, GIF, JPG, LBM, PCX, PNG, PNM, TGA, TIFF, XCF, XPM and XV image formats.</p>
<p>SDL_image requires <a target="_blank" href="http://www.ijg.org">JPEG library</a> for JPG image support, <a target="_blank" href="http://www.libpng.org/pub/png/libpng.html">PGN libarary</a> and <a target="_blank" href="http://www.gzip.org/zlib">zlib library</a> for PGN image format support, and the <a target="_blank" href="http://www.remotesensing.org/libtiff/">TIFF library</a> for TIFF image support.</p>
<blockquote><p>Note: Current version of TIFF library has some problems compiling under Windows/MinGW, so we will disable support for tif file format in SDL_image library.</p></blockquote>
<p><span id="more-8"></span></p>
<h2>2. Compiling SDL_image</h2>
<h3>2.1. Compiling zlib library</h3>
<p>Download the latest version of <a href="http://www.zlib.net/zlib-1.2.3.tar.gz">zlib library</a> (version 1.2.3, at the time of writing), and save it in your MSYS home folder.</p>
<p><code> $ tar -xzvf zlib-1.2.3.tar.gz<br />
$ cd zlib-1.2.3<br />
$ configure --prefix=/mingw<br />
$ make<br />
$ make install</code></p>
<h3>2.2. Compiling PNG library</h3>
<p>Download latest version of <a href="ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-1.2.12.tar.bz2">libpng library</a> (version 1.2.12, at the time of writing), and save it in you MSYS home directory.</p>
<blockquote><p>Note: Current version of PNG library has some problems with installing shared version of library under MinGW system, so we will disable compilation of shared version, and patch the generated Makefile with a simple sed script, to make it work without problems.</p></blockquote>
<p><code> $ tar -xjvf libpng-1.2.12.tar.bz2<br />
$ cd libpng-1.2.12<br />
$ ./configure --prefix=/mingw --disable-shared<br />
$ mv Makefile Makefile.orig<br />
$ sed -e 's/for ext in a la so; do/for ext in a la; do/' Makefile.orig > Makefile<br />
$ make<br />
$ make install<br />
</code></p>
<h3>2.3. Compiling JPEG library</h3>
<p>Download the source code for <a href="ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz">JPEG library</a> (version 6b, at the time of writing), and save it in your MSYS home directory.</p>
<p><code> $ tar -xzvf jpegsrc.v6b.tar.gz<br />
$ cd jpeg-6b<br />
$ ./configure --prefix=/mingw --enable-static<br />
$ make<br />
$ make install-lib<br />
</code></p>
<h3>2.4. Compiling SDL_image</h3>
<p>Now that we have compiled all needed dependencies for SDL_image library, we can proceed and compile SDL_image library itself. Download the latest version of <a href="http://www.libsdl.org/projects/SDL_image/release/SDL_image-1.2.5.tar.gz">SDL_image library</a> (version 1.2.5, at the time of writing), and save it in you MSYS home directory.</p>
<p><code> $ ./configure --prefix=/mingw --disable-tif --disable-jpg-shared --disable-png-shared<br />
$ make<br />
$ make install<br />
</code></p>
<h2>3. Conclusion</h2>
<p>This procedure will get you compiled SDL_image library, that you can use in your SDL projects. Do not forget to copy SDL_image.dll library from /mingw/bin to you application directory, if you application makes use of it.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.pantokrator.net/2006/08/13/compiling-sdl_image-with-msysmingw/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Setting up MSYS/MinGW build system for compiling SDL/OpenGL applications</title>
		<link>http://blog.pantokrator.net/2006/08/08/setting-up-msysmingw-build-system-for-compiling-sdlopengl-applications/</link>
		<comments>http://blog.pantokrator.net/2006/08/08/setting-up-msysmingw-build-system-for-compiling-sdlopengl-applications/#comments</comments>
		<pubDate>Tue, 08 Aug 2006 21:25:52 +0000</pubDate>
		<dc:creator>pantokrator</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://blog.pantokrator.net/?p=5</guid>
		<description><![CDATA[1. Introduction
MSYS is a Minimal SYStem to provide POSIX/Bourne configure scripts the ability to execute and create a Makefile used by make on MS Windows operating system.
 MinGW is a collection of freely available and freely distributable Windows specific header files and import libraries combined with GNU tool sets that allow one to produce native [...]]]></description>
			<content:encoded><![CDATA[<h2>1. Introduction</h2>
<p><a target="_blank" href="http://www.mingw.org">MSYS</a> is a Minimal SYStem to provide POSIX/Bourne configure scripts the ability to execute and create a Makefile used by make on MS Windows operating system.<br />
<a target="_blank" href="http://www.mingw.org"> MinGW</a> is a collection of freely available and freely distributable Windows specific header files and import libraries combined with GNU tool sets that allow one to produce native Windows programs that do not rely on any 3rd-party C runtime DLLs.<br />
In this tutorial we will setup MSYS/MinGW configuration, and compile libraries needed for development of SDL and OpenGL applications.</p>
<p><span id="more-7"></span></p>
<h2>2. Installation</h2>
<h3>2.1. MSYS Installation</h3>
<p>First, you need to download <a target="_blank" href="http://prdownloads.sf.net/mingw/MSYS-1.0.10.exe?download">MSYS setup</a> exe file, and execute it. Once you have started setup, accept the license and select the folder where MSYS will be installed (or leave it on C:\msys\1.0, which is the default installation location). When installation is finished, MSYS will start post-install script in console window, which will try to detect if there is a previous installation of MSYS on your system (just enter y here), and then it will ask if you have MinGW installed (enter n here, because MinGW will be installed later). Follow the instructions presented, and installation will finish.</p>
<p>Now you have basic Bourne shell on your Windows system, with some standard UNIX-like utilities (make, diff, awk, etc). You can start MSYS shell from Start->Programs->MinGW->MSYS menu.</p>
<p>Next you need to download and install <a target="_blank" href="http://prdownloads.sf.net/mingw/msysDTK-1.0.1.exe?download">msysDTK</a>. The msysDTK package is MSYS Developer Tool Kit, which contains the following list of tools: autoconf, automake, libtool, guile, cvs, openssl, openssh, inetutils, perl and vim. Similar to MSYS, the download is an installation binary. It will default the directory location to your MSYS installation.</p>
<h3>2.2. MinGW Installation</h3>
<p>Download the most recent <a target="_blank" href="http://prdownloads.sf.net/mingw/MinGW-5.0.2.exe?download">MinGW setup</a>, in the time of writing this, it is version 5.0.2. This setup will download and install components of MinGW package. It will present you a list of SourceForge mirror sites, and an option to download only or download and install MinGW components. Next, choose Current as a type of MinGW package, and select components to be installed. At least, choose MinGW base tools, which will install a GNU C compiler, binutils, and Win32 API header files for you. Other components you can choose are g++ compiler (GNU C++ compiler), g77 compiler (fortran), Ada, Java and Objective C Compiler. Next, you need to select a destination folder for component installation. Since we already installed MSYS, you can choose mingw folder in MSYS installation folder for destination folder.</p>
<blockquote><p>If you choose some other folder, you will need to modify /etc/fstab file under MSYS, and map a MinGW installation folder to /mingw MSYS folder. For example, if you installed MinGW in C:\mingw, you will need to add the following line to /etc/fstab file:<br />
<code>C:/mingw /mingw</code></p></blockquote>
<h2>3. SDL compilation</h2>
<h3>3.1. Introduction</h3>
<p><a target="_blank" href="http://www.libstd.org">Simple DirectMedia Layer</a> is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via <a target="_blank" href="http://www.opengl.org">OpenGL</a>, and 2D video framebuffer.<br />
We will download source version of SDL library, and compile it under MSYS/MinGW. There are also precompiled versions of library for MinGW, but if you compile it yourself, you have a control over library configuration and compilation.</p>
<h3>3.2. Preparation</h3>
<p>Download <a target="_blank" href="http://www.libsdl.org/download-1.2.php">SDL library source code</a> (the .tar.gz archive) and put it in your MSYS user home directory. The current library version in the time of writing is SDL 1.2.11.</p>
<blockquote><p>Note: After installing MSYS, setup creates user home folder with the name of system user name, under the MSYS /home folder. You can access it from Windows Explorer from {msys_instal_dir}\home\{windows_user}. When you start MSYS shell, working directory is set to user home directory.</p></blockquote>
<p>Extract the content of the archive and enter SDL directory:</p>
<p><code>$ tar -xzvf SDL-1.2.11.tar.gz<br />
$ cd SDL-1.2.11</code></p>
<h3>3.3. Configuring SDL</h3>
<p>SDL library compilation can be configured with many options. Configure script examines the capabilities of system, and tries to adapt the library configuration. Some options can be controlled by user. For a list of available configuration options and their default values, run:</p>
<p><code>$ ./configure --help</code></p>
<p>One option that you will need to set is &#8211;prefix=PREFIX option. This options set installation directory for the library. Under MSYS, we need to set this option to /mingw directory, so that include files and compiled library is installed in compiler directory.</p>
<p><code>$ ./configure --prefix=/mingw</code></p>
<p>Some options control what parts of SDL subsystem will be compiled into the library:</p>
<p><code> --enable-audio          Enable the audio subsystem [default=yes]<br />
--enable-video          Enable the video subsystem [default=yes]<br />
--enable-events         Enable the events subsystem [default=yes]<br />
--enable-joystick       Enable the joystick subsystem [default=yes]<br />
--enable-cdrom          Enable the cdrom subsystem [default=yes]<br />
--enable-threads        Enable the threading subsystem [default=yes]<br />
--enable-timers         Enable the timer subsystem [default=yes]<br />
--enable-file           Enable the file subsystem [default=yes]<br />
--enable-loadso         Enable the shared object loading subsystem [default=yes]<br />
--enable-cpuinfo        Enable the cpuinfo subsystem [default=yes]</code></p>
<p>If you do not need some SDL subsystems, you can configure compilation to exclude it, by passing parameters to configure script. For example, if you do not need the support for joystick and cdrom subsystem, you can configure SDL with:</p>
<p><code>$ ./configure --prefix=/mingw --enable-joystick=no --enable-cdrom=no</code></p>
<p>Another option that might be interesting is <code>--enable-stdio-redirect</code>, which is enabled by default on Win32 systems. This option enables redirection of standard console output to files stdio.txt and stderr.txt. If this option is enabled, every program output (using functions like printf in C, for example) is redirected to these files. If you don&#8217;t want these files to be created when your SDL program is started, you can disable this option:</p>
<p><code>$ ./configure --prefix=/mingw --enable-stdio-redirect=no</code></p>
<p>You can control C <a target="_blank" href="http://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/Option-Summary.html">compiler options</a> by setting <code>CFLAGS</code> environmental variable before configuring library compilation. Also, you can set <a target="_blank" href="http://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/Link-Options.html">linker flags</a> by setting <code>LDFLAGS</code> variable. Be carefull, setting some compiler options can cause serious compilation or execution problems, so, before setting options, be sure that you know what you are doing. You set environmental variables by using export shell command. For example, to set compiler optimization for size, type:</p>
<p><code>$ export CFLAGS=-Os</code></p>
<p>If you don&#8217;t want to make any customizations to SDL configuration and leave all options to their default values, than just configure it with the following command:</p>
<p><code>$ ./configure --prefix=/mingw</code></p>
<h3>3.4 Compiling SDL</h3>
<p>Now that SDL library is configured for compilation, you can proceed with compilation and installation.</p>
<p><code>$ make<br />
$ make install</code></p>
<p>After that, you will have installed a working version of SDL library, and header files.</p>
<h3>3.5 Testing compiled SDL library</h3>
<p>SDL library provides testing examples in <code>test</code> subdirectory, which you can use to test various features and capabilities of an SDL library. To compile test examples:<br />
<code>$ cd test<br />
$ ./configure<br />
$ make</code></p>
<p>When make process is finished, you can start examples from MSYS shell, by typing the name of test exe file. If you want to start example from Windows, you will need to copy exe file with the SDL.dll library, which can be found under /mingw/bin directory, to some separate directory and start it from there.</p>
<blockquote><p>Note: You can also copy SDL.dll library in windows\system32 directory, and in that case, all the applications that use SDL will use that copy of the library, which might lead to some problems, depending of the options you used during compilation&#8230;</p>
<p>Note: Almost every SDL example gives some output, so depending of options you specified during the SDL library configuration, you can see that output on console, or saved in stdio.txt file.</p></blockquote>
<h2>4. Conclusion</h2>
<p>This procedure will get you complete system for configuring and compiling SDL applications, and you should be able to compile existing SDL application, or write your own&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.pantokrator.net/2006/08/08/setting-up-msysmingw-build-system-for-compiling-sdlopengl-applications/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

