<?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"
	>

<channel>
	<title>blog.s11n.net &#187; software-dev</title>
	<atom:link href="http://blog.s11n.net/?feed=rss2&#038;cat=14" rel="self" type="application/rss+xml" />
	<link>http://blog.s11n.net</link>
	<description>blog for s11n.net</description>
	<pubDate>Thu, 23 Aug 2012 15:51:29 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>JSON API in the Fossil SCM</title>
		<link>http://blog.s11n.net/?p=103</link>
		<comments>http://blog.s11n.net/?p=103#comments</comments>
		<pubDate>Fri, 04 Nov 2011 21:31:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[StrangerThanFiction]]></category>

		<category><![CDATA[software-dev]]></category>

		<category><![CDATA[fossil]]></category>

		<category><![CDATA[json]]></category>

		<guid isPermaLink="false">http://blog.s11n.net/?p=103</guid>
		<description><![CDATA[

Hi, all!
Since mid September i&#8217;ve been working on adding a JSON API to the Fossil SCM. As of just a short while ago, D. Richard Hipp, legendary author of sqlite3 and Fossil, merged that API into the Fossil trunk. :-D
The pseudo-historic commit is here:
http://www.fossil-scm.org/fossil/info/796dcfe072
With these features it becomes possible to write custom applications on top of [...]]]></description>
			<content:encoded><![CDATA[<p><span></p>
<div>
<p>Hi, all!</p>
<p>Since mid September i&#8217;ve been working on adding a JSON API to the <a title="Fossil SCM" href="http://www.fossil-scm.org/" target="_blank">Fossil SCM</a>. As of just a short while ago, D. Richard Hipp, legendary author of sqlite3 and Fossil, merged that API into the Fossil trunk. :-D</p>
<p>The pseudo-historic commit is here:</p>
<p><a href="http://www.fossil-scm.org/fossil/info/796dcfe072">http://www.fossil-scm.org/fossil/info/796dcfe072</a></p>
<p>With these features it becomes possible to write custom applications on top of fossil, communicating with it via JSON (either over HTTP or stdin/file-based JSON). There&#8217;s still lots of work to make the JSON API widely usable, but this merge widens exposure to the new features, and exposure is the best way for us to evolve the feature sets the API needs.</p>
<p><strong><em><strong><em>Happy Hacking!</em></strong></em></strong></p>
<p>&#8212;&#8211; stephan beal</p>
</div>
<p></span></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.s11n.net/?feed=rss2&amp;p=103</wfw:commentRss>
		</item>
		<item>
		<title>Generating JSON output from Databases on the Command Line</title>
		<link>http://blog.s11n.net/?p=98</link>
		<comments>http://blog.s11n.net/?p=98#comments</comments>
		<pubDate>Sun, 17 Apr 2011 11:00:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[software-dev]]></category>

		<category><![CDATA[c]]></category>

		<category><![CDATA[database]]></category>

		<category><![CDATA[json]]></category>

		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://blog.s11n.net/?p=98</guid>
		<description><![CDATA[Hello, JSON fans,
This morning i wrote a small C application which can be used to fetch data from sqlite3 and MySQLv5 databases and convert it to JSON. While it was originally written as a test app for my C JSON library, it certainly has other uses.
It can be found here:
http://fossil.wanderinghorse.net/repos/cson/index.cgi/wiki/select-to-json
It &#8220;should&#8221; compile fine out of [...]]]></description>
			<content:encoded><![CDATA[<p>Hello, JSON fans,</p>
<p>This morning i wrote a small C application which can be used to fetch data from sqlite3 and MySQLv5 databases and convert it to JSON. While it was originally written as a test app for <a href="http://fossil.wanderinghorse.net/repos/cson/">my C JSON library</a>, it certainly has other uses.</p>
<p>It can be found here:</p>
<p><a href="http://fossil.wanderinghorse.net/repos/cson/index.cgi/wiki/select-to-json">http://fossil.wanderinghorse.net/repos/cson/index.cgi/wiki/select-to-json</a></p>
<p>It &#8220;should&#8221; compile fine out of the box on any Linux-like system with gcc, bash, and GNU Make. Building on other platforms requires either converting the included Makefile logic to the platform&#8217;s build tool, or linking it against <a href="http://fossil.wanderinghorse.net/repos/cson/index.cgi/wiki/AmalgamationBuild">the &#8220;amalgamation build&#8221;</a> of the underlying JSON library. The code is portable ANSI C-89 and should not require any platform-specific fixes.</p>
<p><strong><em>Happy Hacking!</em></strong></p>
<p>&#8212;&#8211; stephan beal</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.s11n.net/?feed=rss2&amp;p=98</wfw:commentRss>
		</item>
		<item>
		<title>JSON-centric CGI Applications in C</title>
		<link>http://blog.s11n.net/?p=97</link>
		<comments>http://blog.s11n.net/?p=97#comments</comments>
		<pubDate>Mon, 11 Apr 2011 21:38:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[software-dev]]></category>

		<category><![CDATA[c]]></category>

		<category><![CDATA[CGI]]></category>

		<category><![CDATA[json]]></category>

		<guid isPermaLink="false">http://blog.s11n.net/?p=97</guid>
		<description><![CDATA[Hello, fellow C hackers, (everyone else can stop reading now)
A few months ago i started writing cson (pronounced &#8220;season&#8221;), a C library for generating and consuming JSON data using an OO interface (as opposed to a printf()-like API). The past few days i&#8217;ve extended it to support a mini-framework for writing JSON-only CGI applications. It&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>Hello, fellow C hackers, (everyone else can stop reading now)</p>
<p>A few months ago i started writing <a href="http://fossil.wanderinghorse.net/repos/cson/">cson</a> (pronounced &#8220;season&#8221;), a C library for generating and consuming <a href="http://www.json.org">JSON</a> data using an OO interface (as opposed to a printf()-like API). The past few days i&#8217;ve extended it to support a mini-framework for writing JSON-only CGI applications. It&#8217;s biggest claim to fame is that it can use HTTP cookies (or a client-provided session ID) to manage persistent application sessions, which are stored (of course) as JSON. It currently supports using files, sqlite3, or mysql5 for session storage, and can easily be extended to support new back-ends. (So far i have been unable to find any other C/C++ CGI libraries which support persistent sessions.)</p>
<p>If you just happen to be one of the 3 or 4 remaining C hackers who like to write CGI apps, and you are also a big fan of JSON, the code might be of interest to you:</p>
<p><a href="http://fossil.wanderinghorse.net/repos/cson/index.cgi/wiki/cson_cgi">http://fossil.wanderinghorse.net/repos/cson/index.cgi/wiki/cson_cgi</a></p>
<p>The JSON-based session support is actually independent of the CGI bits, and can be used without HTTP/CGI:</p>
<p><a href="http://fossil.wanderinghorse.net/repos/cson/index.cgi/wiki/cson_session"> http://fossil.wanderinghorse.net/repos/cson/index.cgi/wiki/cson_session</a></p>
<p>Here&#8217;s a demo:</p>
<p><a href="http://fossil.wanderinghorse.net/demos/cson/">http://fossil.wanderinghorse.net/demos/cson/</a></p>
<p><em><strong><em>Happy Hacking!</em></strong></em></p>
<p>&#8212;&#8211; stephan beal</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.s11n.net/?feed=rss2&amp;p=97</wfw:commentRss>
		</item>
		<item>
		<title>Wanted: Late-night Hacker seeks SSH Access&#8230;</title>
		<link>http://blog.s11n.net/?p=96</link>
		<comments>http://blog.s11n.net/?p=96#comments</comments>
		<pubDate>Wed, 02 Feb 2011 05:54:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[StrangerThanFiction]]></category>

		<category><![CDATA[software-dev]]></category>

		<category><![CDATA[begging]]></category>

		<category><![CDATA[c]]></category>

		<category><![CDATA[oracle]]></category>

		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://blog.s11n.net/?p=96</guid>
		<description><![CDATA[Hello, fellow hackers!
i just have to ask&#8230;
As part of the cpdo project i would really like to start work on a database driver for Oracle (based on ocilib, which i quite like and is well documented). My main limiting factor here is access to a Unix/Unix-ish machine with the necessary Oracle bits.
If there is anyone [...]]]></description>
			<content:encoded><![CDATA[<p>Hello, fellow hackers!</p>
<p>i just <em>have</em> to ask&#8230;</p>
<p>As part of the <a href="http://fossil.wanderinghorse.net/repos/cpdo/">cpdo project</a> i would really like to start work on a database driver for Oracle (based on <a href="http://orclib.sourceforge.net">ocilib</a>, which i quite like and is well documented). My main limiting factor here is access to a Unix/Unix-ish machine with the necessary Oracle bits.</p>
<p>If there is <em>anyone</em> out there who could give me (<em>unprivileged!</em>) SSH access to such a machine, you would be doing me a great service. My requirements would be:</p>
<ul>
<li>Some form of Linux, BSD, Solaris, etc.</li>
<li>A decent C compiler and related build tools.</li>
<li>Access to link to libclntsh.so (some admins lock that away in a dir only readable by the oracle user and/or dba group).</li>
<li>A decent editor: xemacs (preferred) or emacs. (Note that xemacs works fine <em>without</em> X11, and i would <em>not</em> need to tunnel X11 over ssh.)</li>
<li>Access to a single Oracle database with minimal space requirements (maybe a meg or two, at the very most).</li>
<li>i <em>think</em> that i need Oracle v10 or higher, but to be honest i&#8217;m not certain.</li>
<li>Far under 1% (amortized) of your total CPU capacity, with most of that coming from the C compiler and the linker.</li>
<li>Initially i would need a total of probably 36-48 hours of login time, and would of course like to have further access to improve upon the driver over time (but i would settle for the initial block if that&#8217;s all i can get).</li>
</ul>
<p>i would of course <em>Do No Evil</em> (or even <em>Mischief</em>) on your machine - my sole purpose would be to develop and test this driver. i would of course also sign any disclaimers, waivers, etc. which you would require, as long as copyrights to the source code developed there are not transfered from me (the code will remain free and open source, like the should be).</p>
<p>Is there someone out there who could help a brother out? If so, please get in touch (contact info is at <a href="http://wanderinghorse.net/home/stephan/">http://wanderinghorse.net/home/stephan/</a>).</p>
<p>i actually have tried to get Oracle running, but after spending a whole day trying, and never getting past the installer, i gave up. (Oracle for Linux requires truly ancient system libraries which have not been seen on my PCs since about the time of Bill Clinton&#8217;s presidency.)</p>
<p>Thanks once again for reading, and <strong><em>Happy Hacking!</em></strong></p>
<p>&#8212;&#8211; stephan beal</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.s11n.net/?feed=rss2&amp;p=96</wfw:commentRss>
		</item>
		<item>
		<title>New Project: cpdo database abstraction API for C</title>
		<link>http://blog.s11n.net/?p=95</link>
		<comments>http://blog.s11n.net/?p=95#comments</comments>
		<pubDate>Sun, 30 Jan 2011 12:34:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[software-dev]]></category>

		<category><![CDATA[c]]></category>

		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://blog.s11n.net/?p=95</guid>
		<description><![CDATA[Hello, C hackers!
Inspired by a recent project at work, where i had to write a DB abstraction layer for wrapping MySQL and Oracle, i&#8217;ve started a new database abstraction library for C:
http://fossil.wanderinghorse.net/repos/cpdo/
cpdo gets its name from the PHP PDO API, after which it is modeled.
It comes with a driver for sqlite3. Work started on a [...]]]></description>
			<content:encoded><![CDATA[<p>Hello, C hackers!</p>
<p>Inspired by a recent project at work, where i had to write a DB abstraction layer for wrapping MySQL and Oracle, i&#8217;ve started a new database abstraction library for C:</p>
<p><a href="http://fossil.wanderinghorse.net/repos/cpdo/">http://fossil.wanderinghorse.net/repos/cpdo/</a></p>
<p>cpdo gets its name from the <a href="http://php.net/manual/en/book.pdo.php">PHP PDO API</a>, after which it is modeled.</p>
<p>It comes with a driver for <a href="http://www.sqlite.org">sqlite3</a>. Work started on a <a href="http://www.mysql.com">MySQL</a> driver, but their prepared statements API is essentially unusable from such an abstraction layer (as best as i can determine, anyway), so i gave up. (Update: and later got it working - see below.)</p>
<p>The original wrapper (part of a <a href="http://www.op5.org/community/plugin-inventory/op5-projects/merlin">commercially-supported add-on</a> for the <a href="http://www.nagios.org/">Nagios monitoring framework</a>) only needed &#8220;plain SQL&#8221; support, not prepared statements, and thus worked fine with MySQL and Oracle. (We replaced their usage of <a href="http://libdbi.sourceforge.net">libdbi</a> so that they can support Oracle.) With cpdo, i decided to &#8220;implement it properly&#8221; and internally use only prepared statements for all SQL. This, however, this appears to be essentially impossible using the MySQL API, so we&#8217;re left with an abstraction layer which abstracts only sqlite3 for the time being.</p>
<p><strike>If there are any MySQL-loving C gurus out there with too much energy on their hands who would like to help implement the MySQL binding (or for some other database), <a href="http://www.wanderinghorse.net/home/stephan/">please get in touch</a>. i&#8217;ve implemented the driver skeleton and maybe 1/3rd of the code (e.g. connection, disconnection, and the first step of preparing statements), but can&#8217;t proceed because the MySQL prepared statements API is so insane.</strike> <strong><em><span style="color: #3366ff;">Update 2011-Jan-31 @ 00:17:</span> </em></strong>The MySQL driver is now basically working. There&#8217;s more testing to be done, in particular with BLOBs and large string fields, but it appears to work. Thankfully, i found a useful example (most aren&#8217;t!) of how to use the MySQL in the PHP source tree (for their mysqli bindings), and that made all the difference.</p>
<p><strong><em>Happy Hacking!</em></strong></p>
<p>&#8212;&#8211; stephan beal</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.s11n.net/?feed=rss2&amp;p=95</wfw:commentRss>
		</item>
		<item>
		<title>New Project: v8::convert</title>
		<link>http://blog.s11n.net/?p=94</link>
		<comments>http://blog.s11n.net/?p=94#comments</comments>
		<pubDate>Sun, 23 Jan 2011 14:48:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[software-dev]]></category>

		<category><![CDATA[c]]></category>

		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[v8]]></category>

		<guid isPermaLink="false">http://blog.s11n.net/?p=94</guid>
		<description><![CDATA[Hello, fellow v8 hackers,
(If you have no idea what a &#8220;v8 hacker&#8221; is then this post will mean nothing to you.)
i would like to announce a new v8-based project&#8230;
 v8::convert is a header-only utility library for Google v8 with a very small focus:

Converting between v8 and native values, including client-defined types.
Converting C/C++ functions/methods to v8::InvocationCallback implementations.

With  [...]]]></description>
			<content:encoded><![CDATA[<p>Hello, fellow v8 hackers,</p>
<p>(If you have no idea what a &#8220;v8 hacker&#8221; is then this post will mean nothing to you.)</p>
<p>i would like to announce a new <a title="Google v8 home page" href="http://code.google.com/p/v8">v8-based</a> project&#8230;</p>
<p><a href="http://code.google.com/p/v8-juice/wiki/V8Convert"> v8::convert</a> is a header-only utility library for <a title="Google v8 home page" href="http://code.google.com/p/v8">Google v8</a> with a very small focus:</p>
<ul>
<li>Converting between v8 and native values, including client-defined types.</li>
<li>Converting C/C++ functions/methods to v8::InvocationCallback implementations.</li>
</ul>
<p>With  those two features we have almost everything we need for most  class-binding purposes. The the ability to convert functions to have  v8::InvocationCallback signatures has proven especially useful, and  allows us to plug in in many C-standard or 3rd-party APIs with ease.  Conversions are compile-time typesafe where possible and runtime  conversion failures fail gracefully (e.g. by throwing a JS-side  exception).</p>
<p>The core components are in no way project-specific, and can be used in  conjunction with arbitrary other function/class binding mechanisms.  Since the implementation is header-only, it&#8217;s particularly easy to  include into other projects.</p>
<p>The API is trivial to use. The client API contains a good number of  classes and functions, but most client code needs only one or m/ore of  the 5 main function templates: CastToJS(), CastFromJS(),  FunctionToInvocationCallback(), MethodToInvocationCallback(), and  ConstMethodToInvocationCallback().</p>
<p>The missing parts are:</p>
<p>- Binding JS accessors to native values/functions. i have the code in v8-juice but need to port it to this API&#8217;s conventions.<br />
- A class binding mechanism which takes care of the WeakPointer bits.  There is such a mechanism in v8::convert, but it is not considered a  core component because hackers tend to each have their own favourite  class binding mechanism.</p>
<p>The code is largely a spin-off of the core-most <a title="v8-juice home page" href="http://code.google.com/p/v8-juice/">v8-juice</a> components,  but the function-binding parts were re-implemented from scratch so that  we can use function-pointer-style template parameters (which, IMO, are  more readable than the v8-juice&#8217;s approach). Additionally, instead of  inheriting v8-juice&#8217;s huge collection of weirdly-named function-binding  templates, clients now need only 3 templates to bind functions (one each  for free functions, const- and non-const member functions).</p>
<p>The idea of doing a header-only spin-off has been brewing for some  time, but i was recently inspired to finally do the work by two other  <a title="v8-users" href="http://groups.google.com/group/v8-users">v8-users list</a> members:</p>
<p>- James Pike: when i saw how <a title="vu8 home page" href="https://github.com/tsa/vu8">vu8</a> takes advantage of  function-pointer-style template parameters, i just <em>had</em> to have that  feature for myself.</p>
<p>- Fuzzy Spoon: the separation of const- and non-const member handling  was prompted by Fuzzy&#8217;s report about MSVC not being able to select the  proper template specializations when the the member functions differ  only in constness.</p>
<p>v8::convert is only about 3 nights old, but already has at least as much API documentation as v8 itself.  There is an overview and example code here:</p>
<p><a href="http://code.google.com/p/v8-juice/wiki/V8Convert" target="_blank">http://code.google.com/p/v8-juice/wiki/V8Convert</a></p>
<p>The source code is at:</p>
<p><a href="http://code.google.com/p/v8-juice/source/browse/#svn/convert" target="_blank">http://code.google.com/p/v8-juice/source/browse/#svn/convert</a></p>
<p>It includes a standalone demo application and a demo v8-juice plugin.</p>
<p><strong><em>Happy Hacking!</em></strong><br />
&#8212;&#8211; stephan beal</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.s11n.net/?feed=rss2&amp;p=94</wfw:commentRss>
		</item>
		<item>
		<title>Tip: Code Commenting</title>
		<link>http://blog.s11n.net/?p=92</link>
		<comments>http://blog.s11n.net/?p=92#comments</comments>
		<pubDate>Tue, 14 Dec 2010 18:47:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[software-dev]]></category>

		<guid isPermaLink="false">http://blog.s11n.net/?p=92</guid>
		<description><![CDATA[Hello, fellow hackers!
We&#8217;re all aware of the &#8220;dangers&#8221; of adding comments to implementation code, such as:
int x = 32; // default value was decided by committee...
In practice, comments tend become disassociated from their code, especially when more than one person works on the same code. For example, the following is relatively common in real-world code:
// [...]]]></description>
			<content:encoded><![CDATA[<p>Hello, fellow hackers!</p>
<p>We&#8217;re all aware of the &#8220;dangers&#8221; of adding comments to implementation code, such as:</p>
<pre>int x = 32; // default value was decided by committee...</pre>
<p>In practice, comments tend become disassociated from their code, especially when more than one person works on the same code. For example, the following is relatively common in real-world code:</p>
<pre>// default value was decided by committee...
int y = 7;
int x = 32;</pre>
<p>With that change, we&#8217;re not really sure which default value the comment is referring to.</p>
<p>Recently i stumbled across a commenting approach which has helped me avoid this type of problem:</p>
<pre>int x = 32 /*default value was ...*/;</pre>
<p>Note that the comment is inside the statement, before the semicolon. The side-effect of that is that coders who edit that line are much more likely to have to deal with the comment. For longer comments, it helps to split up the lines:</p>
<pre>int x = 32
  /* default value was ...
     on 20101214 ... by ....
   */
;</pre>
<p>Again, the comment is inserted as part of the statement. If someone wants to move that line, they&#8217;ll be forced to acknowledge that &#8220;something unusual&#8221; is happening, and are likely to read the comment to figure out what&#8217;s standing in their way.</p>
<p>It&#8217;s a simple to apply approach which i&#8217;ve started using in all my code, and i nowadays i recommend it as standard-practice over adding comments in the more conventional forms:</p>
<pre>// before the code:
int x = ...;

int y = ...;
// ^^^^ after the code, with carets meaning "look up to the previous line"

int z = ...; // after the semicolon</pre>
<p><strong><em>Happy Hacking!</em></strong></p>
<p>&#8212;- stephan beal</p>
<p>PS: there are people out there who despise any form of comments, and i was once told (on a popular open source project) that having comments in my code contributions made an &#8220;unprofessional&#8221; impression. You may disagree that comments are useful/necessary/whatever in code, and that&#8217;s fine. Let&#8217;s just agree to disagree.</p>
<p>Update on 2010.12.20: some of you will simply laugh and say, &#8220;my programming language of choice doesn&#8217;t use semicolons&#8221; or &#8220;my programming language uses semicolons as comment markers!&#8221; To you i say, &#8220;how sad!&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.s11n.net/?feed=rss2&amp;p=92</wfw:commentRss>
		</item>
		<item>
		<title>New Article: Doing OO in C</title>
		<link>http://blog.s11n.net/?p=91</link>
		<comments>http://blog.s11n.net/?p=91#comments</comments>
		<pubDate>Fri, 10 Dec 2010 18:09:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[StrangerThanFiction]]></category>

		<category><![CDATA[software-dev]]></category>

		<category><![CDATA[c]]></category>

		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://blog.s11n.net/?p=91</guid>
		<description><![CDATA[Good evening, fellow hackers!
While i tend to write absurd amounts of technical documentation,  mostly in the form of API docs and other code documentation, it&#8217;s been  several years since i&#8217;ve published a technical article.
For those 5 or 6 remaining aspiring C programmers in the world, i&#8217;ve  got a new article which demonstrates [...]]]></description>
			<content:encoded><![CDATA[<p>Good evening, fellow hackers!</p>
<p>While i tend to write absurd amounts of technical documentation,  mostly in the form of API docs and other code documentation, it&#8217;s been  several years since i&#8217;ve published a technical <em>article</em>.</p>
<p>For those 5 or 6 remaining aspiring C programmers in the world, i&#8217;ve  got a new article which demonstrates a useful 999(shit, my left shift  key just quit working&#8230;)&#8230; ahem&#8230; demonstrates a useful (in my  opinion) model for implementing object-oriented data structures and APIs  in C. DAMMIT, AND NOW MY ENTER KEY BROKE!</p>
<p>(thank god for the numeric pad&#8217;s enter key&#8230;)</p>
<p>Since my keyboard just died, i&#8217;ll keep this short&#8230; the article is here:</p>
<p><a title="Doing OO in C" href="http://wanderinghorse.net/computing/papers/#oo_c">http://wanderinghorse.net/computing/papers/</a></p>
<p><em><strong>happy hacking1</strong></em></p>
<p>9you never truly appreciate the left shift key until it&#8217;s gone&#8230;0</p>
<p>&#8212;&#8211; stephan beal</p>
<p>Update:</p>
<p>LOL! (i&#8217;ve now got my backup keyboard&#8230;) At the very same time my keyboard broke i began being affected by this new Google Chrome bug:</p>
<p><a href="http://code.google.com/p/chromium/issues/detail?id=66071">http://code.google.com/p/chromium/issues/detail?id=66071</a></p>
<p>(Short version: mouse wheel cannot scroll up, but can scroll down.)</p>
<p>i thought, because my keyboard and mouse (in Chrome, anyway) weren&#8217;t working, that maybe my USB bus was dying.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.s11n.net/?feed=rss2&amp;p=91</wfw:commentRss>
		</item>
		<item>
		<title>On-storage Hashtable in C</title>
		<link>http://blog.s11n.net/?p=89</link>
		<comments>http://blog.s11n.net/?p=89#comments</comments>
		<pubDate>Sun, 05 Dec 2010 13:14:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[software-dev]]></category>

		<category><![CDATA[c]]></category>

		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://blog.s11n.net/?p=89</guid>
		<description><![CDATA[Hello, C hackers! (Everyone else can skip this post!)
For a couple years now i&#8217;ve been maintaining a project called whio, the wanderinghorse.net I/O library for C. In short, it&#8217;s a collection of input/output APIs for working with sequential streams and random-access devices. It allows one to wrap a variety of lower-level I/O APIs (e.g. standard [...]]]></description>
			<content:encoded><![CDATA[<p>Hello, C hackers! (Everyone else can skip this post!)</p>
<p>For a couple years now i&#8217;ve been maintaining a project called <a title="whio home page" href="http://fossil.wanderinghorse.net/repos/whio/">whio</a>, the <a href="http://wanderinghorse.net">wanderinghorse.net</a> I/O library for C. In short, it&#8217;s a collection of input/output APIs for working with sequential streams and random-access devices. It allows one to wrap a variety of lower-level I/O APIs (e.g. standard FILE handles or file descriptors), or implement custom ones, behind a uniform interface. Over the years it has grown to include a good deal of functionality.</p>
<p>i&#8217;ve spent a good deal of time looking for and investigating storage-based hashtables for C over the years (B-trees as well), and have found depressingly few of them (and none which i could drop in and re-use without modification). The few i did find were limited to using C-standard FILE handles as storage, and FILE handles don&#8217;t always suit my I/O needs. The <a title="whio_dev page" href="http://fossil.wanderinghorse.net/repos/whio/index.cgi/wiki/whio_dev">whio_dev</a> API has several different device implementations, not just for files, and i wanted a hashtable with that flexibility. So of course i had to write one myself ;).</p>
<p>A few days ago i added a new API to whio, called <a title="whio_ht page" href="http://fossil.wanderinghorse.net/repos/whio/index.cgi/wiki/whio_ht">whio_ht</a>, which is an on-storage hashtable.</p>
<p>A very brief summary of its properties:</p>
<ul>
<li>Insertion, searching, and removal are all <a title="WTF does O(1) mean?" href="http://en.wikipedia.org/wiki/Time_complexity#Constant_time">amortized O(1)</a>. This means that the time it takes to insert, search for, and remove records is essentially independent of the number of records in the hashtable.</li>
<li>Constant memory usage of <em>less than 500 bytes</em>. (There is one exceptional case involving &#8220;really long&#8221; keys, but it is not expected to that most clients will fall into that category.)</li>
<li>Can use any storage back-end for which we have a <a title="whio_dev page" href="http://fossil.wanderinghorse.net/repos/whio/index.cgi/wiki/whio_dev">whio_dev</a> implementation. e.g. it can be used with a memory buffer device or embedded as a pseudofile within a <a href="http://fossil.wanderinghorse.net/repos/whio/index.cgi/wiki/whio_epfs">whio_epfs</a> container.</li>
<li>Data file format is platform-neutral. Encoding of keys/values, if necessary, is left to the client.</li>
<li>Supports arbitrary key types, provided the user can supply hashing and comparison functions for them. The library includes routines for hashing/comparing strings and the standard fixed-sized integer types (from <tt>stdint.h</tt>).</li>
</ul>
<p>If you&#8217;re <em>still</em> looking for a storage-based hashtable API in C, <a title="whio_ht page" href="http://fossil.wanderinghorse.net/repos/whio/index.cgi/wiki/whio_ht">whio_ht</a> might just be of interest to you.</p>
<p><strong><em>Happy Hacking!</em></strong></p>
<p>&#8212;&#8211; stephan beal</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.s11n.net/?feed=rss2&amp;p=89</wfw:commentRss>
		</item>
		<item>
		<title>s11n for JSON</title>
		<link>http://blog.s11n.net/?p=88</link>
		<comments>http://blog.s11n.net/?p=88#comments</comments>
		<pubDate>Thu, 25 Nov 2010 14:18:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[libs11n]]></category>

		<category><![CDATA[software-dev]]></category>

		<guid isPermaLink="false">http://blog.s11n.net/?p=88</guid>
		<description><![CDATA[Hello, fans of C++ and JSON! (Everyone else can stop reading here.)
Recently i started another pet project, the nosjob library, which is a C++ library for creating and consuming JSON data. It provides a set of JSON-specified value types, like String, Boolean, Object, and Array, which can be combined to create data structures of near-arbitrary [...]]]></description>
			<content:encoded><![CDATA[<p>Hello, fans of C++ and JSON! (Everyone else can stop reading here.)</p>
<p>Recently i started another pet project, the <a title="nosjob home page" href="http://fossil.wanderinghorse.net/repos/nosjob/">nosjob</a> library, which is a C++ library for creating and consuming <a title="JSON home page" href="http://www.json.org">JSON</a> data. It provides a set of JSON-specified value types, like String, Boolean, Object, and Array, which can be combined to create data structures of near-arbitrary complexity. The library can output such structures to JSON form and parse such structures from JSON input.</p>
<p>One particularly interesting aspect of it is that it contains a bare-bones variant of <a title="s11n home page" href="http://s11n.net">libs11n</a> with which it can de/serialize near-arbitrary client types from/to JSON.</p>
<p>For example, in its simplest form:</p>
<pre>std::map&lt;int,double&gt; map;
for( int i = 0; i &lt; 5; ++i ) {
    map[i] = i * 1.1;
}
nosjob::s11n::save( map, std::cout );</pre>
<p>(Strangely enough, a std::map actually serializes to a JSON <em>Array</em>, instead of a JSON <em>Object</em>, in order to be able to support map keys of arbitrary type (JSON Object keys are always <em>strings</em>).)</p>
<p>More detailed examples can be found <a title="nosjob s11n page" href="http://fossil.wanderinghorse.net/repos/nosjob/index.cgi/wiki/s11n">here</a>.</p>
<p>Like libs11n, it uses a two-step serialization process: first serialize the &#8220;client data&#8221; to a JSON-compatible data structure, then format that JSON data structure to a given output stream (or output iterator). For deserialization, it it parses JSON input (from a stream or input iterator), builds up a tree of JSON-like value objects, and then feeds that data to the client-defined deserialization routine for final processing. The client provides a pair of conversion functors for converting their type to/from JSON-compatible form, and nosjob does the rest.</p>
<p>The serialization support does not rival libs11n&#8217;s in terms of flexibility and features, but it&#8217;s not supposed to.</p>
<p>If you&#8217;re (still) looking for easy-to-use JSON support for your C++ application, then <a title="nosjob home page" href="http://fossil.wanderinghorse.net/repos/nosjob/">nosjob</a> might be interesting for you.</p>
<p><strong><em>Happy Hacking!</em></strong><br />
<strong><em> Bob Ross is The Man!</em></strong></p>
<p>&#8212;&#8211; stephan</p>
<p>PS: one might ask why not simply build this support into libs11n? By the time the nosjob code got to a point where i could add an s11n API for it, the effort and architectural overhead of including it into libs11n seemed too high. There are also disparities in the libs11n and JSON data models which would be awkward to consolidate (e.g. in s11n key/value pairs are only used for basic data types, where JSON allows keys to reference arbitrary other data types). Adding the s11n-like API to the library was a trivial, straightforward task, however: less than 50 lines of code, not including the built-in JSON-to/from-Native conversions which the nosjob::s11n bits use as the default de/serialization implementations (i had already written them for other reasons, which is why they don&#8217;t count as &#8220;effort&#8221; for this purpose).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.s11n.net/?feed=rss2&amp;p=88</wfw:commentRss>
		</item>
	</channel>
</rss>
