Example #1
0
/* Complete file processing */
static int parser_post(struct parser_obj *po)
{
    int error = EOK;

    TRACE_FLOW_ENTRY();

    /* If there was just a comment at the bottom
     * put it directly into the config object
     */
    if((po->ic) && (!(po->key))) {
        if (po->co->last_comment) {
            error = ini_comment_add(po->ic, po->co->last_comment);
            if (error) {
                TRACE_ERROR_NUMBER("Failed to merge comment", error);
                return error;
            }
        }
        else {
            error = ini_comment_copy(po->ic, &(po->co->last_comment));
            if (error) {
                TRACE_ERROR_NUMBER("Failed to copy comment", error);
                return error;
            }
        }

        ini_comment_destroy(po->ic);
        po->ic = NULL;
    }

    /* If there is a key being processed add it */
    if (po->key) {
        error = complete_value_processing(po);
        if (error) {
            TRACE_ERROR_NUMBER("Failed to complete value processing", error);
            return error;
        }
    }

    /* If we are done save the section */
    error = parser_save_section(po);
    if (error) {
        TRACE_ERROR_NUMBER("Failed to save section", error);
        return error;
    }

    /* Move to the next action */
    error = col_enqueue_unsigned_property(po->queue,
                                          PARSE_ACTION,
                                          PARSE_DONE);
    if (error) {
        TRACE_ERROR_NUMBER("Failed to schedule an action", error);
        return error;
    }

    TRACE_FLOW_EXIT();
    return EOK;
}
Example #2
0
/* Destroy a value object */
void value_destroy(struct value_obj *vo)
{
    TRACE_FLOW_ENTRY();

    if (vo) {
        /* Free arrays if any */
        value_destroy_arrays(vo->raw_lines,
                             vo->raw_lengths);
        /* Free the simple buffer if any */
        simplebuffer_free(vo->unfolded);
        /* Function checks validity inside */
        ini_comment_destroy(vo->ic);
        free(vo);
    }

    TRACE_FLOW_EXIT();
}
Example #3
0
/* Destroy parser object */
static void parser_destroy(struct parser_obj *po)
{
    TRACE_FLOW_ENTRY();

    if(po) {
        col_destroy_queue(po->queue);
        col_destroy_collection_with_cb(po->sec, ini_cleanup_cb, NULL);
        ini_comment_destroy(po->ic);
        value_destroy_arrays(po->raw_lines,
                             po->raw_lengths);
        if (po->last_read) free(po->last_read);
        if (po->key) free(po->key);
        col_destroy_collection_with_cb(po->top, ini_cleanup_cb, NULL);
        free(po);
    }

    TRACE_FLOW_EXIT();
}
Example #4
0
/* Set comment into the value */
int value_put_comment(struct value_obj *vo, struct ini_comment *ic)
{
    int error = EOK;

    TRACE_FLOW_ENTRY();

    if ((!vo) || (!ic)) {
        TRACE_ERROR_NUMBER("Invalid input parameter", EINVAL);
        return EINVAL;
    }

    if (vo->ic != ic) {
        /* Remove existing comment if any */
        ini_comment_destroy(vo->ic);
    }

    vo->ic = ic;

    TRACE_FLOW_EXIT();
    return error;

}