Commit 5a558936 authored by rswindell's avatar rswindell
Browse files

Automatically determine destination network type using smb_netaddr_type().

Use to_address as to_name if no (or default) to_name specified.
Only prompt for to_number if to_address not specified.
Let smb_addmsg() handle the index initialization.
parent fe3d3a42
......@@ -217,6 +217,8 @@ void postmsg(char type, char* to, char* to_number, char* to_address,
msg.hdr.when_written.zone=tzone;
msg.hdr.when_imported=msg.hdr.when_written;
if((to==NULL || stricmp(to,"All")==0) && to_address!=NULL)
to=to_address;
if(to==NULL) {
printf("To User Name: ");
fgets(str,sizeof(str),stdin);
......@@ -232,36 +234,30 @@ void postmsg(char type, char* to, char* to_number, char* to_address,
if(type=='E' || type=='N')
smb.status.attr|=SMB_EMAIL;
if(smb.status.attr&SMB_EMAIL) {
if(to_number==NULL) {
printf("To User Number (0=QWKnet or Internet): ");
gets(str);
} else
SAFECOPY(str,to_number);
truncsp(str);
if((i=smb_hfield_str(&msg,RECIPIENTEXT,str))!=SMB_SUCCESS) {
fprintf(errfp,"\n%s!smb_hfield_str(0x%02X) returned %d: %s\n"
,beep,RECIPIENTEXT,i,smb.last_error);
bail(1);
if(to_address==NULL) {
if(to_number==NULL) {
printf("To User Number: ");
gets(str);
} else
SAFECOPY(str,to_number);
truncsp(str);
if((i=smb_hfield_str(&msg,RECIPIENTEXT,str))!=SMB_SUCCESS) {
fprintf(errfp,"\n%s!smb_hfield_str(0x%02X) returned %d: %s\n"
,beep,RECIPIENTEXT,i,smb.last_error);
bail(1);
}
}
msg.idx.to=atoi(str);
}
else {
strlwr(str);
msg.idx.to=crc16(str,0);
}
if(smb.status.attr&SMB_EMAIL && (type=='N' || !msg.idx.to)) {
if(smb.status.attr&SMB_EMAIL && (type=='N' || to_address!=NULL)) {
if(to_address==NULL) {
printf("To Address: ");
printf("To Address (e.g. user@host): ");
gets(str);
} else
SAFECOPY(str,to_address);
truncsp(str);
if(*str) {
if(strchr(str,'.'))
net=NET_INTERNET;
else
net=NET_QWK;
net=smb_netaddr_type(str);
if((i=smb_hfield(&msg,RECIPIENTNETTYPE,sizeof(net),&net))!=SMB_SUCCESS) {
fprintf(errfp,"\n%s!smb_hfield(0x%02X) returned %d: %s\n"
,beep,RECIPIENTNETTYPE,i,smb.last_error);
......@@ -298,10 +294,6 @@ void postmsg(char type, char* to, char* to_number, char* to_address,
,beep,SENDEREXT,i,smb.last_error);
bail(1);
}
msg.idx.from=atoi(str);
} else {
strlwr(str);
msg.idx.from=crc16(str,0);
}
if((i=smb_hfield(&msg, SENDERAGENT, sizeof(agent), &agent))!=SMB_SUCCESS) {
fprintf(errfp,"\n%s!smb_hfield(0x%02X) returned %d: %s\n"
......@@ -320,7 +312,6 @@ void postmsg(char type, char* to, char* to_number, char* to_address,
,beep,SUBJECT,i,smb.last_error);
bail(1);
}
msg.idx.subj=smb_subject_crc(str);
safe_snprintf(str,sizeof(str),"SMBUTIL %s-%s r%s %s %s"
,SMBUTIL_VER
......
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