*
* @context A krb5_context
* @path_in The path to expand tokens from
- * @token Variable number of pairs of strings, the first of each
+ * @ppath_out The expanded path
+ * @... Variable number of pairs of strings, the first of each
* being a token (e.g., "luser") and the second a string to
* replace it with. The list is terminated by a NULL.
*
char **extra_tokens = NULL;
const char *path_left;
const char *s;
- size_t nextra_tokens = 0;
+ size_t nargs = 0;
size_t len = 0;
va_list ap;
va_start(ap, ppath_out);
while ((s = va_arg(ap, const char *))) {
- nextra_tokens++;
- s = va_arg(ap, const char *);
+ nargs++;
+ s = va_arg(ap, const char *);
}
va_end(ap);
+ nargs *= 2;
/* Get extra tokens */
- if (nextra_tokens) {
+ if (nargs) {
size_t i;
- extra_tokens = calloc(nextra_tokens + 2, sizeof (*extra_tokens));
+ extra_tokens = calloc(nargs + 1, sizeof (*extra_tokens));
if (extra_tokens == NULL)
return krb5_enomem(context);
va_start(ap, ppath_out);
- for (i = 0; i < nextra_tokens; i++) {
- s = va_arg(ap, const char *);
+ for (i = 0; i < nargs; i++) {
+ s = va_arg(ap, const char *); /* token key */
if (s == NULL)
break;
extra_tokens[i] = strdup(s);
free_extra_tokens(extra_tokens);
return krb5_enomem(context);
}
- s = va_arg(ap, const char *);
+ s = va_arg(ap, const char *); /* token value */
if (s == NULL)
- break;
+ s = "";
extra_tokens[i] = strdup(s);
if (extra_tokens[i] == NULL) {
free_extra_tokens(extra_tokens);
#define free rk_free
#define malloc rk_malloc
#define realloc rk_realloc
+#define strdup rk_strdup
+#define wcsdup rk_wcsdup
#endif
ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
rk_realloc(void *, size_t);
+ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
+rk_strdup(const char *);
+
+ROKEN_LIB_FUNCTION unsigned short * ROKEN_LIB_CALL
+rk_wcsdup(const unsigned short *);
+
#endif /* _MSC_VER */
#ifdef HAVE_WINSOCK