diff options
author | Jannis Hoffmann <jannis@fehcom.de> | 2024-07-03 15:52:39 +0200 |
---|---|---|
committer | Jannis Hoffmann <jannis@fehcom.de> | 2024-07-03 15:52:39 +0200 |
commit | a6a7d6ce079cabdaf2fa502b2e2cf15e5428ac6f (patch) | |
tree | b88cc7a8457658d67e0321718556ac807f6bccf3 /src/newfield.c | |
parent | 00be7622c428f279872f84569f098ce16150f8a8 (diff) |
format files
Diffstat (limited to 'src/newfield.c')
-rw-r--r-- | src/newfield.c | 75 |
1 files changed, 53 insertions, 22 deletions
diff --git a/src/newfield.c b/src/newfield.c index 6d69ec6..2e6b07f 100644 --- a/src/newfield.c +++ b/src/newfield.c @@ -1,9 +1,12 @@ +#include "newfield.h" + #include <unistd.h> + #include "fmt.h" -#include "datetime.h" #include "stralloc.h" + #include "date822fmt.h" -#include "newfield.h" +#include "datetime.h" /* "Date: 26 Sep 1995 04:46:53 -0000\n" */ stralloc newfield_date = {0}; @@ -15,10 +18,14 @@ static unsigned int datefmt(char *s, datetime_sec when) unsigned int i; unsigned int len; struct datetime dt; - datetime_tai(&dt,when); + datetime_tai(&dt, when); len = 0; - i = fmt_str(s,"Date: "); len += i; if (s) s += i; - i = date822fmt(s,&dt); len += i; if (s) s += i; + i = fmt_str(s, "Date: "); + len += i; + if (s) s += i; + i = date822fmt(s, &dt); + len += i; + if (s) s += i; return len; } @@ -27,33 +34,57 @@ static unsigned int msgidfmt(char *s, char *idhost, int idhostlen, datetime_sec unsigned int i; unsigned int len; struct datetime dt; - datetime_tai(&dt,when); + datetime_tai(&dt, when); len = 0; - i = fmt_str(s,"Message-ID: <"); len += i; if (s) s += i; - i = fmt_uint(s,dt.year + 1900); len += i; if (s) s += i; - i = fmt_uint0(s,dt.mon + 1,2); len += i; if (s) s += i; - i = fmt_uint0(s,dt.mday,2); len += i; if (s) s += i; - i = fmt_uint0(s,dt.hour,2); len += i; if (s) s += i; - i = fmt_uint0(s,dt.min,2); len += i; if (s) s += i; - i = fmt_uint0(s,dt.sec,2); len += i; if (s) s += i; - i = fmt_str(s,"."); len += i; if (s) s += i; - i = fmt_uint(s,getpid()); len += i; if (s) s += i; - i = fmt_str(s,".qmail@"); len += i; if (s) s += i; - i = fmt_strn(s,idhost,idhostlen); len += i; if (s) s += i; - i = fmt_str(s,">\n"); len += i; if (s) s += i; + i = fmt_str(s, "Message-ID: <"); + len += i; + if (s) s += i; + i = fmt_uint(s, dt.year + 1900); + len += i; + if (s) s += i; + i = fmt_uint0(s, dt.mon + 1, 2); + len += i; + if (s) s += i; + i = fmt_uint0(s, dt.mday, 2); + len += i; + if (s) s += i; + i = fmt_uint0(s, dt.hour, 2); + len += i; + if (s) s += i; + i = fmt_uint0(s, dt.min, 2); + len += i; + if (s) s += i; + i = fmt_uint0(s, dt.sec, 2); + len += i; + if (s) s += i; + i = fmt_str(s, "."); + len += i; + if (s) s += i; + i = fmt_uint(s, getpid()); + len += i; + if (s) s += i; + i = fmt_str(s, ".qmail@"); + len += i; + if (s) s += i; + i = fmt_strn(s, idhost, idhostlen); + len += i; + if (s) s += i; + i = fmt_str(s, ">\n"); + len += i; + if (s) s += i; return len; } int newfield_datemake(datetime_sec when) { - if (!stralloc_ready(&newfield_date,datefmt(FMT_LEN,when))) return 0; - newfield_date.len = datefmt(newfield_date.s,when); + if (!stralloc_ready(&newfield_date, datefmt(FMT_LEN, when))) return 0; + newfield_date.len = datefmt(newfield_date.s, when); return 1; } int newfield_msgidmake(char *idhost, int idhostlen, datetime_sec when) { - if (!stralloc_ready(&newfield_msgid,msgidfmt(FMT_LEN,idhost,idhostlen,when))) return 0; - newfield_msgid.len = msgidfmt(newfield_msgid.s,idhost,idhostlen,when); + if (!stralloc_ready(&newfield_msgid, msgidfmt(FMT_LEN, idhost, idhostlen, when))) return 0; + newfield_msgid.len = msgidfmt(newfield_msgid.s, idhost, idhostlen, when); return 1; } |