Support up to 16-character internal codes for Synchronet, patch by Rob Swindell, 1:103/705

This commit is contained in:
Max Vasilyev 2016-02-01 14:32:16 +00:00
parent c24758eb5b
commit b56cd0ed8c
2 changed files with 24 additions and 9 deletions

View File

@ -43,6 +43,8 @@
// ------------------------------------------------------------------ // ------------------------------------------------------------------
const int LEN_CODE = 8; // Maximum length of internal codes
const int LEN_EXTCODE = (LEN_CODE*2); // Code prefix + suffix
const int LEN_DIR = 63; // Maximum length of directory paths const int LEN_DIR = 63; // Maximum length of directory paths
const int LEN_ARSTR = 40; // Max length of Access Requirement string const int LEN_ARSTR = 40; // Max length of Access Requirement string
const int LEN_GSNAME = 15; // Group/Lib short name const int LEN_GSNAME = 15; // Group/Lib short name
@ -91,7 +93,8 @@ typedef struct { // Message group info
char lname[LEN_GLNAME+1], // Short name char lname[LEN_GLNAME+1], // Short name
sname[LEN_GSNAME+1]; // Long name sname[LEN_GSNAME+1]; // Long name
uint8_t ar[LEN_ARSTR+1], // Access requirements uint8_t ar[LEN_ARSTR+1], // Access requirements
unused[96]; // unused code_prefix[LEN_CODE+1], // Prefix for internal code of every sub in this group
unused[87]; // unused
} grp_t; } grp_t;
typedef struct { // Message sub board info typedef struct { // Message sub board info
@ -99,7 +102,7 @@ typedef struct { // Message sub board info
char lname[LEN_SLNAME+1], // Long name - used for listing char lname[LEN_SLNAME+1], // Long name - used for listing
sname[LEN_SSNAME+1], // Short name - used for prompts sname[LEN_SSNAME+1], // Short name - used for prompts
qwkname[LEN_SQWKNAME+1], // QWK name qwkname[LEN_SQWKNAME+1], // QWK name
code[9], // Eight character code code_suffix[LEN_CODE+1], // Internal code (or just suffix)
data_dir[LEN_DIR+1]; // Data file directory data_dir[LEN_DIR+1]; // Data file directory
uint8_t ar[LEN_ARSTR+1], // Access requirements uint8_t ar[LEN_ARSTR+1], // Access requirements
read_ar[LEN_ARSTR+1], // Read requirements read_ar[LEN_ARSTR+1], // Read requirements
@ -116,8 +119,9 @@ typedef struct { // Message sub board info
uint16_t maxage, // Max age of messages (in days) uint16_t maxage, // Max age of messages (in days)
ptridx; // Index into pointer file ptridx; // Index into pointer file
uint8_t mod_ar[LEN_ARSTR+1]; // Moderated user requirements uint8_t mod_ar[LEN_ARSTR+1]; // Moderated user requirements
uint16_t qwkconf; // QWK configuration uint16_t qwkconf; // QWK conference number
uint8_t unused[53]; // unused char code[LEN_EXTCODE+1]; // Not actually read from the .cnf file
uint8_t unused[36]; // unused
} sub_t; } sub_t;
// ------------------------------------------------------------------ // ------------------------------------------------------------------

View File

@ -44,7 +44,6 @@ void gareafile::ReadSynchronet(char* tag) {
Path file, path; Path file, path;
char options[80]; char options[80];
uint16_t shrt, i; uint16_t shrt, i;
grp_t grp;
sub_t sub; sub_t sub;
strcpy(options, tag); strcpy(options, tag);
@ -102,9 +101,14 @@ void gareafile::ReadSynchronet(char* tag) {
// unused (0xff) 512 // unused (0xff) 512
fseek(in, 1034, SEEK_CUR); fseek(in, 1034, SEEK_CUR);
if(fread(&shrt, sizeof(uint16_t), 1, in) == 1) { uint16_t total_groups = 0;
for(i = 0; i < shrt; i++) { grp_t* grp = NULL;
if(fread(&grp, sizeof(grp_t), 1, in) != 1)
if(fread(&total_groups, sizeof(total_groups), 1, in) == 1
&& total_groups >= 1
&& (grp = (grp_t*)malloc(total_groups * sizeof(grp_t))) != NULL) {
for(i = 0; i < total_groups; i++) {
if(fread(&grp[i], sizeof(grp_t), 1, in) != 1)
break; break;
} }
} }
@ -112,9 +116,14 @@ void gareafile::ReadSynchronet(char* tag) {
for(i = 0; i < shrt; i++) { for(i = 0; i < shrt; i++) {
if(fread(&sub, sizeof(sub_t), 1, in) != 1) if(fread(&sub, sizeof(sub_t), 1, in) != 1)
break; break;
if(sub.grp >= total_groups) // Illegal group number
continue;
/* A sub-board's internal code is the combination of the grp's code_prefix & the sub's code_suffix */
memset(sub.code, 0, sizeof(sub.code));
snprintf(sub.code, sizeof(sub.code)-1, "%s%s", grp[sub.grp].code_prefix, sub.code_suffix);
AreaCfg aa; AreaCfg aa;
aa.reset(); aa.reset();
aa.type = (sub.misc & SUB_QNET) ? GMB_LOCAL : GMB_ECHO; aa.type = (sub.misc & SUB_FIDO) ? GMB_ECHO : GMB_LOCAL;
aa.attr = attribsecho; aa.attr = attribsecho;
aa.basetype = "SMB"; aa.basetype = "SMB";
aa.setechoid((sub.misc & SUB_FIDO) ? sub.sname : sub.code); aa.setechoid((sub.misc & SUB_FIDO) ? sub.sname : sub.code);
@ -132,6 +141,8 @@ void gareafile::ReadSynchronet(char* tag) {
AddNewArea(aa); AddNewArea(aa);
} }
} }
if(grp != NULL)
free(grp);
} }
fclose(in); fclose(in);
} }