PokerUnicorn
Loading...
Searching...
No Matches
util.h
Go to the documentation of this file.
1/*
2 * PokerUnicorn Server
3 * This project uses test network, NO real coin or NO real money involved.
4 * Copyright (C) 2023, Oğuzhan Eroğlu <meowingcate@gmail.com> (https://meowingcat.io)
5 * Licensed under GPLv3 License
6 * See LICENSE for more info
7 */
8
9#pragma once
10
22#include <stdbool.h>
23#include <stdint.h>
24#include <stdlib.h>
25#include <stdio.h>
26#include <execinfo.h>
27
28static bool is_verbose = true;
29
35
39#define PKRSRV_UTIL_ASSERT(condition) \
40 { \
41 if (!(condition)) { \
42 printf("Assertion failed: %s\n", #condition); \
43 printf("\tat: %s:%d\n", __FILE__, __LINE__); \
44 \
45 void* callstack[128]; \
46 int frames = backtrace(callstack, sizeof(callstack) / sizeof(void*)); \
47 char** lines = backtrace_symbols(callstack, frames); \
48 \
49 if (lines) { \
50 printf("Call Stack:\n"); \
51 \
52 for (int i = 0; i < frames; i++) { \
53 printf("%s\n", lines[i]); \
54 } \
55 } \
56 pkrsrv_util_assert_fail(); \
57 }; \
58 }
59
60void pkrsrv_util_verbose(const char* format, ...);
61void pkrsrv_util_verbose_set(int p_is_verbose);
62int pkrsrv_util_msleep(long millis);
64int pkrsrv_util_int2str(int number, char* target);
65unsigned char* pkrsrv_util_base64_encode(unsigned char* data, int length);
66unsigned char* pkrsrv_util_base64_decode(unsigned char* data, int length);
67
unsigned char * pkrsrv_util_base64_decode(unsigned char *data, int length)
int pkrsrv_util_msleep(long millis)
void pkrsrv_util_verbose(const char *format,...)
int pkrsrv_util_int2str(int number, char *target)
void pkrsrv_util_assert_fail()
void pkrsrv_util_verbose_set(int p_is_verbose)
unsigned char * pkrsrv_util_base64_encode(unsigned char *data, int length)
uint64_t pkrsrv_util_get_time_msec()