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/>.
21 void print_errno_and_exit(int last_errno
, char *file
, int line
)
23 char *message_format
= "%s (%s:%i)";
27 message
= g_strdup_printf(message_format
, program_name
, file
, line
);
34 void handle_sigsegv(int signal_number
)
37 fprintf(stderr
, "%s\n", g_strsignal(SIGSEGV
));
41 void handle_sigint(int signal_number
)
47 void set_sighandlers(void)
51 act
.sa_handler
= handle_sigsegv
;
52 sigemptyset(&act
.sa_mask
);
54 sigaction(SIGSEGV
, &act
, NULL
);
56 act
.sa_handler
= handle_sigint
;
57 sigaction(SIGINT
, &act
, NULL
);
59 act
.sa_handler
= handle_sigwinch
;
60 sigaction(SIGWINCH
, &act
, NULL
);
63 void unset_sighandlers(void)
67 act
.sa_handler
= SIG_IGN
;
68 sigemptyset(&act
.sa_mask
);
71 sigaction(SIGSEGV
, &act
, NULL
);
72 sigaction(SIGINT
, &act
, NULL
);
73 sigaction(SIGWINCH
, &act
, NULL
);
76 int main(int argc
, char *argv
[])
78 if (argc
> 1 && !strcmp(argv
[1], "-h")) {
79 printf("Usage: fm [<root_directory>]\n");
83 if (setlocale(LC_ALL
, "") == NULL
)
84 fprintf(stderr
, "Error: Can't set the specified locale\n");
87 program_name
= argv
[0];
This page took 0.297991 seconds and 4 git commands to generate.