Theta/utility.h

67 lines
2.3 KiB
C

/*
Copyright (C) 2019-2020 Toldi Balázs Ádám
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 <https://www.gnu.org/licenses/>.
File created at: 2019. 10. 11.
*/
#pragma once
#define _CRT_SECURE_NO_WARNINGS
#include "lib/map.h"
#include "lib/net.h"
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdarg.h>
#include <string.h>
#include <assert.h>
#include "lib/debugmalloc/debugmalloc.h"
#ifndef _WIN32
#define strtok_s(S,T,R) strtok_r(S,T,R)
#endif
//! (MAXIMUM) Ekkora mérető csomagokat küld el a program alapértelmezetten.
#define DEFAULT_BUFLEN 4096
/*!
* @brief Generál egy \p len(+1 a lezáró nullának) méretű karaktertömböt,amit feltölt véletlenszerű base58-as karakterekkel
* @param[in] len A generálandó sztring hossza
* @return A generált sztring
*/
char* generateSeed(int len);
/*!
* @brief Értelmez egy megadott csomag sztringjét
* A csomagok formátuma:
* <ul>
* <li>A csomag első karakterének kukac karakternek(@) kell lennie</li>
* <li>A kulcsokat és a hozzájuk tartozó értékeket egyenlőségjel(=) választja el</li>
* <li>Az egyes paramétereket AND jel(&) választja el</li>
* </ul>
* Példa \code
* @id=84uzkhv4vMuu2PRD&port=6327&nickname=ToldiBalazs
* \endcode
* @param[in] text Az értelmezendő sztring
* @return Map,ami tartalmazza a kulcsokat és a hozzájuk rendelt értékeket
* @note A szöveg nem tartalmazhat Entert,tabulátort vagy szóközt.
*/
Map getPacketData(char* text);
/**
* @brief Kiír egy üzenetet dátummal az elején és sor vége jellel a végén a képernyőre,valamint a log.txt fájlba
* @param _Format Lásd <a href="http://www.cplusplus.com/reference/cstdio/printf/#parameters">printf</a>
* @param ...
*/
void logger_log(const char* _Format, ...);