1 /* Copyright (C) 2008 Ricardo Catalinas Jiménez <jimenezrick@gmail.com>
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
27 destroy_directory_content(tree_root
);
28 free_node_data(tree_root
, NULL
);
29 g_node_destroy(tree_root
);
32 void print_errno_and_exit(int last_errno
, char *file
, int line
)
34 char *message_format
= "%s (%s:%i)";
38 message
= g_strdup_printf(message_format
, program_name
, file
, line
);
45 void handle_sigsegv(int signal_number
)
48 fprintf(stderr
, "%s\n", g_strsignal(SIGSEGV
));
52 void handle_sigint(int signal_number
)
58 void set_sighandlers(void)
62 act
.sa_handler
= handle_sigsegv
;
63 sigemptyset(&act
.sa_mask
);
65 sigaction(SIGSEGV
, &act
, NULL
);
67 act
.sa_handler
= handle_sigint
;
68 sigaction(SIGINT
, &act
, NULL
);
70 act
.sa_handler
= handle_sigwinch
;
71 sigaction(SIGWINCH
, &act
, NULL
);
74 void unset_sighandlers(void)
78 act
.sa_handler
= SIG_IGN
;
79 sigemptyset(&act
.sa_mask
);
82 sigaction(SIGSEGV
, &act
, NULL
);
83 sigaction(SIGINT
, &act
, NULL
);
84 sigaction(SIGWINCH
, &act
, NULL
);
87 void print_usage(void)
89 printf("Usage: %s [-h|-d] [<tree_root>]\n", program_name
);
90 printf("The root of the displayed tree is `tree_root'.\n");
91 printf("\t-h: show this help\n\t-d: print on stderr inotify events debug info\n");
94 int main(int argc
, char *argv
[])
96 program_name
= argv
[0];
97 if (argc
> 1 && !strcmp(argv
[1], "-h")) {
100 } else if ((argc
== 2 || argc
== 3) && !strcmp(argv
[1], "-d")) {
102 debug_inotify
= TRUE
;
104 } else if ((argc
> 3 && !strcmp(argv
[1], "-d")) || argc
> 2) {
105 fprintf(stderr
, "%s: invalid option\n", program_name
);
109 if (setlocale(LC_ALL
, "") == NULL
)
110 fprintf(stderr
, "Error: Can't set the specified locale\n");
115 else if (argc
== 2 && !strcmp(argv
[1], "-d"))
This page took 0.339619 seconds and 4 git commands to generate.