X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fsrc%2Flookups%2Flf_quote.c;h=6f4143d9f7d41bdc44dd58ccd18df40b6c9e818a;hb=25bd12fdff615275da6b811570b0f65d57ddc441;hp=8be03652ecfa5c84d9470c5626402746cf0237ea;hpb=d7d7b7b91dd75cec636fc144da7e27eed860f971;p=user%2Fhenk%2Fcode%2Fexim.git diff --git a/src/src/lookups/lf_quote.c b/src/src/lookups/lf_quote.c index 8be03652e..6f4143d9f 100644 --- a/src/src/lookups/lf_quote.c +++ b/src/src/lookups/lf_quote.c @@ -1,10 +1,8 @@ -/* $Cambridge: exim/src/src/lookups/lf_quote.c,v 1.3 2006/02/07 11:19:01 ph10 Exp $ */ - /************************************************* * Exim - an Internet mail transport agent * *************************************************/ -/* Copyright (c) University of Cambridge 1995 - 2006 */ +/* Copyright (c) University of Cambridge 1995 - 2018 */ /* See the file NOTICE for conditions of use and distribution. */ @@ -24,44 +22,42 @@ Arguments: name the field name value the data value vlength the data length - result the result pointer - asize points to the size variable - aoffset points to the offset variable + result the result expanding-string Returns: the result pointer (possibly updated) */ -uschar * -lf_quote(uschar *name, uschar *value, int vlength, uschar *result, int *asize, - int *aoffset) +gstring * +lf_quote(uschar *name, uschar *value, int vlength, gstring * result) { -result = string_append(result, asize, aoffset, 2, name, US"="); +result = string_append(result, 2, name, US"="); /* NULL is handled as an empty string */ -if (value == NULL) value = US""; +if (!value) + { + value = US""; + vlength = 0; + } /* Quote the value if it is empty, contains white space, or starts with a quote character. */ if (value[0] == 0 || Ustrpbrk(value, " \t\n\r") != NULL || value[0] == '\"') { - int j; - result = string_cat(result, asize, aoffset, US"\"", 1); - for (j = 0; j < vlength; j++) + result = string_catn(result, US"\"", 1); + for (int j = 0; j < vlength; j++) { if (value[j] == '\"' || value[j] == '\\') - result = string_cat(result, asize, aoffset, US"\\", 1); - result = string_cat(result, asize, aoffset, US value+j, 1); + result = string_catn(result, US"\\", 1); + result = string_catn(result, US value+j, 1); } - result = string_cat(result, asize, aoffset, US"\"", 1); + result = string_catn(result, US"\"", 1); } else - { - result = string_cat(result, asize, aoffset, US value, vlength); - } + result = string_catn(result, US value, vlength); -return string_cat(result, asize, aoffset, US" ", 1); +return string_catn(result, US" ", 1); } /* End of lf_quote.c */