Hello
Here is a patch to get minimal_client.c to compile.
--------- log message -----------
Changes to minimal_client.c to match the rework of the authentication
provider prompting API in revision 6928.
* tools/examples/minimal_client.c
my_prompt_callback: removed
(my_simple_prompt_callback, my_username_prompt_callback): added
main: changes to match the new API
Index: tools/examples/minimal_client.c
===================================================================
--- tools/examples/minimal_client.c (revision 7045)
+++ tools/examples/minimal_client.c (working copy)
@@ -32,28 +32,67 @@
#include "svn_config.h"
-/* A tiny callback function of type 'svn_client_prompt_t'. For a much
- better example, see svn_cl__prompt_user() in the official svn
- cmdline client. */
+/* A tiny callback function of type 'svn_auth_simple_prompt_func_t'. For
+ a much better example, see svn_cl__auth_simple_prompt in the official
+ svn cmdline client. */
svn_error_t *
-my_prompt_callback (const char **info,
- const char *prompt,
- svn_boolean_t hide,
- void *baton,
- apr_pool_t *pool)
+my_simple_prompt_callback (svn_auth_cred_simple_t **cred,
+ void *baton,
+ const char *realm,
+ const char *username,
+ apr_pool_t *pool)
{
- char *answer;
+ svn_auth_cred_simple_t *ret = apr_pcalloc (pool, sizeof (*ret));
char answerbuf[100];
- int len;
- printf ("%s: ", prompt);
- answer = fgets (answerbuf, 100, stdin);
+ if (realm)
+ {
+ printf ("Authentication realm: %s\n", realm);
+ }
+ /* ask for username if not allready know it */
+ if (username)
+ ret->username = apr_pstrdup (pool, username);
+ else
+ {
+ printf ("Username: ");
+ fgets (answerbuf, sizeof (answerbuf), stdin);
+ answerbuf[strlen (answerbuf)-1] = 0; /* cuts trailing LF */
+ ret->username = apr_pstrdup (pool, answerbuf);
+ }
+ /* ask for password */
+ printf ("Password: ");
+ fgets (answerbuf, sizeof (answerbuf), stdin);
+ answerbuf[strlen (answerbuf)-1] = 0;
+ ret->password = apr_pstrdup (pool, answerbuf);
- len = strlen(answer);
- if (answer[len-1] == '\n')
- answer[len-1] = '\0';
+ *cred = ret;
+ return SVN_NO_ERROR;
+}
- *info = apr_pstrdup (pool, answer);
+
+/* A tiny callback function of type 'svn_auth_username_prompt_func_t'. For
+ a much better example, see svn_cl__auth_username_prompt in the official
+ svn cmdline client. */
+svn_error_t *
+my_username_prompt_callback (svn_auth_cred_username_t **cred,
+ void *baton,
+ const char *realm,
+ apr_pool_t *pool)
+{
+ svn_auth_cred_username_t *ret = apr_pcalloc (pool, sizeof (*ret));
+ char answerbuf[100];
+
+ if (realm)
+ {
+ printf ("Authentication realm: %s\n", realm);
+ }
+ /* ask for username if not allready know it */
+ printf ("Username: ");
+ fgets (answerbuf, sizeof (answerbuf), stdin);
+ answerbuf[strlen (answerbuf)-1] = 0;
+ ret->username = apr_pstrdup (pool, answerbuf);
+
+ *cred = ret;
return SVN_NO_ERROR;
}
@@ -87,7 +126,7 @@
pool = svn_pool_create (NULL);
/* Make sure the ~/.subversion run-time config files exist */
- err = svn_config_ensure (pool);
+ err = svn_config_ensure (NULL, pool);
if (err)
{
/* For functions deeper in the stack, we usually use the
@@ -99,12 +138,8 @@
/* All clients need to fill out a client_ctx object. */
{
- /* A function (& context) which can prompt the user for information. */
- ctx.prompt_func = my_prompt_callback;
- ctx.prompt_baton = NULL;
-
/* Load the run-time config file into a hash */
- if ((err = svn_config_get_config (&(ctx.config), pool)))
+ if ((err = svn_config_get_config (&(ctx.config), NULL, pool)))
{
svn_handle_error (err, stderr, 0);
return EXIT_FAILURE;
@@ -135,12 +170,14 @@
= apr_array_make (pool, 4, sizeof (svn_auth_provider_object_t *));
svn_client_get_simple_prompt_provider (&provider,
- my_prompt_callback, NULL,
+ my_simple_prompt_callback,
+ NULL, /* baton */
2, /* retry limit */ pool);
APR_ARRAY_PUSH (providers, svn_auth_provider_object_t *) = provider;
svn_client_get_username_prompt_provider (&provider,
- my_prompt_callback, NULL,
+ my_username_prompt_callback,
+ NULL, /* baton */
2, /* retry limit */ pool);
APR_ARRAY_PUSH (providers, svn_auth_provider_object_t *) = provider;
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sun Sep 14 06:55:07 2003