Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit affd175b authored by Rob Swindell's avatar Rob Swindell 💬

Add support for editing extended file descriptions

New text.dat string:
- EditExtDescriptionQ

Removed text.dat string:
DeleteExtDescriptionQ
parent 54de9ce3
Pipeline #2215 passed with stage
in 10 minutes and 12 seconds
......@@ -335,14 +335,13 @@ bool sbbs_t::editfileinfo(file_t* f)
if((f->tags == NULL && *tags != '\0') || (f->tags != NULL && strcmp(tags, f->tags)))
smb_new_hfield_str(f, SMB_TAGS, tags);
}
#if 0
// Extended Description
if(f->extdesc != NULL && *f->extdesc) {
if(!noyes(text[DeleteExtDescriptionQ])) {
// TODO
}
if(!noyes(text[EditExtDescriptionQ])) {
if(editmsg(&smb, f)) {
if(f->extdesc != NULL)
smb_freemsgtxt(f->extdesc);
f->extdesc = smb_getmsgtxt(&smb, f, GETMSGTXT_BODY_ONLY);
}
}
#endif
if(dir_op(f->dir)) {
char uploader[LEN_ALIAS + 1];
SAFECOPY(uploader, f->from);
......
......@@ -43,7 +43,6 @@ int sbbs_t::listfiles(uint dirnum, const char *filespec, FILE* tofile, long mode
size_t m=0;
long anchor=0,next;
file_t* bf[BF_MAX]; /* bf is batch flagged files */
smb_t smb;
ulong file_row[BF_MAX];
size_t longest = 0;
......@@ -740,7 +739,6 @@ int sbbs_t::listfileinfo(uint dirnum, const char *filespec, long mode)
time_t start,end,t;
file_t* f;
struct tm tm;
smb_t smb;
if(!smb_init_dir(&cfg, &smb, dirnum))
return 0;
......
......@@ -265,11 +265,11 @@ enum {
,CouldntRenameFile
,FileRenamed
,EditDescription
,DeleteExtDescriptionQ
,Unused255
,EditUploader
,EditCreditValue
,EditTimesDownloaded
,EditOpenCount
,EditExtDescriptionQ
,Unused260
,YouOnlyHaveNCredits
,NotEnoughCredits
......
......@@ -414,11 +414,11 @@ const char * const text_defaults[TOTAL_TEXT]={
"\x6e\x0d\x0a" // 252 CouldntRenameFile
,"\x25\x73\x20\x72\x65\x6e\x61\x6d\x65\x64\x20\x74\x6f\x20\x25\x73\x0d\x0a" // 253 FileRenamed
,"\x01\x5f\x01\x79\x01\x68\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6f\x6e\x20\x20\x20\x20\x20\x20\x3a\x20\x01\x6e" // 254 EditDescription
,"\x44\x65\x6c\x65\x74\x65\x20\x65\x78\x74\x65\x6e\x64\x65\x64\x20\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6f\x6e" // 255 DeleteExtDescriptionQ
,"\x55\x4e\x55\x53\x45\x44\x32\x35\x35" // 255 Unused255
,"\x01\x5f\x01\x79\x01\x68\x55\x70\x6c\x6f\x61\x64\x65\x72\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3a\x20\x01\x6e" // 256 EditUploader
,"\x01\x5f\x01\x79\x01\x68\x43\x72\x65\x64\x69\x74\x20\x76\x61\x6c\x75\x65\x20\x20\x20\x20\x20\x3a\x20\x01\x6e" // 257 EditCreditValue
,"\x01\x5f\x01\x79\x01\x68\x54\x69\x6d\x65\x73\x20\x64\x6f\x77\x6e\x6c\x6f\x61\x64\x65\x64\x20\x3a\x20\x01\x6e" // 258 EditTimesDownloaded
,"\x01\x5f\x01\x79\x01\x68\x4f\x70\x65\x6e\x20\x63\x6f\x75\x6e\x74\x20\x20\x20\x20\x20\x20\x20\x3a\x20\x01\x6e" // 259 EditOpenCount
,"\x45\x64\x69\x74\x20\x65\x78\x74\x65\x6e\x64\x65\x64\x20\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6f\x6e" // 259 EditExtDescriptionQ
,"\x55\x4e\x55\x53\x45\x44\x32\x36\x30" // 260 Unused260
,"\x0d\x0a\x01\x77\x01\x68\x59\x6f\x75\x20\x6f\x6e\x6c\x79\x20\x68\x61\x76\x65\x20\x25\x73\x20\x63\x72\x65\x64\x69\x74\x73\x2e\x0d"
"\x0a" // 261 YouOnlyHaveNCredits
......
......@@ -1607,14 +1607,19 @@ bool sbbs_t::editmsg(smb_t* smb, smbmsg_t *msg)
long length;
off_t offset;
FILE *instream;
bool is_msg = (msg->hdr.type == SMB_MSG_TYPE_NORMAL);
if(!msg->hdr.total_dfields)
return false;
if(!msg->hdr.total_dfields) {
if(!is_msg)
smb_dfield(msg, TEXT_BODY, 0);
else
return false;
}
msg_tmp_fname(useron.xedit, msgtmp, sizeof(msgtmp));
(void)removecase(msgtmp);
msgtotxt(smb, msg, msgtmp, /* header: */false, /* mode: */GETMSGTXT_ALL);
if(!editfile(msgtmp, /* msg: */true))
msgtotxt(smb, msg, msgtmp, /* header: */false, /* mode: */is_msg ? GETMSGTXT_ALL : GETMSGTXT_BODY_ONLY);
if(!editfile(msgtmp, is_msg))
return false;
length=(long)flength(msgtmp);
if(length<1L)
......@@ -1644,18 +1649,20 @@ bool sbbs_t::editmsg(smb_t* smb, smbmsg_t *msg)
msg->dfield[0].type=TEXT_BODY; /* Make one single data field */
msg->dfield[0].length=length;
msg->dfield[0].offset=0;
for(x=1;x<msg->hdr.total_dfields;x++) { /* Clear the other data fields */
msg->dfield[x].type=UNUSED; /* so we leave the header length */
msg->dfield[x].length=0; /* unchanged */
msg->dfield[x].offset=0;
if(is_msg) {
for(x=1;x<msg->hdr.total_dfields;x++) { /* Clear the other data fields */
msg->dfield[x].type=UNUSED; /* so we leave the header length */
msg->dfield[x].length=0; /* unchanged */
msg->dfield[x].offset=0;
}
}
if(smb->status.attr&SMB_HYPERALLOC)
offset=smb_hallocdat(smb);
else {
if((smb->subnum!=INVALID_SUB && cfg.sub[smb->subnum]->misc&SUB_FAST)
|| (smb->subnum==INVALID_SUB && cfg.sys_misc&SM_FASTMAIL))
if(is_msg
&& ((smb->subnum!=INVALID_SUB && cfg.sub[smb->subnum]->misc&SUB_FAST)
|| (smb->subnum==INVALID_SUB && cfg.sys_misc&SM_FASTMAIL)))
offset=smb_fallocdat(smb,length,1);
else
offset=smb_allocdat(smb,length,1);
......
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