Skip to content
Snippets Groups Projects
Select Git revision
  • 43e70f351f013f3d8b38513fd0cc8af194fcefe2
  • v2018.2.x default
  • experimental
  • master
  • v2021.1.2-ffs
  • v2021.1.1-ffs
  • nrb/gluon-master-cpe510
  • v2021.1-ffs
  • v2020.2.3-ffs
  • nrbffs/fastd-remove-delay
  • v2020.2.2-ffs
  • v2020.2.1-ffs
  • v2020.2-ffs
  • v2020.2.x
  • v2020.1.3-ffs
  • v2020.1.1-ffs
  • v2020.1-ffs
  • v2019.1.2-ffs
  • v2019.1.1-ffs
  • nrb/test-radv-filter
  • v2019.1-ffs
  • nrbffs/netgear-ex6120
  • v2021.1.2-ffs0.2
  • v2021.1.2-ffs0.1
  • v2021.1.1-ffs0.4
  • v2021.1.1-ffs0.3
  • v2021.1.1-ffs0.2
  • v2021.1.1-ffs0.1
  • v2021.1-ffs0.1
  • v2020.2.3-ffs0.3
  • v2020.2.3-ffs0.2
  • v2020.2.3-ffs0.1
  • v2020.2.2-ffs0.1
  • v2020.2.1-ffs0.1
  • v2020.2-ffs0.1
  • v2020.2
  • v2020.2.x-ffs0.1
  • v2020.1.3-ffs0.1
  • v2020.1.1-ffs0.1
  • v2020.1-ffs0.1
  • v2019.1.2-ffs0.1
  • v2019.1.1-ffs0.1
42 results

template_utils.h

Blame
  • Forked from firmware / FFS Gluon
    3003 commits behind the upstream repository.
    user avatar
    Matthias Schiffer authored
    By emitting Lua code to call translate() and pcdata(), we are more
    flexible than when doing this internally in the parser. The performance
    penalty should be negligible.
    43e70f35
    History
    template_utils.h 1.32 KiB
    /*
     * gluon-web Template - Utility header
     *
     *   Copyright (C) 2010-2012 Jo-Philipp Wich <jow@openwrt.org>
     *   Copyright (C) 2018 Matthias Schiffer <mschiffer@universe-factory.net>
     *
     *  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.
     */
    
    #ifndef _TEMPLATE_UTILS_H_
    #define _TEMPLATE_UTILS_H_
    
    #include <stdbool.h>
    #include <stddef.h>
    
    
    /* buffer object */
    struct template_buffer {
    	char *data;
    	char *dptr;
    	size_t size;
    };
    
    struct template_buffer * buf_init(size_t size);
    bool buf_putchar(struct template_buffer *buf, char c);
    bool buf_append(struct template_buffer *buf, const char *s, size_t len);
    char * buf_destroy(struct template_buffer *buf);
    
    /* read buffer length */
    static inline size_t buf_length(struct template_buffer *buf)
    {
    	return buf->dptr - buf->data;
    }
    
    
    char * pcdata(const char *s, size_t l, size_t *outl);
    
    #endif