1 /* Handling of dynamic sring tokens.
2 Copyright (C) 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 /* Determine the number of DST elements in the name. Only if IS_PATH is
21 nonzero paths are recognized (i.e., multiple, ':' separated filenames). */
22 #define DL_DST_COUNT(name, is_path) \
25 const char *__sf = strchr (name, '$'); \
27 if (__builtin_expect (__sf != NULL, 0)) \
28 __cnt = _dl_dst_count (__sf, is_path); \
32 # define _dl_dst_count GLRO(dl_dst_count)
36 /* Guess from the number of DSTs the length of the result string. */
37 #define DL_DST_REQUIRED(l, name, len, cnt) \
39 size_t __len = (len); \
40 size_t __cnt = (cnt); \
45 /* Now we make a guess how many extra characters on top of the \
46 length of S we need to represent the result. We know that \
47 we have CNT replacements. Each at most can use \
48 MAX (strlen (ORIGIN), strlen (_dl_platform)) \
49 minus 7 (which is the length of "$ORIGIN"). \
51 First get the origin string if it is not available yet. \
52 This can only happen for the map of the executable. */ \
53 if ((l)->l_origin == NULL) \
55 assert ((l)->l_name[0] == '\0'); \
56 (l)->l_origin = _dl_get_origin (); \
57 origin_len = ((l)->l_origin && (l)->l_origin != (char *) -1 \
58 ? strlen ((l)->l_origin) : 0); \
61 origin_len = (l)->l_origin == (char *) -1 \
62 ? 0 : strlen ((l)->l_origin); \
64 __len += __cnt * (MAX (origin_len, GLRO(dl_platformlen)) - 7); \
70 # define _dl_get_origin GLRO(dl_get_origin)
71 # define _dl_dst_substitute GLRO(dl_dst_substitute)