lib/krb5: krb5_init_creds_set_service fail if set_realm fails
[heimdal.git] / lib / krb5 / expand_path.c
bloba0402350d0f3bd1979be50a33d7e6220424a9c97
2 /***********************************************************************
3 * Copyright (c) 2009, Secure Endpoints Inc.
4 * All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * - Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
29 * OF THE POSSIBILITY OF SUCH DAMAGE.
31 **********************************************************************/
33 #include "krb5_locl.h"
35 #include <stdarg.h>
37 /**
38 * Internal function to expand tokens in paths.
40 * Inputs:
42 * @context A krb5_context
43 * @path_in The path to expand tokens from
44 * @filepath True if the value is a filesystem path (converts slashes to
45 * backslashes on Windows)
46 * @ppath_out The expanded path
48 * Outputs:
50 * @ppath_out Path with expanded tokens (caller must free() this)
52 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
53 _krb5_expand_path_tokens(krb5_context context,
54 const char *path_in,
55 int filepath,
56 char **ppath_out)
58 return heim_expand_path_tokens(context ? context->hcontext : NULL, path_in,
59 filepath, ppath_out, NULL);
62 /**
63 * Internal function to expand tokens in paths.
65 * Inputs:
67 * @context A krb5_context
68 * @path_in The path to expand tokens from
69 * @filepath True if the value is a filesystem path (converts slashes to
70 * backslashes on Windows)
71 * @ppath_out The expanded path
72 * @... Variable number of pairs of strings, the first of each
73 * being a token (e.g., "luser") and the second a string to
74 * replace it with. The list is terminated by a NULL.
76 * Outputs:
78 * @ppath_out Path with expanded tokens (caller must free() this)
80 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
81 _krb5_expand_path_tokensv(krb5_context context,
82 const char *path_in,
83 int filepath,
84 char **ppath_out, ...)
86 krb5_error_code ret;
87 va_list ap;
89 va_start(ap, ppath_out);
90 ret = heim_expand_path_tokensv(context->hcontext, path_in, filepath, ppath_out, ap);
91 va_end(ap);
93 return ret;