happyfish100/libfastcommon logo

happyfish100/libfastcommon

Free

c common functions library extracted from my open source project FastDFS. this library is very simple and stable. functions including: string, logger, chain, hash, socket, ini file reader, base64 encode / decode, url encode / decode, fast timer, skiplist, object pool etc. detail info please see the

FreeFree tier
Type
Open Source

About happyfish100/libfastcommon

libfastcommon is a C common functions library extracted from the open source projects FastDFS and FastDHT. It provides a stable and simple set of core utilities for building high-performance C applications. The library includes an asynchronous logging system with thread safety, log rotation, and compression; an INI file reader that supports sections, multiple values, include directives, and control statements (if/else/for); a unique 64-bit ID generator for multi-process environments; string operations; base64 and URL encoding/decoding; MD5 hashing; hash tables; singly linked lists; blocked queues; AVL trees; skiplists (flat and multi); socket wrappers with IPv6 support; an ioevent abstraction (like epoll) supporting Linux, FreeBSD, and SunOS; I/O buffer management; memory pools; object allocators; connection pools; a time-wheel-based timer for network timeout management; local IP address functions; system information retrieval (CPU, memory, load, filesystems, processes); process control for start/stop/restart; task scheduling for repeated tasks; and character conversion utilities. Detailed usage information is available in the C header files and the project's forum at bbs.chinaunix.net.

Key Features

Asynchronous logging with thread safety, log rotation, and compression
INI file reader with sections, multiple values, #include, and control statements (#if, #for)
64-bit unique ID generator for multi-process environments
Socket wrappers with IPv6 support and epoll-like ioevent abstraction
Time-wheel-based timer for high-performance network timeout management
Connection pool, memory pool, and object allocator utilities
Multiple skiplist implementations (flat, multi) and AVL tree
System info retrieval (CPU, memory, load, filesystems, processes)
Process control (start/stop/restart) and task scheduler for repeated tasks
PHP extension wrappers available for some functions

Pros & Cons

Pros
  • Stable and simple library with a proven track record in FastDFS
  • High-performance asynchronous logging with automatic compression and deletion
  • Thread-safe components (logger, ID generator)
  • Rich set of data structures (AVL trees, skiplists, hash tables, etc.)
  • IPv6 support in socket functions
  • Flexible INI file reader supporting advanced control statements
Cons
  • Only available in C; no direct bindings for other languages (except PHP partial wraps)
  • Documentation is primarily in the C header files with limited English comments and a Chinese-language forum
  • Some advanced features (INI control statements) have a learning curve
  • Less actively maintained compared to larger ecosystem libraries

Best For

Building high-performance network servers and servicesDeveloping distributed file systems (e.g., FastDFS, FastDHT)Embedding in C projects that require reusable data structures and utilitiesCreating custom logging and configuration systemsImplementing unique ID generation across multiple processes

FAQ

What is libfastcommon?
libfastcommon is a C library of common functions extracted from the FastDFS and FastDHT open source projects. It provides logging, INI parsing, ID generation, socket wrappers, data structures, and other utilities for high-performance C applications.
Is libfastcommon thread-safe?
Yes, components like the asynchronous logger and ID generator are designed to be thread-safe.
What platforms are supported?
The library supports Linux, FreeBSD, and SunOS (indicated by ioevent implementation).
How do I use libfastcommon?
Detailed information about each function is available in the corresponding C header files in the source. Also, the project's forum at bbs.chinaunix.net provides additional guidance.
Is there a PHP extension for libfastcommon functions?
Yes, some functions such as fastcommon_gethostaddrs and id generator wrappers are provided as PHP extensions.