qs_parse

Simple HTTP query string parsing library in C

  • Owner: bartgrantham/qs_parse
  • Platform:
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

qs_parse

Description

A set of simple and easy functions for parsing URL query strings, such as
those generated in an HTTP GET form submission.

How to Use

These qs_* functions can be used in two different ways:

qs_parse()/qs_k2v(): A faster version that requires a pre-processing stage
and is destructive to the query string

  • Better for repeated lookups of k/v pairs
  • Does all decoding/processing in-place, so no memory copying
  • Requires an array of pointers to strings to be passed to the preprocessing stage
  • Cannot be used where the query string is const

qs_scanvalue(): A slower version that will scan for the given key and will
decode the value into a user-provided string

  • Doesn't alter the query string so can be used where it is const, or cannot be altered
  • Only needs a user-passed char string for copying into
  • Scans the entire qs on each call, so isn't as fast as qs_k2v()

Since qs_parse()/qs_k2v() alters the query string that is passed to it in a way
that defeats qs_scanvalue(), do not mix these two methods (or if you must,
either don't call qs_scanvalue() after a call to qs_parse() or be sure make
a copy of the query string beforehand)

[note: speed comparisons will be more relevant when the sorting the k/v pairs
code is implemented]

Installation

All you really need is qs_parse.h and qs_parse.c. I've included my test program
("qs_test.c") and an example program that shows how to use these functions
("qs_example.c"). Also included is a quick Makefile. If you want to see it
come to life just get all the files and:

# make
# ./qs_example

Bugs, etc.

Please let me know if you find any, or if you have license-friendly enhancements
to add.

License

MIT License. See ./LICENSE or http://www.opensource.org/licenses/mit-license.php

Few things are more enjoyable than the knowledge that you've helped another
person. If you do use these functions for anything, I'd love to hear about it:

bart@bartgrantham.com

Enjoy!

-Bart

Main metrics

Overview
Name With Ownerbartgrantham/qs_parse
Primary LanguageC
Program languageC (Language Count: 1)
Platform
License:MIT License
所有者活动
Created At2012-06-17 08:39:27
Pushed At2012-06-17 08:42:16
Last Commit At2012-06-17 01:38:16
Release Count0
用户参与
Stargazers Count58
Watchers Count9
Fork Count5
Commits Count23
Has Issues Enabled
Issues Count0
Issue Open Count0
Pull Requests Count0
Pull Requests Open Count0
Pull Requests Close Count0
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private