Skip to content
/ rapp Public

RApp is an application container, written in C.

License

Notifications You must be signed in to change notification settings

rugginoso/rapp

Repository files navigation

     (
 )\ )   (
(()/(   )\
 /(_)|(((_)(  `  )  `  )
(_))  )\ _ )\ /(/(  /(/(
| _ \ (_)_\(_|(_)_\((_)_\
|   /  / _ \ | '_ \) '_ \)
|_|_\ /_/ \_\| .__/| .__/
             |_|   |_|

Build Status

Overview

RApp is an application container, written in C. It is focused on performances, targets GNU/Linux only and uses most of its own features like epoll and signalfd.

Status

RApp is still not complete, currently it accepts connections, parses http requests (using joyent's http_parser) and closes connection.

Architecture

Class Diagram

Dependencies

RApp requires a modern (>= 2013, kernel >= 3.8) Linux system to build and run. RApp depends on an handful of external packages:

  • libYAML to handle the configuration.
  • check for the testsuite.

Compile

RApp uses cmake. Once you have cloned this repository and installed cmake run:

    $ git submodule init
    $ git submodule update
    $ mkdir build
    $ cd build
    $ cmake ..
    $ make

Then you can start RApp using:

    $ cd build
    $ ./src/rapp

For run tests:

   $ cmake -DENABLE_TESTS=1 -DCMAKE_BUILD_TYPE=Debug ..
   $ make
   $ make test

To generate test coverage report:

   $ cmake -DENABLE_TESTS=1 -DENABLE_TESTS_COVERAGE=1 -DCMAKE_BUILD_TYPE=Debug ..
   $ make
   $ make coverage
   $ open coverage/index.html

Coding Style

Indentation

2 spaces new line at the end of file.

Functions

In function declaration, the parameters can be in the same line of the function name:

    int foo(struct Bar *object, int value, void *data);

But in function implementation, the return value is in its own line as well each parameter:

   int
   foo(struct Bar *object,
       int         value,
       void       *data)
   {
     ...
   }

Note also the alignment of parameters types and names.

Braces

Braces must be at the right of the control structures

    if (fd = open(path, O_RDONLY)) < 0) {
      ...
    }

    for (p = object->items; p != NULL; p = p->next) {
      ...
    }

    while (count) {
      ...
    }

But functions have braches on a new line

    int
    foobar(void)
    {
      ...
    }

Variables

Variables must have descriptive names, short names are allowed only for automatic variables used in loops.

Variables must be defined and initialized at the start of the function:

    int
    foobar(void)
    {
      int fd = -1;
      char *name = NULL;
      struct SomeObject *some_object = NULL;
      ...
    }

Assertions

Use assert conditions on all function parameters on which makes sense. Assert expecially pointers values. Assertions on parameters are placed after variables declaaration.

   int
   foobar(struct SomeObject *object,
          char              *name)
   {
     int foo = 0;

     assert(object != NULL);
     assert(name != NULL);
     ...
   }

Objects

RApp uses an OOP approach. Each object must have its own header and implemwntation files, which must be named as the object they are defining.

Use opaque structures for private data.

Methods must be named _, taking as the first parameter on instance.

Each object must define an _new method, returning an instance, and a _destroy method, returning void and taking an instance as the only parameter.

   struct SomeObject;

   struct SomeObject *some_object_new(void);
   void some_object_destroy(struct SomeObject *some_object);

   void some_object_do_action(struct SomeObject *some_object, int foo);

Includes

Includes should be grouped by scope, divided by one empty line. System includes must come first, applications ones after.

   #include <stdlib.h>
   #include <string.h>

   #include <sys/types.h>
   #include <sys/stat.h>

   #include "someotherobject.h"
   #include "someobject.h"

License

RApp is realeased under the GPLv2.

About

RApp is an application container, written in C.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages