Skip to content
Snippets Groups Projects
Commit 6b6aaa69 authored by rswindell's avatar rswindell
Browse files

Created smb_init_idx() which initializes the idx record in an smbmsg_t (to be

used by smb_addmsg() and other higher level functions).
parent 26f99bfe
Branches
Tags
No related merge requests found
...@@ -330,11 +330,14 @@ int SMBCALL smb_getmsghdr_by_hash(smb_t* smb, smbmsg_t* msg, unsigned source ...@@ -330,11 +330,14 @@ int SMBCALL smb_getmsghdr_by_hash(smb_t* smb, smbmsg_t* msg, unsigned source
return(retval); return(retval);
} }
ushort SMBCALL smb_subject_crc(const char *subj) ushort SMBCALL smb_subject_crc(const char* subj)
{ {
char* str; char* str;
ushort crc; ushort crc;
if(subj==NULL)
return(0xffff);
while(!strnicmp(subj,"RE:",3)) { while(!strnicmp(subj,"RE:",3)) {
subj+=3; subj+=3;
while(*subj==' ') while(*subj==' ')
...@@ -350,3 +353,41 @@ ushort SMBCALL smb_subject_crc(const char *subj) ...@@ -350,3 +353,41 @@ ushort SMBCALL smb_subject_crc(const char *subj)
return(crc); return(crc);
} }
ushort SMBCALL smb_name_crc(const char* name)
{
char* str;
ushort crc;
if(name==NULL)
return(0xffff);
if((str=strdup(name))==NULL)
return(0xffff);
strlwr(str);
crc=crc16(str,0 /* auto-length */);
free(str);
return(crc);
}
int SMBCALL smb_init_idx(smb_t* smb, smbmsg_t* msg)
{
msg->idx.subj=smb_subject_crc(msg->subj);
if(smb->status.attr&SMB_EMAIL) {
if(msg->to_ext)
msg->idx.to=atoi(msg->to_ext);
else
msg->idx.to=0;
if(msg->from_ext)
msg->idx.from=atoi(msg->from_ext);
else
msg->idx.from=0;
} else {
msg->idx.to=smb_name_crc(msg->to);
msg->idx.from=smb_name_crc(msg->from);
}
return(SMB_SUCCESS);
}
...@@ -181,7 +181,9 @@ SMBEXPORT hash_t* SMBCALL smb_hashstr(ulong msgnum, ulong time, unsigned source ...@@ -181,7 +181,9 @@ SMBEXPORT hash_t* SMBCALL smb_hashstr(ulong msgnum, ulong time, unsigned source
SMBEXPORT hash_t** SMBCALL smb_msghashes(smbmsg_t* msg, const uchar* text); SMBEXPORT hash_t** SMBCALL smb_msghashes(smbmsg_t* msg, const uchar* text);
SMBEXPORT int SMBCALL smb_addhashes(smb_t* smb, hash_t** hash_list, BOOL skip_marked); SMBEXPORT int SMBCALL smb_addhashes(smb_t* smb, hash_t** hash_list, BOOL skip_marked);
SMBEXPORT ushort SMBCALL smb_name_crc(const char* name);
SMBEXPORT ushort SMBCALL smb_subject_crc(const char *subj); SMBEXPORT ushort SMBCALL smb_subject_crc(const char *subj);
SMBEXPORT int SMBCALL smb_init_idx(smb_t* smb, smbmsg_t* msg);
/* Fast look-up functions (using hashes) */ /* Fast look-up functions (using hashes) */
SMBEXPORT int SMBCALL smb_getmsgidx_by_hash(smb_t* smb, smbmsg_t* msg, unsigned source SMBEXPORT int SMBCALL smb_getmsgidx_by_hash(smb_t* smb, smbmsg_t* msg, unsigned source
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment