Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
* info_display_nline.c
*
* Copyright (c) 2018-2021 Eric Vidal <eric@obarun.org>
*
* All rights reserved.
*
* This file is part of Obarun. It is subject to the license terms in
* the LICENSE file found in the top-level directory of this
* distribution.
* This file may not be copied, modified, propagated, or distributed
* except according to the terms contained in the LICENSE file./
* */
#include <string.h>
#include <oblibs/log.h>
#include <oblibs/string.h>
#include <oblibs/sastr.h>
#include <skalibs/stralloc.h>
#include <skalibs/lolstdio.h>
#include <66/info.h>
void info_display_nline(char const *field,char const *str)
{
log_flow() ;
size_t pos = 0, padding = info_length_from_wchar(field) + 1, len ;
stralloc sa = STRALLOC_ZERO ;
if (!auto_stra(&sa, str))
log_die_nomem("stralloc") ;
if (!sastr_split_string_in_nline(&sa))
log_dieu(LOG_EXIT_SYS,"split string in nline") ;
len = sa.len ;
char tmp[sa.len + 1] ;
sastr_to_char(tmp, &sa) ;
for (;pos < len ; pos += strlen(tmp + pos) + 1) {
sa.len = 0 ;
if (!auto_stra(&sa,tmp + pos))
log_die_nomem("stralloc") ;
if (field) {
if (pos) {
if (!bprintf(buffer_1,"%*s",padding,""))
log_dieusys(LOG_EXIT_SYS,"write to stdout") ;
}
}
info_display_list(field,&sa) ;
}
stralloc_free(&sa) ;
}