Convert from numbers to correct SMB_FIND_XX constant names.
[ira/wip.git] / source3 / libsmb / clilist.c
index 1431b804b040e0258670f79e24a171b3635bbb08..5a972041ba3ed7be0631ce42fb5e91fb0414db0a 100644 (file)
@@ -38,8 +38,9 @@ static size_t calc_next_entry_offset(const char *base, const char *pdata_end)
 /****************************************************************************
  Interpret a long filename structure - this is mostly guesses at the moment.
  The length of the structure is returned
- The structure of a long filename depends on the info level. 260 is used
- by NT and 2 is used by OS/2
+ The structure of a long filename depends on the info level.
+ SMB_FIND_FILE_BOTH_DIRECTORY_INFO is used
+ by NT and SMB_FIND_EA_SIZE is used by OS/2
 ****************************************************************************/
 
 static size_t interpret_long_filename(TALLOC_CTX *ctx,
@@ -64,7 +65,7 @@ static size_t interpret_long_filename(TALLOC_CTX *ctx,
        finfo->cli = cli;
 
        switch (level) {
-               case 1: /* OS/2 understands this */
+               case SMB_FIND_INFO_STANDARD: /* OS/2 understands this */
                        /* these dates are converted to GMT by
                            make_unix_date */
                        if (pdata_end - base < 27) {
@@ -98,7 +99,7 @@ static size_t interpret_long_filename(TALLOC_CTX *ctx,
                           between win2000 and win9x for this call
                           (tridge) */
                        ret = clistr_pull_talloc(ctx,
-                                               cli,
+                                               cli->inbuf,
                                                &finfo->name,
                                                p,
                                                len+2,
@@ -109,7 +110,7 @@ static size_t interpret_long_filename(TALLOC_CTX *ctx,
                        p += ret;
                        return PTR_DIFF(p, base);
 
-               case 2: /* this is what OS/2 uses mostly */
+               case SMB_FIND_EA_SIZE: /* this is what OS/2 uses mostly */
                        /* these dates are converted to GMT by
                            make_unix_date */
                        if (pdata_end - base < 31) {
@@ -127,7 +128,7 @@ static size_t interpret_long_filename(TALLOC_CTX *ctx,
                                return pdata_end - base;
                        }
                        ret = clistr_pull_talloc(ctx,
-                                               cli,
+                                               cli->inbuf,
                                                &finfo->name,
                                                p,
                                                len,
@@ -138,7 +139,7 @@ static size_t interpret_long_filename(TALLOC_CTX *ctx,
                        p += ret;
                        return PTR_DIFF(p, base) + 1;
 
-               case 260: /* NT uses this, but also accepts 2 */
+               case SMB_FIND_FILE_BOTH_DIRECTORY_INFO: /* NT uses this, but also accepts 2 */
                {
                        size_t namelen, slen;
 
@@ -179,7 +180,7 @@ static size_t interpret_long_filename(TALLOC_CTX *ctx,
                                /* stupid NT bugs. grr */
                                int flags = 0;
                                if (p[1] == 0 && namelen > 1) flags |= STR_UNICODE;
-                               clistr_pull(cli, finfo->short_name, p,
+                               clistr_pull(cli->inbuf, finfo->short_name, p,
                                            sizeof(finfo->short_name),
                                            slen, flags);
                        }
@@ -188,7 +189,7 @@ static size_t interpret_long_filename(TALLOC_CTX *ctx,
                                return pdata_end - base;
                        }
                        ret = clistr_pull_talloc(ctx,
-                                               cli,
+                                               cli->inbuf,
                                                &finfo->name,
                                                p,
                                                namelen,
@@ -244,13 +245,14 @@ int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute,
        unsigned int param_len, data_len;
        uint16 setup;
        char *param;
-       const char *mnt;
        uint32 resume_key = 0;
        TALLOC_CTX *frame = talloc_stackframe();
        DATA_BLOB last_name_raw = data_blob(NULL, 0);
 
-       /* NT uses 260, OS/2 uses 2. Both accept 1. */
-       info_level = (cli->capabilities&CAP_NT_SMBS)?260:1;
+       /* NT uses SMB_FIND_FILE_BOTH_DIRECTORY_INFO,
+          OS/2 uses SMB_FIND_EA_SIZE. Both accept SMB_FIND_INFO_STANDARD. */
+       info_level = (cli->capabilities&CAP_NT_SMBS)?
+               SMB_FIND_FILE_BOTH_DIRECTORY_INFO : SMB_FIND_INFO_STANDARD;
 
        mask = SMB_STRDUP(Mask);
        if (!mask) {
@@ -390,7 +392,8 @@ int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute,
 
                /* we might need the lastname for continuations */
                for (p2=p,i=0;i<ff_searchcount && p2 < rdata_end;i++) {
-                       if ((info_level == 260) && (i == ff_searchcount-1)) {
+                       if ((info_level == SMB_FIND_FILE_BOTH_DIRECTORY_INFO) &&
+                                       (i == ff_searchcount-1)) {
                                /* Last entry - fixup the last offset length. */
                                SIVAL(p2,0,PTR_DIFF((rdata + data_len),p2));
                        }
@@ -457,8 +460,6 @@ int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute,
                First = False;
        }
 
-       mnt = cli_cm_get_mntpoint( cli );
-
         /* see if the server disconnected or the connection otherwise failed */
         if (cli_is_error(cli)) {
                 total_received = -1;
@@ -479,7 +480,7 @@ int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute,
                                        info_level));
                                break;
                        }
-                        fn(mnt,&finfo, Mask, state);
+                        fn(cli->dfs_mountpoint, &finfo, Mask, state);
                 }
         }
 
@@ -514,7 +515,7 @@ static bool interpret_short_filename(TALLOC_CTX *ctx,
        finfo->mtime_ts.tv_nsec = finfo->atime_ts.tv_nsec = 0;
        finfo->size = IVAL(p,26);
        ret = clistr_pull_talloc(ctx,
-                       cli,
+                       cli->inbuf,
                        &finfo->name,
                        p+30,
                        12,