olaf@108: /* olaf@108: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. olaf@108: * olaf@108: * Copyright 2013 Olaf Wintermann. All rights reserved. olaf@108: * olaf@108: * Redistribution and use in source and binary forms, with or without olaf@108: * modification, are permitted provided that the following conditions are met: olaf@108: * olaf@108: * 1. Redistributions of source code must retain the above copyright olaf@108: * notice, this list of conditions and the following disclaimer. olaf@108: * olaf@108: * 2. Redistributions in binary form must reproduce the above copyright olaf@108: * notice, this list of conditions and the following disclaimer in the olaf@108: * documentation and/or other materials provided with the distribution. olaf@108: * olaf@108: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" olaf@108: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE olaf@108: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE olaf@108: * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE olaf@108: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR olaf@108: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF olaf@108: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS olaf@108: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN olaf@108: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) olaf@108: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE olaf@108: * POSSIBILITY OF SUCH DAMAGE. olaf@108: */ olaf@108: olaf@108: #ifndef PROPERTIES_H olaf@108: #define PROPERTIES_H olaf@108: olaf@108: #include "ucx.h" olaf@108: #include "map.h" olaf@108: olaf@108: #ifdef __cplusplus olaf@108: extern "C" { olaf@108: #endif olaf@108: olaf@108: typedef struct { olaf@108: char *buffer; olaf@108: size_t buflen; olaf@108: size_t pos; olaf@108: char *tmp; olaf@108: size_t tmplen; olaf@108: size_t tmpcap; olaf@109: int error; olaf@108: char delimiter; olaf@108: char comment1; olaf@108: char comment2; olaf@108: char comment3; olaf@108: } UcxPropParser; olaf@108: olaf@108: olaf@108: UcxPropParser *ucx_prop_new(); olaf@108: void ucx_prop_free(UcxPropParser *parser); olaf@108: void ucx_prop_fill(UcxPropParser *parser, char *buf, size_t len); olaf@108: int ucx_prop_parse(UcxPropParser *parser, sstr_t *name, sstr_t *value); olaf@109: int ucx_prop_parse2map(UcxPropParser *parser, UcxMap *map); olaf@109: olaf@109: int ucx_properties_load(UcxMap *map, FILE *file); olaf@109: int ucx_properties_store(UcxMap *map, FILE *file); olaf@108: olaf@108: #ifdef __cplusplus olaf@108: } olaf@108: #endif olaf@108: olaf@108: #endif /* PROPERTIES_H */ olaf@108: