nightmaremail

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit b18cf997b30aa1c30a1b4e450f94621782f76b74
parent bc76cc72218ad3ecbc3caaede9688a5fa4d4d535
Author: Ellenor Bjornsdottir <ellenor@umbrellix.net>
Date:   Sat, 15 Oct 2022 12:44:40 +0000

something

Diffstat:
Mconf-ld | 2+-
Mdoc/man/mxf-remote.8 | 1+
Msrc/constmap.c | 191+++++++++++++++++++++++++++++++++++++++----------------------------------------
Msrc/qmail-rspawn.c | 1-
4 files changed, 96 insertions(+), 99 deletions(-)

diff --git a/conf-ld b/conf-ld @@ -1,3 +1,3 @@ -cc /package/prog/skalibs/library/libskarnet.a +cc This will be used to link .o files into an executable. diff --git a/doc/man/mxf-remote.8 b/doc/man/mxf-remote.8 @@ -57,3 +57,4 @@ the smtp client in MXF Remote .It Xr qmail-send 5 .It Xr qmail-smtpd 5 .It Xr qmail-control 5 +.El diff --git a/src/constmap.c b/src/constmap.c @@ -3,113 +3,110 @@ #include "alloc.h" #include "case.h" -static constmap_hash hash(s,len) -char *s; -int len; +static constmap_hash hash(char *s, int len) { - unsigned char ch; - constmap_hash h; - h = 5381; - while (len > 0) { - ch = *s++ - 'A'; - if (ch <= 'Z' - 'A') ch += 'a' - 'A'; - h = ((h << 5) + h) ^ ch; - --len; - } - return h; + unsigned char ch; + constmap_hash h; + h = 5381; + while (len > 0) { + ch = *s++ - 'A'; + if (ch <= 'Z' - 'A') + ch += 'a' - 'A'; + h = ((h << 5) + h) ^ ch; + --len; + } + return h; } -char *constmap(cm,s,len) -struct constmap *cm; -char *s; -int len; +char *constmap(struct constmap *cm, char *s, int len) { - constmap_hash h; - int pos; - h = hash(s,len); - pos = cm->first[h & cm->mask]; - while (pos != -1) { - if (h == cm->hash[pos]) - if (len == cm->inputlen[pos]) - if (!case_diffb(cm->input[pos],len,s)) - return cm->input[pos] + cm->inputlen[pos] + 1; - pos = cm->next[pos]; - } - return 0; + constmap_hash h; + int pos; + h = hash(s, len); + pos = cm->first[h & cm->mask]; + while (pos != -1) { + if (h == cm->hash[pos]) + if (len == cm->inputlen[pos]) + if (!case_diffb(cm->input[pos], len, s)) + return cm->input[pos] + cm->inputlen[pos] + 1; + pos = cm->next[pos]; + } + return 0; } -int constmap_init(cm,s,len,flagcolon) -struct constmap *cm; -char *s; -int len; -int flagcolon; +int constmap_init(struct constmap *cm, char *s, int len, int flagcolon) { - int i; - int j; - int k; - int pos; - constmap_hash h; - - cm->num = 0; - for (j = 0;j < len;++j) if (!s[j]) ++cm->num; - - h = 64; - while (h && (h < cm->num)) h += h; - cm->mask = h - 1; - - cm->first = (int *) alloc(sizeof(int) * h); - if (cm->first) { - cm->input = (char **) alloc(sizeof(char *) * cm->num); - if (cm->input) { - cm->inputlen = (int *) alloc(sizeof(int) * cm->num); - if (cm->inputlen) { - cm->hash = (constmap_hash *) alloc(sizeof(constmap_hash) * cm->num); - if (cm->hash) { - cm->next = (int *) alloc(sizeof(int) * cm->num); - if (cm->next) { - for (h = 0;h <= cm->mask;++h) - cm->first[h] = -1; - pos = 0; - i = 0; - for (j = 0;j < len;++j) - if (!s[j]) { - k = j - i; - if (flagcolon) { - for (k = i;k < j;++k) - if (s[k] == ':') - break; - if (k >= j) { i = j + 1; continue; } - k -= i; + int i; + int j; + int k; + int pos; + constmap_hash h; + + cm->num = 0; + for (j = 0; j < len; ++j) + if (!s[j]) + ++cm->num; + + h = 64; + while (h && (h < cm->num)) + h += h; + cm->mask = h - 1; + + cm->first = (int *)alloc(sizeof(int) * h); + if (cm->first) { + cm->input = (char **)alloc(sizeof(char *) * cm->num); + if (cm->input) { + cm->inputlen = (int *)alloc(sizeof(int) * cm->num); + if (cm->inputlen) { + cm->hash = (constmap_hash *) alloc(sizeof(constmap_hash) * cm->num); + if (cm->hash) { + cm->next = (int *)alloc(sizeof(int) * cm->num); + if (cm->next) { + for (h = 0; h <= cm->mask; ++h) + cm->first[h] = -1; + pos = 0; + i = 0; + for (j = 0; j < len; ++j) + if (!s[j]) { + k = j - i; + if (flagcolon) { + for (k = i; k < j; ++k) + if (s[k] == ':') + break; + if (k >= j) { + i = j + 1; + continue; + } + k -= i; + } + cm->input[pos] = s + i; + cm->inputlen[pos] = k; + h = hash(s + i, k); + cm->hash[pos] = h; + h &= cm->mask; + cm->next[pos] = cm->first[h]; + cm->first[h] = pos; + ++pos; + i = j + 1; + } + return 1; + } + alloc_free(cm->hash); + } + alloc_free(cm->inputlen); + } + alloc_free(cm->input); } - cm->input[pos] = s + i; - cm->inputlen[pos] = k; - h = hash(s + i,k); - cm->hash[pos] = h; - h &= cm->mask; - cm->next[pos] = cm->first[h]; - cm->first[h] = pos; - ++pos; - i = j + 1; - } - return 1; - } - alloc_free(cm->hash); + alloc_free(cm->first); } - alloc_free(cm->inputlen); - } - alloc_free(cm->input); - } - alloc_free(cm->first); - } - return 0; + return 0; } -void constmap_free(cm) -struct constmap *cm; +void constmap_free(struct constmap *cm) { - alloc_free(cm->next); - alloc_free(cm->hash); - alloc_free(cm->inputlen); - alloc_free(cm->input); - alloc_free(cm->first); + alloc_free(cm->next); + alloc_free(cm->hash); + alloc_free(cm->inputlen); + alloc_free(cm->input); + alloc_free(cm->first); } diff --git a/src/qmail-rspawn.c b/src/qmail-rspawn.c @@ -44,7 +44,6 @@ int len; { substdio_puts(ss,"Zqmail-remote produced no output.\n"); return; } result = -1; - info = 0; j = 0; for (k = 0;k < len;++k) if (!s[k])