"Fossies" - the Fresh Open Source Software Archive 
Member "netbiff-0.9.18/netbiff.c" (5 Aug 2004, 1619 Bytes) of package /linux/privat/old/netbiff-0.9.18.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
1 #include <stdio.h>
2 #include <string.h>
3
4 #ifdef HAVE_GETOPT_H
5 #include <getopt.h>
6 #endif
7
8 #include "child.h"
9 #include "conf.h"
10 #include "connection.h"
11 #include "defaults.h"
12 #include "gui.h"
13 #include "home.h"
14 #include "proto.h"
15 #include "xlib.h"
16
17 static void printhelp(FILE *out) {
18 fprintf(out, "Usage: netbiff [options]\n");
19 fprintf(out, "\t-c, --conf\tSpecify configuration file "
20 "(default: ~/.netbiffrc)\n");
21 fprintf(out, "\t-g, --gui\tSpecify the interface to use\n");
22 fprintf(out, "\t-h, --help\tThis screen\n");
23 }
24
25 int main(int argc, char **argv) {
26 int ch;
27 char *conf_dir = NULL;
28 char *gui_name = NULL;
29
30 child_ignore();
31
32 while((ch = getopt(argc, argv, "hc:g:")) != -1) {
33 switch(ch) {
34 case 'h': printhelp(stdout); exit(0);
35 case 'c': conf_dir = xstrdup(optarg); break;
36 case 'g': gui_name = optarg; break;
37 case '?': printhelp(stderr); exit(1);
38 }
39 }
40 argv += optind - 1;
41 argc -= optind - 1;
42
43 if(gui_init(&argc, &argv, gui_name) < 0)
44 xdie("unable to init interface");
45
46 if(!conf_dir) {
47 const char* home;
48
49 home = find_home();
50 if(!home)
51 xdie("Unable to locate home directory");
52
53 conf_dir = xmalloc(strlen(DEFAULT_CONF_DIR) + strlen(home) + 2);
54 strcpy(conf_dir, home);
55 strcat(conf_dir, "/");
56 strcat(conf_dir, DEFAULT_CONF_DIR);
57 }
58
59 conf_set_base(conf_dir);
60 free(conf_dir);
61
62 if(conf_read_options() < 0 ||
63 conf_read_actions() < 0 ||
64 conf_read_connections() < 0)
65 xdie("unable to read configuration");
66
67 gui.register_connections();
68
69 proto_do_retries();
70
71 gui.event_loop();
72
73 return 0;
74 }