moriyoshi               Tue Jan 14 11:42:19 2003 EDT

  Modified files:              
    /php4/ext/standard  filters.c 
  Log:
  Added a new option "force-encode-first" to the quoted-printable encoder
  as per Wez's request. If enabled, the encoder forcefully does qp
  tranformation on every first character of lines in incoming stream.
  
  
Index: php4/ext/standard/filters.c
diff -u php4/ext/standard/filters.c:1.17 php4/ext/standard/filters.c:1.18
--- php4/ext/standard/filters.c:1.17    Mon Jan 13 20:27:57 2003
+++ php4/ext/standard/filters.c Tue Jan 14 11:42:18 2003
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: filters.c,v 1.17 2003/01/14 01:27:57 moriyoshi Exp $ */
+/* $Id: filters.c,v 1.18 2003/01/14 16:42:18 moriyoshi Exp $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -665,7 +665,8 @@
        unsigned int lb_cnt;
 } php_conv_qprint_encode;
 
-#define PHP_CONV_QPRINT_OPT_BINARY 0x00000001
+#define PHP_CONV_QPRINT_OPT_BINARY             0x00000001
+#define PHP_CONV_QPRINT_OPT_FORCE_ENCODE_FIRST 0x00000002
 
 static void php_conv_qprint_encode_dtor(php_conv_qprint_encode *inst);
 static php_conv_err_t php_conv_qprint_encode_convert(php_conv_qprint_encode *inst, 
const char **in_pp, size_t *in_left_p, char **out_pp, size_t *out_left_p);
@@ -772,7 +773,7 @@
                                line_ccnt--;
                                CONSUME_CHAR(ps, icnt, lb_ptr, lb_cnt);
                        }
-               } else if ((c >= 33 && c <= 60) || (c >= 62 && c <= 126)) { 
+               } else if ((!(opts & PHP_CONV_QPRINT_OPT_FORCE_ENCODE_FIRST) || 
+line_ccnt < inst->line_len) && ((c >= 33 && c <= 60) || (c >= 62 && c <= 126))) { 
                        if (line_ccnt < 2) {
                                if (ocnt < inst->lbchars_len + 1) {
                                        err = PHP_CONV_ERR_TOO_BIG;
@@ -1172,10 +1173,12 @@
 
                        if (options != NULL) {
                                int opt_binary = 0;
+                               int opt_force_encode_first = 0;
 
                                GET_STR_PROP(options, lbchars, lbchars_len, 
"line-break-chars", 0);
                                GET_UINT_PROP(options, line_len, "line-length");
                                GET_BOOL_PROP(options, opt_binary, "binary"); 
+                               GET_BOOL_PROP(options, opt_force_encode_first, 
+"force-encode-first"); 
 
                                if (line_len < 4) {
                                        if (lbchars != NULL) {
@@ -1189,6 +1192,7 @@
                                        }
                                }
                                opts |= (opt_binary ? PHP_CONV_QPRINT_OPT_BINARY : 0);
+                               opts |= (opt_force_encode_first ? 
+PHP_CONV_QPRINT_OPT_FORCE_ENCODE_FIRST : 0);
                        }
                        retval = pemalloc(sizeof(php_conv_qprint_encode), persistent);
                        if (lbchars != NULL) {



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to