Some fixes for jamlib

This commit is contained in:
Andrew Pamment 2016-03-25 15:58:08 +10:00
parent 8a3413203f
commit 3251db6b46
3 changed files with 84 additions and 47 deletions

View File

@ -27,19 +27,19 @@
#include "jam.h"
#include "structrw.h"
uint16_t jamgetuword(char *buf,uint32_t offset)
uint16_t jamgetuword(unsigned char *buf,uint32_t offset)
{
return (uint16_t) buf[offset]+
buf[offset+1]*256;
}
void jamputuword(char *buf,uint32_t offset,uint16_t num)
void jamputuword(unsigned char *buf,uint32_t offset,uint16_t num)
{
buf[offset]=num%256;
buf[offset+1]=num/256;
}
void jamputuint32_t(char *buf,uint32_t offset,uint32_t num)
void jamputuint32_t(unsigned char *buf,uint32_t offset,uint32_t num)
{
buf[offset]=num%256;
buf[offset+1]=(num / 256) % 256;
@ -47,7 +47,7 @@ void jamputuint32_t(char *buf,uint32_t offset,uint32_t num)
buf[offset+3]=(num / 256 / 256 / 256) % 256;
}
uint32_t jamgetuint32_t(char *buf,uint32_t offset)
uint32_t jamgetuint32_t(unsigned char *buf,uint32_t offset)
{
return (uint32_t) buf[offset]+
buf[offset+1]*256+
@ -57,7 +57,7 @@ uint32_t jamgetuint32_t(char *buf,uint32_t offset)
int freadjambaseheader(FILE *fp,s_JamBaseHeader *s_JamBaseHeader)
{
char buf[SIZE_JAMBASEHEADER];
unsigned char buf[SIZE_JAMBASEHEADER];
if(fread(buf,SIZE_JAMBASEHEADER,1,fp) != 1)
return 0;
@ -77,7 +77,7 @@ int freadjambaseheader(FILE *fp,s_JamBaseHeader *s_JamBaseHeader)
int fwritejambaseheader(FILE *fp,s_JamBaseHeader *s_JamBaseHeader)
{
char buf[SIZE_JAMBASEHEADER];
unsigned char buf[SIZE_JAMBASEHEADER];
memcpy(&buf[JAMBASEHEADER_SIGNATURE],s_JamBaseHeader->Signature,4);
@ -97,7 +97,7 @@ int fwritejambaseheader(FILE *fp,s_JamBaseHeader *s_JamBaseHeader)
int freadjammsgheader(FILE *fp,s_JamMsgHeader *s_JamMsgHeader)
{
char buf[SIZE_JAMMSGHEADER];
unsigned char buf[SIZE_JAMMSGHEADER];
if(fread(buf,SIZE_JAMMSGHEADER,1,fp) != 1)
return 0;
@ -129,7 +129,7 @@ int freadjammsgheader(FILE *fp,s_JamMsgHeader *s_JamMsgHeader)
int fwritejammsgheader(FILE *fp,s_JamMsgHeader *s_JamMsgHeader)
{
char buf[SIZE_JAMMSGHEADER];
unsigned char buf[SIZE_JAMMSGHEADER];
memcpy(&buf[JAMMSGHEADER_SIGNATURE],s_JamMsgHeader->Signature,4);
@ -161,7 +161,7 @@ int fwritejammsgheader(FILE *fp,s_JamMsgHeader *s_JamMsgHeader)
int freadjamindex(FILE *fp,s_JamIndex *s_JamIndex)
{
char buf[SIZE_JAMINDEX];
unsigned char buf[SIZE_JAMINDEX];
if(fread(buf,SIZE_JAMINDEX,1,fp) != 1)
return 0;
@ -174,7 +174,7 @@ int freadjamindex(FILE *fp,s_JamIndex *s_JamIndex)
int fwritejamindex(FILE *fp,s_JamIndex *s_JamIndex)
{
char buf[SIZE_JAMINDEX];
unsigned char buf[SIZE_JAMINDEX];
jamputuint32_t(buf,JAMINDEX_USERCRC, s_JamIndex->UserCRC);
jamputuint32_t(buf,JAMINDEX_HDROFFSET, s_JamIndex->HdrOffset);
@ -187,7 +187,7 @@ int fwritejamindex(FILE *fp,s_JamIndex *s_JamIndex)
int freadjamlastread(FILE *fp,s_JamLastRead *s_JamLastRead)
{
char buf[SIZE_JAMLASTREAD];
unsigned char buf[SIZE_JAMLASTREAD];
if(fread(buf,SIZE_JAMLASTREAD,1,fp) != 1)
return 0;
@ -202,7 +202,7 @@ int freadjamlastread(FILE *fp,s_JamLastRead *s_JamLastRead)
int fwritejamlastread(FILE *fp,s_JamLastRead *s_JamLastRead)
{
char buf[SIZE_JAMLASTREAD];
unsigned char buf[SIZE_JAMLASTREAD];
jamputuint32_t(buf,JAMLASTREAD_USERCRC,s_JamLastRead->UserCRC);
jamputuint32_t(buf,JAMLASTREAD_USERID,s_JamLastRead->UserID);
@ -217,7 +217,7 @@ int fwritejamlastread(FILE *fp,s_JamLastRead *s_JamLastRead)
int fwritejamsavesubfield(FILE *fp,s_JamSaveSubfield *s_JamSaveSubfield)
{
char buf[SIZE_JAMLASTREAD];
unsigned char buf[SIZE_JAMLASTREAD];
jamputuword(buf,JAMSAVESUBFIELD_LOID, s_JamSaveSubfield->LoID);
jamputuword(buf,JAMSAVESUBFIELD_HIID, s_JamSaveSubfield->HiID);
@ -229,7 +229,7 @@ int fwritejamsavesubfield(FILE *fp,s_JamSaveSubfield *s_JamSaveSubfield)
return 1;
}
void getjamsubfield(char *buf,s_JamSubfield *Subfield_S)
void getjamsubfield(unsigned char *buf,s_JamSubfield *Subfield_S)
{
Subfield_S->LoID = jamgetuword(buf,JAMSAVESUBFIELD_LOID);
Subfield_S->HiID = jamgetuword(buf,JAMSAVESUBFIELD_HIID);

View File

@ -81,6 +81,6 @@ int freadjamlastread(FILE *fp,s_JamLastRead *s_JamLastRead);
int fwritejamlastread(FILE *fp,s_JamLastRead *s_JamLastRead);
int fwritejamsavesubfield(FILE *fp,s_JamSaveSubfield *s_JamSaveSubfield);
void getjamsubfield(char *buf,s_JamSubfield *Subfield_S);
void getjamsubfield(unsigned char *buf,s_JamSubfield *Subfield_S);

View File

@ -420,10 +420,16 @@ void read_message(int socket, struct user_record *user, int mailno) {
jmh.Attribute |= MSG_TYPEECHO;
if (conf.mail_conferences[user->cur_mail_conf]->nettype == NETWORK_FIDO) {
sprintf(buffer, "%d:%d/%d.%d", conf.mail_conferences[user->cur_mail_conf]->fidoaddr->zone,
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->net,
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->node,
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->point);
if (conf.mail_conferences[user->cur_mail_conf]->fidoaddr->point) {
sprintf(buffer, "%d:%d/%d.%d", conf.mail_conferences[user->cur_mail_conf]->fidoaddr->zone,
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->net,
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->node,
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->point);
} else {
sprintf(buffer, "%d:%d/%d", conf.mail_conferences[user->cur_mail_conf]->fidoaddr->zone,
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->net,
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->node);
}
jsf.LoID = JAMSFLD_OADDRESS;
jsf.HiID = 0;
jsf.DatLen = strlen(buffer);
@ -434,10 +440,16 @@ void read_message(int socket, struct user_record *user, int mailno) {
jmh.Attribute |= MSG_TYPENET;
jmh.Attribute |= MSG_KILLSENT;
if (conf.mail_conferences[user->cur_mail_conf]->nettype == NETWORK_FIDO) {
sprintf(buffer, "%d:%d/%d.%d", conf.mail_conferences[user->cur_mail_conf]->fidoaddr->zone,
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->net,
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->node,
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->point);
if (conf.mail_conferences[user->cur_mail_conf]->fidoaddr->point) {
sprintf(buffer, "%d:%d/%d.%d", conf.mail_conferences[user->cur_mail_conf]->fidoaddr->zone,
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->net,
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->node,
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->point);
} else {
sprintf(buffer, "%d:%d/%d", conf.mail_conferences[user->cur_mail_conf]->fidoaddr->zone,
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->net,
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->node);
}
jsf.LoID = JAMSFLD_OADDRESS;
jsf.HiID = 0;
jsf.DatLen = strlen(buffer);
@ -445,11 +457,16 @@ void read_message(int socket, struct user_record *user, int mailno) {
JAM_PutSubfield(jsp, &jsf);
if (from_addr != NULL) {
sprintf(buffer, "%d:%d/%d.%d", from_addr->zone,
from_addr->net,
from_addr->node,
from_addr->point);
if (from_addr->point) {
sprintf(buffer, "%d:%d/%d.%d", from_addr->zone,
from_addr->net,
from_addr->node,
from_addr->point);
} else {
sprintf(buffer, "%d:%d/%d", from_addr->zone,
from_addr->net,
from_addr->node);
}
jsf.LoID = JAMSFLD_DADDRESS;
jsf.HiID = 0;
jsf.DatLen = strlen(buffer);
@ -630,43 +647,61 @@ int mail_menu(int socket, struct user_record *user) {
jsf.DatLen = strlen(subject);
jsf.Buffer = (uchar *)subject;
JAM_PutSubfield(jsp, &jsf);
/*
if (conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->type == TYPE_ECHOMAIL_AREA) {
jmh.Attribute |= MSG_TYPEECHO;
if (conf.mail_conferences[user->cur_mail_conf]->nettype == NETWORK_FIDO) {
sprintf(buffer, "%d:%d/%d.%d", conf.mail_conferences[user->cur_mail_conf]->fidoaddr->zone,
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->net,
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->node,
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->point);
if (conf.mail_conferences[user->cur_mail_conf]->fidoaddr->point) {
sprintf(buffer, "%d:%d/%d.%d", conf.mail_conferences[user->cur_mail_conf]->fidoaddr->zone,
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->net,
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->node,
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->point);
} else {
sprintf(buffer, "%d:%d/%d", conf.mail_conferences[user->cur_mail_conf]->fidoaddr->zone,
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->net,
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->node);
}
jsf.LoID = JAMSFLD_OADDRESS;
jsf.HiID = 0;
jsf.DatLen = strlen(buffer);
jsf.Buffer = (uchar *)buffer;
JAM_PutSubfield(jsp, &jsf);
}
} else*/
} else
if (conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->type == TYPE_NETMAIL_AREA) {
jmh.Attribute |= MSG_TYPENET;
jmh.Attribute |= MSG_KILLSENT;
if (conf.mail_conferences[user->cur_mail_conf]->nettype == NETWORK_FIDO) {
/*
sprintf(buffer, "%d:%d/%d.%d", conf.mail_conferences[user->cur_mail_conf]->fidoaddr->zone,
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->net,
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->node,
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->point);
if (conf.mail_conferences[user->cur_mail_conf]->fidoaddr->point) {
sprintf(buffer, "%d:%d/%d.%d", conf.mail_conferences[user->cur_mail_conf]->fidoaddr->zone,
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->net,
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->node,
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->point);
} else {
sprintf(buffer, "%d:%d/%d", conf.mail_conferences[user->cur_mail_conf]->fidoaddr->zone,
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->net,
conf.mail_conferences[user->cur_mail_conf]->fidoaddr->node);
}
jsf.LoID = JAMSFLD_OADDRESS;
jsf.HiID = 0;
jsf.DatLen = strlen(buffer);
jsf.Buffer = (uchar *)buffer;
JAM_PutSubfield(jsp, &jsf);
*/
if (from_addr != NULL) {
sprintf(buffer, "%d:%d/%d.%d", from_addr->zone,
from_addr->net,
from_addr->node,
from_addr->point);
if (from_addr != NULL) {
if (from_addr->point) {
sprintf(buffer, "%d:%d/%d.%d", from_addr->zone,
from_addr->net,
from_addr->node,
from_addr->point);
} else {
sprintf(buffer, "%d:%d/%d", from_addr->zone,
from_addr->net,
from_addr->node);
}
jsf.LoID = JAMSFLD_DADDRESS;
jsf.HiID = 0;
jsf.DatLen = strlen(buffer);
@ -732,13 +767,15 @@ int mail_menu(int socket, struct user_record *user) {
for (j=i;j<jbh.ActiveMsgs;j++) {
memset(&jmh, 0, sizeof(s_JamMsgHeader));
printf("MSG %d\n", j);
z = JAM_ReadMsgHeader(jb, j, &jmh, &jsp);
z = JAM_ReadMsgHeader(jb, j, &jmh, &jsp);
if (z != 0) {
printf("Failed to read msg header: %d Erro %d\n", z, JAM_Errno(jb));
continue;
}
if (jmh.Attribute & MSG_DELETED) {
printf("Deleted MSG\n");
JAM_DelSubPacket(jsp);