Hex Encode and Decode in C

Introduction A very common task when working with binary data in C is, converting it to and from Hex. It’s unfortunate that C doesn’t provide a standard function that can take care of this for us. However, it’s pretty easy to implement a set of functions to handle it. Hex encoding is always twice the […]

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 has two functions for adding and […]

JNI is (Not) Your Friend

Introduction So far we’ve scratched the surface of using JNI when we looked at wrapping a C library and Calling Java from C. Now we’re going to look into some more complex uses. Java Class Since we’re working with JNI, we’ll need a Java class to use what we’re going to expose from C. DemoFuncs.java […]

Calling Java From C

Introduction Obviously, JNI lets you call Java functions and use Java classes in C. Typical a Java app is the one calling into C. Now Let’s say you don’t have a Java app that kicks off the process but you want your C app to still use some Java code. Okay, I know what you’re […]

Wrapping a C library in Java

Introduction It can’t be argued that Java is popular and successful. It is consistently the number one language on TIOBE’s popularity list, above C which comes in as number two. This ranking is based on popularity and doesn’t mean Java is more used than C but that doesn’t change the fact that there is a […]

Lua Template Engine Revisited

Introduction A while ago I wrote a template engine in Lua. This engine was fairly basic and I wrote it for work as a proof of concept. It was meant as a way to see this was a viable solution. After moving forward with the project I found that the engine was usable but it […]

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 capable and easy to use language […]

Using Lua as a Templating Engine

Introduction There are a lot of templating engines to choose from. The vast majority of which are primarily geared toward the web. Meaning they’re specially designed for outputting HTML/XML documents. Lua provides more flexibility and can easily be used as a general templating engine. Also, Lua is very easy to embed and use from a […]

Wrapping a Lua module in C

Introduction So far I’ve covered wrapping a C library in Lua, writing a Lua module, and calling Lua from C. The next step is using this knowledge to wrap a Lua module in C. Basically, the opposite of wrapping a C library in Lua for use in Lua. In this case we want the library […]

Calling Lua From C

Introduction One very useful feature of Lua is how easy it is to work with from C. Unlike other scripting languages Lua’s C support goes to and from. Meaning you not only can call C from Lua but you can call Lua from C. Often you’ll see applications written in a high level language with […]