Skip to content
Snippets Groups Projects
Select Git revision
1 result Searching

projection_wgs84_test.go

Blame
  • config_utils.c 6.79 KiB
    /*
     * Copyright (C) 2007 The Android Open Source Project
     *
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     *      http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     */
    
    #include <string.h>
    #include <ctype.h>
    #include <stdlib.h>
    #include <fcntl.h>
    #include <unistd.h>
    
    #include <cutils/config_utils.h>
    #include <cutils/misc.h>
    
    cnode* config_node(const char *name, const char *value)
    {
        cnode *node;
    
        node = calloc(sizeof(cnode), 1);
        if(node) {
            node->name = name ? name : "";
            node->value = value ? value : "";
        }
    
        return node;
    }
    
    cnode* config_find(cnode *root, const char *name)
    {
        cnode *node, *match = NULL;
    
        /* we walk the whole list, as we need to return the last (newest) entry */
        for(node = root->first_child; node; node = node->next)
            if(!strcmp(node->name, name))
                match = node;
    
        return match;
    }
    
    static cnode* _config_create(cnode *root, const char *name)
    {
        cnode *node;
    
        node = config_node(name, NULL);
    
        if(root->last_child)
            root->last_child->next = node;
        else
            root->first_child = node;
    
        root->last_child = node;
    
        return node;
    }
    
    int config_bool(cnode *root, const char *name, int _default)
    {
        cnode *node;