Git Product home page Git Product logo

libcprop's Introduction

libcprop

A C library for loading Java-style .properties files. Currently, the library does not support Unicode escape sequences.

API

The library consists of a few simple functions. They are defined and documented in include/cprop.h. An online version of the documentation can be found here.

/* Loads properties from file */
Properties *cprop_load(char *filename);

/* Destroys Properties structure */
void cprop_free(Properties *prop);

/* Retrieves value associated with key */
char *cprop_get(Properties *prop, char *key);

/* Associates value with key */
int cprop_set(Properties *prop, char *key, char *value);

/* Deletes property marked by key */
int cprop_delete(Properties *prop, char *key);

/* Prints all properties to provided stream */
void cprop_print(FILE *stream, Properties *prop);

Example

An example program is included in example/src/main.c, which showcases how the library should be used. The sample example/example.properties is used for this purpose. Read instructions on how to run the example.

Usage

Clone this repository and cd into the libcprop directory. Edit the CC variable in the Makefile to choose your preferred C compiler.

Build the library

$ make                          # compile the library

The lib directory will contain the static library libcprop.a and the shared library libcprop.so.

Install shared library

Edit the PREFIX variable in the Makefile to choose where the shared library will be installed. The default path is /usr/local. Next, run the following.

$ make                          # compile the library
$ sudo make install             # install shared library in chosen location
                                # sudo may or may not be required depending on PREFIX

Run example program

$ make example-static           # build and run example using the static version of libcprop
$ make example-shared           # build and run example using the shared version of libcprop

Run unit tests

The Check framework is required in order to run the included tests.

$ make test                     # build and run unit tests using the static version of libcprop

Notes

This project has been tested against:

  • gcc version 7.1.1, and
  • clang version 4.0.1

See also:

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.