- if ((c == '.') && seen_lf) {
- seen_lfdot = 1;
- continue;
- }
-
- if (seen_lf) {
- /* normal lf, just send it */
- dk_message(dk_context, "\n", 1);
- seen_lf = 0;
- }
-
- if (c == '\n') {
- seen_lf = 1;
- continue;
+ while((sread = read(dk_fd,&buf,4096)) > 0) {
+ int pos = 0;
+ char c;
+
+ while (pos < sread) {
+ c = buf[pos++];
+
+ if ((c == '.') && seen_lfdot) {
+ /* escaped dot, write "\n.", continue */
+ dk_message(dk_context, CUS "\n.", 2);
+ seen_lf = 0;
+ seen_lfdot = 0;
+ continue;
+ }
+
+ if (seen_lfdot) {
+ /* EOM, write "\n" and break */
+ dk_message(dk_context, CUS "\n", 1);
+ break;
+ }
+
+ if ((c == '.') && seen_lf) {
+ seen_lfdot = 1;
+ continue;
+ }
+
+ if (seen_lf) {
+ /* normal lf, just send it */
+ dk_message(dk_context, CUS "\n", 1);
+ seen_lf = 0;
+ }
+
+ if (c == '\n') {
+ seen_lf = 1;
+ continue;
+ }
+
+ /* write the char */
+ dk_message(dk_context, CUS &c, 1);