mess822x 1.23
mess822x
Loading...
Searching...
No Matches
mess822_ok.c
Go to the documentation of this file.
1#include "mess822.h"
2#include "byte.h"
3
4int mess822_ok(stralloc *sa)
5{
6 int i;
7 int len;
8 int colon;
9
10 len = sa->len;
11 if (len && (sa->s[len - 1] == '\n')) --len;
12 if (!len) return 0;
13
14 /* if input message is 822-compliant, will return 1 after this */
15
16 if (sa->s[0] == ' ') return 1;
17 if (sa->s[0] == '\t') return 1;
18
19 colon = byte_chr(sa->s,sa->len,':');
20 if (colon >= sa->len) return 0;
21
22 while (colon && ((sa->s[colon - 1] == ' ') || (sa->s[colon - 1] == '\t')))
23 --colon;
24
25 if (!colon) return 0;
26
27 for (i = 0; i < colon; ++i) if (sa->s[i] < 33) return 0;
28 for (i = 0; i < colon; ++i) if (sa->s[i] > 126) return 0;
29
30 return 1;
31}
int mess822_ok(stralloc *sa)
Definition: mess822_ok.c:4