Skip to content

A small, portable C89 library for parsing strings into argc/argv-style arrays

License

Notifications You must be signed in to change notification settings

ryanflannery/str2argv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

License: ISC Build Status

This is a small portable C (strict C89) library to convert between c-style strings and argc/argv pairs. It handles escaping spaces, tabs, etc. Useful if you have an application that has shell-like features, where it takes input strings/commands from users and runs functions/plugins/etc.

Details

There are two main functions exported by this lib.

The first is to convert a string to an argc/argv pair:

    int
    str2argv(char *str, int *argc, char ***argv, const char **errmsg)

The resulting argv can be free()d using

    void argv_free(int *argc, char ***argv)

The second function does the reverse: given an argc/argv pair, it returns a string.

    char*
    argv2str(int argc, char *argv[])

Install

Edit the variables in Makefile for where to install the .h and the lib. Then

   $ ./configure
   $ make
   $ make install
   $ make test          /* run gtests */

License

The code is released under an ISC (2-clause BSD) style license.

About

A small, portable C89 library for parsing strings into argc/argv-style arrays

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published