-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
156 lines (123 loc) · 3.83 KB
/
Copy pathmain.c
File metadata and controls
156 lines (123 loc) · 3.83 KB
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
/*
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: gofiche [-DepsdolBuh].
[-D] [-e] [-d domain] [-p port] [-s slug size]
[-o output directory] [-B buffer size] [-u user name]
[-l log file] --h usage]
[-g gopher domain]
Use netcat to push text - example:
$ cat fiche.c | nc localhost 9999
-------------------------------------------------------------------------------
*/
#include "fiche.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <getopt.h>
int main(int argc, char **argv) {
// Fiche settings instance
Fiche_Settings fs;
// Initialize settings instance to default values
fiche_init(&fs);
// Note: fiche_run is responsible for checking if these values
// were set correctly
// Note: according to getopt documentation, we don't need to
// copy strings, so we decided to go with pointer approach for these
// Parse input arguments
int c;
while ((c = getopt(argc, argv, "D6eSp:s:d:o:l:B:u:g:h")) != -1) {
switch (c) {
// domain
case 'd':
{
fs.domain = optarg;
}
break;
// port
case 'p':
{
fs.port = atoi(optarg);
}
break;
// slug size
case 's':
{
fs.slug_len = atoi(optarg);
}
break;
// https
case 'S':
{
fs.https = true;
}
break;
// output directory path
case 'o':
{
fs.output_dir_path = optarg;
}
break;
// buffer size
case 'B':
{
fs.buffer_len = atoi(optarg);
}
break;
// user name
case 'u':
{
fs.user_name = optarg;
}
break;
// log file path
case 'l':
{
fs.log_file_path = optarg;
}
break;
// banlist file path
case 'b':
{
fs.banlist_path = optarg;
}
break;
// whitelist file path
case 'w':
{
fs.whitelist_path = optarg;
}
break;
// gopher
case 'g':
{
fs.godomain = optarg;
}
break;
case 'h':
printf("usage: gofiche [-dpsSoBulgh].\n");
printf(" [-d domain] [-p port] [-s slug size]\n");
printf(" [-o output directory] [-B buffer size] [-u user name]\n");
printf(" [-l log file] [-S]\n");
printf(" [-g gopher domain] [-h usage]\n");
return 0;
// Display help in case of any unsupported argument
default:
{
printf("usage: gofiche [-dpsSoBulgh].\n");
printf(" [-d domain] [-p port] [-s slug size]\n");
printf(" [-o output directory] [-B buffer size] [-u user name]\n");
printf(" [-l log file] [-S]\n");
printf(" [-g gopher domain] [-h usage]\n");
return 0;
}
break;
}
}
fiche_run(fs);
return 0;
}