/*
- * "$Id: ipptool.c 11370 2013-10-30 15:08:29Z msweet $"
+ * "$Id: ipptool.c 11707 2014-03-19 18:38:23Z msweet $"
*
* ipptool command for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
+ * Copyright 2007-2014 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
PassCount = 0, /* Number of passing tests */
FailCount = 0, /* Number of failing tests */
SkipCount = 0; /* Number of skipped tests */
-char *Password = NULL; /* Password from URI */
+static char *Username = NULL, /* Username from URI */
+ *Password = NULL; /* Password from URI */
+static int PasswordTries = 0; /* Number of tries with password */
const char * const URIStatusStrings[] = /* URI status strings */
{
"URI too large",
if ((Password = strchr(vars.userpass, ':')) != NULL)
*Password++ = '\0';
- cupsSetUser(vars.userpass);
+ Username = vars.userpass;
cupsSetPasswordCB(password_cb);
set_variable(&vars, "uriuser", vars.userpass);
}
goto skip_error;
}
+ PasswordTries = 0;
repeat_count = 0;
repeat_interval = 1;
repeat_prev = 1;
{
repeat_count ++;
- status = HTTP_OK;
+ status = HTTP_STATUS_OK;
if (transfer == _CUPS_TRANSFER_CHUNKED ||
(transfer == _CUPS_TRANSFER_AUTO && filename[0]))
repeat_test = 0;
prev_pass = 1;
- if (status != HTTP_ERROR)
+ if (status != HTTP_STATUS_ERROR)
{
while (!response && !Cancel && prev_pass)
{
httpSetField(http, HTTP_FIELD_CONTENT_ENCODING, compression);
#endif /* HAVE_LIBZ */
- if (!Cancel && status == HTTP_CONTINUE &&
+ if (!Cancel && status == HTTP_STATUS_CONTINUE &&
request->state == IPP_DATA && filename[0])
{
if ((reqfile = cupsFileOpen(filename, "r")) != NULL)
(bytes = cupsFileRead(reqfile, buffer,
sizeof(buffer))) > 0)
if ((status = cupsWriteRequestData(http, buffer,
- bytes)) != HTTP_CONTINUE)
+ bytes)) != HTTP_STATUS_CONTINUE)
break;
cupsFileClose(reqfile);
strerror(errno));
_cupsSetError(IPP_INTERNAL_ERROR, buffer, 0);
- status = HTTP_ERROR;
+ status = HTTP_STATUS_ERROR;
}
}
* Get the server's response...
*/
- if (!Cancel && status != HTTP_ERROR)
+ if (!Cancel && status != HTTP_STATUS_ERROR)
{
response = cupsGetResponse(http, resource);
status = httpGetStatus(http);
}
- if (!Cancel && status == HTTP_ERROR && http->error != EINVAL &&
+ if (!Cancel && status == HTTP_STATUS_ERROR && http->error != EINVAL &&
#ifdef WIN32
http->error != WSAETIMEDOUT)
#else
if (httpReconnect(http))
prev_pass = 0;
}
- else if (status == HTTP_ERROR)
+ else if (status == HTTP_STATUS_ERROR || status == HTTP_STATUS_CUPS_AUTHORIZATION_CANCELED)
{
prev_pass = 0;
break;
}
- else if (status != HTTP_OK)
+ else if (status != HTTP_STATUS_OK)
{
httpFlush(http);
}
}
- if (!Cancel && status == HTTP_ERROR && http->error != EINVAL &&
+ if (!Cancel && status == HTTP_STATUS_ERROR && http->error != EINVAL &&
#ifdef WIN32
http->error != WSAETIMEDOUT)
#else
if (httpReconnect(http))
prev_pass = 0;
}
- else if (status == HTTP_ERROR)
+ else if (status == HTTP_STATUS_ERROR)
{
if (!Cancel)
httpReconnect(http);
prev_pass = 0;
}
- else if (status != HTTP_OK)
+ else if (status != HTTP_STATUS_OK)
{
httpFlush(http);
prev_pass = 0;
{
(void)prompt;
- return (Password);
+ if (PasswordTries < 3)
+ {
+ PasswordTries ++;
+
+ cupsSetUser(Username);
+
+ return (Password);
+ }
+ else
+ return (NULL);
}
/*
- * End of "$Id: ipptool.c 11370 2013-10-30 15:08:29Z msweet $".
+ * End of "$Id: ipptool.c 11707 2014-03-19 18:38:23Z msweet $".
*/