WAFer is a C language-based software platform for scalable server-side and networking applications. Think node.js for C programmers.

Related tags

Utilities WAFer
Overview

Build Status

WAFer

WAFer is a C language-based ultra-light scalable server-side web applications framework. Think node.js for C programmers. Because it's written in C for the C eco system, WAFer is wafer-thins with a memory footprint that is only a fraction of that of node.js and other bulky frameworks.

Just copy server.c (say, as myserver.c), put your code inside the function void server(Request request) in myserver.c and, make with make SERVER=myserver, and you are good to go.

WAFer can operate in many different configurations, all selected at compile time. They include:

  1. Single-threaded (Default) or multi-threaded (make with THREADS=n where n>0)

  2. Select(Default) or epoll (make with LOOP=epoll) based event loop

  3. C10K mode (make with LOOP=epoll MAX_CON_CONS=n where n>10,000)

Default port is 4242. Set environment variable 'PORT' to change it.

That's really it. The source comes with a simple example example.c to get you started.

Note to Contributors

Thank you for making this a wonderful project!

Here's our preferred formatting style:

find . \( -name '*.c' -o -name '*.h' \) -exec indent --no-tabs  --linux-style --line-length 90 --indent-level 4 -bli0 \{\} \;

Acknowledgements

  1. J. David Blackstone and Feng Shen, whose web servers have been repurposed to build this platform.

  2. Mark Karpeles for the incredible number of bug fixes!

  3. Fine folks at /r/programming for the honest and constructive feedback.

Comments
  • Who needs a web framework written under GPL terms anyway

    Who needs a web framework written under GPL terms anyway

    Writing web applications in C is a great idea. Still, people who want to write their own app using C can't legally do it without opening their sources. That's because you distribute it under GPL terms as a set of source files which should be extended by users to get their functionality:

    2. You may modify your copy or copies of the Program or any portion
    of it, thus forming a work based on the Program, and copy and
    distribute such modifications or work under the terms of Section 1
    above, provided that you also meet all of these conditions:
    
        a) You must cause the modified files to carry prominent notices
        stating that you changed the files and the date of any change.
    
        b) You must cause any work that you distribute or publish, that in
        whole or in part contains or is derived from the Program or any
        part thereof, to be licensed as a whole at no charge to all third
        parties under the terms of this License.
    
        c) If the modified program normally reads commands interactively
        when run, you must cause it, when started running for such
        interactive use in the most ordinary way, to print or display an
        announcement including an appropriate copyright notice and a
        notice that there is no warranty (or else, saying that you provide
        a warranty) and that users may redistribute the program under
        these conditions, and telling the user how to view a copy of this
        License.  (Exception: if the Program itself is interactive but
        does not normally print such an announcement, your work based 
    

    It would be more appropriate to license it under dual MIT/GPL license so people could use your framework without opening the application source code.

    opened by yanalunaterra 5
  • Is there a standard function to handle 404?

    Is there a standard function to handle 404?

    an alternative solution might be

    void server(Request request)
    {
        int is_404 = 0;
        is_404 |= nope_route(request, "/factor", &factor, true);
        is_404 |= something else...
        if(!is_404)
        {
            handler_404(request);
        }
    }
    
    void handler_404(Request request)
    {
        not_found(request.client);
    }
    
    opened by ly0 2
  • resolve memory leak due to duplicating strings

    resolve memory leak due to duplicating strings

    resolve memory leak due to duplicating strings and not freeing them.

    Also replaced dupstr() with strdup()

    Actually using a static buffer in the calling function would probably be even better

    opened by MagicalTux 2
  • Private caching, POST content data, source file directory

    Private caching, POST content data, source file directory

    This pull request actually implements several different changes I made.

    The first, and simplest, is moving the source code files and headers into the src/ directory and object files into the obj/ directory.

    The second allows to parse data from the POST requests as the request's "contentData".

    The last one implements caching and Last-Modified header support for the serveFile() function.

    If accepting such a pull request is too difficult, I may split it into several if so necessary.

    opened by usrshare 1
  • Fix double close bug when using serveFile api

    Fix double close bug when using serveFile api

    Wrote a small service to serve static content using this method. Closing the write handle here leads to double close bugs later on. It's unnecessary given the wrapping framework.

    opened by wulfen 1
  • Integer overflow in array allocations

    Integer overflow in array allocations

    malloc(n * size) is an antipattern as n * size can overflow (especially from an attacker). You'll want to use calloc or create your own malloc_array function. Something like the following could work:

    static inline void * malloc_array(size_t nmemb, size_t size)
    {
        /* Make the check so that a constant size deletes the zero check
         * and the division.
         */
        if (size != 0u && SIZE_MAX / size < nmemb) {
            errno = ENOMEM;
            return NULL;
        }
    
        return malloc(size * nmemb);
    }
    
    opened by mstewartgallus 1
  • Method to set response Mimetype

    Method to set response Mimetype

    Perhaps not an issue, may be my short sightedness. Is there any way to set the mimetype of the response. I would like to use nope.c to produce small rest servers serving simple dynamic json. i would like to be able to set response mimetype as "application/json", based on the response.

    opened by thawkins 1
  • improved makefile, fixed some warnings and removed linking on pthread (unused)

    improved makefile, fixed some warnings and removed linking on pthread (unused)

    Made makefile look slightly better, building nope.c as a static library (libnope.a), and added the ability to have multiple samples (variable "MODULES" in the makefile) compiled. Additionally if you develop your own module (ex. foobar.c) in nope.c's main directory, you can then type "make foobar" to get your source compiled against nope.c.

    Also removed -pthread parameter since only fork() is being used (ie. no threads right now).

    Finally fixed some warnings in nope.c and nopeutils.c

    opened by MagicalTux 1
  • Completion of error handling

    Completion of error handling

    opened by elfring 0
  • README needs info on size of WAFer

    README needs info on size of WAFer

    WAFer is: ultra-light ... wafer-thin

    Can you be more specific in the README? We would like to see approximate LOC, size in memory, size on disk. (compared with node.js etc.)

    opened by ahazred8 0
  • Some clean up

    Some clean up

    notify_parent() is not used in your curent version and timespec is not used too. Could you clean this up? The way you called getnameinfo without checking its failure mode is a bit confusing to me.

    opened by janus 0
  • AF-Unix

    AF-Unix

    I was a bit confused while going through your code particularly when I noticed that socket used "AF-Unix" . Why using it? I also noticed that now you have epoll, thread, and select. I fcntl and thread, but what do you again with epoll

    opened by janus 1
  • Load Test Failed

    Load Test Failed

    I carried out a load test for nope example.

    ./wrk -t1 -c1 -d10s http://localhost:4242/factor
    

    The config is: NOPE_EPOLL, NOPE_THREAD 2 The bug looks like this:

    GET /factorGET /factorGET /factorGET /factorGET /factorGET /factorGET /factorGET /factorGET .... /factorGET /factorGEclose: Bad file descriptor
    
    opened by truongminh 3
Releases(v0.0.4-alpha)
  • v0.0.4-alpha(Aug 15, 2014)

Owner
Riolet Corporation
Riolet Corporation
Applications based on Wi-Fi CSI (Channel state information), such as indoor positioning, human detection

ESP-CSI The main purpose of this project is to show the use of ESP-WIFI-CSI. The human body detection algorithm is still being optimized. You can get

Espressif Systems 301 Nov 20, 2022
The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.

The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.

Microsoft 7.1k Nov 21, 2022
SMACK Software Verifier and Verification Toolchain

SMACK is both a modular software verification toolchain and a self-contained software verifier. It can be used to verify the assertions in its input p

null 391 Nov 27, 2022
A cross-platform OpenXR capabilities explorer and runtime switcher with a CLI and GUI.

OpenXR Explorer OpenXR Explorer is a handy debug tool for OpenXR developers. It allows for easy switching between OpenXR runtimes, shows lists of the

Nick Klingensmith 150 Nov 24, 2022
Simple Virtual Machine with its own Bytecode and Assembly language.

BM Simple Virtual Machine with its own Bytecode and Assembly language. Build We are using nobuild build system which requires a bootstrapping step wit

Tsoding 84 Nov 13, 2022
A tiny programming language that transpiles to C, C++, Java, TypeScript, Python, C#, Swift, Lua and WebAssembly 🚀

A tiny programming language that transpiles to C, C++, Java, TypeScript, Python, C#, Swift, Lua and WebAssembly ??

Lingdong Huang 576 Nov 23, 2022
My collection of raylib code examples - For learning the C language with 2D and 3D games.

Raylib-Examples My collection of raylib examples. ( https://www.raylib.com/index.html ) For Raylib Version of 4 april 2020 ( Notepad++ windows install

Rudy Boudewijn van Etten 48 Sep 8, 2022
C-code generator for docopt language.

C-code generator for docopt language Note, at this point the code generator handles only options (positional arguments, commands and pattern matching

null 310 Nov 10, 2022
Open Data Description Language

Open Data Description Language This is the reference parser for the Open Data Description Language (OpenDDL), version 3.0. The official language speci

Eric Lengyel 41 Nov 8, 2022
C language utility library

versatile and easy to use C language utility library with functions and macros commonly used in various applications

Tilen Majerle 41 Nov 8, 2022
Statically typed programming language.

Summary Luxury is a statically programming langage which is targeting embedded programming. I will eventually stop using C and fully use this language

null 39 Oct 5, 2022
A interpreter that runs the script which is programmed in the language of FF0 script (or you can call it as Warfarin)

ff0-script A interpreter that runs the script which is programmed in the language of FF0 script (or you can call it as Warfarin) You can do it, unders

null 24 Apr 27, 2022
An implementation of yacc for the janet programming language.

janet-yacc An implementation of yacc for the janet programming language. The implementation is based heavily on https://c9x.me/yacc/. Example from ./e

null 11 Nov 22, 2021
Whitee is a tiny compiler written in C++17, which translates SysY language into ARM-v7a assembly.

Whitee is a tiny compiler written in C++17, which translates SysY language into ARM-v7a assembly. Table of Contents Background Install Usage Ar

null 13 Sep 21, 2022
A cross platform C99 library to get cpu features at runtime.

cpu_features A cross-platform C library to retrieve CPU features (such as available instructions) at runtime. Table of Contents Design Rationale Code

Google 2.1k Nov 19, 2022
A cross-platform protocol library to communicate with iOS devices

libimobiledevice A library to communicate with services on iOS devices using native protocols. Features libimobiledevice is a cross-platform software

libimobiledevice 5.3k Nov 19, 2022
Platform independent Near Field Communication (NFC) library

*- * Free/Libre Near Field Communication (NFC) library * * Libnfc historical contributors: * Copyright (C) 2009 Roel Verdult * Copyright (C) 2009

null 1.3k Nov 18, 2022
PRK is a keyboard firmware platform in PicoRuby

PRK is a keyboard firmware written and configured in PicoRuby which is an alternative mruby implementation targeting on one-chip microcontroller.

PicoRuby 380 Nov 22, 2022
LibOS is a modern C++17 library that makes OS-specific features cross-platform.

LibOS is a modern C++17 library that makes OS-specific features cross-platform. Ever tried to get Windows version after Windows 8? Or to send ke

Gavrilikhin Daniil 27 Sep 13, 2022