Posts

Test Anything Protocol (TAP) with autotools and cmocka

Image
Autotoole can handle test suits of several types. Usually, I store my tests in "test" directory in the root of the project and set up each test in "Makefile.am" file. Each test to run is a separate executable file listed in "TEST" variable in makefile. For example: TESTS = foo_test bar_test xyz_test

OpenSIPS command line tricks

OpenSIPS provides powerful and flexible tool called "opensipsctl". Here I put some useful commands I am using while working with OpenSIPS to: restart phone, change MWI, change presence, remote dial with REFER.

Mongoose - small, fast and simply awesome network library

Recently, I have been looking for a C library which can provide handy API for web-socket protocol. While searching the Web for "websocket" I have found many popular and good libraries, but just when I was going to give a try one of them, I have suddenly saw the link to "mongoose" library. After reading some documentation and introduction , I had a feeling that this is exactly what I am looking for! Mongoose developers describe their library as a "embedded web server" and as a "multi-protocol network library". Web-socket is only the part of its functionality, there are several other protocols as well as pure TCP/UDP communication functions that can help to implement any other protocol you wish. Basically, all that you need to start developing with mongoose can be found in the brief documentation page or on the  github repository . It is amazingly easy to use! Just put files "mongoose.c" and "mongoose.h" in you project and ...

Using Ragel to implement TFTP protocol client

Image
This blog is about how to implement TFTP protocol (RFC1350) with ragel. Ragel is a very powerful State Machine compiler, perfect for text parsing. One of the tasks where ragel can be used for is "Writing robust protocol implementations". More detailed information about ragel can be found here:  http://www.colm.net/open-source/ragel . Indeed, there are projects which successfully use ragel to parse network protocol packets: Mongrel , the web-server developed by Zed Shaw. Mongrel and its derivatives (like Thin) are using ragel to parse HTTP protocol. OverSIP , SIP proxy developed by IƱaki Baz Castillo and using ragel to parse SIP protocol. Both HTTP and SIP are text based protocols. There are many articles and blogs that explain how to parse text with ragel. TFTP is a bit different and I thought it would be fun to try implement this protocol with ragel.

C project IDE and skeleton [part 2]: vim, autotools, ctags, cmocka, lcov, dejagnu, apr, doxygen, git, guard

Image
This is second part. The first part is here . After setting up my development environment I am starting with writing tests. I do prefer TDD way and usually the process RED-GREEN-REFACTORING takes many changes during development as TDD allows to improve and optimize code any time (refactoring). But here I will put just final version of the code. The final version can be found on my github repo . Before starting, I run "guard" command in the console to let this amazing utility run all commands for my.

URL parser ruby C extension binding with C library re2c lexer

This is step-by-step description how to create Ruby C extension using static library. Creating Ruby extensions is not a complicated task. There are plenty of tutorials and articles. Also Ruby API is clean and well described. For me, an interesting task was to create a Ruby project using external library included in the project within git repository. Lets imaging we want to create Ruby library for parsing text. Lets say, URL. Of course, there is standard Ruby library (URI), and it is ruby code. But if we want something faster,  it is good idea to use C extension.

Boolean types using function pointers

There are many ways to use Boolean  date types in C. C99 standard library <stdbool.h> or many others, one just need to "google". While reading book "Understanding and Using C Pointers" it came to my mind that another way to define Boolean type is C pointers. Something like this: typedef void (*bool)(); void true() {} void false(){} To use it we can simply do that: bool is_correct; is_correct = false; Here is a working example: