Diff for /parser3/src/main/pa_uue.C between versions 1.4.2.4 and 1.19

version 1.4.2.4, 2003/01/31 12:34:38 version 1.19, 2020/12/15 17:10:37
Line 1 Line 1
 /** @file  /** @file
         Parser: uuencoding impl.          Parser: uuencoding impl.
   
         Copyright(c) 2000,2001-2003 ArtLebedev Group(http://www.artlebedev.com)          Copyright (c) 2001-2020 Art. Lebedev Studio (http://www.artlebedev.com)
         Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)          Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
   
         @todo setrlimit          @todo setrlimit
 */  */
   
 static const char* IDENT_UUE_C="$Date$";  
   
 #include "pa_config_includes.h"  #include "pa_config_includes.h"
   
 #include "pa_uue.h"  #include "pa_uue.h"
 #include "pa_value_includes.h"  #include "pa_memory.h"
   
   volatile const char * IDENT_PA_UUE_C="$Id$" IDENT_PA_UUE_H;
   
 static unsigned char uue_table[64] = {  static unsigned char uue_table[64] = {
   '`', '!', '"', '#', '$', '%', '&', '\'',    '`', '!', '"', '#', '$', '%', '&', '\'',
Line 24  static unsigned char uue_table[64] = { Line 24  static unsigned char uue_table[64] = {
   'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',    'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
   'X', 'Y', 'Z', '[', '\\',']', '^', '_'    'X', 'Y', 'Z', '[', '\\',']', '^', '_'
 };  };
 void pa_uuencode(Pool& pool, String& result, StringPtr file_name, const VFile& vfile) {  
   const char* pa_uuencode(const unsigned char* in, size_t in_size, const char* file_name) {
           int count=45;
   
           size_t new_size = ((in_size / 3 + 1) * 4);
           new_size += 2 * new_size / (count / 3 * 4) /*chars in line + new lines*/ + 2;
           new_size += strlen(file_name) + 11/*header*/ + 6/*footer*/ + 1/*zero terminator*/;
   
           const char* result=new(PointerFreeGC) char[new_size];
           char* optr=(char*)result;
   
         //header          //header
         result << "content-transfer-encoding: x-uuencode\n" << "\n";          optr += sprintf(optr, "begin 644 %s\n", file_name);
         result << "begin 644 " << *file_name << "\n";  
   
         //body          //body
         const unsigned char *in=(const unsigned char *)vfile.value_ptr();          for(const unsigned char *itemp=in; itemp<(in+in_size); itemp+=count) {
         size_t in_length=vfile.value_size();  
   
         int count=45;  
         for(const unsigned char *itemp=in; itemp<(in+in_length); itemp+=count) {  
                 int index;                        int index;      
   
                 if((itemp+count)>(in+in_length))                   if((itemp+count)>(in+in_size)) 
                         count=in_length-(itemp-in);                          count=in_size-(itemp-in);
   
                 char *buf=new(pool) char[MAX_STRING];  
                 char *optr=buf;  
                   
                 /*                  /*
                 * for UU and XX, encode the number of bytes as first character                  * for UU and XX, encode the number of bytes as first character
                 */                  */
Line 76  void pa_uuencode(Pool& pool, String& res Line 78  void pa_uuencode(Pool& pool, String& res
                 /*                  /*
                 * end of line                  * end of line
                 */                  */
                 *optr++ = '\n';                   *optr++ = '\n';
                 *optr = 0;  
                 result << buf;  
         }          }
                   
         //footer          //footer
         result.APPEND_AS_IS((const char* )uue_table, 1/* one char */, 0, 0) << "\n"          optr += sprintf(optr, "`\nend\n");
                 "end\n";  
           //throw Exception(PARSER_RUNTIME, 0, "%d %d %d", in_size, new_size, (size_t)(optr-result));
           assert((size_t)(optr-result) < new_size);
   
           return result;
 }  }

Removed from v.1.4.2.4  
changed lines
  Added in v.1.19


E-mail: