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 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14 * implied. See the License for the specific language governing
15 * permissions and limitations under the License.
16 *
17 * SPDX-License-Identifier: Apache-2.0
18 */
19
28#include "nilorea.h"
29
30int main(void) {
32
33 N_STR* nstr = NULL;
34
35 printf("str:%s\n", _nstr(nstr));
36
37 nstrprintf(nstr, "Hello, file is %s line %d date %s", __FILE__, __LINE__, __TIME__);
38
39 printf("str:%s\n", _nstr(nstr));
40
41 nstrprintf_cat(nstr, " - This will be added at file %s line %d date %s", __FILE__, __LINE__, __TIME__);
42
43 printf("str:%s\n", _nstr(nstr));
44
45 free_nstr(&nstr);
46
47 nstr = new_nstr(1024);
48
49 printf("str:%s\n", _nstr(nstr));
50
51 nstrprintf(nstr, "Hello, file is %s line %d date %s", __FILE__, __LINE__, __TIME__);
52
53 printf("str:%s\n", _nstr(nstr));
54
55 nstrprintf_cat(nstr, " - This will be added at file %s line %d date %s", __FILE__, __LINE__, __TIME__);
56
57 printf("str:%s\n", _nstr(nstr));
58
59 nstrprintf_cat(nstr, " - some more texte");
60
61 N_STR* nstr2 = nstrdup(nstr);
62
63 printf("str: %s\n str2: %s\n", _nstr(nstr), _nstr(nstr2));
64
65 N_STR* nstr3 = NULL;
66
67 nstrcat(nstr3, nstr);
68 nstrcat(nstr3, nstr2);
69
70 printf("str:%s\n", _nstr(nstr3));
71
72 free_nstr(&nstr3);
73 nstr3 = new_nstr(10);
74
75 nstrcat(nstr3, nstr);
76 nstrcat(nstr3, nstr2);
77
78 printf("str:%s\n", _nstr(nstr3));
79
80 free_nstr(&nstr);
81 free_nstr(&nstr2);
82 free_nstr(&nstr3);
83
84 exit(0);
85}
int main(void)
#define _nstr(__PTR)
N_STR or "NULL" string for logging purposes.
Definition n_common.h:199
#define LOG_DEBUG
debug-level messages
Definition n_log.h:84
void set_log_level(const int log_level)
Set the global log level value ( static int LOG_LEVEL )
Definition n_log.c:121
#define free_nstr(__ptr)
free a N_STR structure and set the pointer to NULL
Definition n_str.h:203
#define nstrcat(__nstr_dst, __nstr_src)
Macro to quickly concatenate two N_STR.
Definition n_str.h:125
N_STR * nstrdup(N_STR *str)
Duplicate a N_STR.
Definition n_str.c:716
#define nstrprintf_cat(__nstr_var, __format,...)
Macro to quickly allocate and sprintf and cat to a N_STR.
Definition n_str.h:121
N_STR * new_nstr(NSTRBYTE size)
create a new N_STR string
Definition n_str.c:207
#define nstrprintf(__nstr_var, __format,...)
Macro to quickly allocate and sprintf to N_STR.
Definition n_str.h:117
A box including a string and his lenght.
Definition n_str.h:61
Header for a monolith use.