Allow NULL request and/or response pointers to be passed to wbcRequestResponse().
[ira/wip.git] / source3 / torture / utable.c
index d9c1fcbafd10c3ee8197033411f8918245c52eb4..7032cea99b82aa1fe70eefbd95ebdb7a4e5c6f7b 100644 (file)
@@ -5,7 +5,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/>.
 */
 
-#define NO_SYSLOG
-
 #include "includes.h"
 
-BOOL torture_utable(int dummy)
+bool torture_utable(int dummy)
 {
        struct cli_state *cli;
        fstring fname, alt_name;
@@ -34,7 +31,7 @@ BOOL torture_utable(int dummy)
 
        printf("starting utable\n");
 
-       if (!torture_open_connection(&cli)) {
+       if (!torture_open_connection(&cli, 0)) {
                return False;
        }
 
@@ -49,9 +46,9 @@ BOOL torture_utable(int dummy)
                SSVAL(&c2, 0, c);
                fstrcpy(fname, "\\utable\\x");
                p = fname+strlen(fname);
-               len = convert_string(CH_UCS2, CH_UNIX, 
+               len = convert_string(CH_UTF16LE, CH_UNIX, 
                                     &c2, 2, 
-                                    p, sizeof(fname)-strlen(fname));
+                                    p, sizeof(fname)-strlen(fname), True);
                p[len] = 0;
                fstrcat(fname,"_a_long_extension");
 
@@ -106,14 +103,14 @@ static char *form_name(int c)
        p = fname+strlen(fname);
        SSVAL(&c2, 0, c);
 
-       len = convert_string(CH_UCS2, CH_UNIX, 
+       len = convert_string(CH_UTF16LE, CH_UNIX, 
                             &c2, 2, 
-                            p, sizeof(fname)-strlen(fname));
+                            p, sizeof(fname)-strlen(fname), True);
        p[len] = 0;
        return fname;
 }
 
-BOOL torture_casetable(int dummy)
+bool torture_casetable(int dummy)
 {
        static struct cli_state *cli;
        char *fname;
@@ -123,30 +120,37 @@ BOOL torture_casetable(int dummy)
        smb_ucs2_t equiv[0x10000][MAX_EQUIVALENCE];
        printf("starting casetable\n");
 
-       if (!torture_open_connection(&cli)) {
+       if (!torture_open_connection(&cli, 0)) {
                return False;
        }
 
        memset(equiv, 0, sizeof(equiv));
 
-       cli_mkdir(cli, "\\utable");
        cli_unlink(cli, "\\utable\\*");
+       cli_rmdir(cli, "\\utable");
+       if (!cli_mkdir(cli, "\\utable")) {
+               printf("Failed to create utable directory!\n");
+               return False;
+       }
 
        for (c=1; c < 0x10000; c++) {
-               size_t size;
+               SMB_OFF_T size;
 
                if (c == '.' || c == '\\') continue;
 
-               printf("%04x\n", c);
+               printf("%04x (%c)\n", c, isprint(c)?c:'.');
 
                fname = form_name(c);
-               fnum = cli_nt_create_full(cli, fname, 
+               fnum = cli_nt_create_full(cli, fname, 0,
                                          GENERIC_ALL_ACCESS, 
                                          FILE_ATTRIBUTE_NORMAL,
                                          FILE_SHARE_NONE,
-                                         FILE_OPEN_IF, 0);
+                                         FILE_OPEN_IF, 0, 0);
 
-               if (fnum == -1) continue;
+               if (fnum == -1) {
+                       printf("Failed to create file with char %04x\n", c);
+                       continue;
+               }
 
                size = 0;
 
@@ -158,8 +162,8 @@ BOOL torture_casetable(int dummy)
                        int c2[MAX_EQUIVALENCE];
 
                        if (size/sizeof(int) >= MAX_EQUIVALENCE) {
-                               printf("too many chars match?? size=%d c=0x%04x\n",
-                                      size, c);
+                               printf("too many chars match?? size=%ld c=0x%04x\n",
+                                      (unsigned long)size, c);
                                cli_close(cli, fnum);
                                return False;
                        }