Coder Social home page Coder Social logo

liburlcodec's Introduction

简介

该项目属于实验项目,以验证rust与waf的可融合性。

编译过程

  1. rust编译 cargo build --release
  2. 生成头文件 cbindgen --config cbindgen.toml --crate liburlcodec --output liburlcodec.h --lang c

如何在c语言中调用?

参考 test.c

gcc 编译命令

gcc -o test test.c -L target/release/ -lurlcodec

  • -L 是rust编译产物(shared library)所在的目录
  • -l 是rust编译产物的名称,去掉文件名前lib这三个字母(gcc会自动帮你加上)

如何调试?

  1. 请针对你的函数,编写详细的unit test文档。
  2. 在vs code中,点击debug tests即可。这样不需要借助GDB一类的调试器,在vscode中借助于rust,查看你断点处的各种变量
  3. 如果还是不可以,请参考https://juejin.cn/s/vscode%20debug%20rust%20unit%20test

运行结果参考(双重url编码的解码)

➜  liburlcodec git:(default) ✗ ./test                                          
raw: %25%36%31%25%36%32%25%36%33%25%36%34%25%36%35%25%36%34
result: abcded

参考文档

  1. https://github.com/mozilla/cbindgen

liburlcodec's People

Contributors

potapo avatar potats0 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.