/*
 * LEIGH:plc
 * Copyright 2022 Alex Leigh
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _MECHA_H
#define _MECHA_H

#include <stdio.h>

bool strFis_terminated(const char *str, size_t len);
void netFudp_listener(void (*pkt_handler)(const char *buf, size_t buf_len), uint16_t port, size_t maxsz);
void netFmc_listener(void (*pkt_handler)(const char *buf, size_t buf_len, const char *source_ip), struct sockaddr_in *addr);

struct dynSstring {
    char *str;
    size_t len;
    size_t strlen;
};
typedef struct dynSstring dynTstring;
dynTstring *dynFinit (void);
void dynFfree (dynTstring * ds);
size_t dynFappend (dynTstring * ds, const char *str, size_t len);
size_t dynFappend_string (dynTstring * ds, const dynTstring * src);
size_t dynFsappend (dynTstring * ds, const char *str);
size_t dynFappend_print (dynTstring * ds, const char *fmt, ...);
const char *dynFgetstr (const dynTstring * ds);
size_t dynFgetlen(const dynTstring *ds);
void dynFreset(dynTstring *ds);

#endif