path:
/fiche.h
3.13 KB | plain
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/*
Fiche - Command line pastebin for sharing terminal output.
-------------------------------------------------------------------------------
License: MIT (http://www.opensource.org/licenses/mit-license.php)
Repository: https://github.com/solusipse/fiche/
Live example: http://termbin.com
-------------------------------------------------------------------------------
usage: fiche [-DepbsdolBuw].
[-D] [-e] [-d domain] [-p port] [-s slug size]
[-o output directory] [-B buffer size] [-u user name]
[-l log file] [-b banlist] [-w whitelist]
Use netcat to push text - example:
$ cat fiche.c | nc localhost 9999
-------------------------------------------------------------------------------
*/
#ifndef FICHE_H
#define FICHE_H
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
/**
* @brief Used as a container for fiche settings. Create before
* the initialization
*
*/
typedef struct Fiche_Settings {
/**
* @brief Domain used in output links
*/
char *domain;
/**
* @brief Path to directory used for storing uploaded pastes
*/
char *output_dir_path;
/**
* @brief Address on which fiche is waiting for connections
*/
char *listen_addr;
/**
* @brief Port on which fiche is waiting for connections
*/
uint16_t port;
/**
* @brief Length of a paste's name
*/
uint8_t slug_len;
/**
* @brief If set, returns url with https prefix instead of http
*/
bool https;
/**
* @brief Connection buffer length
*
* @remarks Length of this buffer limits max size of uploaded files
*/
uint32_t buffer_len;
/**
* @brief Name of the user that runs fiche process
*/
char *user_name;
/**
* @brief Path to the log file
*/
char *log_file_path;
/**
* @brief Path to the file with banned IPs
*/
char *banlist_path;
/**
* @brief Path to the file with whitelisted IPs
*/
char *whitelist_path;
} Fiche_Settings;
struct fiche_connection {
char *hostname;
char *ip;
uint8_t* buffer;
size_t buffer_len;
size_t rx_len;
Fiche_Settings *settings;
};
// Logging-related
/**
* @brief Displays error messages
*/
void print_error(const char *format, ...);
/**
* @brief Displays status messages with date
*/
void print_status_with_date(const char *format, ...);
/**
* @brief Displays status messages
*/
void print_status(const char *format, ...);
/**
* @brief Displays horizontal line
*/
void print_separator();
/**
* @brief Saves connection entry to the logfile
*/
void log_entry(const Fiche_Settings *s, const char *ip,
const char *hostname, const char *slug);
/**
* @brief Initializes Fiche_Settings instance
*/
void fiche_init(Fiche_Settings *settings);
/**
* @brief Runs fiche server
*
* @return 0 if it was able to start, any other value otherwise
*/
int fiche_run(Fiche_Settings settings);
/**
* @brief array of symbols used in slug generation
* @remarks defined in fiche.c
*/
extern const char *Fiche_Symbols;
void post_handle_connection(struct fiche_connection* c);
#endif