Tag: c++

Wrapping C++ objects in C

Introduction Using C functions from C++ is very easy but going the other way isn’t. However, it can be done with a little ingenuity. Really, this isn’t as crazy as it sounds. I’ll use a simple adder for the object. It takes an integer as a starting value and... Continue reading

s2n Memory Hardening Analysis

Recently Amazon.com introduced s2n as a new TLS implementation. The idea is to have a small and simplified TLS library. Looking at it I noticed it’s very Linux centric. It cannot be compiled on Windows. There are patches to make it work on OS X. There is a report that... Continue reading

Effective Threading Using Qt

Effective Threading Using Qt Introduction Over the years using Qt I’ve seen a lot of difficulty using threads with Qt. Threads can be difficult and Qt provides a lot of ways to make threads easy to work with. Still basic / direct / low level threading (I’ll just call... Continue reading

Extending an Application with Lua Plugins

Introduction A very common use of the Lua language (which is a very versatile) is using Lua to extend an application via plugins. Many popular games use Lua for this very purpose. Adding a plugin framework to an existing application is trivial with Lua. Also, Lua provides a very... Continue reading

Calling Functions in EXE From Plugins in Windows

When writing an application that uses plugins sometimes it’s necessary to have the plugin call functions from the application. This is fairly easy to do on pretty much any OS but on Windows it requires the plugin to link to the application. Sometimes explicit linking is unreasonable. One situation where... Continue reading

Wrapping a C library in COM/ActiveX

Introduction Not very long ago my boss walked up to my desk, put a pile of books down beside me and said “Not it”. The books were all related to COM programming. The project he gave me was to create a COM wrapper for an existing C library we... Continue reading

Retrieve Formatting Set by QSyntaxHighlighter

I have been working on adding inline spell check to Sigil recently and ran into a quirk on Qt that isn’t immediately obvious. I ended up having to look though the Qt source code to understand exactly what was happening. When dealing with a QPlainTextEdit you can get the QTextCursor... Continue reading

lebookread 0.2

I’ve made a new release of lebookread. This version supports the following formats: palmdoc, ztxt, epub, tcr, rb, mobi, and fb2. The library is usable but still needs a lot of work. Unit testing, examples, more code comments and more formats to name a few things. Continue reading

Qt Remove Directory and Its Contents

When dealing with directories, Qt has a large number of functions to make manipulating them easy. However, it does not include a way to delete a non-empty directory. This little omission is easily solved. Following is a recursive function that will delete a directory along with all of it’s contents.... Continue reading

C++ Derived Classes and Object Destruction

While working on lebookread I realized that the the destructor for my reader classes would never be called. lebook read has a base class (FormatReader) that exports all of the necessary functionality for use by applications using the library. All of the readers are a subclass of FormatReader. The library... Continue reading


I have been taking a short break from blogging again. The pressure at work has only increased and is eating into a lot of my time. I haven’t been motivated to work on personal projects because well they are work. However, this has recently changed a bit. I’ve started a... Continue reading

Sending WM_DELETE_WINDOW client messages

In my X11 Intercept Window Close Event post I left out one very important piece of information. How to actually close the embedded window after intercepting the WM_DELETE_WINDOW message. The best thing to do is send our own WM_DELETE_WINDOW message to the embedded window. This will keep the embedded... Continue reading

X11 Intercept Window Close Event

Note Nov, 8 2009: a few additions have been made to the code samples to make them more complete. Specifically subscribing to X11 events. A feature request for KDocker was made a few days ago for docking when closed. Basically the person wants the window to iconify when the... Continue reading

KDocker 4.2 released

This release includes bug fixes as usual. Some new features: bash completion, iconify on focus lost option and Italian translation thanks to Alessio Cassibba. There is also a small change to the behavior when activating the tray icon. If the window is not visible it will become active and if... Continue reading

KDocker 4.0

Recently I’ve become the maintainer of the KDocker project. KDocker is a Qt application what allows you dock any application into the system tray. It currently supports any X Windows system. What I’ve done for the 4.0 release is, move the project to launchpad (Girish, the creator of the project... Continue reading

eBook Adding Empty Lines At End of File

Continuing my work to clean up my eBooks I’ve written another little tool to help. I like for my eBooks to have two blank lines at the end of the file. The only major caveat of this one is it assumes Unix end of lines. Meaning a single n character.... Continue reading

eBook Paragraph Formating

Today I wrote two simple programs to help me clean up my ebooks. I prefer to keep my ebook collection as plain text files with paragraphs separated by a blank line. The first program reflows the paragraphs to put each on a single line. The second removes extraneous whitespace from... Continue reading