1 /* This file is part of GNU tar.
2 Copyright (C) 2007, 2009 Free Software Foundation, Inc.
4 Written by Sergey Poznyakoff.
6 GNU tar is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 3, or (at your option) any later
11 GNU tar is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
14 Public License for more details.
16 You should have received a copy of the GNU General Public License along
17 with GNU tar. If not, see <http://www.gnu.org/licenses/>. */
22 struct compression_suffix
29 struct compression_suffix compression_suffixes
[] = {
30 #define S(s,p) #s, sizeof (#s) - 1, #p
47 int nsuffixes
= sizeof (compression_suffixes
) /
48 sizeof (compression_suffixes
[0]);
51 find_compression_program (const char *name
, const char *defprog
)
53 char *suf
= strrchr (name
, '.');
63 for (i
= 0; i
< nsuffixes
; i
++)
65 if (compression_suffixes
[i
].length
== len
66 && memcmp (compression_suffixes
[i
].suffix
, suf
, len
) == 0)
67 return compression_suffixes
[i
].program
;
74 set_comression_program_by_suffix (const char *name
, const char *defprog
)
76 const char *program
= find_compression_program (name
, defprog
);
78 use_compress_program_option
= program
;