Skip to content
Snippets Groups Projects
Select Git revision
  • 49aa2a3d692482c9191c69e3c27e99c718e6f500
  • experimental default protected
  • v2023.2.5-ffs
  • nrb/ex400-remove-wps
  • nrb/airmax-test
  • v2023.2.4-ffs
  • nrb/ar9344-reset-sequence
  • autinerd/experimental-openwrt-24.10
  • v2023.2.3-ffs
  • v2023.2.2-ffs
  • v2023.2-ffs
  • v2023.1-ffs
  • v2022.1.4-ffs
  • feature/addMikrotikwAP
  • v2022.1.3-ffs
  • v2021.1.2-ffs
  • v2022.1.1-ffs
  • master protected
  • v2021.1.1-ffs
  • nrb/gluon-master-cpe510
  • v2021.1-ffs
  • experimental-2025-08-04
  • experimental-2025-08-04-base
  • experimental-2025-07-31
  • experimental-2025-07-31-base
  • experimental-2025-07-29
  • experimental-2025-07-29-base
  • experimental-2025-07-28
  • experimental-2025-07-28-base
  • experimental-2025-07-26
  • experimental-2025-07-26-base
  • experimental-2025-07-24
  • experimental-2025-07-24-base
  • experimental-2025-07-22
  • experimental-2025-07-22-base
  • experimental-2025-07-21
  • experimental-2025-07-21-base
  • experimental-2025-07-20
  • experimental-2025-07-20-base
  • experimental-2025-07-19
  • experimental-2025-07-19-base
41 results

template_utils.h

Blame
  • user avatar
    Matthias Schiffer authored
    1a426c3b
    History
    template_utils.h 1.34 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(const struct template_buffer *buf)
    {
    	return buf->dptr - buf->data;
    }
    
    bool pcdata(const char *s, size_t l, char **out, size_t *outl);
    
    #endif