Skip to content

AndreLouisCaron/cnetstring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cnetstring: Streaming netstring parser for C

Authors: André Caron
Contact: [email protected]

Description

This library provides a parser for netstrings. The parser is implemented as a finite state machine (FSM) for use in streaming applications (i.e. data arrives at an unpredictable rate and the parser must be interruptible). As such, the parser itself does not buffer any received data. It just forwards it to registered callbacks. It requires little overhead and is well suited for being used in an object-oriented wrapper.

Known uses

The parser is used in the cscgi project to parse the SCGI request headers.

Getting started

The library is currently only distributed in source form. However, it has no dependencies on external projects and will compile as-is with almost any C compiler.

The following presents the supported way to get up and running with cnetstring. Feel free to experiment with your toolchain of choice.

Requirements

Dependencies are:

  1. Git
  2. CMake
  3. Doxygen
  4. A C++ compiler toolchain:
    • Microsoft Visual Studio
    • g++ and make

Standalone build

  1. Get the source code.

    > git clone git://github.com/AndreLouisCaron/cnetstring.git
    > cd cnetstring
    

    Feel free to check out a specific version

    > git tag
    v0.1
    
    > git checkout v0.1
    
  2. Generate the build scripts.

    > mkdir work
    > cd work
    > cmake -G "NMake Makefiles" ..
    

    The following CMake options are supported:

    1. CNETSTRING_BUILD_CXX: build C++ targets.
    2. CNETSTRING_BUILD_DEMOS: build demo programs.
    3. CNETSTRING_BUILD_TESTS: build test programs.

    All options are set to ON by default in the standalone builds. Options for demos and tests are ignored and forced to OFF when build as a dependency.

    To change these settings, use the CMake -D command line option. For example, to skip compilation of the demo programs, use this command:

    > cmake -G "NMake Makefiles" .. -DCNETSTRING_BUILD_DEMOS=OFF
    
  3. Build the source code.

    > nmake
    
  4. Run the test suite.

    > nmake /A test
    

    If the CNETSTRING_BUILD_TESTS option was set to OFF, this will not run any tests.

  5. Build the API documentation.

    > nmake help
    

    Open the HTML documentation in help/html/index.html.

    If Doxygen is not available, this target is not registered so you cannot build the documentation.

Embedded build

  1. Register as a Git sub-module.

    > cd myproject
    > git submodule add git://github.com/AndreLouisCaron/cnetstring.git libs/cnetstring
    

    Feel free to check out a specific version.

    > cd libs/cnetstring
    > git tag
    v0.1
    
    > git checkout v0.1
    > cd ../..
    > git add libs/cnetstring
    
  2. Add cnetstring targets to your CMake project.

    set(cnetstring_DIR
      ${CMAKE_SOURCE_DIR}/libs/cnetstring
    )
    
  3. Make sure your CMake project can #include <netstring.h>.

    include_directories(
      ${cnetstring_include_dirs}
    )
    
  4. Link against the netstring library.

    target_link_libraries(my-application ${cnetstring_libraries})
    

About

Stream netstring parser for C

Resources

License

Stars

Watchers

Forks

Packages

No packages published