GithubHelp home page GithubHelp logo

argv's Introduction

Codacy Badge

A small ISO C90 library to manage simple dynamic string vectors a-la argv

Author: [email protected]

Public domain.

Link against a libc with system-supplied library routine strdup(), which is fairly commonplace even though not strictly standard C.

Type naming convention

typedef const char *  TStr;
typedef strut argv    TVec;

Methods (API)

  • TVec *argv_init()

    Initialize a brand new vector and return associated pointer handle

  • void argv_free(TVec *vec)

    Free up dynamically allocated resources, invalidates handle

  • long argv_find(TVec *haystack, TStr needle)

    Return zero-based index of first occurrence of needle in haystack, -1 otherwise. This performs a simple linear search.

  • void argv_append(TVec *vec, TStr entry)

    Copy string argument (by value, strdup) into argv

Data members (ABI)

  • TVec.argv of type *TStr, aka const char**

    a NULL-terminated string ector

  • TVec.argc, size of argv, number of elements (not including implicit NULL entry)

Characteristics

  • Vector is append-only, no direct method of removing elements

  • Methods are re-entrant, but not thread-safe, explicit synchornization of access to shared argv is left up to the user

  • Only simple linear search is provided as a shortcut, other methods of search with assumptions about the relative order of elements, or different interpretations of the identity relation can be trivially achieved through use of standard routines such as bsearch(3)/qsort(3).

  • No methods of iteration are provided, argv is walkable by either subscripting argv with index 0 up to the value of argc-1, or by testing for the (char*)NULL entry

Typical use cases

  • Construction of an argv suitable for use with the exec(2) family of syscalls (with trailing NULL entry)

  • With a combination of find/append, can be used to represent a set of strings elements

argv's People

Contributors

cval-c4q 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.