Blame server/util_cfgtree.c

Packit 90a5c9
/* Licensed to the Apache Software Foundation (ASF) under one or more
Packit 90a5c9
 * contributor license agreements.  See the NOTICE file distributed with
Packit 90a5c9
 * this work for additional information regarding copyright ownership.
Packit 90a5c9
 * The ASF licenses this file to You under the Apache License, Version 2.0
Packit 90a5c9
 * (the "License"); you may not use this file except in compliance with
Packit 90a5c9
 * the License.  You may obtain a copy of the License at
Packit 90a5c9
 *
Packit 90a5c9
 *     http://www.apache.org/licenses/LICENSE-2.0
Packit 90a5c9
 *
Packit 90a5c9
 * Unless required by applicable law or agreed to in writing, software
Packit 90a5c9
 * distributed under the License is distributed on an "AS IS" BASIS,
Packit 90a5c9
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit 90a5c9
 * See the License for the specific language governing permissions and
Packit 90a5c9
 * limitations under the License.
Packit 90a5c9
 */
Packit 90a5c9
Packit 90a5c9
#include "util_cfgtree.h"
Packit 90a5c9
#include <stdlib.h>
Packit 90a5c9
Packit 90a5c9
ap_directive_t *ap_add_node(ap_directive_t **parent, ap_directive_t *current,
Packit 90a5c9
                            ap_directive_t *toadd, int child)
Packit 90a5c9
{
Packit 90a5c9
    if (current == NULL) {
Packit 90a5c9
        /* we just started a new parent */
Packit 90a5c9
        if (*parent != NULL) {
Packit 90a5c9
            (*parent)->first_child = toadd;
Packit 90a5c9
            toadd->parent = *parent;
Packit 90a5c9
        }
Packit 90a5c9
        if (child) {
Packit 90a5c9
            /* First item in config file or container is a container */
Packit 90a5c9
            *parent = toadd;
Packit 90a5c9
            return NULL;
Packit 90a5c9
        }
Packit 90a5c9
        return toadd;
Packit 90a5c9
    }
Packit 90a5c9
    current->next = toadd;
Packit 90a5c9
    toadd->parent = *parent;
Packit 90a5c9
    if (child) {
Packit 90a5c9
        /* switch parents, navigate into child */
Packit 90a5c9
        *parent = toadd;
Packit 90a5c9
        return NULL;
Packit 90a5c9
    }
Packit 90a5c9
    return toadd;
Packit 90a5c9
}
Packit 90a5c9
Packit 90a5c9