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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
#ifndef SHARED_H
#define SHARED_H
#include <stdint.h>
#include <stdio.h>
#include <sys/stat.h>
#include <pwd.h>
#define ANSCII "\x1b["
#define NEXT ";"
#define RESET "0"
#define BOLD "1"
#define NORMAL "3"
#define BACKGROUND "4"
#define HIGHLIGHT "9"
#define BLACK "0"
#define RED "1"
#define GREEN "2"
#define YELLOW "3"
#define BLUE "4"
#define MAGENTA "5"
#define TURQUOISE "6"
#define WHITE "7"
#define COLOR "m"
typedef uint8_t bool;
#define true 1
#define false 0
#define UNUSED(x) (void)(x)
#define ARG_UNUSED 0
#define ARG_USED 1
#define ARG_IGNORE 2
#define ARG_INVALID 3
void check_arg (char* arg);
void global_help(void (*help)(void));
void parse_help (int argc, char** argv, void (*help)(void));
int parse_args (int argc, char** argv, void (*help)(void), int (*short_arg)(char, char*), int (*long_arg)(char*, char*));
FILE* get_file_s(const char* path, const char* type);
FILE* get_file(const char* path, const char* type);
int get_tty(void);
FILE* get_tty_stream(char* type);
void nuke_str(char* type);
char* get_path_buffer(void);
int push_path_buffer(const char* string);
void pop_path_buffer(int i);
char* get_path_buffer_2(void);
int push_path_buffer_2(const char* string);
void pop_path_buffer_2(int i);
long int get_number(const char* text);
long int get_blkm(const char* text);
mode_t get_mode(const char* text);
bool streql(const char* a, const char* b);
bool prefix(const char* pre, const char* str);
void print_file_size(size_t bytes, char buf[5]);
void print_date_time(time_t mills, char buf[13]);
void print_file_path(char* path);
bool is_dot_dir(const char* path);
const char* get_last_component(const char* path);
void die (void);
__attribute__ ((__format__(printf, 1, 2)))
void error_s(const char* format, ...);
__attribute__ ((__format__(printf, 1, 2)))
void error(const char* format, ...);
__attribute__ ((__format__(printf, 1, 2)))
void output(const char* format, ...);
typedef struct regex_t* re_t;
re_t re_compile(const char* pattern);
int re_matchp(re_t pattern, const char* text, int* matchlength);
int re_match(const char* pattern, const char* text, int* matchlength);
struct Stack {
size_t size;
size_t capacity;
void* data;
};
void stack_init(struct Stack* stack, size_t size);
void stack_push(struct Stack* stack, void* data, size_t len);
void* stack_pop(struct Stack* stack, size_t len);
void stack_free(struct Stack* stack);
void stack_push_int(struct Stack* stack, int value);
bool stack_pop_int(struct Stack* stack, int* value);
#define DEFAULT_SHELL "/bin/sh"
#define DEFAULT_PATH "/sbin:/usr/sbin:/bin:/usr/bin"
void setup_environment(const char *shell, bool new_env, bool clear_env, const struct passwd *pw);
void exec_shell(const char *shell, bool loginshell, const char **additional_args);
int check_password(const struct passwd *pw, char* plaintext);
int prompt_password(const struct passwd *pw, char* prompt);
void change_identity(const struct passwd* pw);
void* xalloc(size_t size);
void* xrealloc(void* ptr, size_t size);
void* xzalloc(size_t size);
void xsetenv(const char *name, const char *value);
void xsetuid(uid_t uid);
void xsetgid(gid_t gid);
struct passwd* xgetpwnam(char* name);
char* crypt(const char* plaintext, const char* pw_pass);
#define PASSWORD_INVALID 0
#define PASSWORD_VALID 1
#define PASSWORD_EMPTY 2
#endif
|