Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
db4cdac2
Commit
db4cdac2
authored
3 years ago
by
Rob Swindell
Browse files
Options
Downloads
Patches
Plain Diff
Eliminate list_archive_contents()
Do this in JS and use JSON for format instead of .ini.
parent
8fb39fdb
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/sbbs3/filedat.c
+0
-105
0 additions, 105 deletions
src/sbbs3/filedat.c
src/sbbs3/filedat.h
+0
-1
0 additions, 1 deletion
src/sbbs3/filedat.h
with
0 additions
and
106 deletions
src/sbbs3/filedat.c
+
0
−
105
View file @
db4cdac2
...
...
@@ -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
;
...
...
This diff is collapsed.
Click to expand it.
src/sbbs3/filedat.h
+
0
−
1
View file @
db4cdac2
...
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment