Introduction
Introduction Statistics Contact Development Disclaimer Help
main.c - fiche - A pastebin adjusted for gopher use
git clone git://vernunftzentrum.de/fiche.git
Log
Files
Refs
LICENSE
---
main.c (3314B)
---
1 /*
2 Fiche - Command line pastebin for sharing terminal output.
3
4 ------------------------------------------------------------------------…
5
6 License: MIT (http://www.opensource.org/licenses/mit-license.php)
7 Repository: https://github.com/solusipse/fiche/
8 Live example: http://termbin.com
9
10 ------------------------------------------------------------------------…
11
12 usage: fiche [-DepbsdolBuw].
13 [-D] [-e] [-d domain] [-p port] [-s slug size]
14 [-o output directory] [-B buffer size] [-u user name]
15 [-l log file] [-b banlist] [-w whitelist]
16
17 Use netcat to push text - example:
18 $ cat fiche.c | nc localhost 9999
19
20 ------------------------------------------------------------------------…
21 */
22
23 #include "fiche.h"
24
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <unistd.h>
28 #include <getopt.h>
29
30
31 int main(int argc, char **argv) {
32
33 // Fiche settings instance
34 Fiche_Settings fs;
35
36 // Initialize settings instance to default values
37 fiche_init(&fs);
38
39 // Note: fiche_run is responsible for checking if these values
40 // were set correctly
41
42 // Note: according to getopt documentation, we don't need to
43 // copy strings, so we decided to go with pointer approach for these
44
45 // Parse input arguments
46 int c;
47 while ((c = getopt(argc, argv, "D6ep:b:s:d:o:P:l:B:u:w:")) != -1) {
48 switch (c) {
49
50 // domain
51 case 'd':
52 {
53 fs.domain = optarg;
54 }
55 break;
56
57 // port
58 case 'p':
59 {
60 fs.port = atoi(optarg);
61 }
62 break;
63
64 // slug size
65 case 's':
66 {
67 fs.slug_len = atoi(optarg);
68 }
69 break;
70
71 // custom protocol prefix
72 case 'P':
73 {
74 fs.prefix = optarg;
75 }
76 break;
77
78 // output directory path
79 case 'o':
80 {
81 fs.output_dir_path = optarg;
82 }
83 break;
84
85 // buffer size
86 case 'B':
87 {
88 fs.buffer_len = atoi(optarg);
89 }
90 break;
91
92 // user name
93 case 'u':
94 {
95 fs.user_name = optarg;
96 }
97 break;
98
99 // log file path
100 case 'l':
101 {
102 fs.log_file_path = optarg;
103 }
104 break;
105
106 // banlist file path
107 case 'b':
108 {
109 fs.banlist_path = optarg;
110 }
111 break;
112
113 // whitelist file path
114 case 'w':
115 {
116 fs.whitelist_path = optarg;
117 }
118 break;
119
120 // Display help in case of any unsupported argument
121 default:
122 {
123 printf("usage: fiche [-dpsSoBulbw].\n");
124 printf(" [-d domain] [-p port] [-P protocol]…
125 printf(" [-o output directory] [-B buffer si…
126 printf(" [-l log file] [-b banlist] [-w whit…
127 return 0;
128 }
129 break;
130 }
131 }
132
133 return fiche_run(fs);
134 }
135
136
You are viewing proxied material from vernunftzentrum.de. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.