-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheader.h
129 lines (94 loc) · 2.55 KB
/
header.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#ifndef HEADER_H
#define HEADER_H
#include <stdio.h> // printf
#include <stdlib.h>
#include <dirent.h>
#include <sys/stat.h>
#include <pwd.h>
#include <grp.h>
#include <time.h>
#include <sys/xattr.h>
#include <strings.h>
# include <sys/ioctl.h>
#include <unistd.h>
#include "nc_lib.h"
enum Bool{FALSE, TRUE};
#define PATH_MAX 4096
#define RESET "\033[0m"
#define ISDIR(x) ((((fileInfo *)(x)->content)->mode)[0] == 'd')
#define GETBLOCKS(x) ((fileInfo *)(x)->content)->block
#define GETPATH(x) ((fileInfo *)(x)->content)->path
#define GETNAME(x) ((fileInfo *)(x)->content)->name
#define HASNEXT(x) ((fileInfo *)(x)->next)
/* flags */
typedef struct s_flags
{
int a:1;
int l:1;
int r:1;
int t:1;
int R:1;
}flags;
flags g_flag;
/* to split arguments on main */
typedef struct s_seperate_arguments
{
t_list **trash;
t_list **dirs;
t_list **files;
}seperated_arguments;
/* FileInfo struct */
typedef struct s_info
{
char *mode;
char *pname;
char *gname;
char *name;
char *time;
char *path;
char *link;
long long int size;
long long int block;
int nlink;
long seconds;
long nano;
char *color;
}fileInfo;
/* strings */
char *(*makeFileString)(t_list *file);
char *fileLongMake(t_list *file);
char *fileShortMake(t_list *file);
void print(t_list **files);
void printTrash(t_list **files);
/* Sorting */
int byName(void *one, void *two);
int byNameRev(void *one, void *two);
int byTime(void *one, void *two);
int byTimeRev(void *one, void *two);
int stringByName(void *one, void *two);
int (*compare)(void*,void*);
/* deleting */
void delStrings(void *str);
void delFieInfoStruct(void *file);
/* Struct Info creation */
char *getLink(char *path);
/* fileINfo Struct creation */
void *copyFileInfoStruct(fileInfo *old);
fileInfo *makeInfoStruct(char *path, char *name);
/* mode & time */
char *trimTime(char *ctime, long seconds);
char *mode(int num, char **color);
/* path */
char *joinPath(char *s1, char *s2);
/* Walk */
void startWalk(t_list **curent);
void walk(t_list *curent);
/* init */
char **parseArgs(char **args);
void setFunctions(void);
seperated_arguments separateArgs(char **argv);
/* main */
t_list **handleDir(t_list **files);
/* wrapper */
void addToListSorted(t_list **head, void *data);
#endif