Skip to content

Commit

Permalink
Compat
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelortmann committed Jun 22, 2024
1 parent eb04aa8 commit fc6955e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 13 deletions.
52 changes: 41 additions & 11 deletions src/mod/share.mod/uf_features.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ static void uf_features_parse(int idx, char *par)
{
char *buf, *feature, *brkt;
uff_list_t *ul;
int len = 0;

uff_sbuf[0] = 0; /* Reset static buffer */
buf = nmalloc(strlen(par) + 1); /* Allocate temp buffer */
Expand All @@ -251,10 +252,22 @@ static void uf_features_parse(int idx, char *par)
/* Is the feature available and active? */
ul = uff_findentry_byname(feature);
if (ul && (ul->entry->ask_func == NULL || ul->entry->ask_func(idx))) {
dcc[idx].u.bot->uff_flags |= ul->entry->flag; /* Set flag */
if (uff_sbuf[0])
strncat(uff_sbuf, " ", sizeof uff_sbuf - strlen(uff_sbuf) - 1);
strncat(uff_sbuf, ul->entry->feature, sizeof uff_sbuf - strlen(uff_sbuf) - 1); /* Add feature to list */
/* Add feature to list */
if ((!strcmp(ul->entry->feature, "compress")) &&
(dcc[idx].u.bot->numver >= 1090200) &&
(dcc[idx].u.bot->numver <= 1090504))
debug2("share: uf_features_parse(): quirk workaround: compress disabled for idx %i bot version %i", idx, dcc[idx].u.bot->numver);
else {
dcc[idx].u.bot->uff_flags |= ul->entry->flag; /* Set flag */
if (dcc[idx].u.bot->numver >= 1090507) {
if (len)
uff_sbuf[len++] = ' ';
len += strlcpy(uff_sbuf + len, ul->entry->feature, (sizeof uff_sbuf) - len);
} else
/* quirk workaround: add trailing whitespace */
len += snprintf(uff_sbuf + len, (sizeof uff_sbuf) - len, "%s ",
ul->entry->feature);
}
}
}
nfree(buf);
Expand All @@ -269,13 +282,25 @@ static void uf_features_parse(int idx, char *par)
static char *uf_features_dump(int idx)
{
uff_list_t *ul;
int len = 0;

uff_sbuf[0] = 0;
for (ul = uff_list.start; ul; ul = ul->next)
for (ul = uff_list.start; ul && (((sizeof uff_sbuf) - len) < 3);
ul = ul->next)
if (ul->entry->ask_func == NULL || ul->entry->ask_func(idx)) {
if (uff_sbuf[0])
strncat(uff_sbuf, " ", sizeof uff_sbuf - strlen(uff_sbuf) - 1);
strncat(uff_sbuf, ul->entry->feature, sizeof uff_sbuf - strlen(uff_sbuf) - 1); /* Add feature to list */
/* Add feature to list */
if ((!strcmp(ul->entry->feature, "compress")) &&
(dcc[idx].u.bot->numver >= 1090200) &&
(dcc[idx].u.bot->numver <= 1090504))
debug2("share: uf_features_dump(): quirk workaround: compress disabled for idx %i bot version %i", idx, dcc[idx].u.bot->numver);
else if (dcc[idx].u.bot->numver >= 1090507) {
if (len)
uff_sbuf[len++] = ' ';
len += strlcpy(uff_sbuf + len, ul->entry->feature, (sizeof uff_sbuf) - len);
} else
/* quirk workaround: add trailing whitespace */
len += snprintf(uff_sbuf + len, (sizeof uff_sbuf) - len, "%s ",
ul->entry->feature);
}
return uff_sbuf;
}
Expand All @@ -298,9 +323,14 @@ static int uf_features_check(int idx, char *par)
feature = strtok_r(NULL, " ", &brkt)) {
/* Is the feature available and active? */
ul = uff_findentry_byname(feature);
if (ul && (ul->entry->ask_func == NULL || ul->entry->ask_func(idx)))
dcc[idx].u.bot->uff_flags |= ul->entry->flag; /* Set flag */
else {
if (ul && (ul->entry->ask_func == NULL || ul->entry->ask_func(idx))) {
if ((!strcmp(feature, "compress")) &&
(dcc[idx].u.bot->numver >= 1090200) &&
(dcc[idx].u.bot->numver <= 1090504)) {
debug2("share: uf_features_check(): quirk workaround: compress disabled for idx %i bot version %i", idx, dcc[idx].u.bot->numver);
} else
dcc[idx].u.bot->uff_flags |= ul->entry->flag; /* Set flag */
} else {
/* It isn't, and our hub wants to use it! This either happens
* because the hub doesn't look at the features we suggested to
* use or because our admin changed the flags, so that formerly
Expand Down
4 changes: 2 additions & 2 deletions src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@
*/

#define EGG_STRINGVER "1.9.5"
#define EGG_NUMVER 1090506
#define EGG_PATCH "accounttracking"
#define EGG_NUMVER 1090507
#define EGG_PATCH "sharefeature"

0 comments on commit fc6955e

Please sign in to comment.