#include "common.h"#include "linefile.h"#include "dystring.h"#include "quotedP.h"Include dependency graph for quotedP.c:

Go to the source code of this file.
Functions | |
| char * | quotedPrintableEncode (char *input) |
| boolean | quotedPCollapse (char *line) |
| char * | quotedPrintableDecode (char *input) |
| boolean quotedPCollapse | ( | char * | line | ) |
Definition at line 45 of file quotedP.c.
References lastChar().
Referenced by quotedPrintableDecode().
00049 { 00050 size_t i=0,j=0,l=strlen(line); 00051 boolean result = lastChar(line) != '='; 00052 char c1 = ' ', c2 = ' '; 00053 while(i < l) 00054 { 00055 if (line[i] == '=') 00056 { 00057 if (i > (l-3)) 00058 break; /* not enough room left for whole char */ 00059 ++i; 00060 c1 = line[i++]; 00061 c2 = line[i++]; 00062 toupper(c1); 00063 toupper(c2); 00064 if (isdigit(c1)) 00065 c1 -= 48; 00066 else 00067 c1 -= 55; 00068 if (isdigit(c2)) 00069 c2 -= 48; 00070 else 00071 c2 -= 55; 00072 line[j++] = (c1 * 16) + c2; 00073 } 00074 else 00075 { 00076 line[j++] = line[i++]; 00077 } 00078 } 00079 line[j] = 0; /* terminate line */ 00080 return result; 00081 }
Here is the call graph for this function:

Here is the caller graph for this function:

| char* quotedPrintableDecode | ( | char * | input | ) |
Definition at line 83 of file quotedP.c.
References cloneString(), FALSE, lineFileClose(), lineFileNext(), lineFileOnString(), needMem(), quotedPCollapse(), and TRUE.
00086 { 00087 size_t inplen = strlen(input); 00088 char *result = (char *)needMem(inplen+1); 00089 size_t j=0; 00090 char *line = NULL; 00091 int size = 0; 00092 int i = 0; 00093 boolean newLine = FALSE; 00094 00095 struct lineFile *lf = lineFileOnString("", TRUE, cloneString(input)); 00096 00097 while (lineFileNext(lf, &line, &size)) 00098 { 00099 newLine = quotedPCollapse(line); 00100 size = strlen(line); 00101 for (i = 0; i < size; ) 00102 result[j++] = line[i++]; 00103 if (newLine) 00104 result[j++] = '\n'; 00105 } 00106 00107 lineFileClose(&lf); /* frees cloned string */ 00108 00109 result[j] = 0; /* terminate text string */ 00110 00111 return result; 00112 }
Here is the call graph for this function:

| char* quotedPrintableEncode | ( | char * | input | ) |
Definition at line 6 of file quotedP.c.
References dyStringAppendC(), dyStringCannibalize(), dyStringNew, dyStringPrintf(), lastChar(), and dyString::string.
00008 { 00009 struct dyString *dy = dyStringNew(0); 00010 size_t i=0,l=strlen(input); 00011 int width = 0; 00012 for (i=0; i < l; ++i) 00013 { 00014 char c = input[i]; 00015 switch (c) 00016 { 00017 case '=': 00018 case '\t': 00019 case '\r': 00020 case '\n': 00021 case ' ': 00022 dyStringAppendC(dy, '='); 00023 dyStringPrintf(dy, "%2x", c); 00024 width += 3; 00025 break; 00026 default: 00027 dyStringAppendC(dy, c); 00028 ++width; 00029 } 00030 if (width > 72) 00031 { 00032 dyStringAppendC(dy, '='); 00033 dyStringAppendC(dy, '\n'); 00034 width = 0; 00035 } 00036 00037 } 00038 /* add terminator to prevent extra newline */ 00039 if (lastChar(dy->string) != '=') 00040 dyStringAppendC(dy, '='); 00041 00042 return dyStringCannibalize(&dy); 00043 }
Here is the call graph for this function:

1.5.2