Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
ex_monolith.c
Go to the documentation of this file.
1/*
2 * Nilorea Library
3 * Copyright (C) 2005-2026 Castagnier Mickael
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
27#include "nilorea.h"
28
29int main(void) {
31
32 N_STR* nstr = NULL;
33
34 printf("str:%s\n", _nstr(nstr));
35
36 nstrprintf(nstr, "Hello, file is %s line %d date %s", __FILE__, __LINE__, __TIME__);
37
38 printf("str:%s\n", _nstr(nstr));
39
40 nstrprintf_cat(nstr, " - This will be added at file %s line %d date %s", __FILE__, __LINE__, __TIME__);
41
42 printf("str:%s\n", _nstr(nstr));
43
44 free_nstr(&nstr);
45
46 nstr = new_nstr(1024);
47
48 printf("str:%s\n", _nstr(nstr));
49
50 nstrprintf(nstr, "Hello, file is %s line %d date %s", __FILE__, __LINE__, __TIME__);
51
52 printf("str:%s\n", _nstr(nstr));
53
54 nstrprintf_cat(nstr, " - This will be added at file %s line %d date %s", __FILE__, __LINE__, __TIME__);
55
56 printf("str:%s\n", _nstr(nstr));
57
58 nstrprintf_cat(nstr, " - some more texte");
59
60 N_STR* nstr2 = nstrdup(nstr);
61
62 printf("str: %s\n str2: %s\n", _nstr(nstr), _nstr(nstr2));
63
64 N_STR* nstr3 = NULL;
65
66 nstrcat(nstr3, nstr);
67 nstrcat(nstr3, nstr2);
68
69 printf("str:%s\n", _nstr(nstr3));
70
71 free_nstr(&nstr3);
72 nstr3 = new_nstr(10);
73
74 nstrcat(nstr3, nstr);
75 nstrcat(nstr3, nstr2);
76
77 printf("str:%s\n", _nstr(nstr3));
78
79 free_nstr(&nstr);
80 free_nstr(&nstr2);
81 free_nstr(&nstr3);
82
83 exit(0);
84}
int main(void)
#define _nstr(__PTR)
N_STR or "NULL" string for logging purposes.
Definition n_common.h:198
#define LOG_DEBUG
debug-level messages
Definition n_log.h:83
void set_log_level(const int log_level)
Set the global log level value ( static int LOG_LEVEL )
Definition n_log.c:120
#define free_nstr(__ptr)
free a N_STR structure and set the pointer to NULL
Definition n_str.h:201
#define nstrcat(__nstr_dst, __nstr_src)
Macro to quickly concatenate two N_STR.
Definition n_str.h:123
N_STR * nstrdup(N_STR *str)
Duplicate a N_STR.
Definition n_str.c:708
#define nstrprintf_cat(__nstr_var, __format,...)
Macro to quickly allocate and sprintf and cat to a N_STR.
Definition n_str.h:119
N_STR * new_nstr(NSTRBYTE size)
create a new N_STR string
Definition n_str.c:206
#define nstrprintf(__nstr_var, __format,...)
Macro to quickly allocate and sprintf to N_STR.
Definition n_str.h:115
A box including a string and his lenght.
Definition n_str.h:60
Header for a monolith use.