OSDN Git Service

addid library source 20140221
[zither/ds-zither.git] / libms / safe_base64.c
1 // safe_base64.c
2 // masashi shimakura 20140223
3
4
5 #include<stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
8
9 #include"libms.h"
10
11
12 // char * safe_base64(char *, int, int);
13  
14
15 char * safe_base64(char * data)
16 {
17 char * swap;
18 int max;
19
20 max = (int)strlen(data);
21
22 if(max > 0){
23    swap = (char *)calloc((max * 2), (int)sizeof(char));
24    base64(data, max, swap);
25    data = safe_memcpy(data, swap, BUF_MAX);
26    free(swap);
27    }
28 else{
29    fprintf(stderr,"safe_base64(): not 64 encode.\n");
30    }
31
32 return data;
33 }
34
35
36