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
77027966
Commit
77027966
authored
21 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Created the "smbutil d" command to delete all msgs in a msgbase (without
effecting message numbering, pointer files, etc.).
parent
2d155112
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sbbs3/smbutil.c
+69
-11
69 additions, 11 deletions
src/sbbs3/smbutil.c
with
69 additions
and
11 deletions
src/sbbs3/smbutil.c
+
69
−
11
View file @
77027966
...
...
@@ -35,7 +35,7 @@
* Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/
#define SMBUTIL_VER "2.3
2
"
#define SMBUTIL_VER "2.3
3
"
char
revision
[
16
];
char
compiler
[
32
];
...
...
@@ -76,6 +76,8 @@ char compiler[32];
/* gets is dangerous */
#define gets(str) fgets((str), sizeof(str), stdin)
#define CHSIZE_FP(fp,size) if(chsize(fileno(fp),size)) printf("chsize failed!\n");
/********************/
/* Global variables */
/********************/
...
...
@@ -100,6 +102,7 @@ char *usage=
" n[f] = import netmail from text file f (or use stdin)
\n
"
" s = display msg base status
\n
"
" c = change msg base status
\n
"
" d = delete all msgs
\n
"
" m = maintain msg base - delete old msgs and msgs over max
\n
"
" p[k] = pack msg base (k specifies minimum packable Kbytes)
\n
"
"opts:
\n
"
...
...
@@ -821,8 +824,7 @@ void maint(void)
printf
(
"Re-writing index...
\n
"
);
rewind
(
smb
.
sid_fp
);
if
(
chsize
(
fileno
(
smb
.
sid_fp
),
0L
))
printf
(
"chsize failed!
\n
"
);
CHSIZE_FP
(
smb
.
sid_fp
,
0
);
for
(
m
=
n
=
0
;
m
<
l
;
m
++
)
{
if
(
idx
[
m
].
attr
&
MSG_DELETE
)
continue
;
...
...
@@ -890,16 +892,16 @@ void packmsgs(ulong packable)
if
(
!
smb
.
status
.
total_msgs
)
{
printf
(
"Empty
\n
"
);
rewind
(
smb
.
shd_fp
);
chsize
(
fileno
(
smb
.
shd_fp
)
,
smb
.
status
.
header_offset
);
CHSIZE_FP
(
smb
.
shd_fp
,
smb
.
status
.
header_offset
);
rewind
(
smb
.
sdt_fp
);
chsize
(
fileno
(
smb
.
sdt_fp
)
,
0
L
);
CHSIZE_FP
(
smb
.
sdt_fp
,
0
);
rewind
(
smb
.
sid_fp
);
chsize
(
fileno
(
smb
.
sid_fp
)
,
0
L
);
CHSIZE_FP
(
smb
.
sid_fp
,
0
);
if
(
!
(
smb
.
status
.
attr
&
SMB_HYPERALLOC
))
{
rewind
(
smb
.
sha_fp
);
chsize
(
fileno
(
smb
.
sha_fp
)
,
0
L
);
CHSIZE_FP
(
smb
.
sha_fp
,
0
);
rewind
(
smb
.
sda_fp
);
chsize
(
fileno
(
smb
.
sda_fp
)
,
0
L
);
CHSIZE_FP
(
smb
.
sda_fp
,
0
);
smb_close_ha
(
&
smb
);
smb_close_da
(
&
smb
);
}
...
...
@@ -960,9 +962,9 @@ void packmsgs(ulong packable)
if
(
!
(
smb
.
status
.
attr
&
SMB_HYPERALLOC
))
{
rewind
(
smb
.
sha_fp
);
chsize
(
fileno
(
smb
.
sha_fp
)
,
0
L
);
/* Reset both allocation tables */
CHSIZE_FP
(
smb
.
sha_fp
,
0
);
/* Reset both allocation tables */
rewind
(
smb
.
sda_fp
);
chsize
(
fileno
(
smb
.
sda_fp
)
,
0
L
);
CHSIZE_FP
(
smb
.
sda_fp
,
0
);
}
if
(
smb
.
status
.
attr
&
SMB_HYPERALLOC
&&
!
(
mode
&
NOANALYSIS
))
{
...
...
@@ -1242,6 +1244,54 @@ void packmsgs(ulong packable)
printf
(
"
\n
Done.
\n\n
"
);
}
void
delmsgs
(
void
)
{
int
i
;
printf
(
"Deleting %s
\n
"
,
smb
.
file
);
i
=
smb_locksmbhdr
(
&
smb
);
if
(
i
)
{
fprintf
(
stderr
,
"
\n\7
!smb_locksmbhdr returned %d: %s
\n
"
,
i
,
smb
.
last_error
);
return
;
}
i
=
smb_getstatus
(
&
smb
);
if
(
i
)
{
smb_unlocksmbhdr
(
&
smb
);
fprintf
(
stderr
,
"
\n\7
!smb_getstatus returned %d: %s
\n
"
,
i
,
smb
.
last_error
);
return
;
}
if
(
!
(
smb
.
status
.
attr
&
SMB_HYPERALLOC
))
{
i
=
smb_open_da
(
&
smb
);
if
(
i
)
{
smb_unlocksmbhdr
(
&
smb
);
fprintf
(
stderr
,
"
\n\7
!smb_open_da returned %d: %s
\n
"
,
i
,
smb
.
last_error
);
exit
(
1
);
}
i
=
smb_open_ha
(
&
smb
);
if
(
i
)
{
smb_unlocksmbhdr
(
&
smb
);
fprintf
(
stderr
,
"
\n\7
!smb_open_ha returned %d: %s
\n
"
,
i
,
smb
.
last_error
);
exit
(
1
);
}
/* Reset both allocation tables */
CHSIZE_FP
(
smb
.
sha_fp
,
0
);
CHSIZE_FP
(
smb
.
sda_fp
,
0
);
smb_close_ha
(
&
smb
);
smb_close_da
(
&
smb
);
}
CHSIZE_FP
(
smb
.
sid_fp
,
0
);
CHSIZE_FP
(
smb
.
shd_fp
,
smb
.
status
.
header_offset
);
CHSIZE_FP
(
smb
.
sdt_fp
,
0
);
/* re-write status header */
smb
.
status
.
total_msgs
=
0
;
if
((
i
=
smb_putstatus
(
&
smb
))
!=
0
)
fprintf
(
stderr
,
"
\n\7
!smb_putstatus returned %d: %s
\n
"
,
i
,
smb
.
last_error
);
smb_unlocksmbhdr
(
&
smb
);
printf
(
"
\n
Done.
\n\n
"
);
}
/****************************************************************************/
/* Read messages in message base */
...
...
@@ -1566,11 +1616,19 @@ int main(int argc, char **argv)
y
=
strlen
(
cmd
)
-
1
;
break
;
case
'P'
:
case
'D'
:
if
((
i
=
smb_lock
(
&
smb
))
!=
0
)
{
fprintf
(
stderr
,
"
\n\7
!smb_lock returned %d: %s
\n
"
,
i
,
smb
.
last_error
);
return
(
i
);
}
packmsgs
(
atol
(
cmd
+
y
+
1
));
switch
(
toupper
(
cmd
[
y
]))
{
case
'P'
:
packmsgs
(
atol
(
cmd
+
y
+
1
));
break
;
case
'D'
:
delmsgs
();
break
;
}
smb_unlock
(
&
smb
);
y
=
strlen
(
cmd
)
-
1
;
break
;
...
...
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