Commit e45cbc0a authored by rswindell's avatar rswindell
Browse files

Created new functions (moved from src/sbbs3/* and renamed):

smb_faddrtoa(), smb_netaddr(), smb_subject_crc(), and smb_zonestr().
parent 810c66ad
......@@ -40,7 +40,10 @@
#include <string.h> /* strnicmp */
#include <ctype.h> /* toupper */
#include "sbbs.h"
#include "smblib.h"
#include "genwrap.h" /* PLATFORM_DESC */
#include "str_list.h" /* strList API */
#include "crc16.h"
smb_t smb;
BOOL renumber=FALSE;
......@@ -213,7 +216,7 @@ int fixsmb(char* sub)
msg.idx.number=msg.hdr.number;
msg.idx.attr=msg.hdr.attr;
msg.idx.time=msg.hdr.when_imported.time;
msg.idx.subj=subject_crc(msg.subj);
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);
......
......@@ -39,6 +39,11 @@
char revision[16];
char compiler[32];
const char *wday[]={"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
const char *mon[]={"Jan","Feb","Mar","Apr","May","Jun"
,"Jul","Aug","Sep","Oct","Nov","Dec"};
#define NOANALYSIS (1L<<0)
#define NOCRC (1L<<1)
......@@ -60,12 +65,12 @@ char compiler[32];
#include <string.h> /* strrchr */
#include <ctype.h> /* toupper */
#include "sbbs.h"
#include "genwrap.h" /* stricmp */
#include "dirwrap.h" /* fexist */
#include "conwrap.h" /* getch */
#include "filewrap.h"
#include "smblib.h"
#include "crc16.h"
#include "crc32.h"
#include "gen_defs.h" /* MAX_PATH */
......@@ -135,6 +140,8 @@ ulong lf_expand(BYTE* inbuf, ulong inlen, BYTE* outbuf)
return(j);
}
#include "truncsp.c"
/****************************************************************************/
/* Adds a new message to the message base */
/****************************************************************************/
......@@ -326,7 +333,7 @@ void postmsg(char type, char* to, char* to_number, char* to_address,
smb_freemsgdat(&smb,offset,length,1);
exit(1);
}
msg.idx.subj=subject_crc(str);
msg.idx.subj=smb_subject_crc(str);
i=smb_dfield(&msg,TEXT_BODY,length);
if(i) {
......@@ -1059,7 +1066,7 @@ void packmsgs(ulong packable)
msg.idx.number=msg.hdr.number;
msg.idx.attr=msg.hdr.attr;
msg.idx.time=msg.hdr.when_imported.time;
msg.idx.subj=subject_crc(msg.subj);
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);
......@@ -1247,16 +1254,13 @@ void readmsgs(ulong start)
printf("Subj : %s\n",msg.subj);
printf("To : %s",msg.to);
if(msg.to_net.type)
printf(" (%s)",msg.to_net.type==NET_FIDO
? faddrtoa((fidoaddr_t *)msg.to_net.addr,NULL) : (char*)msg.to_net.addr);
printf(" (%s)",smb_netaddr(&msg.to_net));
printf("\nFrom : %s",msg.from);
if(msg.from_net.type)
printf(" (%s)",msg.from_net.type==NET_FIDO
? faddrtoa((fidoaddr_t *)msg.from_net.addr,NULL)
: (char*)msg.from_net.addr);
printf(" (%s)",smb_netaddr(&msg.from_net));
printf("\nDate : %.24s %s"
,my_timestr((time_t*)&msg.hdr.when_written.time)
,zonestr(msg.hdr.when_written.zone));
,smb_zonestr(msg.hdr.when_written.zone,NULL));
printf("\n\n");
......
......@@ -2677,4 +2677,127 @@ int SMBCALL smb_getmsghdr_by_hash(smb_t* smb, smbmsg_t* msg, unsigned source
}
ushort SMBCALL smb_subject_crc(const char *subj)
{
char* str;
ushort crc;
while(!strnicmp(subj,"RE:",3)) {
subj+=3;
while(*subj==' ')
subj++;
}
if((str=strdup(subj))==NULL)
return(0xffff);
strlwr(str);
crc=crc16(str,0 /* auto-length */);
free(str);
return(crc);
}
/****************************************************************************/
/* Returns an ASCII string for FidoNet address 'addr' */
/****************************************************************************/
char* SMBCALL smb_faddrtoa(fidoaddr_t* addr, char* outstr)
{
static char str[64];
char point[25];
if(addr==NULL)
return("0:0/0");
sprintf(str,"%hu:%hu/%hu",addr->zone,addr->net,addr->node);
if(addr->point) {
sprintf(point,".%hu",addr->point);
strcat(str,point);
}
if(outstr==NULL)
return(str);
strcpy(outstr,str);
return(outstr);
}
char* SMBCALL smb_netaddr(net_t* net)
{
if(net->type==NET_FIDO)
return(smb_faddrtoa((fidoaddr_t*)net->addr,NULL));
return(net->addr);
}
/****************************************************************************/
/* Converts when_t.zone into ASCII format */
/****************************************************************************/
char* DLLCALL smb_zonestr(short zone, char* outstr)
{
char* plus;
static char str[32];
switch((ushort)zone) {
case 0: return("UTC");
case AST: return("AST");
case EST: return("EST");
case CST: return("CST");
case MST: return("MST");
case PST: return("PST");
case YST: return("YST");
case HST: return("HST");
case BST: return("BST");
case ADT: return("ADT");
case EDT: return("EDT");
case CDT: return("CDT");
case MDT: return("MDT");
case PDT: return("PDT");
case YDT: return("YDT");
case HDT: return("HDT");
case BDT: return("BDT");
case MID: return("MID");
case VAN: return("VAN");
case EDM: return("EDM");
case WIN: return("WIN");
case BOG: return("BOG");
case CAR: return("CAR");
case RIO: return("RIO");
case FER: return("FER");
case AZO: return("AZO");
case LON: return("LON");
case BER: return("BER");
case ATH: return("ATH");
case MOS: return("MOS");
case DUB: return("DUB");
case KAB: return("KAB");
case KAR: return("KAR");
case BOM: return("BOM");
case KAT: return("KAT");
case DHA: return("DHA");
case BAN: return("BAN");
case HON: return("HON");
case TOK: return("TOK");
case SYD: return("SYD");
case NOU: return("NOU");
case WEL: return("WEL");
}
if(!OTHER_ZONE(zone)) {
if(zone&(WESTERN_ZONE|US_ZONE)) /* West of UTC? */
zone=-(zone&0xfff);
else
zone&=0xfff;
}
if(zone>0)
plus="+";
else
plus="";
sprintf(str,"UTC%s%d:%02u", plus, zone/60, zone<0 ? (-zone)%60 : zone%60);
if(outstr==NULL)
return(str);
strcpy(outstr,str);
return(outstr);
}
/* End of SMBLIB.C */
......@@ -88,6 +88,7 @@
#define SMB_IS_OPEN(smb) ((smb)->shd_fp!=NULL)
/* Legacy API functions */
#include "filewrap.h" /* SH_DENYRW */
#define smb_incmsg(smb,msg) smb_incmsg_dfields(smb,msg,1)
#define smb_incdat smb_incmsgdat
#define smb_open_da(smb) smb_open_fp(smb,&(smb)->sda_fp,SH_DENYRW)
......@@ -161,6 +162,11 @@ SMBEXPORT void SMBCALL smb_freemsgtxt(char* buf);
SMBEXPORT int SMBCALL smb_copymsgmem(smb_t* smb, smbmsg_t* destmsg, smbmsg_t* srcmsg);
SMBEXPORT int SMBCALL smb_tzutc(short timezone);
SMBEXPORT int SMBCALL smb_updatethread(smb_t* smb, smbmsg_t* remsg, ulong newmsgnum);
SMBEXPORT ushort SMBCALL smb_subject_crc(const char *subj);
SMBEXPORT char* SMBCALL smb_faddrtoa(fidoaddr_t* addr, char* outstr);
SMBEXPORT char* SMBCALL smb_netaddr(net_t* net);
SMBEXPORT char* SMBCALL smb_zonestr(short zone, char* outstr);
/* hash-related functions */
SMBEXPORT int SMBCALL smb_findhash(smb_t* smb, hash_t** compare_list, hash_t* found, BOOL mark);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment