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
140a364e
Commit
140a364e
authored
9 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Created smb_getmsgidx_by_time(), derived from sbbs_t::getmsgnum().
parent
83cd7103
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/smblib/smbdefs.h
+2
-2
2 additions, 2 deletions
src/smblib/smbdefs.h
src/smblib/smblib.c
+57
-0
57 additions, 0 deletions
src/smblib/smblib.c
src/smblib/smblib.h
+1
-0
1 addition, 0 deletions
src/smblib/smblib.h
with
60 additions
and
2 deletions
src/smblib/smbdefs.h
+
2
−
2
View file @
140a364e
...
...
@@ -627,7 +627,7 @@ typedef struct { /* Message */
}
smbmsg_t
;
typedef
struct
{
/* Message base */
typedef
struct
{
/* Message base */
char
file
[
128
];
/* Path and base filename (no extension) */
FILE
*
sdt_fp
;
/* File pointer for data (.sdt) file */
...
...
@@ -638,7 +638,7 @@ typedef struct { /* Message base */
FILE
*
hash_fp
;
/* File pointer for hash (.hash) file */
uint32_t
retry_time
;
/* Maximum number of seconds to retry opens/locks */
uint32_t
retry_delay
;
/* Time-slice yield (milliseconds) while retrying */
smbstatus_t
status
;
/* Status header record */
smbstatus_t
status
;
/* Status header record */
BOOL
locked
;
/* SMB header is locked */
char
last_error
[
MAX_PATH
*
2
];
/* Last error message */
...
...
This diff is collapsed.
Click to expand it.
src/smblib/smblib.c
+
57
−
0
View file @
140a364e
...
...
@@ -648,6 +648,63 @@ int SMBCALL smb_getlastidx(smb_t* smb, idxrec_t *idx)
return
(
SMB_SUCCESS
);
}
/****************************************************************************/
/* Finds index of last message imported at or after specified time */
/****************************************************************************/
int
SMBCALL
smb_getmsgidx_by_time
(
smb_t
*
smb
,
idxrec_t
*
idx
,
time_t
t
)
{
int
i
;
ulong
l
,
total
,
bot
,
top
;
if
(
idx
==
NULL
)
return
SMB_FAILURE
;
memset
(
idx
,
0
,
sizeof
(
idxrec_t
));
if
(
t
<=
0
)
return
SMB_FAILURE
;
total
=
filelength
(
fileno
(
smb
->
sid_fp
))
/
sizeof
(
idxrec_t
);
if
(
!
total
)
/* Empty base */
return
SMB_ERR_NOT_FOUND
;
if
((
i
=
smb_locksmbhdr
(
smb
))
!=
SMB_SUCCESS
)
return
i
;
if
((
i
=
smb_getlastidx
(
smb
,
idx
))
!=
SMB_SUCCESS
)
{
smb_unlocksmbhdr
(
smb
);
return
i
;
}
if
((
time_t
)
idx
->
time
>
t
)
{
bot
=
0
;
top
=
total
;
l
=
total
/
2
;
/* Start at middle index */
clearerr
(
smb
->
sid_fp
);
while
(
1
)
{
fseek
(
smb
->
sid_fp
,
l
*
sizeof
(
idxrec_t
),
SEEK_SET
);
if
(
!
fread
(
idx
,
sizeof
(
idxrec_t
),
1
,
smb
->
sid_fp
))
break
;
if
(
bot
==
top
-
1
)
break
;
if
((
time_t
)
idx
->
time
>
t
)
{
top
=
l
;
l
=
bot
+
((
top
-
bot
)
/
2
);
continue
;
}
if
((
time_t
)
idx
->
time
<
t
)
{
bot
=
l
;
l
=
top
-
((
top
-
bot
)
/
2
);
continue
;
}
break
;
}
}
smb_unlocksmbhdr
(
smb
);
return
SMB_SUCCESS
;
}
/****************************************************************************/
/* Figures out the total length of the header record for 'msg' */
/* Returns length */
...
...
This diff is collapsed.
Click to expand it.
src/smblib/smblib.h
+
1
−
0
View file @
140a364e
...
...
@@ -190,6 +190,7 @@ SMBEXPORT int SMBCALL smb_addhashes(smb_t* smb, hash_t** hash_list, BOOL skip_m
SMBEXPORT
uint16_t
SMBCALL
smb_name_crc
(
const
char
*
name
);
SMBEXPORT
uint16_t
SMBCALL
smb_subject_crc
(
const
char
*
subj
);
SMBEXPORT
void
SMBCALL
smb_freehashes
(
hash_t
**
);
SMBEXPORT
int
SMBCALL
smb_getmsgidx_by_time
(
smb_t
*
,
idxrec_t
*
,
time_t
);
/* Fast look-up functions (using hashes) */
SMBEXPORT
int
SMBCALL
smb_getmsgidx_by_hash
(
smb_t
*
smb
,
smbmsg_t
*
msg
,
unsigned
source
...
...
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