]> git.sommitrealweird.co.uk Git - onak.git/blobdiff - armor.c
Fold in some of dsilvers' autoconf changes.
[onak.git] / armor.c
diff --git a/armor.c b/armor.c
index f2e97fcd791e04c1c8698c7824b32c61984a00d2..ac1d23f44d1696ede71258dafde24f6b4086061d 100644 (file)
--- a/armor.c
+++ b/armor.c
@@ -4,8 +4,6 @@
  * Jonathan McDowell <noodles@earth.li>
  *
  * Copyright 2002 Project Purple
  * Jonathan McDowell <noodles@earth.li>
  *
  * Copyright 2002 Project Purple
- *
- * $Id: armor.c,v 1.7 2003/09/30 20:40:10 noodles Exp $
  */
 
 #include <assert.h>
  */
 
 #include <assert.h>
@@ -102,16 +100,28 @@ static void armor_finish(struct armor_context *state)
                state->putchar_func(state->ctx, 1, &c);
                state->putchar_func(state->ctx, 1, (unsigned char *) "=");
                state->putchar_func(state->ctx, 1, (unsigned char *) "=");
                state->putchar_func(state->ctx, 1, &c);
                state->putchar_func(state->ctx, 1, (unsigned char *) "=");
                state->putchar_func(state->ctx, 1, (unsigned char *) "=");
+               state->count += 3;
+               if ((state->count % ARMOR_WIDTH) == 0) {
+                       state->putchar_func(state->ctx, 1,
+                                (unsigned char *) "\n");
+               }
                break;
        case 2:
                c = encode64((state->lastoctet & 0xF) << 2);
                state->putchar_func(state->ctx, 1, &c);
                state->putchar_func(state->ctx, 1, (unsigned char *) "=");
                break;
        case 2:
                c = encode64((state->lastoctet & 0xF) << 2);
                state->putchar_func(state->ctx, 1, &c);
                state->putchar_func(state->ctx, 1, (unsigned char *) "=");
+               state->count += 2;
+               if ((state->count % ARMOR_WIDTH) == 0) {
+                       state->putchar_func(state->ctx, 1,
+                                (unsigned char *) "\n");
+               }
                break;
        }
 
        state->crc24 &= 0xffffffL;
                break;
        }
 
        state->crc24 &= 0xffffffL;
-       state->putchar_func(state->ctx, 1, (unsigned char *) "\n");
+       if ((state->count % ARMOR_WIDTH) != 0) {
+               state->putchar_func(state->ctx, 1, (unsigned char *) "\n");
+       }
        state->putchar_func(state->ctx, 1, (unsigned char *) "=");
        c = encode64(state->crc24 >> 18);
        state->putchar_func(state->ctx, 1, &c);
        state->putchar_func(state->ctx, 1, (unsigned char *) "=");
        c = encode64(state->crc24 >> 18);
        state->putchar_func(state->ctx, 1, &c);