-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_ls.h
94 lines (78 loc) · 2.82 KB
/
ft_ls.h
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_ls.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: alischyn <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/24 13:09:42 by alischyn #+# #+# */
/* Updated: 2017/03/29 18:25:51 by alischyn ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef __FT_LS_H
# define __FT_LS_H
# include <sys/stat.h>
# include <sys/xattr.h>
# include <pwd.h>
# include <grp.h>
# include <stdbool.h>
# include <string.h>
# include <time.h>
# include "ft_printf.h"
# include "vec.h"
# define PROGNAME "ft_ls"
# define IS_PARAM(c) (c == 'a' || c == 'l' || c == 'r' || c == 'R' || c == 't')
typedef struct s_fileinfo
{
struct stat stat;
struct passwd *pwd;
struct group *grp;
char xattr[4096];
char name[256];
char fullname[512];
char lnk_dest[256];
char fmt_perms[16];
char fmt_nlinks[8];
int fmt_nlinks_pad;
char fmt_owner_name[32];
int fmt_owner_name_pad;
char fmt_owner_group[32];
int fmt_owner_group_pad;
char fmt_size[16];
int fmt_size_pad;
char fmt_mtime[24];
char fmt_name[512];
} t_fileinfo;
typedef struct s_list
{
char path[512];
bool print_path;
t_fileinfo fileinfo;
t_vec items;
int nblocks;
} t_list;
bool g_params[256];
void arg_error(char chr);
void arg_parse(int argc,
char *argv[],
char *(*args[]));
bool fileinfo_get(t_fileinfo *fi, const char *filename, bool single);
void fileinfo_format(t_fileinfo *fi);
void fileinfo_format_perms(t_fileinfo *fi);
void fileinfo_format_nlinks(t_fileinfo *fi);
void fileinfo_format_owner_name(t_fileinfo *fi);
void fileinfo_format_owner_group(t_fileinfo *fi);
void fileinfo_format_size(t_fileinfo *fi);
void fileinfo_format_mtime(t_fileinfo *fi);
void fileinfo_format_name(t_fileinfo *fi);
void ls_count_blocks(t_list *list);
void ls_pre_main(t_vec *list);
void ls_main_singles(t_fileinfo **fi, int count);
void ls_main_dirs(t_fileinfo **fi, int count, bool x);
void ls_print_list(t_list *list, bool no_total);
void ls_print_list_prepare_nlinks_pad(t_list *list);
void ls_print_list_prepare_owner_name_pad(t_list *list);
void ls_print_list_prepare_owner_group_pad(t_list *list);
void ls_print_list_prepare_size_pad(t_list *list);
void ls_sort(t_vec *vec);
#endif