Remove most of the remaining globals out of lib/util_sock.c.
[samba.git] / source3 / printing / print_iprint.c
index 6193dbe2ca94cbc50f69428c6580789ec24bdece..b038f8d1fe85547917edb640689c02e4b4c2d059 100644 (file)
@@ -7,7 +7,7 @@
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  * 
  * This program is distributed in the hope that it will be useful,
@@ -16,8 +16,7 @@
  * GNU General Public License for more details.
  * 
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #include "includes.h"
@@ -92,7 +91,7 @@ static int iprint_get_server_version(http_t *http, char* serviceUri)
 
        request = ippNew();
 
-       request->request.op.operation_id = OPERATION_NOVELL_MGMT;
+       request->request.op.operation_id = (ipp_op_t)OPERATION_NOVELL_MGMT;
        request->request.op.request_id   = 1;
 
        language = cupsLangDefault();
@@ -306,7 +305,7 @@ static int iprint_cache_add_printer(http_t *http,
        return(0);
 }
 
-BOOL iprint_cache_reload(void)
+bool iprint_cache_reload(void)
 {
        http_t          *http = NULL;           /* HTTP connection to server */
        ipp_t           *request = NULL,        /* IPP Request */
@@ -314,7 +313,7 @@ BOOL iprint_cache_reload(void)
        ipp_attribute_t *attr;                  /* Current attribute */
        cups_lang_t     *language = NULL;       /* Default language */
        int             i;
-       BOOL ret = False;
+       bool ret = False;
 
        DEBUG(5, ("reloading iprint printcap cache\n"));
 
@@ -343,7 +342,8 @@ BOOL iprint_cache_reload(void)
 
        request = ippNew();
 
-       request->request.op.operation_id = OPERATION_NOVELL_LIST_PRINTERS;
+       request->request.op.operation_id =
+               (ipp_op_t)OPERATION_NOVELL_LIST_PRINTERS;
        request->request.op.request_id   = 1;
 
        language = cupsLangDefault();
@@ -726,7 +726,8 @@ static int iprint_job_submit(int snum, struct printjob *pjob)
        ipp_attribute_t *attr;          /* Current attribute */
        cups_lang_t     *language = NULL;       /* Default language */
        char            uri[HTTP_MAX_URI]; /* printer-uri attribute */
-       char            *clientname = NULL;     /* hostname of client for job-originating-host attribute */
+       const char      *clientname = NULL;     /* hostname of client for job-originating-host attribute */
+       char addr[INET6_ADDRSTRLEN];
 
        DEBUG(5,("iprint_job_submit(%d, %p (%d))\n", snum, pjob, pjob->sysjob));
 
@@ -778,11 +779,11 @@ static int iprint_job_submit(int snum, struct printjob *pjob)
        ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
                     NULL, pjob->user);
 
-       clientname = client_name();
+       clientname = client_name(get_client_fd());
        if (strcmp(clientname, "UNKNOWN") == 0) {
-               clientname = client_addr();
+               clientname = client_addr(get_client_fd(),addr,sizeof(addr));
        }
-
+       
        ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
                     "job-originating-host-name", NULL,
                     clientname);
@@ -1074,16 +1075,13 @@ static int iprint_queue_get(const char *sharename,
                if (qcount >= qalloc) {
                        qalloc += 16;
 
-                       temp = SMB_REALLOC_ARRAY(queue, print_queue_struct, qalloc);
+                       queue = SMB_REALLOC_ARRAY(queue, print_queue_struct, qalloc);
 
-                       if (temp == NULL) {
+                       if (queue == NULL) {
                                DEBUG(0,("iprint_queue_get: Not enough memory!"));
                                qcount = 0;
-                               SAFE_FREE(queue);
                                goto out;
                        }
-
-                       queue = temp;
                }
 
                temp = queue + qcount;
@@ -1206,7 +1204,7 @@ static int iprint_queue_get(const char *sharename,
 
 static int iprint_queue_pause(int snum)
 {
-       return(-1); //Not supported without credentials
+       return(-1); /* Not supported without credentials */
 }
 
 
@@ -1216,7 +1214,7 @@ static int iprint_queue_pause(int snum)
 
 static int iprint_queue_resume(int snum)
 {
-       return(-1); //Not supported without credentials
+       return(-1); /* Not supported without credentials */
 }
 
 /*******************************************************************
@@ -1237,5 +1235,6 @@ struct printif    iprint_printif =
 
 #else
  /* this keeps fussy compilers happy */
+ void print_iprint_dummy(void);
  void print_iprint_dummy(void) {}
 #endif /* HAVE_IPRINT */