~ubuntu-branches/ubuntu/vivid/exim4/vivid

« back to all changes in this revision

Viewing changes to src/string.c

  • Committer: Package Import Robot
  • Author(s): Corey Bryant
  • Date: 2014-08-04 11:48:39 UTC
  • mfrom: (56.1.2 utopic)
  • Revision ID: package-import@ubuntu.com-20140804114839-xoulpcx9nxi5m72u
Tags: 4.84~RC1-3ubuntu1
* Merge from Debian unstable (LP: #1351470). Remaining changes:
  - Show Ubuntu distribution on smtp:
    + debian/patches/fix_smtp_banner.patch: updated SMTP banner
      with Ubuntu distribution
    + debian/control: added lsb-release build dependency
  - Don't provide default-mta; in Ubuntu, we want postfix to be the
    default.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
*     Exim - an Internet mail transport agent    *
3
3
*************************************************/
4
4
 
5
 
/* Copyright (c) University of Cambridge 1995 - 2012 */
 
5
/* Copyright (c) University of Cambridge 1995 - 2014 */
6
6
/* See the file NOTICE for conditions of use and distribution. */
7
7
 
8
8
/* Miscellaneous string-handling functions. Some are not required for
34
34
*/
35
35
 
36
36
int
37
 
string_is_ip_address(uschar *s, int *maskptr)
 
37
string_is_ip_address(const uschar *s, int *maskptr)
38
38
{
39
39
int i;
40
40
int yield = 4;
44
44
 
45
45
if (maskptr != NULL)
46
46
  {
47
 
  uschar *ss = s + Ustrlen(s);
 
47
  const uschar *ss = s + Ustrlen(s);
48
48
  *maskptr = 0;
49
49
  if (s != ss && isdigit(*(--ss)))
50
50
    {
304
304
/* Get a new block of store guaranteed big enough to hold the
305
305
expanded string. */
306
306
 
307
 
ss = store_get(length + nonprintcount * 4 + 1);
 
307
ss = store_get(length + nonprintcount * 3 + 1);
308
308
 
309
309
/* Copy everying, escaping non printers. */
310
310
 
374
374
  {
375
375
  if (*p == '\\')
376
376
    {
377
 
    *q = string_interpret_escape(&p);
 
377
    *q++ = string_interpret_escape(&p);
 
378
    p++;
378
379
    }
379
380
  else
380
381
    {
716
717
va_start(ap, format);
717
718
if (!string_vformat(buffer, sizeof(buffer), format, ap))
718
719
  log_write(0, LOG_MAIN|LOG_PANIC_DIE,
719
 
    "string_sprintf expansion was longer than " SIZE_T_FMT, sizeof(buffer));
 
720
    "string_sprintf expansion was longer than " SIZE_T_FMT " (%s)",
 
721
    sizeof(buffer), format);
720
722
va_end(ap);
721
723
return string_copy(buffer);
722
724
}
965
967
#endif  /* COMPILE_UTILITY */
966
968
 
967
969
 
 
970
#ifndef COMPILE_UTILITY
 
971
/************************************************
 
972
*       Add element to seperated list           *
 
973
************************************************/
 
974
/* This function is used to build a list, returning
 
975
an allocated null-terminated growable string. The
 
976
given element has any embedded seperator characters
 
977
doubled.
 
978
 
 
979
Arguments:
 
980
  list  points to the start of the list that is being built, or NULL
 
981
        if this is a new list that has no contents yet
 
982
  sep   list seperator charactoer
 
983
  ele   new lement to be appended to the list
 
984
 
 
985
Returns:  pointer to the start of the list, changed if copied for expansion.
 
986
*/
 
987
 
 
988
uschar *
 
989
string_append_listele(uschar * list, uschar sep, const uschar * ele)
 
990
{
 
991
uschar * new = NULL;
 
992
int sz = 0, off = 0;
 
993
uschar * sp;
 
994
 
 
995
if (list)
 
996
  {
 
997
  new = string_cat(new, &sz, &off, list, Ustrlen(list));
 
998
  new = string_cat(new, &sz, &off, &sep, 1);
 
999
  }
 
1000
 
 
1001
while((sp = Ustrchr(ele, sep)))
 
1002
  {
 
1003
  new = string_cat(new, &sz, &off, ele, sp-ele+1);
 
1004
  new = string_cat(new, &sz, &off, &sep, 1);
 
1005
  ele = sp+1;
 
1006
  }
 
1007
new = string_cat(new, &sz, &off, ele, Ustrlen(ele));
 
1008
new[off] = '\0';
 
1009
return new;
 
1010
}
 
1011
#endif  /* COMPILE_UTILITY */
 
1012
 
 
1013
 
968
1014
 
969
1015
#ifndef COMPILE_UTILITY
970
1016
/*************************************************