s3-talloc Change TALLOC_ZERO_P() to talloc_zero()
[nivanova/samba-autobuild/.git] / source3 / torture / vfstest.c
index de68a0b3c52d943061f99f8454593f77998ea8a8..490dd2bd529ac31b2fcd38bfbf31c7ccbb580ec0 100644 (file)
 */
 
 #include "includes.h"
+#include "smbd/smbd.h"
+#include "popt_common.h"
 #include "vfstest.h"
+#include "../libcli/smbreadline/smbreadline.h"
 
 /* List to hold groups of commands */
 static struct cmd_list {
@@ -32,11 +35,6 @@ static struct cmd_list {
        struct cmd_set *cmd_set;
 } *cmd_list;
 
-int get_client_fd(void)
-{
-       return -1;
-}
-
 /****************************************************************************
 handle completion of commands for readline
 ****************************************************************************/
@@ -191,7 +189,7 @@ static NTSTATUS cmd_debuglevel(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int a
        }
 
        if (argc == 2) {
-               DEBUGLEVEL = atoi(argv[1]);
+               lp_set_cmdline("log level", argv[1]);
        }
 
        printf("debuglevel is %d\n", DEBUGLEVEL);
@@ -397,6 +395,10 @@ static void process_file(struct vfs_state *pvfs, char *filename) {
        while (fgets(command, 3 * PATH_MAX, file) != NULL) {
                process_cmd(pvfs, command);
        }
+
+       if (file != stdin) {
+               fclose(file);
+       }
 }
 
 void exit_server(const char *reason)
@@ -410,104 +412,8 @@ void exit_server_cleanly(const char *const reason)
        exit_server("normal exit");
 }
 
-static int server_fd = -1;
 int last_message = -1;
 
-int smbd_server_fd(void)
-{
-               return server_fd;
-}
-
-void reload_printers(void)
-{
-       return;
-}
-
-/****************************************************************************
- Reload the services file.
-**************************************************************************/
-
-bool reload_services(bool test)
-{
-       bool ret;
-
-       if (lp_loaded()) {
-               const char *fname = lp_configfile();
-               if (file_exist(fname) &&
-                   !strcsequal(fname, get_dyn_CONFIGFILE())) {
-                       set_dyn_CONFIGFILE(fname);
-                       test = False;
-               }
-       }
-
-       reopen_logs();
-
-       if (test && !lp_file_list_changed())
-               return(True);
-
-       lp_killunused(conn_snum_used);
-
-       ret = lp_load(get_dyn_CONFIGFILE(), False, False, True, True);
-
-       /* perhaps the config filename is now set */
-       if (!test)
-               reload_services(True);
-
-       reopen_logs();
-
-       load_interfaces();
-
-       {
-               if (smbd_server_fd() != -1) {      
-                       set_socket_options(smbd_server_fd(),"SO_KEEPALIVE");
-                       set_socket_options(smbd_server_fd(),
-                                          lp_socket_options());
-               }
-       }
-
-       mangle_reset_cache();
-       reset_stat_cache();
-
-       /* this forces service parameters to be flushed */
-       set_current_service(NULL,0,True);
-
-       return (ret);
-}
-
-struct event_context *smbd_event_context(void)
-{
-       static struct event_context *ctx;
-
-       if (!ctx && !(ctx = event_context_init(NULL))) {
-               smb_panic("Could not init smbd event context\n");
-       }
-       return ctx;
-}
-
-struct messaging_context *smbd_messaging_context(void)
-{
-       static struct messaging_context *ctx;
-
-       if (!ctx && !(ctx = messaging_init(NULL, server_id_self(),
-                                          smbd_event_context()))) {
-               smb_panic("Could not init smbd messaging context\n");
-       }
-       return ctx;
-}
-
-struct memcache *smbd_memcache(void)
-{
-       static struct memcache *cache;
-
-       if (!cache
-           && !(cache = memcache_init(NULL,
-                                      lp_max_stat_cache_size()*1024))) {
-
-               smb_panic("Could not init smbd memcache");
-       }
-       return cache;
-}
-
 /* Main function */
 
 int main(int argc, char *argv[])
@@ -542,12 +448,14 @@ int main(int argc, char *argv[])
 
        poptFreeContext(pc);
 
+       lp_load_initial_only(get_dyn_CONFIGFILE());
+
        /* TODO: check output */
-       reload_services(False);
+       reload_services(smbd_messaging_context(), -1, False);
 
        /* the following functions are part of the Samba debugging
           facilities.  See lib/debug.c */
-       setup_logging("vfstest", True);
+       setup_logging("vfstest", DEBUG_STDOUT);
        
        /* Load command lists */
 
@@ -561,8 +469,8 @@ int main(int argc, char *argv[])
 
        /* some basic initialization stuff */
        sec_init();
-       vfs.conn = TALLOC_ZERO_P(NULL, connection_struct);
-       vfs.conn->params = TALLOC_P(vfs.conn, struct share_params);
+       vfs.conn = talloc_zero(NULL, connection_struct);
+       vfs.conn->params = talloc(vfs.conn, struct share_params);
        for (i=0; i < 1024; i++)
                vfs.files[i] = NULL;