r26339: Make loadparm talloc-allocated.
[kai/samba.git] / source4 / client / smbspool.c
index 25208ac93a28181f82dfb3e85ec9ae5ac60aabd1..0951fb2befec5aa27b54c50c99e0e65782001b69 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,
    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"
 
-/*
- * Globals...
- */
-
-extern BOOL            in_client;      /* Boolean for client library */
-
-
 /*
  * Local functions...
  */
@@ -58,6 +50,7 @@ static int            smb_print(struct smbcli_state *, char *, FILE *);
   FILE         *fp;            /* File to print */
   int          status=0;               /* Status of LPD job */
   struct smbcli_state *cli;    /* SMB interface */
+  struct loadparm_context *lp_ctx;
 
   /* we expect the URI in argv[0]. Detect the case where it is in argv[1] and cope */
   if (argc > 2 && strncmp(argv[0],"smb://", 6) && !strncmp(argv[1],"smb://", 6)) {
@@ -182,20 +175,15 @@ static int                smb_print(struct smbcli_state *, char *, FILE *);
   * Setup the SAMBA server state...
   */
 
-  setup_logging("smbspool", DEBUG_STDOUT);
+  setup_logging(argv[0], DEBUG_STDOUT);
 
-  in_client = True;   /* Make sure that we tell lp_load we are */
-
-  if (!lp_load(dyn_CONFIGFILE, True, False, False))
-  {
-    fprintf(stderr, "ERROR: Can't load %s - run testparm to debug it\n", dyn_CONFIGFILE);
-    return (1);
+  if (!lp_load(talloc_autofree_context(), dyn_CONFIGFILE, &lp_ctx)) {
+         fprintf(stderr, "ERROR: Can't load %s - run testparm to debug it\n", lp_config_file());
+         return (1);
   }
 
   if (workgroup == NULL)
-    workgroup = lp_workgroup();
-
-  load_interfaces();
+    workgroup = lp_workgroup(lp_ctx);
 
   do
   {
@@ -233,7 +221,7 @@ static int          smb_print(struct smbcli_state *, char *, FILE *);
     if ((status = smb_print(cli, argv[3] /* title */, fp)) != 0)
       break;
 
-  smbcli_shutdown(cli);
+  talloc_free(cli);
 
  /*
   * Return the queue status...
@@ -279,8 +267,8 @@ smb_connect(const char *workgroup,          /* I - Workgroup */
 
   myname = get_myname();  
        
-  nt_status = smbcli_full_connection(&c, myname, server, NULL, 0, share, "?????", 
-                                 username, workgroup, password, 0, NULL);
+  nt_status = smbcli_full_connection(NULL, &c, myname, server, 0, share, NULL,
+                                    username, workgroup, password, NULL);
   
   free(myname);
   if (!NT_STATUS_IS_OK(nt_status)) {