zpl

📐 Pushing the boundaries of simplicity
授权协议 View license
开发语言 C/C++
所属分类 服务器软件、 终端服务器/远程连接
软件类型 开源软件
地区 不详
投 递 者 高山
操作系统 跨平台
开源组织
适用人群 未知
 软件概览
zpl


C99 cross-platform header-only library oriented towards improving the coding experience.
Brought to you by @zaklaus, @inlife, and contributors

Introduction

We have created the library to simplify the development process under C/C++ language, which offers a commonly used set of features that C developers often re-invent themselves. Apart from helper methods that replace/extend the C standard library, this toolkit also consists of modules that are very helpful in broad areas of expertise. The most notable is the JSON5 parser, math library, flexible file API, or various hashing algorithms.

Library is cross-platform and currently works on i386, amd64 and some ARM architectures. It has been tested on Windows, UNIX-like systems, iOS, Emscripten and Android.We're trying to expand the compatibility, but we need your help! If you have a device you want to test zpl on, please let us know about your experience, and we can try to make it work together.

How to obtain this library?

There are several options in getting hands-on zpl:

1. Via CLI (the simplest option)

curl -L zpl.pw/fetch > zpl.h
# OR
wget zpl.pw/fetch -O zpl.h

This approach will download the latest release of zpl with everything prepared for you.

2. Via GitHub releases page

  • Navigate to the releases page of the zpl repository and pick the version you want to use. Each release contains the distributed version of zpl for you to use easily.

3. Cloning the repository

  • Clone the repository by pressing the Clone or download button for instructions or use your terminal to clone:
git clone https://github.com/zpl-c/zpl.git

We use this method to develop zpl as it contains all the development sources that are easy to modify and expand, but it is not suitable for use in production.

Please follow the CONTRIBUTING.md guide to learn how to contribute to the project.

Modules

Name Description Test Coverage Example Coverage
Memory Low-level memory management and allocation strategy models. ��
Collections Versatile set of collections: array, buffer, linked list, ring buffer. ��
String Set of helpful string manipulation methods. ��
String Libary C-friendly string library. ��
Hashtable Instantiated hashtable implementation that works with any type. ��
File File I/O operations forming a basis for other modules. ��
File System Path and folder structure manipulation methods. ��
TAR Archive Ability to archive files or analyze/unpack them. ��
Memory Streamer Memory-mapped file I/O operations.
Print Re-implementation of various printf-family methods.
Time Helper methods for retrieving the current time in many forms under different precisions.
Random Fast and simple RNG library. ��
Sorting Various sorting and searching algorithms. ��
Threading Threading, and blocking models, thread merge operation based on stb_sync, as well as CPU affinity management. ��
Regex Regular expressions library. ��
DLL Cross-platform methods for loading dynamic libraries. ��
Timer Callback-based primitive timer library. ��
Hashing Various hashing methods. Contains: base64, adler32, crc32/64, fnv32/64/a and murmur32/64
Text Parsers Various text parsers for different formats that offer cross-language transformations. Currently supported: JSON5/SJSON, CSV.
Options CLI options parser. Parsing flags, switches, and arguments from the command line. ��
Process Primitives for low-level process management. ��
Jobs System Asynchronous task-based scheduling system. ��
Co-routines LUA-inspired module implementing co-routines feature for C11. ��
Math Gamedev friendly library for math. ��
Miscellaneous Other valuable methods that are part of the core distribution.

Distributions

All distributions are defined at compile-time. You can always opt-in to any distribution kind without a need to maintain different copies of the library.

Default

zpl enables all of its modules by default, which allows you to make full use of the library effortlessly.

ZPL_NANO

The nano distribution provides the core parts of the library. It omits some specialized modules in favor of broader compatibility, and that also makes the library lightweight.

ZPL_PICO

We've also made a pico distribution that only contains: Memory and Collections modules. There is no ability to enable specific core submodules within the pico distribution; however, consider using the nano distribution in that case.

Custom distributions

zpl also allows you to enable/disable various modules at will, allowing you to create your distribution suiting your needs.

Examples

We cover many of these modules with example code you can explore at apps/examples folder. They serve as a good starting point to better understand how the library works. Have a look at this base64 text encoder:

#define ZPL_IMPL
#define ZPL_NANO
#define ZPL_ENABLE_OPTS
#define ZPL_ENABLE_HASHING
#include <zpl.h>

void exit_with_help(zpl_opts *opts);

int main(int argc, char **argv) {
    zpl_opts opts={0};

    zpl_opts_init(&opts, zpl_heap(), argv[0]);
    zpl_opts_add(&opts, "s", "string", "input string.", ZPL_OPTS_STRING);
    zpl_opts_positional_add(&opts, "string");
    zpl_b32 ok = zpl_opts_compile(&opts, argc, argv);
    if (!ok || !zpl_opts_positionals_filled(&opts))
        exit_with_help(&opts);

    zpl_string input = zpl_opts_string(&opts, "string", 0);
    zpl_u8 *encoded_str = zpl_base64_encode(zpl_heap(), cast(void*)input, zpl_string_length(input));
    zpl_printf("Original: %s\nEncoded: %s\n", input, encoded_str);

    zpl_mfree(encoded_str);
    zpl_opts_free(&opts);
    return 0;
}

void exit_with_help(zpl_opts *opts) {
    zpl_opts_print_errors(opts);
    zpl_opts_print_help(opts);
    zpl_exit(-1);
}

Frequently Asked Questions

What is this library based on?

zpl is a fork of a library made by @gingerBill called gb that we've decided to expand and rewriteto fit our needs better. Although many parts of the library still stay faithful to their original, a significant amount of work shaped the library into what we present now.

Can I contribute to the project?

Yes, indeed. This project is dual-licensed according to LICENSE. You are free to fork it, contribute to it, or even sell it as you see fit.

Can I submit suggestions?

Indeed, we'd also gladly discuss those with you on Discord, if possible.

  • ZPL

    ZPL指令及条码选择整理(斑马S4M) ^XA ^LH50,20^FO10,50^BY2,2.0,200^BCC^FD>51234567890^FS ^CW1,E:MSUNG24.FNT^CI17^FO40,270^A1N,20,20^F8^FD测试文本^FS ^XZ ZPL指令是区分大小写的。 ^XA和^XZ是开始和结束标记。 这些ZPL指令可以参考下面的标记,主要解释一下^BC是128码,12

  • public partial class ZplPrintControl     {         public string ZPL_Start()         {             StringBuilder builder = new StringBuilder();             builder.AppendLine("^XA"); //指令块的开始        

  • ^XA ^CI26  //ASCII Transparency和多字节亚洲编码 ^SEE:GB18030.DAT  //码表 ^CW1,E:SIMSUN.FNT  //字体(宋体) ^FO200,200^A1N,48,48^FD中文^FS //打印文字 ^FT448,288^BQ2,2,10^A1N,48,48^FD中文^FS  //打印二维码 ^XZ

  • 最近用C#结合ZPL指令实现了打印中文的功能,在这里对其中的代码以及一些资源,分享一下. 一.直接使用ZPL打印 对于直接使用ZPL命令打印中文,首先需要明确几个概念: 1.码表文件: 字符编码文件,打印中文需要制定的码表,常用中文码表为 GB.DAT,GB8BIT.DAT,GB2312.DAT,GB18030.DAT, 其中 GB.DAT,GB8BIT.DAT为较早的机型使用编码表文件,码表可以

  • 回车换行在电脑上是敲入ENTER回车键,但在ZPL中无法直接敲ENTER回车,必须把ENTER的ACSII值输入到ZPL指令中,如ENTER回车是0D,换行是0A,ZPL中加入^FH指令,如: ^FO30,30^BQN,2,3^FH^FDHM,B0058Shanghai WinFuture Technology,Inc._0D_0A上海京威子科技有限公司^FS 这样扫描出来时就变成 Shangha

  • 很久没有写博了,趁着这个有限的空余时间,把我最近研究的,觉得可以分享的zpl技术给写个心得. 由于项目需要打印条码,公司买了个斑马GT800条码打印机,初次接触打印,还真有点不知所措.一步一步来吧,先研究了会java打印服务,觉得还是挻好用的.然后再试着用java打印服务打印条码,结果打得一踏糊涂,真是扯淡,居然不支持(肯定是有办法打印的,只是我没有深入研究,要不然java也太衰了).后来把目光转

  • 由于公司一个地方需要用到图片转换ZPL格式去打印;这里的ZPL格式是打印斑马打印机,这里面有一些小的地方是需要注意的. 由于斑马打印机的型号不一样,设置不一样,外加自身的图片格式(.jpg,.png的不一样),图片的高度和宽度也不一样,就会直接导致打印出来的东西和你理想中的效果不一样,所以这里就需要设置图片的参数和斑马打印机自身的参数等设置。 然后下面贴出来图片转换为ZPL格式的代码,也可以当一个

相关阅读

相关文章

相关问答

相关文档