Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Main
Synchronet
Commits
75b575f1
Commit
75b575f1
authored
May 12, 2021
by
Rob Swindell
💬
Browse files
Eliminate list_archive_contents()
Do this in JS and use JSON for format instead of .ini.
parent
b3d55fd2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
106 deletions
+0
-106
src/sbbs3/filedat.c
src/sbbs3/filedat.c
+0
-105
src/sbbs3/filedat.h
src/sbbs3/filedat.h
+0
-1
No files found.
src/sbbs3/filedat.c
View file @
75b575f1
...
...
@@ -700,111 +700,6 @@ int archive_type(const char* archive, char* str, size_t size)
return
result
;
}
str_list_t
list_archive_contents
(
const
char
*
filename
,
const
char
*
pattern
,
bool
hash
,
bool
sort
,
char
*
error
,
size_t
maxerrlen
)
{
int
result
;
struct
archive
*
ar
;
struct
archive_entry
*
entry
;
if
((
ar
=
archive_read_new
())
==
NULL
)
{
safe_snprintf
(
error
,
maxerrlen
,
"archive_read_new() returned NULL"
);
return
NULL
;
}
archive_read_support_filter_all
(
ar
);
archive_read_support_format_all
(
ar
);
if
((
result
=
archive_read_open_filename
(
ar
,
filename
,
10240
))
!=
ARCHIVE_OK
)
{
safe_snprintf
(
error
,
maxerrlen
,
"archive_read_open_filename() returned %d: %s"
,
result
,
archive_error_string
(
ar
));
archive_read_free
(
ar
);
return
NULL
;
}
str_list_t
list
=
strListInit
();
if
(
list
==
NULL
)
{
safe_snprintf
(
error
,
maxerrlen
,
"strListInit() returned NULL"
);
archive_read_free
(
ar
);
return
NULL
;
}
while
(
1
)
{
result
=
archive_read_next_header
(
ar
,
&
entry
);
if
(
result
!=
ARCHIVE_OK
)
{
if
(
result
!=
ARCHIVE_EOF
)
{
safe_snprintf
(
error
,
maxerrlen
,
"archive_read_next_header() returned %d: %s"
,
result
,
archive_error_string
(
ar
));
archive_read_free
(
ar
);
strListFree
(
&
list
);
return
NULL
;
}
break
;
}
const
char
*
pathname
=
archive_entry_pathname
(
entry
);
if
(
pathname
==
NULL
)
continue
;
if
(
pattern
!=
NULL
&&
*
pattern
&&
!
wildmatch
(
pathname
,
pattern
,
/* path: */
false
,
/* case-sensitive: */
false
))
continue
;
const
char
*
type
;
switch
(
archive_entry_filetype
(
entry
))
{
case
AE_IFREG
:
type
=
"file"
;
break
;
case
AE_IFLNK
:
type
=
"link"
;
break
;
case
AE_IFDIR
:
type
=
"directory"
;
break
;
default:
continue
;
}
strListAppendFormat
(
&
list
,
"[%s]"
,
pathname
);
strListAppendFormat
(
&
list
,
"type=%s"
,
type
);
strListAppendFormat
(
&
list
,
"size=%"
PRId64
,
archive_entry_size
(
entry
));
strListAppendFormat
(
&
list
,
"time=%"
PRId64
,
archive_entry_mtime
(
entry
));
strListAppendFormat
(
&
list
,
"mode=%d"
,
archive_entry_mode
(
entry
));
strListAppendFormat
(
&
list
,
"format=%s"
,
archive_format_name
(
ar
));
strListAppendFormat
(
&
list
,
"compression=%s"
,
archive_filter_name
(
ar
,
0
));
if
(
hash
&&
archive_entry_filetype
(
entry
)
==
AE_IFREG
)
{
MD5
md5_ctx
;
SHA1_CTX
sha1_ctx
;
uint8_t
md5
[
MD5_DIGEST_SIZE
];
uint8_t
sha1
[
SHA1_DIGEST_SIZE
];
uint32_t
crc32
=
0
;
MD5_open
(
&
md5_ctx
);
SHA1Init
(
&
sha1_ctx
);
const
void
*
buff
;
size_t
size
;
la_int64_t
offset
;
for
(;;)
{
result
=
archive_read_data_block
(
ar
,
&
buff
,
&
size
,
&
offset
);
if
(
result
!=
ARCHIVE_OK
)
break
;
crc32
=
crc32i
(
~
crc32
,
buff
,
size
);
MD5_digest
(
&
md5_ctx
,
buff
,
size
);
SHA1Update
(
&
sha1_ctx
,
buff
,
size
);
}
MD5_close
(
&
md5_ctx
,
md5
);
SHA1Final
(
&
sha1_ctx
,
sha1
);
strListAppendFormat
(
&
list
,
"crc32=0x%lx"
,
crc32
);
char
hex
[
128
];
strListAppendFormat
(
&
list
,
"md5=%s"
,
MD5_hex
(
hex
,
md5
));
strListAppendFormat
(
&
list
,
"sha1=%s"
,
SHA1_hex
(
hex
,
sha1
));
}
}
archive_read_free
(
ar
);
if
(
sort
)
iniSortSections
(
&
list
,
/* sort_keys: */
FALSE
);
return
list
;
}
str_list_t
directory
(
const
char
*
path
)
{
int
flags
=
GLOB_MARK
;
...
...
src/sbbs3/filedat.h
View file @
75b575f1
...
...
@@ -67,7 +67,6 @@ DLLEXPORT int file_sauce_hfields(file_t*, struct sauce_charinfo*);
DLLEXPORT
str_list_t
directory
(
const
char
*
path
);
DLLEXPORT
long
create_archive
(
const
char
*
archive
,
const
char
*
format
,
bool
with_path
,
str_list_t
file_list
,
char
*
error
,
size_t
maxerrlen
);
DLLEXPORT
str_list_t
list_archive_contents
(
const
char
*
archive
,
const
char
*
pattern
,
bool
hash
,
bool
sort
,
char
*
error
,
size_t
maxerrlen
);
DLLEXPORT
char
*
cmdstr
(
scfg_t
*
,
user_t
*
,
const
char
*
instr
,
const
char
*
fpath
,
const
char
*
fspec
,
char
*
cmd
,
size_t
);
DLLEXPORT
long
extract_files_from_archive
(
const
char
*
archive
,
const
char
*
outdir
,
const
char
*
allowed_filename_chars
,
bool
with_path
,
long
max_files
,
str_list_t
file_list
,
char
*
error
,
size_t
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment