summaryrefslogtreecommitdiff
path: root/source3/printing
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2006-08-24 22:10:59 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:38:51 -0500
commit17ed5d07f4fbae8c4a9e1f171a36b7978f653769 (patch)
tree19743f313cb66ab9458e54098f34b0ad0cf08bc8 /source3/printing
parentf8f1ed21dbc64baf495166d0b86d66bd2e3b17c8 (diff)
downloadsamba-17ed5d07f4fbae8c4a9e1f171a36b7978f653769.tar.gz
samba-17ed5d07f4fbae8c4a9e1f171a36b7978f653769.tar.bz2
samba-17ed5d07f4fbae8c4a9e1f171a36b7978f653769.zip
r17816: Merge my cupsprot branch. It is now possible to (optionally) specify :port in
the "cups server" smb.conf parameter. (This used to be commit 3f665f4ec4cda80cc20e050458e150c086dc1412)
Diffstat (limited to 'source3/printing')
-rw-r--r--source3/printing/print_cups.c68
1 files changed, 37 insertions, 31 deletions
diff --git a/source3/printing/print_cups.c b/source3/printing/print_cups.c
index afa301bbea..a551876489 100644
--- a/source3/printing/print_cups.c
+++ b/source3/printing/print_cups.c
@@ -40,16 +40,38 @@ cups_passwd_cb(const char *prompt) /* I - Prompt */
return (NULL);
}
-static const char *cups_server(void)
+static http_t *cups_connect(void)
{
- if ((lp_cups_server() != NULL) && (strlen(lp_cups_server()) > 0)) {
- DEBUG(10, ("cups server explicitly set to %s\n",
- lp_cups_server()));
- return lp_cups_server();
+ http_t *http;
+ char *server, *p;
+ int port;
+
+ if (lp_cups_server() != NULL && strlen(lp_cups_server()) > 0) {
+ server = smb_xstrdup(lp_cups_server());
+ } else {
+ server = smb_xstrdup(cupsServer());
+ }
+
+ p = strchr(server, ':');
+ if (p) {
+ port = atoi(p+1);
+ *p = '\0';
+ } else {
+ port = ippPort();
+ }
+
+ DEBUG(10, ("connecting to cups server %s:%d\n",
+ server, port));
+
+ if ((http = httpConnect(server, port)) == NULL) {
+ DEBUG(0,("Unable to connect to CUPS server %s:%d - %s\n",
+ server, port, strerror(errno)));
+ SAFE_FREE(server);
+ return NULL;
}
- DEBUG(10, ("cups server left to default %s\n", cupsServer()));
- return cupsServer();
+ SAFE_FREE(server);
+ return http;
}
BOOL cups_cache_reload(void)
@@ -80,9 +102,7 @@ BOOL cups_cache_reload(void)
* Try to connect to the server...
*/
- if ((http = httpConnect(cups_server(), ippPort())) == NULL) {
- DEBUG(0,("Unable to connect to CUPS server %s - %s\n",
- cups_server(), strerror(errno)));
+ if ((http = cups_connect()) == NULL) {
goto out;
}
@@ -287,9 +307,7 @@ static int cups_job_delete(const char *sharename, const char *lprm_command, stru
* Try to connect to the server...
*/
- if ((http = httpConnect(cups_server(), ippPort())) == NULL) {
- DEBUG(0,("Unable to connect to CUPS server %s - %s\n",
- cups_server(), strerror(errno)));
+ if ((http = cups_connect()) == NULL) {
goto out;
}
@@ -379,9 +397,7 @@ static int cups_job_pause(int snum, struct printjob *pjob)
* Try to connect to the server...
*/
- if ((http = httpConnect(cups_server(), ippPort())) == NULL) {
- DEBUG(0,("Unable to connect to CUPS server %s - %s\n",
- cups_server(), strerror(errno)));
+ if ((http = cups_connect()) == NULL) {
goto out;
}
@@ -471,9 +487,7 @@ static int cups_job_resume(int snum, struct printjob *pjob)
* Try to connect to the server...
*/
- if ((http = httpConnect(cups_server(), ippPort())) == NULL) {
- DEBUG(0,("Unable to connect to CUPS server %s - %s\n",
- cups_server(), strerror(errno)));
+ if ((http = cups_connect()) == NULL) {
goto out;
}
@@ -566,9 +580,7 @@ static int cups_job_submit(int snum, struct printjob *pjob)
* Try to connect to the server...
*/
- if ((http = httpConnect(cups_server(), ippPort())) == NULL) {
- DEBUG(0,("Unable to connect to CUPS server %s - %s\n",
- cups_server(), strerror(errno)));
+ if ((http = cups_connect()) == NULL) {
goto out;
}
@@ -732,9 +744,7 @@ static int cups_queue_get(const char *sharename,
* Try to connect to the server...
*/
- if ((http = httpConnect(cups_server(), ippPort())) == NULL) {
- DEBUG(0,("Unable to connect to CUPS server %s - %s\n",
- cups_server(), strerror(errno)));
+ if ((http = cups_connect()) == NULL) {
goto out;
}
@@ -1017,9 +1027,7 @@ static int cups_queue_pause(int snum)
* Try to connect to the server...
*/
- if ((http = httpConnect(cups_server(), ippPort())) == NULL) {
- DEBUG(0,("Unable to connect to CUPS server %s - %s\n",
- cups_server(), strerror(errno)));
+ if ((http = cups_connect()) == NULL) {
goto out;
}
@@ -1111,9 +1119,7 @@ static int cups_queue_resume(int snum)
* Try to connect to the server...
*/
- if ((http = httpConnect(cups_server(), ippPort())) == NULL) {
- DEBUG(0,("Unable to connect to CUPS server %s - %s\n",
- cups_server(), strerror(errno)));
+ if ((http = cups_connect()) == NULL) {
goto out;
}