20 #if defined(TUKLIB_DOSLIKE) || defined(__VMS)
21 # define strcmp strcasecmp
33 return c ==
'/' ||
c ==
'\\' ||
c ==
':';
45 return strpbrk(
str,
"/\\:") !=
NULL;
47 return strchr(
str,
'/') !=
NULL;
58 has_sfn_suffix(
const char *
str,
size_t len)
89 const size_t suffix_len = strlen(
suffix);
94 if (src_len <= suffix_len
95 ||
is_dir_sep(src_name[src_len - suffix_len - 1]))
98 if (strcmp(
suffix, src_name + src_len - suffix_len) == 0)
99 return src_len - suffix_len;
112 static const struct {
114 const char *uncompressed;
127 const char *new_suffix =
"";
134 "--suffix=.SUF is required unless "
135 "writing to stdout"), src_name);
143 new_suffix = suffixes[
i].uncompressed;
153 if (new_len == 0 && has_sfn_suffix(src_name, src_len)) {
155 new_len = src_len - 1;
165 "skipping"), src_name);
169 const size_t new_suffix_len = strlen(new_suffix);
170 char *dest_name =
xmalloc(new_len + new_suffix_len + 1);
172 memcpy(dest_name, src_name, new_len);
173 memcpy(dest_name + new_len, new_suffix, new_suffix_len);
174 dest_name[new_len + new_suffix_len] =
'\0';
199 static const char *
const all_suffixes[][4] = {
228 const char *
const *suffixes = all_suffixes[format];
231 for (
size_t i = 0; suffixes[
i] !=
NULL; ++
i) {
259 "--suffix=.SUF is required unless "
260 "writing to stdout"), src_name);
266 size_t suffix_len = strlen(
suffix);
269 if (!_use_lfn(src_name)) {
275 const char *sufsep = strrchr(src_name,
'.');
276 if (sufsep ==
NULL || sufsep[1] ==
'\0'
290 if (sufsep !=
NULL && sufsep[1] ==
'\0'
295 && strcasecmp(sufsep,
".tar") == 0) {
301 static const char *
const tar_suffixes[] = {
306 suffix = tar_suffixes[format];
335 src_len = sufsep - src_name;
354 if (strlen(sufsep) > 4 - suffix_len)
355 src_len = sufsep - src_name
362 char *dest_name =
xmalloc(src_len + suffix_len + 1);
364 memcpy(dest_name, src_name, src_len);
366 dest_name[src_len + suffix_len] =
'\0';
379 const size_t src_len = strlen(src_name);
enum format_type opt_format
enum operation_mode opt_mode
unsigned char suffix[65536]
RZ_API void Ht_() free(HtName_(Ht) *ht)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
char * xstrdup(const char *) ATTRIBUTE_MALLOC
assert(limit<=UINT32_MAX/2)
void message_error(const char *fmt,...)
void message_warning(const char *fmt,...)
void message_fatal(const char *fmt,...)
Common includes, definitions, and prototypes.
static char * compressed_name(const char *src_name, size_t src_len)
Appends suffix to src_name.
static char * custom_suffix
void suffix_set(const char *suffix)
Set a custom filename suffix.
static void msg_suffix(const char *src_name, const char *suffix)
static bool has_dir_sep(const char *str)
Test if the string contains a directory separator.
static size_t test_suffix(const char *suffix, const char *src_name, size_t src_len)
Checks if src_name has given compressed_suffix.
char * suffix_get_dest_name(const char *src_name)
Get the name of the destination file.
static bool is_dir_sep(char c)
Test if the char is a directory separator.
static char * uncompressed_name(const char *src_name, const size_t src_len)
Removes the filename suffix of the compressed file.
static uint8_t compressed[1024]
in[] after compression