Deleted Added
full compact
uuencode.c (221420) uuencode.c (255767)
1/* $OpenBSD: uuencode.c,v 1.26 2010/08/31 11:54:45 djm Exp $ */
1/* $OpenBSD: uuencode.c,v 1.27 2013/05/17 00:13:14 djm Exp $ */
2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.

--- 14 unchanged lines hidden (view full) ---

24 */
25
26#include "includes.h"
27
28#include <sys/types.h>
29#include <netinet/in.h>
30#include <resolv.h>
31#include <stdio.h>
2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.

--- 14 unchanged lines hidden (view full) ---

24 */
25
26#include "includes.h"
27
28#include <sys/types.h>
29#include <netinet/in.h>
30#include <resolv.h>
31#include <stdio.h>
32#include <stdlib.h>
32
33#include "xmalloc.h"
34#include "uuencode.h"
35
36/*
37 * Encode binary 'src' of length 'srclength', writing base64-encoded text
38 * to 'target' of size 'targsize'. Will always nul-terminate 'target'.
39 * Returns the number of bytes stored in 'target' or -1 on error (inc.

--- 22 unchanged lines hidden (view full) ---

62 /* skip whitespace and data */
63 for (p = encoded; *p == ' ' || *p == '\t'; p++)
64 ;
65 for (; *p != '\0' && *p != ' ' && *p != '\t'; p++)
66 ;
67 /* and remove trailing whitespace because __b64_pton needs this */
68 *p = '\0';
69 len = __b64_pton(encoded, target, targsize);
33
34#include "xmalloc.h"
35#include "uuencode.h"
36
37/*
38 * Encode binary 'src' of length 'srclength', writing base64-encoded text
39 * to 'target' of size 'targsize'. Will always nul-terminate 'target'.
40 * Returns the number of bytes stored in 'target' or -1 on error (inc.

--- 22 unchanged lines hidden (view full) ---

63 /* skip whitespace and data */
64 for (p = encoded; *p == ' ' || *p == '\t'; p++)
65 ;
66 for (; *p != '\0' && *p != ' ' && *p != '\t'; p++)
67 ;
68 /* and remove trailing whitespace because __b64_pton needs this */
69 *p = '\0';
70 len = __b64_pton(encoded, target, targsize);
70 xfree(encoded);
71 free(encoded);
71 return len;
72}
73
74void
75dump_base64(FILE *fp, const u_char *data, u_int len)
76{
77 char *buf;
78 int i, n;

--- 6 unchanged lines hidden (view full) ---

85 n = uuencode(data, len, buf, 2*len);
86 for (i = 0; i < n; i++) {
87 fprintf(fp, "%c", buf[i]);
88 if (i % 70 == 69)
89 fprintf(fp, "\n");
90 }
91 if (i % 70 != 69)
92 fprintf(fp, "\n");
72 return len;
73}
74
75void
76dump_base64(FILE *fp, const u_char *data, u_int len)
77{
78 char *buf;
79 int i, n;

--- 6 unchanged lines hidden (view full) ---

86 n = uuencode(data, len, buf, 2*len);
87 for (i = 0; i < n; i++) {
88 fprintf(fp, "%c", buf[i]);
89 if (i % 70 == 69)
90 fprintf(fp, "\n");
91 }
92 if (i % 70 != 69)
93 fprintf(fp, "\n");
93 xfree(buf);
94 free(buf);
94}
95}